=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java 2014-09-30 09:08:21 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java 2015-01-07 13:01:27 +0000 @@ -32,8 +32,10 @@ import java.util.List; import java.util.SortedMap; +import org.hisp.dhis.common.SetMap; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementGroup; +import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.Section; import org.hisp.dhis.indicator.Indicator; @@ -91,6 +93,12 @@ // ------------------------------------------------------------------------- /** + * Returns all operands in data entry forms where the category option combo + * is not part of the category combo of the data element. + */ + SetMap getCategoryOptionCombosNotInDataElementCategoryCombo(); + + /** * Gets all section with invalid category combinations. Invalid means that * the data elements in the sections don't have the same category combination. */ === modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java' --- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2014-10-16 06:17:19 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2015-01-07 13:01:27 +0000 @@ -41,13 +41,18 @@ import java.util.SortedMap; import java.util.TreeMap; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.hisp.dhis.common.ListMap; +import org.hisp.dhis.common.SetMap; import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.constant.ConstantService; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.dataelement.DataElementCategoryService; import org.hisp.dhis.dataelement.DataElementGroup; import org.hisp.dhis.dataelement.DataElementGroupSet; +import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataentryform.DataEntryFormService; import org.hisp.dhis.dataset.DataSet; @@ -81,6 +86,8 @@ public class DefaultDataIntegrityService implements DataIntegrityService { + private static final Log log = LogFactory.getLog( DefaultDataIntegrityService.class ); + private static final String FORMULA_SEPARATOR = "#"; // ------------------------------------------------------------------------- @@ -250,7 +257,7 @@ return targets; } - + @Override public SortedMap> getDataElementsInDataSetNotInForm() { @@ -291,6 +298,45 @@ // DataSet // ------------------------------------------------------------------------- + public SetMap getCategoryOptionCombosNotInDataElementCategoryCombo() + { + SetMap map = new SetMap<>(); + + Collection dataSets = dataSetService.getAllDataSets(); + + dataSetLoop: for ( DataSet dataSet : dataSets ) + { + if ( dataSet.hasDataEntryForm() ) + { + Set operands = dataEntryFormService.getOperandsInDataEntryForm( dataSet ); + + if ( operands != null ) + { + if ( operands.size() > 2000 ) + { + log.warn( "Skipped integrity check for data set: " + dataSet.getName() + ", too many operands: " + operands.size() ); + continue dataSetLoop; + } + + for ( DataElementOperand operand : operands ) + { + DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() ); + DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( operand.getOptionComboId() ); + Set optionCombos = dataElement.getCategoryCombo() != null ? dataElement.getCategoryCombo().getOptionCombos() : null; + + if ( optionCombos == null || !optionCombos.contains( optionCombo ) ) + { + DataElementOperand persistedOperand = new DataElementOperand( dataElement, optionCombo ); + map.putValue( dataSet, persistedOperand ); + } + } + } + } + } + + return map; + } + @Override public Collection getDataSetsNotAssignedToOrganisationUnits() { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java 2014-10-16 06:17:19 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java 2015-01-07 13:01:27 +0000 @@ -33,6 +33,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.SortedMap; import org.apache.commons.logging.Log; @@ -40,6 +41,7 @@ import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementGroup; +import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataintegrity.DataIntegrityService; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.Section; @@ -111,6 +113,13 @@ return dataElementsInDataSetNotInForm; } + private Map> categoryOptionCombosNotInDataElementCategoryCombo; + + public Map> getCategoryOptionCombosNotInDataElementCategoryCombo() + { + return categoryOptionCombosNotInDataElementCategoryCombo; + } + private List dataSetsNotAssignedToOrganisationUnits; public List getDataSetsNotAssignedToOrganisationUnits() @@ -238,6 +247,10 @@ log.info( "Checked data elements" ); + categoryOptionCombosNotInDataElementCategoryCombo = dataIntegrityService.getCategoryOptionCombosNotInDataElementCategoryCombo(); + + log.info( "Checked operands" ); + dataSetsNotAssignedToOrganisationUnits = new ArrayList<>( dataIntegrityService.getDataSetsNotAssignedToOrganisationUnits() ); sectionsWithInvalidCategoryCombinations = new ArrayList<>( dataIntegrityService.getSectionsWithInvalidCategoryCombinations() ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2014-12-30 16:20:40 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2015-01-07 13:01:27 +0000 @@ -69,6 +69,7 @@ organisation_units_violating_compulsory_group_sets=Organisation units violating compulsory group sets organisation_units_violation_exclusive_group_sets=Organisation units violating exclusive group sets organisation_unit_groups_without_group_sets=Organisation unit groups without group sets +category_option_combos_not_in_data_element_category_combo=Category option combos not in data element category combo in dat entry form data_integrity_checks_performed=Data integrity checks performed data_elements_assigned_to_period_types_with_different_period_types=Data elements assigned to data sets with different period types category_option_group_set_structure=Category option group set structure === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm 2014-09-30 09:08:21 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm 2015-01-07 13:01:27 +0000 @@ -17,6 +17,7 @@ #integrityItem( $i18n.getString( "data_elements_violating_exclusive_group_sets" ) "dataElementsViolatingExclusiveGroupSets" ) #integrityItem( $i18n.getString( "data_elements_in_data_set_not_in_form" ) "dataElementsInDataSetNotInForm" ) #integrityItem( $i18n.getString( "data_elements_assigned_to_period_types_with_different_period_types" ) "dataElementsAssignedToDataSetsWithDifferentPeriodTypes" ) +#integrityItem( $i18n.getString( "category_option_combos_not_in_data_element_category_combo" ) "categoryOptionCombosNotInDataElementCategoryCombo" ) #integrityItem( $i18n.getString( "data_sets_not_assigned_to_organisation_units" ) "dataSetsNotAssignedToOrganisationUnits" ) #integrityItem( $i18n.getString( "sections_with_invalid_category_combinations" ) "sectionsWithInvalidCategoryCombinations" ) #integrityItem( $i18n.getString( "indicators_with_identical_formulas" ) "indicatorsWithIdenticalFormulas" ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/dataIntegrity.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/dataIntegrity.js 2014-10-04 10:20:19 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/dataIntegrity.js 2015-01-07 13:01:27 +0000 @@ -12,16 +12,17 @@ displayViolationList( json.dataElementsWithoutDataSet, "dataElementsWithoutDataSet", false ); displayViolationList( json.dataElementsWithoutGroups, "dataElementsWithoutGroups", false ); - displayViolationList( json.dataElementsViolatingExclusiveGroupSets, "dataElementsViolatingExclusiveGroupSets", true ); - displayViolationList( json.dataElementsInDataSetNotInForm, "dataElementsInDataSetNotInForm", true ); + displayViolationList( json.dataElementsViolatingExclusiveGroupSets, "dataElementsViolatingExclusiveGroupSets", true ); + displayViolationList( json.dataElementsInDataSetNotInForm, "dataElementsInDataSetNotInForm", true ); displayViolationList( json.dataElementsAssignedToDataSetsWithDifferentPeriodTypes, "dataElementsAssignedToDataSetsWithDifferentPeriodTypes", true ); + displayViolationList( json.categoryOptionCombosNotInDataElementCategoryCombo, "categoryOptionCombosNotInDataElementCategoryCombo", true ); displayViolationList( json.dataSetsNotAssignedToOrganisationUnits, "dataSetsNotAssignedToOrganisationUnits", false ); displayViolationList( json.sectionsWithInvalidCategoryCombinations, "sectionsWithInvalidCategoryCombinations", false ); displayViolationList( json.indicatorsWithIdenticalFormulas, "indicatorsWithIdenticalFormulas", false ); displayViolationList( json.indicatorsWithoutGroups, "indicatorsWithoutGroups", false ); displayViolationList( json.invalidIndicatorNumerators, "invalidIndicatorNumerators", true ); displayViolationList( json.invalidIndicatorDenominators, "invalidIndicatorDenominators", true ); - displayViolationList( json.indicatorsViolatingExclusiveGroupSets, "indicatorsViolatingExclusiveGroupSets", true ); + displayViolationList( json.indicatorsViolatingExclusiveGroupSets, "indicatorsViolatingExclusiveGroupSets", true ); displayViolationList( json.organisationUnitsWithCyclicReferences, "organisationUnitsWithCyclicReferences", false ); displayViolationList( json.orphanedOrganisationUnits, "orphanedOrganisationUnits", false ); displayViolationList( json.organisationUnitsWithoutGroups, "organisationUnitsWithoutGroups", false ); @@ -64,4 +65,4 @@ } $( "#" + id + "Div" ).hide(); -} \ No newline at end of file +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseDataIntegrity.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseDataIntegrity.vm 2014-09-30 09:08:21 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseDataIntegrity.vm 2015-01-07 13:01:27 +0000 @@ -43,6 +43,7 @@ #violationWithMapList( "dataElementsViolatingExclusiveGroupSets" $dataElementsViolatingExclusiveGroupSets ), #violationWithMapList( "dataElementsInDataSetNotInForm" $dataElementsInDataSetNotInForm ), #violationWithMapList( "dataElementsAssignedToDataSetsWithDifferentPeriodTypes" $dataElementsAssignedToDataSetsWithDifferentPeriodTypes ), + #violationWithMapList( "categoryOptionCombosNotInDataElementCategoryCombo" $categoryOptionCombosNotInDataElementCategoryCombo ), #violation( "dataSetsNotAssignedToOrganisationUnits" $dataSetsNotAssignedToOrganisationUnits ), #violation( "sectionsWithInvalidCategoryCombinations" $sectionsWithInvalidCategoryCombinations ), #violationWithCollection( "indicatorsWithIdenticalFormulas" $indicatorsWithIdenticalFormulas ),