← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16877: Data integrity, added check for duplicate periods, i.e. periods with equal period type and start ...

 

------------------------------------------------------------
revno: 16877
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-09-30 11:08:21 +0200
message:
  Data integrity, added check for duplicate periods, i.e. periods with equal period type and start date
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.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/main/resources/META-INF/dhis/beans.xml
  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/resources/org/hisp/dhis/dataadmin/i18n_module.properties
  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/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	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java	2014-09-30 09:08:21 +0000
@@ -29,6 +29,7 @@
  */
 
 import java.util.Collection;
+import java.util.List;
 import java.util.SortedMap;
 
 import org.hisp.dhis.dataelement.DataElement;
@@ -39,11 +40,11 @@
 import org.hisp.dhis.indicator.IndicatorGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.period.Period;
 import org.hisp.dhis.validation.ValidationRule;
 
 /**
  * @author Fredrik Fjeld
- * @version $Id$
  */
 public interface DataIntegrityService
 {
@@ -160,6 +161,16 @@
     SortedMap<OrganisationUnit, Collection<OrganisationUnitGroup>> getOrganisationUnitsViolatingExclusiveGroupSets();
 
     // -------------------------------------------------------------------------
+    // Period
+    // -------------------------------------------------------------------------
+
+    /**
+     * Lists all Periods which are duplicates, based on the period type and start date.
+     * @return
+     */
+    List<Period> getDuplicatePeriods();
+    
+    // -------------------------------------------------------------------------
     // OrganisationUnitGroup
     // -------------------------------------------------------------------------
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java	2014-09-16 16:40:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java	2014-09-30 09:08:21 +0000
@@ -150,12 +150,15 @@
 
             for ( DataElement element : dataElements )
             {
-                if ( categoryCombo != null && !categoryCombo.equals( element.getCategoryCombo() ) )
+                if ( element != null )
                 {
-                    return true;
+                    if ( categoryCombo != null && !categoryCombo.equals( element.getCategoryCombo() ) )
+                    {
+                        return true;
+                    }
+    
+                    categoryCombo = element.getCategoryCombo();
                 }
-
-                categoryCombo = element.getCategoryCombo();
             }
         }
 

=== 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-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java	2014-09-30 09:08:21 +0000
@@ -36,10 +36,12 @@
 import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
+import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.constant.ConstantService;
 import org.hisp.dhis.dataelement.DataElement;
@@ -62,6 +64,8 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.system.filter.OrganisationUnitGroupWithoutGroupSetFilter;
 import org.hisp.dhis.system.util.Filter;
@@ -160,6 +164,13 @@
         this.constantService = constantService;
     }
 
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }    
+    
     // -------------------------------------------------------------------------
     // DataIntegrityService implementation
     // -------------------------------------------------------------------------
@@ -297,7 +308,7 @@
         
         for ( Section section : sectionService.getAllSections() )
         {
-            if ( section.categorComboIsInvalid() )
+            if ( section != null && section.categorComboIsInvalid() )
             {
                 sections.add( section );
             }
@@ -425,6 +436,40 @@
     }
 
     // -------------------------------------------------------------------------
+    // Period
+    // -------------------------------------------------------------------------
+
+    public List<Period> getDuplicatePeriods()
+    {
+        Collection<Period> periods = periodService.getAllPeriods();
+        
+        List<Period> duplicates = new ArrayList<>();
+        
+        ListMap<String, Period> map = new ListMap<>();
+        
+        for ( Period period : periods )
+        {
+            String key = period.getPeriodType().getName() + period.getStartDate().toString();
+            
+            period.setName( period.toString() );
+            
+            map.putValue( key, period );
+        }
+        
+        for ( String key : map.keySet() )
+        {
+            List<Period> values = map.get( key );
+            
+            if ( values != null && values.size() > 1 )
+            {
+                duplicates.addAll( values );
+            }
+        }
+        
+        return duplicates;
+    }
+    
+    // -------------------------------------------------------------------------
     // OrganisationUnit
     // -------------------------------------------------------------------------
 
@@ -580,5 +625,4 @@
 
         return invalids;
     }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2014-08-26 08:46:50 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2014-09-30 09:08:21 +0000
@@ -34,6 +34,7 @@
 	<property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
 	<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
 	<property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
+	<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
   </bean>
   
   <!-- Maintenance -->

=== 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-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java	2014-09-30 09:08:21 +0000
@@ -47,6 +47,7 @@
 import org.hisp.dhis.indicator.IndicatorGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.period.Period;
 import org.hisp.dhis.validation.ValidationRule;
 
 import com.opensymphony.xwork2.Action;
