dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10932
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3015: Added name of groups to the data integrity checks for objects violating exclusive group sets
------------------------------------------------------------
revno: 3015
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-03-13 16:59:37 +0100
message:
Added name of groups to the data integrity checks for objects violating exclusive group sets
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java
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/webapp/dhis-web-maintenance-dataadmin/responseDataIntegrity.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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<DataElement> getDataElementsViolatingExclusiveGroupSets();
+ SortedMap<DataElement, Collection<DataElementGroup>> 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<Indicator> getIndicatorsViolatingExclusiveGroupSets();
+ SortedMap<Indicator, Collection<IndicatorGroup>> 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<OrganisationUnit> getOrganisationUnitsViolatingExclusiveGroupSets();
+ SortedMap<OrganisationUnit, Collection<OrganisationUnitGroup>> 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> DATAELEMENT_COMPARATOR = new DataElementNameComparator();
+ private static final Comparator<Indicator> INDICATOR_COMPARATOR = new IndicatorNameComparator();
+ private static final Comparator<OrganisationUnit> ORGANISATIONUNIT_COMPARATOR = new OrganisationUnitNameComparator();
+ private static final Comparator<ValidationRule> VALIDATIONRULE_COMPARATOR = new ValidationRuleNameComparator();
// -------------------------------------------------------------------------
// Dependencies
@@ -161,8 +168,7 @@
Collection<DataSet> dataSets = dataSetService.getAllDataSets();
- SortedMap<DataElement, Collection<DataSet>> targets = new TreeMap<DataElement, Collection<DataSet>>(
- new DataElementNameComparator() );
+ SortedMap<DataElement, Collection<DataSet>> targets = new TreeMap<DataElement, Collection<DataSet>>( DATAELEMENT_COMPARATOR );
for ( DataElement element : dataElements )
{
@@ -188,16 +194,21 @@
}
@Override
- public Collection<DataElement> getDataElementsViolatingExclusiveGroupSets()
+ public SortedMap<DataElement, Collection<DataElementGroup>> getDataElementsViolatingExclusiveGroupSets()
{
Collection<DataElementGroupSet> groupSets = dataElementService.getAllDataElementGroupSets();
- Set<DataElement> targets = new HashSet<DataElement>();
+ SortedMap<DataElement, Collection<DataElementGroup>> targets = new TreeMap<DataElement, Collection<DataElementGroup>>( DATAELEMENT_COMPARATOR );
for ( DataElementGroupSet groupSet : groupSets )
{
- targets.addAll( getDuplicates( new ArrayList<DataElement>( groupSet.getDataElements() ),
- new DataElementNameComparator() ) );
+ Collection<DataElement> duplicates = getDuplicates(
+ new ArrayList<DataElement>( groupSet.getDataElements() ), DATAELEMENT_COMPARATOR );
+
+ for ( DataElement duplicate : duplicates )
+ {
+ targets.put( duplicate, duplicate.getGroups() );
+ }
}
return targets;
@@ -288,7 +299,7 @@
public SortedMap<Indicator, String> getInvalidIndicatorNumerators()
{
- SortedMap<Indicator, String> invalids = new TreeMap<Indicator, String>( new IndicatorNameComparator() );
+ SortedMap<Indicator, String> invalids = new TreeMap<Indicator, String>( INDICATOR_COMPARATOR );
for ( Indicator indicator : indicatorService.getAllIndicators() )
{
@@ -305,7 +316,7 @@
public SortedMap<Indicator, String> getInvalidIndicatorDenominators()
{
- SortedMap<Indicator, String> invalids = new TreeMap<Indicator, String>( new IndicatorNameComparator() );
+ SortedMap<Indicator, String> invalids = new TreeMap<Indicator, String>( INDICATOR_COMPARATOR );
for ( Indicator indicator : indicatorService.getAllIndicators() )
{
@@ -321,16 +332,21 @@
}
@Override
- public Collection<Indicator> getIndicatorsViolatingExclusiveGroupSets()
+ public SortedMap<Indicator, Collection<IndicatorGroup>> getIndicatorsViolatingExclusiveGroupSets()
{
Collection<IndicatorGroupSet> groupSets = indicatorService.getAllIndicatorGroupSets();
- Set<Indicator> targets = new HashSet<Indicator>();
+ SortedMap<Indicator, Collection<IndicatorGroup>> targets = new TreeMap<Indicator, Collection<IndicatorGroup>>( INDICATOR_COMPARATOR );
for ( IndicatorGroupSet groupSet : groupSets )
{
- targets.addAll( getDuplicates( new ArrayList<Indicator>( groupSet.getIndicators() ),
- new IndicatorNameComparator() ) );
+ Collection<Indicator> duplicates = getDuplicates(
+ new ArrayList<Indicator>( groupSet.getIndicators() ), INDICATOR_COMPARATOR );
+
+ for ( Indicator duplicate : duplicates )
+ {
+ targets.put( duplicate, duplicate.getGroups() );
+ }
}
return targets;
@@ -419,16 +435,22 @@
return targets;
}
- public Collection<OrganisationUnit> getOrganisationUnitsViolatingExclusiveGroupSets()
+ public SortedMap<OrganisationUnit, Collection<OrganisationUnitGroup>> getOrganisationUnitsViolatingExclusiveGroupSets()
{
Collection<OrganisationUnitGroupSet> groupSets = organisationUnitGroupService.getAllOrganisationUnitGroupSets();
- Set<OrganisationUnit> targets = new HashSet<OrganisationUnit>();
+ TreeMap<OrganisationUnit, Collection<OrganisationUnitGroup>> targets =
+ new TreeMap<OrganisationUnit, Collection<OrganisationUnitGroup>>( ORGANISATIONUNIT_COMPARATOR );
for ( OrganisationUnitGroupSet groupSet : groupSets )
{
- targets.addAll( getDuplicates( new ArrayList<OrganisationUnit>( groupSet.getOrganisationUnits() ),
- new OrganisationUnitNameComparator() ) );
+ Collection<OrganisationUnit> duplicates = getDuplicates(
+ new ArrayList<OrganisationUnit>( groupSet.getOrganisationUnits() ), ORGANISATIONUNIT_COMPARATOR );
+
+ for ( OrganisationUnit duplicate : duplicates )
+ {
+ targets.put( duplicate, duplicate.getGroups() );
+ }
}
return targets;
@@ -461,7 +483,7 @@
public SortedMap<ValidationRule, String> getInvalidValidationRuleLeftSideExpressions()
{
SortedMap<ValidationRule, String> invalids = new TreeMap<ValidationRule, String>(
- new ValidationRuleNameComparator() );
+ VALIDATIONRULE_COMPARATOR );
for ( ValidationRule rule : validationRuleService.getAllValidationRules() )
{
@@ -479,7 +501,7 @@
public SortedMap<ValidationRule, String> getInvalidValidationRuleRightSideExpressions()
{
SortedMap<ValidationRule, String> invalids = new TreeMap<ValidationRule, String>(
- 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<OrganisationUnit> expected = dataIntegrityService.getOrganisationUnitsViolatingExclusiveGroupSets();
+ SortedMap<OrganisationUnit, Collection<OrganisationUnitGroup>> 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<DataElement> dataElementsViolatingExclusiveGroupSets;
+ private SortedMap<DataElement, Collection<DataElementGroup>> dataElementsViolatingExclusiveGroupSets;
- public List<DataElement> getDataElementsViolatingExclusiveGroupSets()
+ public SortedMap<DataElement, Collection<DataElementGroup>> getDataElementsViolatingExclusiveGroupSets()
{
return dataElementsViolatingExclusiveGroupSets;
}
@@ -147,9 +150,9 @@
return invalidIndicatorDenominators;
}
- private List<Indicator> indicatorsViolatingExclusiveGroupSets;
+ private SortedMap<Indicator, Collection<IndicatorGroup>> indicatorsViolatingExclusiveGroupSets;
- public List<Indicator> getIndicatorsViolatingExclusiveGroupSets()
+ public SortedMap<Indicator, Collection<IndicatorGroup>> getIndicatorsViolatingExclusiveGroupSets()
{
return indicatorsViolatingExclusiveGroupSets;
}
@@ -182,9 +185,9 @@
return organisationUnitsViolatingCompulsoryGroupSets;
}
- private List<OrganisationUnit> organisationUnitsViolatingExclusiveGroupSets;
+ private SortedMap<OrganisationUnit, Collection<OrganisationUnitGroup>> organisationUnitsViolatingExclusiveGroupSets;
- public List<OrganisationUnit> getOrganisationUnitsViolatingExclusiveGroupSets()
+ public SortedMap<OrganisationUnit, Collection<OrganisationUnitGroup>> getOrganisationUnitsViolatingExclusiveGroupSets()
{
return organisationUnitsViolatingExclusiveGroupSets;
}
@@ -226,7 +229,7 @@
dataElementsWithoutDataSet = new ArrayList<DataElement>( dataIntegrityService.getDataElementsWithoutDataSet() );
dataElementsWithoutGroups = new ArrayList<DataElement>( dataIntegrityService.getDataElementsWithoutGroups() );
dataElementsAssignedToDataSetsWithDifferentPeriodTypes = dataIntegrityService.getDataElementsAssignedToDataSetsWithDifferentPeriodTypes();
- dataElementsViolatingExclusiveGroupSets = new ArrayList<DataElement>( dataIntegrityService.getDataElementsViolatingExclusiveGroupSets() );
+ dataElementsViolatingExclusiveGroupSets = dataIntegrityService.getDataElementsViolatingExclusiveGroupSets();
log.info( "Checked data elements" );
@@ -239,7 +242,7 @@
indicatorsWithoutGroups = new ArrayList<Indicator>( dataIntegrityService.getIndicatorsWithoutGroups() );
invalidIndicatorNumerators = dataIntegrityService.getInvalidIndicatorNumerators();
invalidIndicatorDenominators = dataIntegrityService.getInvalidIndicatorDenominators();
- indicatorsViolatingExclusiveGroupSets = new ArrayList<Indicator>( dataIntegrityService.getIndicatorsViolatingExclusiveGroupSets() );
+ indicatorsViolatingExclusiveGroupSets = dataIntegrityService.getIndicatorsViolatingExclusiveGroupSets();
log.info( "Checked indicators" );
@@ -251,8 +254,7 @@
.getOrganisationUnitsWithoutGroups() );
organisationUnitsViolatingCompulsoryGroupSets = new ArrayList<OrganisationUnit>( dataIntegrityService
.getOrganisationUnitsViolatingCompulsoryGroupSets() );
- organisationUnitsViolatingExclusiveGroupSets = new ArrayList<OrganisationUnit>( dataIntegrityService
- .getOrganisationUnitsViolatingExclusiveGroupSets() );
+ organisationUnitsViolatingExclusiveGroupSets = dataIntegrityService.getOrganisationUnitsViolatingExclusiveGroupSets();
organisationUnitGroupsWithoutGroupSets = new ArrayList<OrganisationUnitGroup>( dataIntegrityService
.getOrganisationUnitGroupsWithoutGroupSets() );
validationRulesWithoutGroups = new ArrayList<ValidationRule>( 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 ),