← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1671: Integrity check only displays one of two identical indicator definitions.

 

------------------------------------------------------------
revno: 1671
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-03-19 11:15:47 +0700
message:
  Integrity check only displays one of two identical indicator definitions.
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/javascript/dataIntegrity.js
  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	2009-12-02 15:08:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java	2010-03-19 04:15:47 +0000
@@ -85,7 +85,7 @@
     /**
      * Gets all indicators with identical numerator and denominator.
      */
-    Collection<Indicator> getIndicatorsWithIdenticalFormulas();
+    Collection<Collection<Indicator>> getIndicatorsWithIdenticalFormulas();
 
     /**
      * Gets all indicators which are not assigned to any groups.

=== 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	2010-03-18 09:31:22 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java	2010-03-19 04:15:47 +0000
@@ -61,14 +61,15 @@
 
 /**
  * @author Lars Helge Overland
- * @version $Id: DefaultDataIntegrityService.java 2010-03-18 11:52:20Z Chau Thu Tran $
+ * @version $Id: DefaultDataIntegrityService.java 2010-03-18 11:52:20Z Chau Thu
+ *          Tran $
  */
 @Transactional
 public class DefaultDataIntegrityService
     implements DataIntegrityService
 {
     private static final String FORMULA_SEPARATOR = "#";
-    
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -100,21 +101,21 @@
     {
         this.organisationUnitService = organisationUnitService;
     }
-    
+
     private OrganisationUnitGroupService organisationUnitGroupService;
 
     public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
     {
         this.organisationUnitGroupService = organisationUnitGroupService;
     }
-    
+
     private ValidationRuleService validationRuleService;
 
     public void setValidationRuleService( ValidationRuleService validationRuleService )
     {
         this.validationRuleService = validationRuleService;
     }
-    
+
     private ExpressionService expressionService;
 
     public void setExpressionService( ExpressionService expressionService )
@@ -137,22 +138,22 @@
 
     public Collection<DataElement> getDataElementsWithoutGroups()
     {
-        return dataElementService.getDataElementsWithoutGroups();        
+        return dataElementService.getDataElementsWithoutGroups();
     }
-    
+
     public Map<DataElement, Collection<DataSet>> getDataElementsAssignedToDataSetsWithDifferentPeriodTypes()
     {
         Collection<DataElement> dataElements = dataElementService.getAllDataElements();
-        
+
         Collection<DataSet> dataSets = dataSetService.getAllDataSets();
-        
+
         Map<DataElement, Collection<DataSet>> targets = new HashMap<DataElement, Collection<DataSet>>();
-                
+
         for ( DataElement element : dataElements )
         {
             final Set<PeriodType> targetPeriodTypes = new HashSet<PeriodType>();
             final Collection<DataSet> targetDataSets = new HashSet<DataSet>();
-            
+
             for ( DataSet dataSet : dataSets )
             {
                 if ( dataSet.getDataElements().contains( element ) )
@@ -161,13 +162,13 @@
                     targetDataSets.add( dataSet );
                 }
             }
-            
+
             if ( targetPeriodTypes.size() > 1 )
             {
                 targets.put( element, targetDataSets );
-            }          
+            }
         }
-        
+
         return targets;
     }
 
@@ -178,25 +179,25 @@
     public Collection<DataSet> getDataSetsNotAssignedToOrganisationUnits()
     {
         Collection<DataSet> dataSets = dataSetService.getAllDataSets();
-        
+
         return FilterUtils.filter( dataSets, new Filter<DataSet>()
+        {
+            public boolean retain( DataSet object )
             {
-                public boolean retain( DataSet object )
-                {
-                    return object.getSources() == null || object.getSources().size() == 0;
-                }
-            } );
+                return object.getSources() == null || object.getSources().size() == 0;
+            }
+        } );
     }
-    
+
     // -------------------------------------------------------------------------
     // Indicator
     // -------------------------------------------------------------------------
 
-    public Collection<Indicator> getIndicatorsWithIdenticalFormulas()
+    public Collection<Collection<Indicator>> getIndicatorsWithIdenticalFormulas()
     {
         Hashtable<String, Indicator> formulas = new Hashtable<String, Indicator>();
         
-        Set<Indicator> targets = new HashSet<Indicator>();
+        Hashtable<String,Collection<Indicator>> targets = new Hashtable<String,Collection<Indicator>>();
         
         Collection<Indicator> indicators = indicatorService.getAllIndicators();
         
@@ -205,9 +206,19 @@
             final String formula = indicator.getNumerator() + FORMULA_SEPARATOR + indicator.getDenominator();
             
             if(formulas.containsKey( formula ))
-            {
-                targets.add (formulas.get( formula ));
-                targets.add( indicator );
+            {  
+                if(targets.containsKey( formula )){
+                    targets.get( formula ).add( indicator );
+                }
+                else{
+                    Set<Indicator> elements = new HashSet<Indicator>();
+                    
+                    elements.add( indicator );
+                    elements.add (formulas.get( formula ));
+                    
+                    targets.put( formula,  elements);
+                    targets.get( formula ).add( indicator );
+                }
             }
             else
             {
@@ -215,48 +226,48 @@
             }
         }
         
-        return targets;
+        return targets.values();
     }
 
     public Collection<Indicator> getIndicatorsWithoutGroups()
     {
         return indicatorService.getIndicatorsWithoutGroups();
     }
