Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Merge Category Option Combo [DHIS2-18321] #19488

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f5a8c80
feat: Initial COC merge setup with some tests [DHIS2-18321]
david-mackessy Nov 15, 2024
3624cbf
feat: Add wrong type test [DHIS2-18321]
david-mackessy Nov 15, 2024
00c1ba3
feat: Working on new cat option test [DHIS2-18321]
david-mackessy Nov 18, 2024
9e8b5a2
Merge branch 'master' into DHIS2-18321
david-mackessy Nov 25, 2024
79d76b9
feat: Fix cat option test [DHIS2-18321]
david-mackessy Nov 26, 2024
40c4efd
resolve conflict
david-mackessy Nov 26, 2024
eb10292
merge master
david-mackessy Nov 26, 2024
81c8fb1
feat: Add metadata handling and tests [DHIS2-18321]
david-mackessy Nov 27, 2024
5af77f3
feat: WIP data value handling and tests [DHIS2-18321]
david-mackessy Nov 28, 2024
21aa2fd
merge master
david-mackessy Nov 28, 2024
04c191c
feat: Fix predictor and data value tests [DHIS2-18321]
david-mackessy Nov 29, 2024
d0d2c1e
Merge branch 'master' into DHIS2-18321
david-mackessy Nov 29, 2024
e944f9f
feat: Extract common data value handling [DHIS2-18321]
david-mackessy Nov 29, 2024
5ef2341
feat: Handle attr opt combo data values, with tests [DHIS2-18321]
david-mackessy Nov 29, 2024
c02efd2
feat: DVA handling and tests [DHIS2-18321]
david-mackessy Dec 2, 2024
8a5b0de
merge master
david-mackessy Dec 2, 2024
d5b892d
feat: Update tests [DHIS2-18321]
david-mackessy Dec 2, 2024
69609d9
feat: Handle data approval audit with tests [DHIS2-18321]
david-mackessy Dec 2, 2024
6471964
feat: Add data approval store method for COC [DHIS2-18321]
david-mackessy Dec 3, 2024
cfb808a
feat: Add Event handling with tests [DHIS2-18321]
david-mackessy Dec 3, 2024
e94cdf0
Merge branch 'master' into DHIS2-18321
david-mackessy Dec 5, 2024
a428641
feat: Handle data approvals with tests [DHSI2-18321]
david-mackessy Dec 6, 2024
c66de8a
feat: Add duplicate and non-dupliate test for DataApproval [DHSI2-18321]
david-mackessy Dec 9, 2024
f50688d
Merge branch 'master' into DHIS2-18321
david-mackessy Dec 9, 2024
3b72e3c
feat: Handle CompleteDataSetRegisration with tests [DHSI2-18321]
david-mackessy Dec 9, 2024
fc3b23f
feat: Add DataElementOperand store test [DHSI2-18321]
david-mackessy Dec 10, 2024
d316eaf
feat: Add more metadata store tests [DHSI2-18321]
david-mackessy Dec 10, 2024
b691a47
Merge branch 'master' into DHIS2-18321
david-mackessy Dec 13, 2024
9b02893
feat: Add predictor store test [DHIS2-18321]
david-mackessy Dec 13, 2024
78d6655
feat: Add data value store tests [DHIS2-18321]
david-mackessy Dec 13, 2024
64af208
feat: Add more store tests [DHIS2-18321]
david-mackessy Dec 13, 2024
0c9ba59
feat: Add more store tests [DHIS2-18321]
david-mackessy Dec 13, 2024
b649678
Merge branch 'master' into DHIS2-18321
david-mackessy Dec 16, 2024
d5dd720
feat: E2E test added for valid merge and auth error [DHIS2-18321]
david-mackessy Dec 16, 2024
1420cc1
feat: Handle events per merge strategy and clean up [DHIS2-18321]
david-mackessy Dec 16, 2024
69846b8
feat: clean up [DHIS2-18321]
david-mackessy Dec 16, 2024
4b581cc
feat: Add javadoc and clean up [DHIS2-18321]
david-mackessy Dec 16, 2024
1727a8f
feat: Format [DHIS2-18321]
david-mackessy Dec 16, 2024
7232555
Merge branch 'master' into DHIS2-18321
david-mackessy Dec 18, 2024
4b65729
feat: Clean up javadoc [DHIS2-18321]
david-mackessy Dec 18, 2024
29d4749
feat: Add DB constraint E2E test [DHIS2-18321]
david-mackessy Dec 18, 2024
bb2a534
feat: Update comment case
david-mackessy Dec 18, 2024
1793439
Merge branch 'master' into DHIS2-18321
david-mackessy Dec 18, 2024
253b246
feat: Move creating new DataValues to util, with tests [DHIS2-18321]
david-mackessy Dec 18, 2024
d13cf13
feat: Update new tests [DHIS2-18321]
david-mackessy Dec 18, 2024
e7b319e
feat: Format [DHIS2-18321]
david-mackessy Dec 19, 2024
be082f3
feat: WIP use SQL for data value merge, adding e2e test [DHIS2-18321]
david-mackessy Jan 7, 2025
9f22891
Merge branch 'master' into dhis2-18321
david-mackessy Jan 7, 2025
2ca1249
feat: COC and AOC SQL merges implemented. e2e tests added. [DHIS2-18321]
david-mackessy Jan 8, 2025
e568aee
Merge branch 'master' into DHIS2-18321
david-mackessy Jan 8, 2025
be1db63
feat: Address sonar issues [DHIS2-18321]
david-mackessy Jan 8, 2025
b2e06ed
feat: Update sql case. Add e2e test cleanup for coc [DHIS2-18321]
david-mackessy Jan 9, 2025
e5db611
feat: Add data value store int test. Add test setup for cat model. [D…
david-mackessy Jan 9, 2025
22d0070
feat: Add store tests for all sql execution paths [DHIS2-18321]
david-mackessy Jan 10, 2025
7fc715b
format
david-mackessy Jan 10, 2025
80b56e3
remove comment from test base class
david-mackessy Jan 10, 2025
d9e0b40
resolve conflicts
david-mackessy Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Fixed Show fixed Hide fixed
* @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 @@ -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
Loading