=== 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 2011-03-13 05:02:23 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java 2011-03-13 15:59:37 +0000 @@ -31,9 +31,11 @@ import java.util.SortedMap; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementGroup; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.Section; import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorGroup; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.validation.ValidationRule; @@ -68,7 +70,7 @@ * Gets all data elements units which are members of more than one group * which enter into an exclusive group set. */ - Collection getDataElementsViolatingExclusiveGroupSets(); + SortedMap> getDataElementsViolatingExclusiveGroupSets(); /** * Returns all data elements which are members of data sets with different @@ -123,7 +125,7 @@ * Gets all indicators units which are members of more than one group * which enter into an exclusive group set. */ - Collection getIndicatorsViolatingExclusiveGroupSets(); + SortedMap> getIndicatorsViolatingExclusiveGroupSets(); // ------------------------------------------------------------------------- // OrganisationUnit @@ -154,7 +156,7 @@ * Gets all organisation units which are members of more than one group * which enter into an exclusive group set. */ - Collection getOrganisationUnitsViolatingExclusiveGroupSets(); + SortedMap> getOrganisationUnitsViolatingExclusiveGroupSets(); // ------------------------------------------------------------------------- // OrganisationUnitGroup === 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 2011-03-13 05:02:23 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2011-03-13 15:59:37 +0000 @@ -31,6 +31,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; import java.util.HashSet; import java.util.Hashtable; import java.util.Set; @@ -38,6 +39,7 @@ import java.util.TreeMap; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementGroup; import org.hisp.dhis.dataelement.DataElementGroupSet; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataelement.comparator.DataElementNameComparator; @@ -47,6 +49,7 @@ import org.hisp.dhis.dataset.SectionService; import org.hisp.dhis.expression.ExpressionService; import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorGroup; import org.hisp.dhis.indicator.IndicatorGroupSet; import org.hisp.dhis.indicator.IndicatorService; import org.hisp.dhis.indicator.comparator.IndicatorNameComparator; @@ -76,6 +79,10 @@ implements DataIntegrityService { private static final String FORMULA_SEPARATOR = "#"; + private static final Comparator DATAELEMENT_COMPARATOR = new DataElementNameComparator(); + private static final Comparator INDICATOR_COMPARATOR = new IndicatorNameComparator(); + private static final Comparator ORGANISATIONUNIT_COMPARATOR = new OrganisationUnitNameComparator(); + private static final Comparator VALIDATIONRULE_COMPARATOR = new ValidationRuleNameComparator(); // ------------------------------------------------------------------------- // Dependencies @@ -161,8 +168,7 @@ Collection dataSets = dataSetService.getAllDataSets(); - SortedMap> targets = new TreeMap>( - new DataElementNameComparator() ); + SortedMap> targets = new TreeMap>( DATAELEMENT_COMPARATOR ); for ( DataElement element : dataElements ) { @@ -188,16 +194,21 @@ } @Override - public Collection getDataElementsViolatingExclusiveGroupSets() + public SortedMap> getDataElementsViolatingExclusiveGroupSets() { Collection groupSets = dataElementService.getAllDataElementGroupSets(); - Set targets = new HashSet(); + SortedMap> targets = new TreeMap>( DATAELEMENT_COMPARATOR ); for ( DataElementGroupSet groupSet : groupSets ) { - targets.addAll( getDuplicates( new ArrayList( groupSet.getDataElements() ), - new DataElementNameComparator() ) ); + Collection duplicates = getDuplicates( + new ArrayList( groupSet.getDataElements() ), DATAELEMENT_COMPARATOR ); + + for ( DataElement duplicate : duplicates ) + { + targets.put( duplicate, duplicate.getGroups() ); + } } return targets; @@ -288,7 +299,7 @@ public SortedMap getInvalidIndicatorNumerators() { - SortedMap invalids = new TreeMap( new IndicatorNameComparator() ); + SortedMap invalids = new TreeMap( INDICATOR_COMPARATOR ); for ( Indicator indicator : indicatorService.getAllIndicators() ) { @@ -305,7 +316,7 @@ public SortedMap getInvalidIndicatorDenominators() { - SortedMap invalids = new TreeMap( new IndicatorNameComparator() ); + SortedMap invalids = new TreeMap( INDICATOR_COMPARATOR ); for ( Indicator indicator : indicatorService.getAllIndicators() ) { @@ -321,16 +332,21 @@ } @Override - public Collection getIndicatorsViolatingExclusiveGroupSets() + public SortedMap> getIndicatorsViolatingExclusiveGroupSets() { Collection groupSets = indicatorService.getAllIndicatorGroupSets(); - Set targets = new HashSet(); + SortedMap> targets = new TreeMap>( INDICATOR_COMPARATOR ); for ( IndicatorGroupSet groupSet : groupSets ) { - targets.addAll( getDuplicates( new ArrayList( groupSet.getIndicators() ), - new IndicatorNameComparator() ) ); + Collection duplicates = getDuplicates( + new ArrayList( groupSet.getIndicators() ), INDICATOR_COMPARATOR ); + + for ( Indicator duplicate : duplicates ) + { + targets.put( duplicate, duplicate.getGroups() ); + } } return targets; @@ -419,16 +435,22 @@ return targets; } - public Collection getOrganisationUnitsViolatingExclusiveGroupSets() + public SortedMap> getOrganisationUnitsViolatingExclusiveGroupSets() { Collection groupSets = organisationUnitGroupService.getAllOrganisationUnitGroupSets(); - Set targets = new HashSet(); + TreeMap> targets = + new TreeMap>( ORGANISATIONUNIT_COMPARATOR ); for ( OrganisationUnitGroupSet groupSet : groupSets ) { - targets.addAll( getDuplicates( new ArrayList( groupSet.getOrganisationUnits() ), - new OrganisationUnitNameComparator() ) ); + Collection duplicates = getDuplicates( + new ArrayList( groupSet.getOrganisationUnits() ), ORGANISATIONUNIT_COMPARATOR ); + + for ( OrganisationUnit duplicate : duplicates ) + { + targets.put( duplicate, duplicate.getGroups() ); + } } return targets; @@ -461,7 +483,7 @@ public SortedMap getInvalidValidationRuleLeftSideExpressions() { SortedMap invalids = new TreeMap( - new ValidationRuleNameComparator() ); + VALIDATIONRULE_COMPARATOR ); for ( ValidationRule rule : validationRuleService.getAllValidationRules() ) { @@ -479,7 +501,7 @@ public SortedMap getInvalidValidationRuleRightSideExpressions() { SortedMap invalids = new TreeMap( - new ValidationRuleNameComparator() ); + VALIDATIONRULE_COMPARATOR ); for ( ValidationRule rule : validationRuleService.getAllValidationRules() ) { === modified file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java' --- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java 2010-04-21 12:14:08 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java 2011-03-13 15:59:37 +0000 @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.Map; +import java.util.SortedMap; import org.hisp.dhis.DhisSpringTest; import org.hisp.dhis.dataelement.DataElement; @@ -333,9 +334,10 @@ @Test public void testGetOrganisationUnitsViolatingExclusiveGroupSets() { - Collection expected = dataIntegrityService.getOrganisationUnitsViolatingExclusiveGroupSets(); + SortedMap> expected = dataIntegrityService.getOrganisationUnitsViolatingExclusiveGroupSets(); - assertTrue( message( expected ), equals( expected, unitA ) ); + assertEquals( 1, expected.size() ); + assertEquals( expected.keySet().iterator().next(), unitA ); } @Test === 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 2011-03-13 05:02:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java 2011-03-13 15:59:37 +0000 @@ -32,10 +32,12 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.SortedMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementGroup; import org.hisp.dhis.dataelement.comparator.DataElementNameComparator; import org.hisp.dhis.dataintegrity.DataIntegrityService; import org.hisp.dhis.dataset.DataSet; @@ -43,6 +45,7 @@ import org.hisp.dhis.dataset.comparator.DataSetNameComparator; import org.hisp.dhis.dataset.comparator.SectionOrderComparator; import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorGroup; import org.hisp.dhis.indicator.comparator.IndicatorNameComparator; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; @@ -91,9 +94,9 @@ return dataElementsWithoutGroups; } - private List dataElementsViolatingExclusiveGroupSets; + private SortedMap> dataElementsViolatingExclusiveGroupSets; - public List getDataElementsViolatingExclusiveGroupSets() + public SortedMap> getDataElementsViolatingExclusiveGroupSets() { return dataElementsViolatingExclusiveGroupSets; } @@ -147,9 +150,9 @@ return invalidIndicatorDenominators; } - private List indicatorsViolatingExclusiveGroupSets; + private SortedMap> indicatorsViolatingExclusiveGroupSets; - public List getIndicatorsViolatingExclusiveGroupSets() + public SortedMap> getIndicatorsViolatingExclusiveGroupSets() { return indicatorsViolatingExclusiveGroupSets; } @@ -182,9 +185,9 @@ return organisationUnitsViolatingCompulsoryGroupSets; } - private List organisationUnitsViolatingExclusiveGroupSets; + private SortedMap> organisationUnitsViolatingExclusiveGroupSets; - public List getOrganisationUnitsViolatingExclusiveGroupSets() + public SortedMap> getOrganisationUnitsViolatingExclusiveGroupSets() { return organisationUnitsViolatingExclusiveGroupSets; } @@ -226,7 +229,7 @@ dataElementsWithoutDataSet = new ArrayList( dataIntegrityService.getDataElementsWithoutDataSet() ); dataElementsWithoutGroups = new ArrayList( dataIntegrityService.getDataElementsWithoutGroups() ); dataElementsAssignedToDataSetsWithDifferentPeriodTypes = dataIntegrityService.getDataElementsAssignedToDataSetsWithDifferentPeriodTypes(); - dataElementsViolatingExclusiveGroupSets = new ArrayList( dataIntegrityService.getDataElementsViolatingExclusiveGroupSets() ); + dataElementsViolatingExclusiveGroupSets = dataIntegrityService.getDataElementsViolatingExclusiveGroupSets(); log.info( "Checked data elements" ); @@ -239,7 +242,7 @@ indicatorsWithoutGroups = new ArrayList( dataIntegrityService.getIndicatorsWithoutGroups() ); invalidIndicatorNumerators = dataIntegrityService.getInvalidIndicatorNumerators(); invalidIndicatorDenominators = dataIntegrityService.getInvalidIndicatorDenominators(); - indicatorsViolatingExclusiveGroupSets = new ArrayList( dataIntegrityService.getIndicatorsViolatingExclusiveGroupSets() ); + indicatorsViolatingExclusiveGroupSets = dataIntegrityService.getIndicatorsViolatingExclusiveGroupSets(); log.info( "Checked indicators" ); @@ -251,8 +254,7 @@ .getOrganisationUnitsWithoutGroups() ); organisationUnitsViolatingCompulsoryGroupSets = new ArrayList( dataIntegrityService .getOrganisationUnitsViolatingCompulsoryGroupSets() ); - organisationUnitsViolatingExclusiveGroupSets = new ArrayList( dataIntegrityService - .getOrganisationUnitsViolatingExclusiveGroupSets() ); + organisationUnitsViolatingExclusiveGroupSets = dataIntegrityService.getOrganisationUnitsViolatingExclusiveGroupSets(); organisationUnitGroupsWithoutGroupSets = new ArrayList( dataIntegrityService .getOrganisationUnitGroupsWithoutGroupSets() ); validationRulesWithoutGroups = new ArrayList( dataIntegrityService @@ -267,16 +269,13 @@ Collections.sort( dataElementsWithoutDataSet, new DataElementNameComparator() ); Collections.sort( dataElementsWithoutGroups, new DataElementNameComparator() ); - Collections.sort( dataElementsViolatingExclusiveGroupSets, new DataElementNameComparator() ); Collections.sort( dataSetsNotAssignedToOrganisationUnits, new DataSetNameComparator() ); Collections.sort( sectionsWithInvalidCategoryCombinations, new SectionOrderComparator() ); Collections.sort( indicatorsWithoutGroups, new IndicatorNameComparator() ); - Collections.sort( indicatorsViolatingExclusiveGroupSets, new IndicatorNameComparator() ); Collections.sort( organisationUnitsWithCyclicReferences, new OrganisationUnitNameComparator() ); Collections.sort( orphanedOrganisationUnits, new OrganisationUnitNameComparator() ); Collections.sort( organisationUnitsWithoutGroups, new OrganisationUnitNameComparator() ); Collections.sort( organisationUnitsViolatingCompulsoryGroupSets, new OrganisationUnitNameComparator() ); - Collections.sort( organisationUnitsViolatingExclusiveGroupSets, new OrganisationUnitNameComparator() ); Collections.sort( organisationUnitGroupsWithoutGroupSets, new OrganisationUnitGroupNameComparator() ); Collections.sort( validationRulesWithoutGroups, new ValidationRuleNameComparator() ); === 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 2011-01-20 11:39:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseDataIntegrity.vm 2011-03-13 15:59:37 +0000 @@ -41,7 +41,7 @@ #violation( "dataElementsWithoutDataSet" $dataElementsWithoutDataSet ), #violation( "dataElementsWithoutGroups" $dataElementsWithoutGroups ), #violation( "dataElementsViolatingCompulsoryGroupSets" $dataElementsViolatingCompulsoryGroupSets ), - #violation( "dataElementsViolatingExclusiveGroupSets" $dataElementsViolatingExclusiveGroupSets ), + #violationWithMapList( "dataElementsViolatingExclusiveGroupSets" $dataElementsViolatingExclusiveGroupSets ), #violationWithMapList( "dataElementsAssignedToDataSetsWithDifferentPeriodTypes" $dataElementsAssignedToDataSetsWithDifferentPeriodTypes ), #violation( "dataSetsNotAssignedToOrganisationUnits" $dataSetsNotAssignedToOrganisationUnits ), #violation( "sectionsWithInvalidCategoryCombinations" $sectionsWithInvalidCategoryCombinations ), @@ -50,12 +50,12 @@ #violationWithMap( "invalidIndicatorNumerators" $invalidIndicatorNumerators ), #violationWithMap( "invalidIndicatorDenominators" $invalidIndicatorDenominators ), #violation( "indicatorsViolatingCompulsoryGroupSets" $indicatorsViolatingCompulsoryGroupSets ), - #violation( "indicatorsViolatingExclusiveGroupSets" $indicatorsViolatingExclusiveGroupSets ), + #violationWithMapList( "indicatorsViolatingExclusiveGroupSets" $indicatorsViolatingExclusiveGroupSets ), #violation( "organisationUnitsWithCyclicReferences" $organisationUnitsWithCyclicReferences ), #violation( "orphanedOrganisationUnits" $orphanedOrganisationUnits ), #violation( "organisationUnitsWithoutGroups" $organisationUnitsWithoutGroups ), #violation( "organisationUnitsViolatingCompulsoryGroupSets" $organisationUnitsViolatingCompulsoryGroupSets ), - #violation( "organisationUnitsViolatingExclusiveGroupSets" $organisationUnitsViolatingExclusiveGroupSets ), + #violationWithMapList( "organisationUnitsViolatingExclusiveGroupSets" $organisationUnitsViolatingExclusiveGroupSets ), #violation( "organisationUnitGroupsWithoutGroupSets" $organisationUnitGroupsWithoutGroupSets ), #violation( "validationRulesWithoutGroups" $validationRulesWithoutGroups ), #violationWithMap( "invalidValidationRuleLeftSideExpressions" $invalidValidationRuleLeftSideExpressions ),