← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20285: Data element operand, centralized method

 

------------------------------------------------------------
revno: 20285
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-09-22 12:25:26 +0200
message:
  Data element operand, centralized method
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementOperandsAction.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-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java	2015-09-22 09:35:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java	2015-09-22 10:25:26 +0000
@@ -618,15 +618,6 @@
      */
     List<DataElementOperand> getOperands( Collection<DataElement> dataElements, boolean includeTotals );
 
-    /**
-     * Gets the Operands for the given Collection of DataElements. Operands will
-     * contain DataElement and CategoryOptionCombo object
-     * 
-     * @param dataElements the Collection of DataElements.
-     * @return the Operands for the given Collection of DataElements.
-     */
-    List<DataElementOperand> getFullOperands( Collection<DataElement> dataElements );
-
     // -------------------------------------------------------------------------
     // CategoryOptionGroup
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java	2015-09-15 09:54:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java	2015-09-22 10:25:26 +0000
@@ -112,6 +112,11 @@
     {
     }
 
+    public DataElementOperand( DataElement dataElement )
+    {
+        this.dataElement = dataElement;
+    }
+
     public DataElementOperand( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo )
     {
         this.dataElement = dataElement;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2015-09-22 09:35:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2015-09-22 10:25:26 +0000
@@ -870,7 +870,7 @@
             {
                 if ( !dataElement.getCategoryCombo().isDefault() && includeTotals )
                 {
-                    DataElementOperand operand = new DataElementOperand();
+                    DataElementOperand operand = new DataElementOperand( dataElement );
                     operand.updateProperties( dataElement );
     
                     operands.add( operand );
@@ -878,7 +878,7 @@
     
                 for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getSortedOptionCombos() )
                 {
-                    DataElementOperand operand = new DataElementOperand();
+                    DataElementOperand operand = new DataElementOperand( dataElement, categoryOptionCombo );
                     operand.updateProperties( dataElement, categoryOptionCombo );
     
                     operands.add( operand );
@@ -889,28 +889,6 @@
         return operands;
     }
 
-    @Override
-    public List<DataElementOperand> getFullOperands( Collection<DataElement> dataElements )
-    {
-        List<DataElementOperand> operands = new ArrayList<>();
-
-        for ( DataElement dataElement : dataElements )
-        {
-            if ( dataElement != null && dataElement.getCategoryCombo() != null )
-            {
-                for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getOptionCombos() )
-                {
-                    DataElementOperand dataElementOperand = new DataElementOperand( dataElement, categoryOptionCombo );
-                    dataElementOperand.updateProperties( dataElement, categoryOptionCombo );
-    
-                    operands.add( dataElementOperand );
-                }
-            }
-        }
-
-        return operands;
-    }
-
     // -------------------------------------------------------------------------
     // CategoryOptionGroup
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java	2015-07-04 16:43:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java	2015-09-22 10:25:26 +0000
@@ -86,12 +86,12 @@
             if ( deGroup != null )
             {
                 DataElementGroup dataElementGroup = manager.get( DataElementGroup.class, deGroup );
-                dataElementOperands = new ArrayList<>( dataElementCategoryService.getFullOperands( dataElementGroup.getMembers() ) );
+                dataElementOperands = new ArrayList<>( dataElementCategoryService.getOperands( dataElementGroup.getMembers() ) );
             }
             else
             {
                 List<DataElement> dataElements = new ArrayList<>( manager.getAllSorted( DataElement.class ) );
-                dataElementOperands = new ArrayList<>( dataElementCategoryService.getFullOperands( dataElements ) );
+                dataElementOperands = new ArrayList<>( dataElementCategoryService.getOperands( dataElements ) );
             }
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementOperandsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementOperandsAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementOperandsAction.java	2015-09-22 10:25:26 +0000
@@ -111,7 +111,7 @@
         {
             dataSet = dataSetService.getDataSet( dataSetId );
 
-            operands = new ArrayList<>( dataElementCategoryService.getFullOperands( dataSet
+            operands = new ArrayList<>( dataElementCategoryService.getOperands( dataSet
                 .getDataElements() ) );
         }
         else