← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9636: DataEntry - Mutli-entry-org-unit form - Fixed bug getting data value.

 

------------------------------------------------------------
revno: 9636
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-01-28 16:58:12 +0700
message:
  DataEntry - Mutli-entry-org-unit form - Fixed bug getting data value.
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/de/action/GetDataValuesForDataSetAction.java


--
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-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java	2012-11-12 12:47:02 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java	2013-01-28 09:58:12 +0000
@@ -190,20 +190,21 @@
         // Data values & Min-max data elements
         // ---------------------------------------------------------------------
 
-        if ( !multiOrganisationUnit )
-        {
-            dataValues = dataValueService.getDataValues( organisationUnit, period, dataSet.getDataElements() );
-            minMaxDataElements = minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataSet.getDataElements() );
-        }
-        else
+        dataValues.addAll( dataValueService.getDataValues( organisationUnit, period, dataSet.getDataElements() ) );
+        minMaxDataElements.addAll( minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataSet
+            .getDataElements() ) );
+
+        if ( multiOrganisationUnit )
         {
             for ( OrganisationUnit ou : children )
             {
-                // make sure that the orgUnit have this dataSet (the same data elements can be contained in another dataSet)
+                // make sure that the orgUnit have this dataSet (the same data
+                // elements can be contained in another dataSet)
                 if ( ou.getDataSets().contains( dataSet ) )
                 {
                     dataValues.addAll( dataValueService.getDataValues( ou, period, dataSet.getDataElements() ) );
-                    minMaxDataElements.addAll( minMaxDataElementService.getMinMaxDataElements( ou, dataSet.getDataElements() ) );
+                    minMaxDataElements.addAll( minMaxDataElementService.getMinMaxDataElements( ou, dataSet
+                        .getDataElements() ) );
                 }
             }
         }