-    
+
     public Map<Indicator, String> getInvalidIndicatorNumerators()
     {
         Map<Indicator, String> invalids = new HashMap<Indicator, String>();
-        
+
         for ( Indicator indicator : indicatorService.getAllIndicators() )
         {
             String result = expressionService.expressionIsValid( indicator.getNumerator() );
-            
+
             if ( !result.equals( ExpressionService.VALID ) )
             {
                 invalids.put( indicator, result );
             }
         }
-        
+
         return invalids;
     }
 
     public Map<Indicator, String> getInvalidIndicatorDenominators()
     {
         Map<Indicator, String> invalids = new HashMap<Indicator, String>();
-        
+
         for ( Indicator indicator : indicatorService.getAllIndicators() )
         {
             String result = expressionService.expressionIsValid( indicator.getDenominator() );
-            
+
             if ( !result.equals( ExpressionService.VALID ) )
             {
                 invalids.put( indicator, result );
             }
         }
-        
+
         return invalids;
     }
-    
+
     // -------------------------------------------------------------------------
     // OrganisationUnit
     // -------------------------------------------------------------------------
@@ -264,52 +275,55 @@
     public Collection<OrganisationUnit> getOrganisationUnitsWithCyclicReferences()
     {
         Collection<OrganisationUnit> organisationUnits = organisationUnitService.getAllOrganisationUnits();
-        
+
         Set<OrganisationUnit> cyclic = new HashSet<OrganisationUnit>();
-        
+
         Set<OrganisationUnit> visited = new HashSet<OrganisationUnit>();
-        
+
         OrganisationUnit parent = null;
-        
+
         for ( OrganisationUnit unit : organisationUnits )
         {
             parent = unit;
-                        
-            while ( ( parent = parent.getParent() ) != null )
+
+            while ( (parent = parent.getParent()) != null )
             {
                 if ( parent.equals( unit ) ) // Cyclic reference
                 {
                     cyclic.add( unit );
 
-                    break;                    
+                    break;
                 }
-                else if ( visited.contains( parent ) ) // Ends in cyclic reference but not part of it
+                else if ( visited.contains( parent ) ) // Ends in cyclic
+                                                       // reference but not part
+                                                       // of it
                 {
                     break;
                 }
-                else // Remember visited
+                else
+                // Remember visited
                 {
                     visited.add( parent );
                 }
             }
-            
+
             visited.clear();
         }
-        
+
         return cyclic;
     }
 
     public Collection<OrganisationUnit> getOrphanedOrganisationUnits()
     {
         Collection<OrganisationUnit> organisationUnits = organisationUnitService.getAllOrganisationUnits();
-        
+
         return FilterUtils.filter( organisationUnits, new Filter<OrganisationUnit>()
+        {
+            public boolean retain( OrganisationUnit object )
             {
-                public boolean retain( OrganisationUnit object )
-                {
-                    return object.getParent() == null && ( object.getChildren() == null || object.getChildren().size() == 0 );
-                }
-            } );
+                return object.getParent() == null && (object.getChildren() == null || object.getChildren().size() == 0);
+            }
+        } );
     }
 
     public Collection<OrganisationUnit> getOrganisationUnitsWithoutGroups()
@@ -319,12 +333,13 @@
 
     public Collection<OrganisationUnit> getOrganisationUnitsViolatingCompulsoryGroupSets()
     {
-        Collection<OrganisationUnitGroupSet> groupSets = organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSets();
-                
+        Collection<OrganisationUnitGroupSet> groupSets = organisationUnitGroupService
+            .getCompulsoryOrganisationUnitGroupSets();
+
         Collection<OrganisationUnit> organisationUnits = organisationUnitService.getAllOrganisationUnits();
-        
+
         Set<OrganisationUnit> targets = new HashSet<OrganisationUnit>();
-        
+
         for ( OrganisationUnit unit : organisationUnits )
         {
             for ( OrganisationUnitGroupSet groupSet : groupSets )
@@ -335,28 +350,29 @@
                 }
             }
         }
-        
+
         return targets;
     }
 
     public Collection<OrganisationUnit> getOrganisationUnitsViolatingExclusiveGroupSets()