@@ -159,6 +160,13 @@
         return indicatorsViolatingExclusiveGroupSets;
     }
 
+    private List<Period> duplicatePeriods;
+    
+    public List<Period> getDuplicatePeriods()
+    {
+        return duplicatePeriods;
+    }
+
     private List<OrganisationUnit> organisationUnitsWithCyclicReferences;
 
     public List<OrganisationUnit> getOrganisationUnitsWithCyclicReferences()
@@ -242,6 +250,10 @@
 
         log.info( "Checked indicators" );
         
+        duplicatePeriods = dataIntegrityService.getDuplicatePeriods();
+
+        log.info( "Checked periods" );
+        
         organisationUnitsWithCyclicReferences = new ArrayList<>( dataIntegrityService
             .getOrganisationUnitsWithCyclicReferences() );
         orphanedOrganisationUnits = new ArrayList<>( dataIntegrityService

=== 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-08-29 15:16:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2014-09-30 09:08:21 +0000
@@ -361,4 +361,6 @@
 please_select_an_organisation_unit = Please select an organisation unit
 prev_year = Prev year
 next_year = Next year
-update_the_data_elements_and_option_combos_in_expression = Update the data elements and option combos in expression
\ No newline at end of file
+update_the_data_elements_and_option_combos_in_expression = Update the data elements and option combos in expression
+org_unit_group_does_not_exist=Org unit group does not exist
+duplicate_periods=Duplicate periods
\ 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/dataIntegrityForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm	2012-07-14 13:44:38 +0000
+++ 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
@@ -24,6 +24,7 @@
 #integrityItem( $i18n.getString( "invalid_indicator_numerators" ) "invalidIndicatorNumerators" )
 #integrityItem( $i18n.getString( "invalid_indicator_denominators" ) "invalidIndicatorDenominators" )
 #integrityItem( $i18n.getString( "indicators_violating_exclusive_group_sets" ) "indicatorsViolatingExclusiveGroupSets" )
+#integrityItem( $i18n.getString( "duplicate_periods" ) "duplicatePeriods" )
 #integrityItem( $i18n.getString( "organisation_units_with_cyclic_references" ) "organisationUnitsWithCyclicReferences" )
 #integrityItem( $i18n.getString( "orphaned_organisation_units" ) "orphanedOrganisationUnits" )
 #integrityItem( $i18n.getString( "organisation_units_without_groups" ) "organisationUnitsWithoutGroups" )

=== 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	2012-07-14 13:44:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/dataIntegrity.js	2014-09-30 09:08:21 +0000
@@ -27,6 +27,7 @@
     displayViolationList( json.organisationUnitsWithoutGroups, "organisationUnitsWithoutGroups" );
     displayViolationList( json.organisationUnitsViolatingExclusiveGroupSets, "organisationUnitsViolatingExclusiveGroupSets" );
     displayViolationList( json.organisationUnitGroupsWithoutGroupSets, "organisationUnitGroupsWithoutGroupSets" );
+    displayViolationList( json.duplicatePeriods, "duplicatePeriods" );
     displayViolationList( json.validationRulesWithoutGroups, "validationRulesWithoutGroups" );
     displayViolationList( json.invalidValidationRuleLeftSideExpressions, "invalidValidationRuleLeftSideExpressions" );
     displayViolationList( json.invalidValidationRuleRightSideExpressions, "invalidValidationRuleRightSideExpressions" );

=== 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	2012-07-14 13:44:38 +0000
+++ 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
@@ -48,8 +48,9 @@
     #violationWithCollection( "indicatorsWithIdenticalFormulas" $indicatorsWithIdenticalFormulas ),
     #violation( "indicatorsWithoutGroups" $indicatorsWithoutGroups ),    
     #violationWithMap( "invalidIndicatorNumerators" $invalidIndicatorNumerators ),
-    #violationWithMap( "invalidIndicatorDenominators" $invalidIndicatorDenominators ),    
-    #violationWithMapList( "indicatorsViolatingExclusiveGroupSets" $indicatorsViolatingExclusiveGroupSets ),        
+    #violationWithMap( "invalidIndicatorDenominators" $invalidIndicatorDenominators ),
+    #violationWithMapList( "indicatorsViolatingExclusiveGroupSets" $indicatorsViolatingExclusiveGroupSets ),
+    #violation( "duplicatePeriods" $duplicatePeriods ),
     #violation( "organisationUnitsWithCyclicReferences" $organisationUnitsWithCyclicReferences ),
     #violation( "orphanedOrganisationUnits" $orphanedOrganisationUnits ),
     #violation( "organisationUnitsWithoutGroups" $organisationUnitsWithoutGroups ),