← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13368: Data entry, made multi-org unit forms work again by using uids everywhere

 

------------------------------------------------------------
revno: 13368
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-12-21 18:07:21 +0100
message:
  Data entry, made multi-org unit forms work again by using uids everywhere
modified:
  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/webapp/dhis-web-dataentry/multiOrgSectionForm.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataValues.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-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	2013-12-09 21:32:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java	2013-12-21 17:07:21 +0000
@@ -29,6 +29,9 @@
  */
 
 import com.opensymphony.xwork2.Action;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataset.CompleteDataSetRegistration;
 import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
 import org.hisp.dhis.dataset.DataSet;
@@ -53,6 +56,8 @@
 public class GetDataValuesForDataSetAction
     implements Action
 {
+    private static final Log log = LogFactory.getLog( GetDataValuesForDataSetAction.class );
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -181,32 +186,33 @@
 
     public String execute()
     {
+        DataSet dataSet = dataSetService.getDataSet( dataSetId );
+
+        Period period = PeriodType.getPeriodFromIsoString( periodId );
+
         OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+        if ( organisationUnit == null || period == null || dataSet == null )
+        {
+            log.warn( "Illegal input, org unit: " + organisationUnit + ", period: " + period + ", data set: " + dataSet );
+        }
+
         Set<OrganisationUnit> children = organisationUnit.getChildren();
-
-        DataSet dataSet = dataSetService.getDataSet( dataSetId );
-
-        Period period = PeriodType.getPeriodFromIsoString( periodId );
-
-        // TODO null-checks
-
+        
         // ---------------------------------------------------------------------
         // Data values & Min-max data elements
         // ---------------------------------------------------------------------
 
-        dataValues.addAll( dataValueService.getDataValues( organisationUnit, period, dataSet.getDataElements() ) );
-
-        minMaxDataElements.addAll( minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataSet
-            .getDataElements() ) );
-
-        if ( multiOrganisationUnit )
+        minMaxDataElements.addAll( minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataSet.getDataElements() ) );
+
+        if ( !multiOrganisationUnit )
+        {
+            dataValues.addAll( dataValueService.getDataValues( organisationUnit, period, dataSet.getDataElements() ) );
+        }
+        else
         {
             for ( OrganisationUnit ou : children )
             {
-                // -------------------------------------------------------------
-                // Make sure that the org unit have this data set 
-                // -------------------------------------------------------------
-
                 if ( ou.getDataSets().contains( dataSet ) )
                 {
                     dataValues.addAll( dataValueService.getDataValues( ou, period, dataSet.getDataElements() ) );
@@ -220,48 +226,45 @@
         // Data set completeness info
         // ---------------------------------------------------------------------
 
-        if ( period != null )
+        if ( !multiOrganisationUnit )
         {
-            if ( !multiOrganisationUnit )
-            {
-                CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet,
-                    period, organisationUnit );
-
-                if ( registration != null )
-                {
-                    complete = true;
-                    date = registration.getDate();
-                    storedBy = registration.getStoredBy();
-                }
-
-                locked = dataSetService.isLocked( dataSet, period, organisationUnit, null );
-            }
-            else
+            CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet,
+                period, organisationUnit );
+
+            if ( registration != null )
             {
                 complete = true;
-
-                // -------------------------------------------------------------
-                // If multi-org and one of the children is locked, lock all
-                // -------------------------------------------------------------
-
-                for ( OrganisationUnit ou : children )
+                date = registration.getDate();
+                storedBy = registration.getStoredBy();
+            }
+
+            locked = dataSetService.isLocked( dataSet, period, organisationUnit, null );
+        }
+        else
+        {
+            complete = true;
+
+            // -----------------------------------------------------------------
+            // If multi-org and one of the children is locked, lock all
+            // -----------------------------------------------------------------
+
+            for ( OrganisationUnit ou : children )
+            {
+                if ( ou.getDataSets().contains( dataSet ) )
                 {
-                    if ( ou.getDataSets().contains( dataSet ) )
-                    {
-                        locked = dataSetService.isLocked( dataSet, period, organisationUnit, null );
-
-                        if ( locked )
-                        {
-                            break;
-                        }
-
-                        CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration(
-                            dataSet, period, ou );
-
-                        if ( complete && registration == null )
-                        {
-                            complete = false;
-                        }
+                    locked = dataSetService.isLocked( dataSet, period, organisationUnit, null );
+
+                    if ( locked )
+                    {
+                        break;
+                    }
+
+                    CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration(
+                        dataSet, period, ou );
+
+                    if ( complete && registration == null )
+                    {
+                        complete = false;
                     }
                 }
             }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multiOrgSectionForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multiOrgSectionForm.vm	2013-12-14 14:14:40 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multiOrgSectionForm.vm	2013-12-21 17:07:21 +0000
@@ -10,7 +10,7 @@
   #set( $marker = 1 )
 #end
 
-#if( !$dataSet.renderHorizontally )
+#if( !$dataSet.renderHorizontally ) ## Render horizontally
 <table class="formSection" data-multiorg="true" style="margin-bottom: 20px;">
 <tr>
   <td>
@@ -71,14 +71,14 @@
         #set( $mark = 1 )
         #end
         #set( $count = $count + 1 )
-        #set( $dataEntryId = "${organisationUnit.id}-${dataElement.uid}-${optionCombo.uid}-val" )
+        #set( $dataEntryId = "${organisationUnit.uid}-${dataElement.uid}-${optionCombo.uid}-val" )
         <tr>
             <td #if( $mark == 1 )class="alt"#else class="reg"#end>${encoder.htmlEncode( $organisationUnit.displayName )}</td>
 
             #foreach( $dataElement in $section.dataElements )
                 <span class="hidden" id="${dataElement.uid}-dataelement">${encoder.htmlEncode( $dataElement.getFormNameFallback() )}</span>
                 #foreach( $optionCombo in $optionCombos )
-                #set( $dataEntryId = "${organisationUnit.id}-${dataElement.uid}-${optionCombo.uid}-val" )
+                #set( $dataEntryId = "${organisationUnit.uid}-${dataElement.uid}-${optionCombo.uid}-val" )
                 #set( $greyedField = false )
                 #set( $greyedField = $greyedFields.get( "$dataElement.uid:$optionCombo.uid" ) )
                 #if( $dataElement.type == "bool" )
@@ -107,7 +107,7 @@
     </td>
   </tr>
 </table>
-#else
+#else ## Render vertically
 <table class="formSection" data-multiorg="true" style="margin-bottom: 20px;">
 <tr>
   <td>
@@ -159,7 +159,7 @@
             #foreach( $organisationUnit in $organisationUnits )
                 <span class="hidden" id="${dataElement.uid}-dataelement">${encoder.htmlEncode( $dataElement.getFormNameFallback() )}</span>
                 #foreach( $optionCombo in $optionCombos )
-                    #set( $dataEntryId = "${organisationUnit.id}-${dataElement.uid}-${optionCombo.uid}-val" )
+                    #set( $dataEntryId = "${organisationUnit.uid}-${dataElement.uid}-${optionCombo.uid}-val" )
                     #set( $greyedField = false )
                     #set( $greyedField = $greyedFields.get( "$dataElement.uid:$optionCombo.uid" ) )
                     #if( $dataElement.type == "bool" )
@@ -208,7 +208,7 @@
 
             #foreach( $organisationUnit in $organisationUnits )
                 <span class="hidden" id="${dataElement.uid}-dataelement">${encoder.htmlEncode( $dataElement.getFormNameFallback() )}</span>
-                #set( $dataEntryId = "${organisationUnit.id}-${dataElement.uid}-${optionCombo.uid}-val" )
+                #set( $dataEntryId = "${organisationUnit.uid}-${dataElement.uid}-${optionCombo.uid}-val" )
                 #set( $greyedField = false )
                 #set( $greyedField = $greyedFields.get( "$dataElement.uid:$optionCombo.uid" ) )
                 #if( $dataElement.type == "bool" )

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataValues.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataValues.vm	2013-08-12 22:04:17 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataValues.vm	2013-12-21 17:07:21 +0000
@@ -4,7 +4,7 @@
   #foreach( $value in $dataValues )
   {
     #if( $multiOrganisationUnit )
-    "id":"${value.source.id}-${value.dataElement.uid}-${value.optionCombo.uid}",
+    "id":"${value.source.uid}-${value.dataElement.uid}-${value.optionCombo.uid}",
     #else
     "id":"${value.dataElement.uid}-${value.optionCombo.uid}",
     #end
@@ -16,7 +16,7 @@
   #foreach( $element in $minMaxDataElements )
   {
     #if( $multiOrganisationUnit )
-    "id":"${element.source.id}-${element.dataElement.uid}-${element.optionCombo.uid}",
+    "id":"${element.source.uid}-${element.dataElement.uid}-${element.optionCombo.uid}",
     #else
     "id":"${element.dataElement.uid}-${element.optionCombo.uid}",
     #end