@@ -216,7 +217,8 @@
         {
             if ( !multiOrganisationUnit )
             {
-                CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, organisationUnit );
+                CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet,
+                    period, organisationUnit );
 
                 if ( registration != null )
                 {
@@ -231,7 +233,8 @@
             {
                 complete = true;
 
-                // if this is multiOrg, and one of the children is locked. Then just lock everything down.
+                // if this is multiOrg, and one of the children is locked. Then
+                // just lock everything down.
                 for ( OrganisationUnit ou : children )
                 {
                     if ( ou.getDataSets().contains( dataSet ) )
@@ -243,7 +246,8 @@
                             break;
                         }
 
-                        CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, ou );
+                        CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration(
+                            dataSet, period, ou );
 
                         if ( complete && registration == null )
                         {

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/de/action/GetDataValuesForDataSetAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/de/action/GetDataValuesForDataSetAction.java	2013-01-10 10:13:56 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/de/action/GetDataValuesForDataSetAction.java	2013-01-28 09:58:12 +0000
@@ -215,72 +215,70 @@
         // Data values & Min-max data elements
         // ---------------------------------------------------------------------
 
-        if ( !multiOrganisationUnit )
-        {
-            dataValues.addAll( dataValueService.getDataValues( organisationUnit, period, dataSet.getDataElements() ) );
-            minMaxDataElements = minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataSet
-                .getDataElements() );
-
-            // ---------------------------------------------------------------------
-            // Modified 1
-            // ---------------------------------------------------------------------
-
-            Set<DataElement> compulsoryElements = new HashSet<DataElement>();
-
-            for ( DataElementOperand operand : dataSet.getCompulsoryDataElementOperands() )
-            {
-                compulsoryElements.add( operand.getDataElement() );
-            }
-
-            for ( DataValue dv : dataValues )
-            {
-                Iterator<DataElement> iterator = compulsoryElements.iterator();
-
-                while ( iterator.hasNext() )
-                {
-                    if ( iterator.next().equals( dv.getDataElement() ) )
-                    {
-                        iterator.remove();
-                    }
-                }
-            }
-
-            if ( !compulsoryElements.isEmpty() )
-            {
-                Collection<Period> periods = localPeriodService.getPreviousPeriods( period );
-
-                Collection<DataValue> previousDataValues = localDataValueService.getDataValues( organisationUnit,
-                    compulsoryElements, periods );
-
-                Map<String, DataValue> dataValueMap = new HashMap<String, DataValue>();
-
-                for ( DataValue dv : previousDataValues )
-                {
-                    String key = dv.getDataElement().getId() + SEPARATE + dv.getOptionCombo().getId();
-
-                    if ( !dataValueMap.containsKey( key )
-                        || dv.getPeriod().getStartDate().after( dataValueMap.get( key ).getPeriod().getStartDate() ) )
-                    {
-                        dataValueMap.put( key, dv );
-                    }
-                }
-
-                if ( !dataValueMap.isEmpty() )
-                {
-                    dataValues.addAll( dataValueMap.values() );
-                }
-
-                periods = null;
-                previousDataValues = null;
-                dataValueMap = null;
-                compulsoryElements = null;
-            }
-
-            // ---------------------------------------------------------------------
-            // End of modified 1
-            // ---------------------------------------------------------------------
-        }
-        else
+        dataValues.addAll( dataValueService.getDataValues( organisationUnit, period, dataSet.getDataElements() ) );
+        minMaxDataElements.addAll( minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataSet
+            .getDataElements() ) );
+
+        // ---------------------------------------------------------------------
+        // Modified 1
+        // ---------------------------------------------------------------------
+
+        Set<DataElement> compulsoryElements = new HashSet<DataElement>();
+
+        for ( DataElementOperand operand : dataSet.getCompulsoryDataElementOperands() )
+        {
+            compulsoryElements.add( operand.getDataElement() );
+        }
+
+        for ( DataValue dv : dataValues )
+        {
+            Iterator<DataElement> iterator = compulsoryElements.iterator();
+
+            while ( iterator.hasNext() )
+            {
+                if ( iterator.next().equals( dv.getDataElement() ) )
+                {
+                    iterator.remove();
+                }
+            }
+        }
+
+        if ( !compulsoryElements.isEmpty() )
+        {
+            Collection<Period> periods = localPeriodService.getPreviousPeriods( period );
+
+            Collection<DataValue> previousDataValues = localDataValueService.getDataValues( organisationUnit,
+                compulsoryElements, periods );
+
+            Map<String, DataValue> dataValueMap = new HashMap<String, DataValue>();
+
+            for ( DataValue dv : previousDataValues )
+            {
+                String key = dv.getDataElement().getId() + SEPARATE + dv.getOptionCombo().getId();
+
+                if ( !dataValueMap.containsKey( key )
+                    || dv.getPeriod().getStartDate().after( dataValueMap.get( key ).getPeriod().getStartDate() ) )
+                {
+                    dataValueMap.put( key, dv );
+                }
+            }
+
+            if ( !dataValueMap.isEmpty() )
+            {
+                dataValues.addAll( dataValueMap.values() );
+            }
+
+            periods = null;
+            previousDataValues = null;
+            dataValueMap = null;
+            compulsoryElements = null;
+        }
+
+        // ---------------------------------------------------------------------
+        // End of modified 1
+        // ---------------------------------------------------------------------
+
+        if ( multiOrganisationUnit )
         {
             for ( OrganisationUnit ou : children )
             {
@@ -296,14 +294,14 @@
                     // Modified 2
                     // ---------------------------------------------------------------------
 
-                    Set<DataElement> compulsoryElements = new HashSet<DataElement>();
+                    Set<DataElement> compulsoryElements2 = new HashSet<DataElement>();
 
                     for ( DataElementOperand operand : dataSet.getCompulsoryDataElementOperands() )
                     {
-                        compulsoryElements.add( operand.getDataElement() );
+                        compulsoryElements2.add( operand.getDataElement() );
                     }
 
-                    Iterator<DataElement> iterator = compulsoryElements.iterator();
+                    Iterator<DataElement> iterator = compulsoryElements2.iterator();
 
                     for ( DataValue dv : dataValues )
                     {
@@ -316,12 +314,12 @@
                         }
                     }
 
-                    if ( !compulsoryElements.isEmpty() )
+                    if ( !compulsoryElements2.isEmpty() )
                     {
                         Collection<Period> periods = localPeriodService.getPreviousPeriods( period );
 
                         Collection<DataValue> previousDataValues = localDataValueService.getDataValues( ou,
-                            compulsoryElements, periods );
+                            compulsoryElements2, periods );
 
                         Map<String, DataValue> dataValueMap = new HashMap<String, DataValue>();
 
@@ -342,7 +340,7 @@
                         periods = null;
                         previousDataValues = null;
                         dataValueMap = null;
-                        compulsoryElements = null;
+                        compulsoryElements2 = null;
                     }
 
                     // ---------------------------------------------------------------------