-    {        
+    {
         Collection<OrganisationUnitGroupSet> groupSets = organisationUnitGroupService.getAllOrganisationUnitGroupSets();
 
         Set<OrganisationUnit> targets = new HashSet<OrganisationUnit>();
 
         for ( OrganisationUnitGroupSet groupSet : groupSets )
         {
-            targets.addAll( getDuplicates( new ArrayList<OrganisationUnit>( groupSet.getOrganisationUnits() ), new OrganisationUnitNameComparator() ) );
+            targets.addAll( getDuplicates( new ArrayList<OrganisationUnit>( groupSet.getOrganisationUnits() ),
+                new OrganisationUnitNameComparator() ) );
         }
-        
+
         return targets;
     }
 
     public Collection<OrganisationUnitGroup> getOrganisationUnitGroupsWithoutGroupSets()
     {
         Collection<OrganisationUnitGroup> groups = organisationUnitGroupService.getAllOrganisationUnitGroups();
-        
+
         return FilterUtils.filter( groups, new OrganisationUnitGroupWithoutGroupSetFilter() );
     }
 
@@ -367,47 +383,49 @@
     public Collection<ValidationRule> getValidationRulesWithoutGroups()
     {
         Collection<ValidationRule> validationRules = validationRuleService.getAllValidationRules();
-        
+
         return FilterUtils.filter( validationRules, new Filter<ValidationRule>()
+        {
+            public boolean retain( ValidationRule object )
             {
-                public boolean retain( ValidationRule object )
-                {
-                    return object.getGroups() == null || object.getGroups().size() == 0;
-                }
-            } );
+                return object.getGroups() == null || object.getGroups().size() == 0;
+            }
+        } );
     }
-    
+
     public Map<ValidationRule, String> getInvalidValidationRuleLeftSideExpressions()
     {
         Map<ValidationRule, String> invalids = new HashMap<ValidationRule, String>();
-        
+
         for ( ValidationRule rule : validationRuleService.getAllValidationRules() )
         {
             String result = expressionService.expressionIsValid( rule.getLeftSide().getExpression() );
-            
+
             if ( !result.equals( ExpressionService.VALID ) )
             {
                 invalids.put( rule, result );
             }
         }
-        
+
         return invalids;
     }
-    
+
     public Map<ValidationRule, String> getInvalidValidationRuleRightSideExpressions()
     {
         Map<ValidationRule, String> invalids = new HashMap<ValidationRule, String>();
-        
+
         for ( ValidationRule rule : validationRuleService.getAllValidationRules() )
         {
             String result = expressionService.expressionIsValid( rule.getRightSide().getExpression() );
-            
+
             if ( !result.equals( ExpressionService.VALID ) )
             {
                 invalids.put( rule, result );
             }
         }
-        
+
         return invalids;
     }
 }
+
+

=== 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-01-20 10:06:43 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java	2010-03-19 04:15:47 +0000
@@ -280,7 +280,7 @@
     @Test
     public void testGetIndicatorsWithIdenticalFormulas()
     {
-        Collection<Indicator> expected = dataIntegrityService.getIndicatorsWithIdenticalFormulas();
+        Collection<Collection<Indicator>> expected = dataIntegrityService.getIndicatorsWithIdenticalFormulas();
         
         assertTrue( message( expected ), equals( expected, indicatorC ) );
     }

=== 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	2009-12-02 15:08:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java	2010-03-19 04:15:47 +0000
@@ -90,9 +90,9 @@
         return dataElementsAssignedToDataSetsWithDifferentPeriodTypes;
     }
 
-    private Collection<Indicator> indicatorsWithIdenticalFormulas;
+    private Collection<Collection<Indicator>> indicatorsWithIdenticalFormulas;
 
-    public Collection<Indicator> getIndicatorsWithIdenticalFormulas()
+    public Collection<Collection<Indicator>> getIndicatorsWithIdenticalFormulas()
     {
         return 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	2010-01-26 21:17:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/dataIntegrity.js	2010-03-19 04:15:47 +0000
@@ -59,4 +59,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	2010-01-26 14:30:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseDataIntegrity.vm	2010-03-19 04:15:47 +0000
@@ -7,6 +7,17 @@
 ]
 #end
 
+#macro( violationWithCollection $name $list )
+#set( $listSize = $list.size() )
+"${name}": [
+#foreach( $o in $list )
+#set( $oSize = $o.size() )
+"#foreach( $p in $o ) ${p.name} #if( $velocityCount < $oSize ), #end
+#end "#if( $velocityCount < $listSize ),#end
+#end
+]
+#end
+
 #macro( violationWithMap $name $map )
 #set( $size = $map.keySet().size() )
 "${name}": [
@@ -31,7 +42,7 @@
     #violation( "dataElementsWithoutGroups" $dataElementsWithoutGroups ),    
     #violationWithMapList( "dataElementsAssignedToDataSetsWithDifferentPeriodTypes" $dataElementsAssignedToDataSetsWithDifferentPeriodTypes ),    
     #violation( "dataSetsNotAssignedToOrganisationUnits" $dataSetsNotAssignedToOrganisationUnits ),
-    #violation( "indicatorsWithIdenticalFormulas" $indicatorsWithIdenticalFormulas ),
+    #violationWithCollection( "indicatorsWithIdenticalFormulas" $indicatorsWithIdenticalFormulas ),
     #violation( "indicatorsWithoutGroups" $indicatorsWithoutGroups ),    
     #violationWithMap( "invalidIndicatorNumerators" $invalidIndicatorNumerators ),
     #violationWithMap( "invalidIndicatorDenominators" $invalidIndicatorDenominators ),