Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into DHIS2-18702-42
Browse files Browse the repository at this point in the history
  • Loading branch information
vietnguyen committed Jan 17, 2025
2 parents bb169e9 + 5f343fd commit b7c770d
Show file tree
Hide file tree
Showing 96 changed files with 7,983 additions and 1,205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.CombinationGenerator;
import org.hisp.dhis.common.DataDimensionType;
Expand Down Expand Up @@ -223,6 +225,18 @@ public void removeAllCategories() {
categories.clear();
}

public void addCategoryOptionCombo(@Nonnull CategoryOptionCombo coc) {
this.getOptionCombos().add(coc);
}

public void removeCategoryOptionCombo(@Nonnull CategoryOptionCombo coc) {
this.getOptionCombos().remove(coc);
}

public void removeCategoryOptionCombos(@Nonnull Collection<CategoryOptionCombo> cocs) {
cocs.forEach(this::removeCategoryOptionCombo);
}

// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,25 @@
*/
package org.hisp.dhis.category;

import java.util.Collection;
import java.util.List;
import javax.annotation.Nonnull;
import org.hisp.dhis.common.DataDimensionType;
import org.hisp.dhis.common.IdentifiableObjectStore;
import org.hisp.dhis.common.UID;

/**
* @author Lars Helge Overland
*/
public interface CategoryComboStore extends IdentifiableObjectStore<CategoryCombo> {
List<CategoryCombo> getCategoryCombosByDimensionType(DataDimensionType dataDimensionType);

/**
* Retrieve all {@link CategoryCombo}s with {@link CategoryOptionCombo} {@link UID}s
*
* @param uids {@link CategoryOptionCombo} {@link UID}s
* @return {@link CategoryCombo}s with references to {@link CategoryOptionCombo} {@link UID}s
* passed in
*/
List<CategoryCombo> getByCategoryOptionCombo(@Nonnull Collection<UID> uids);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
*/
package org.hisp.dhis.category;

import java.util.Collection;
import java.util.List;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.hisp.dhis.common.IdentifiableObjectStore;
import org.hisp.dhis.common.UID;
import org.hisp.dhis.user.UserDetails;
Expand All @@ -47,4 +49,13 @@ public interface CategoryOptionStore extends IdentifiableObjectStore<CategoryOpt
List<CategoryOption> getCategoryOptions(Category category);

List<CategoryOption> getDataWriteCategoryOptions(Category category, UserDetails userDetails);

/**
* Retrieve all {@link CategoryOption}s with {@link CategoryOptionCombo} {@link UID}s
*
* @param uids {@link CategoryOptionCombo} {@link UID}s
* @return {@link CategoryOption}s with references to {@link CategoryOptionCombo} {@link UID}s
* passed in
*/
List<CategoryOption> getByCategoryOptionCombo(@Nonnull Collection<UID> uids);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
import org.apache.commons.collections4.SetValuedMap;
import org.hisp.dhis.common.IdScheme;
import org.hisp.dhis.common.UID;
Expand Down Expand Up @@ -453,7 +454,15 @@ CategoryOptionCombo getCategoryOptionCombo(
* @return categoryOptionCombos with refs to categoryOptions
*/
List<CategoryOptionCombo> getCategoryOptionCombosByCategoryOption(
Collection<UID> categoryOptions);
@Nonnull Collection<UID> categoryOptions);

/**
* Retrieves all CategoryOptionCombos by {@link UID}.
*
* @param uids {@link UID}s to search for
* @return categoryOptionCombos with refs to {@link UID}s
*/
List<CategoryOptionCombo> getCategoryOptionCombosByUid(@Nonnull Collection<UID> uids);

// -------------------------------------------------------------------------
// DataElementOperand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package org.hisp.dhis.dataapproval;

import java.util.List;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.common.GenericStore;
import org.hisp.dhis.organisationunit.OrganisationUnit;

Expand All @@ -46,6 +47,13 @@ public interface DataApprovalAuditStore extends GenericStore<DataApprovalAudit>
*/
void deleteDataApprovalAudits(OrganisationUnit organisationUnit);

/**
* Deletes DataApprovalAudits for the given category option combo.
*
* @param coc the category option combo
*/
void deleteDataApprovalAudits(CategoryOptionCombo coc);

/**
* Returns DataApprovalAudit objects for query parameters.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
import org.hisp.dhis.category.CategoryCombo;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.common.UID;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;

Expand Down Expand Up @@ -162,4 +164,19 @@ List<DataApprovalStatus> getDataApprovalStatuses(
Set<CategoryOptionCombo> attributeOptionCombos,
List<DataApprovalLevel> userApprovalLevels,
Map<Integer, DataApprovalLevel> levelMap);

/**
* Retrieve all {@link DataApproval}s with {@link CategoryOptionCombo} {@link UID}s
*
* @param uids {@link CategoryOptionCombo} {@link UID}s
* @return {@link DataApproval}s with {@link CategoryOptionCombo} {@link UID}s passed in
*/
List<DataApproval> getByCategoryOptionCombo(@Nonnull Collection<UID> uids);

/**
* Delete all {@link DataApproval}s with references to {@link CategoryOptionCombo} {@link UID}s
*
* @param uids {@link CategoryOptionCombo} {@link UID}s
*/
void deleteByCategoryOptionCombo(@Nonnull Collection<UID> uids);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package org.hisp.dhis.datadimensionitem;

import java.util.Collection;
import java.util.List;
import org.hisp.dhis.common.DataDimensionItem;
import org.hisp.dhis.common.GenericStore;
Expand All @@ -47,4 +48,14 @@ public interface DataDimensionItemStore extends GenericStore<DataDimensionItem>
List<DataDimensionItem> getIndicatorDataDimensionItems(List<Indicator> indicators);

List<DataDimensionItem> getDataElementDataDimensionItems(List<DataElement> dataElements);

/**
* Update the entities with refs to the category option combo ids passed in, with the new category
* option combo id passed in.
*
* @param cocIds category option combo ids to be used to update linked data dimension items
* @param newCocId new category option combo id to use
* @return number of entities updated
*/
int updateDeoCategoryOptionCombo(Collection<Long> cocIds, long newCocId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,31 @@

import java.util.Collection;
import java.util.List;
import javax.annotation.Nonnull;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.common.IdentifiableObjectStore;
import org.hisp.dhis.common.UID;

/**
* @author Morten Olav Hansen <[email protected]>
*/
public interface DataElementOperandStore extends IdentifiableObjectStore<DataElementOperand> {
String ID = DataElementOperand.class.getName();

/**
* Retrieve all {@link DataElementOperand}s with {@link DataElement}s
*
* @param dataElements {@link DataElement}s
* @return {@link DataElementOperand}s with references to {@link DataElement}s passed in
*/
List<DataElementOperand> getByDataElement(Collection<DataElement> dataElements);

/**
* Retrieve all {@link DataElementOperand}s with {@link CategoryOptionCombo} {@link UID}s
*
* @param uids {@link CategoryOptionCombo} {@link UID}s
* @return {@link DataElementOperand}s with references to {@link CategoryOptionCombo} {@link UID}s
* passed in
*/
List<DataElementOperand> getByCategoryOptionCombo(@Nonnull Collection<UID> uids);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.google.common.base.MoreObjects;
import java.io.Serializable;
import java.util.Date;
import javax.annotation.Nonnull;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.DxfNamespaces;
Expand Down Expand Up @@ -323,4 +324,28 @@ public String toString() {
.add("isCompleted", completed)
.toString();
}

/**
* Creates a copy of the passed in CompleteDataSetRegistration, using all old values except for
* attributeOptionCombo, which uses the param attributeOptionCombo passed in.
*
* @param old old CompleteDataSetRegistration to use values from
* @param attributeOptionCombo attributeOptionCombo to use as new value in new
* CompleteDataSetRegistration
* @return copy of old CompleteDataSetRegistration except with a new attributeOptionCombo
*/
public static CompleteDataSetRegistration copyWithNewAttributeOptionCombo(
@Nonnull CompleteDataSetRegistration old, @Nonnull CategoryOptionCombo attributeOptionCombo) {
CompleteDataSetRegistration newCopy = new CompleteDataSetRegistration();
newCopy.setDataSet(old.getDataSet());
newCopy.setPeriod(old.getPeriod());
newCopy.setSource(old.getSource());
newCopy.setAttributeOptionCombo(attributeOptionCombo);
newCopy.setDate(old.getDate());
newCopy.setStoredBy(old.getStoredBy());
newCopy.setLastUpdated(old.getLastUpdated());
newCopy.setCompleted(old.getCompleted());
newCopy.setPeriodName(old.getPeriodName());
return newCopy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
*/
package org.hisp.dhis.dataset;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import javax.annotation.Nonnull;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.common.UID;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;

Expand All @@ -44,6 +47,13 @@ public interface CompleteDataSetRegistrationStore {
*/
void saveCompleteDataSetRegistration(CompleteDataSetRegistration registration);

/**
* Saves a CompleteDataSetRegistration without updating its lastUpdated value
*
* @param registration reg to update
*/
void saveWithoutUpdatingLastUpdated(@Nonnull CompleteDataSetRegistration registration);

/**
* Updates a CompleteDataSetRegistration.
*
Expand Down Expand Up @@ -102,4 +112,20 @@ CompleteDataSetRegistration getCompleteDataSetRegistration(
* @return the number of completed DataSets.
*/
int getCompleteDataSetCountLastUpdatedAfter(Date lastUpdated);

/**
* Retrieve all {@link CompleteDataSetRegistration}s with {@link CategoryOptionCombo} {@link UID}s
*
* @param uids {@link CategoryOptionCombo} {@link UID}s
* @return {@link CompleteDataSetRegistration}s with references to {@link CategoryOptionCombo}
* {@link UID}s passed in
*/
List<CompleteDataSetRegistration> getAllByCategoryOptionCombo(@Nonnull Collection<UID> uids);

/**
* Delete all {@link CompleteDataSetRegistration}s with references to {@link CategoryOptionCombo}s
*
* @param cocs {@link CategoryOptionCombo}s
*/
void deleteByCategoryOptionCombo(@Nonnull Collection<CategoryOptionCombo> cocs);
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,34 +272,6 @@ public void mergeWith(DataValue other) {
this.deleted = other.isDeleted();
}

/**
* Method that creates a new {@link DataValue}. All the old values are used from the supplied old
* {@link DataValue} except for the {@link DataElement} field, which uses the supplied {@link
* DataElement}.
*
* @param oldDv old {@link DataValue} whose values will be used in the new {@link DataValue}
* @param newDataElement {@link DataElement} to be used in the new {@link DataValue}
* @return new {@link DataValue}
*/
public static DataValue dataValueWithNewDataElement(DataValue oldDv, DataElement newDataElement) {
DataValue newValue =
DataValue.builder()
.dataElement(newDataElement)
.period(oldDv.getPeriod())
.source(oldDv.getSource())
.categoryOptionCombo(oldDv.getCategoryOptionCombo())
.attributeOptionCombo(oldDv.getAttributeOptionCombo())
.value(oldDv.getValue())
.storedBy(oldDv.getStoredBy())
.lastUpdated(oldDv.getLastUpdated())
.comment(oldDv.getComment())
.followup(oldDv.isFollowup())
.deleted(oldDv.isDeleted())
.build();
newValue.setCreated(oldDv.getCreated());
return newValue;
}

// -------------------------------------------------------------------------
// hashCode and equals
// -------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
package org.hisp.dhis.datavalue;

import java.util.List;
import javax.annotation.Nonnull;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.organisationunit.OrganisationUnit;

Expand Down Expand Up @@ -68,6 +70,14 @@ public interface DataValueAuditStore {
*/
void deleteDataValueAudits(DataElement dataElement);

/**
* Deletes all data value audits for the given category option combo. Both properties:
* categoryOptionCombo & attributeOptionCombo are checked for a match.
*
* @param categoryOptionCombo the categoryOptionCombo.
*/
void deleteDataValueAudits(@Nonnull CategoryOptionCombo categoryOptionCombo);

/**
* Returns data value audits for the given query.
*
Expand Down
Loading

0 comments on commit b7c770d

Please sign in to comment.