← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20282: Re-arranged data element operand methods

 

------------------------------------------------------------
revno: 20282
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-09-22 11:35:56 +0200
message:
  Re-arranged data element operand methods
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.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-08-19 11:58:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java	2015-09-22 09:35:56 +0000
@@ -545,50 +545,6 @@
      */
     DataElementCategoryOptionCombo getDataElementCategoryOptionComboAcl( IdentifiableProperty property, String id );
     
-    /**
-     * Populates all transient properties on each Operand in the given
-     * collection.
-     * 
-     * @param operands the collection of Operands.
-     * @return a set of Operands.
-     */
-    List<DataElementOperand> populateOperands( List<DataElementOperand> operands );
-
-    /**
-     * Gets the Operands for the given Collection of DataElements.
-     * 
-     * @param dataElements the Collection of DataElements.
-     * @return the Operands for the given Collection of DataElements.
-     */
-    List<DataElementOperand> getOperands( Collection<DataElement> dataElements );
-
-    /**
-     * Gets the Operands for the given Collection of DataElements.
-     * 
-     * @param dataElements the Collection of DataElements.
-     * @param includeTotals whether to include DataElement totals in the
-     *        Collection of Operands.
-     * @return the Operands for the given Collection of DataElements.
-     */
-    List<DataElementOperand> getOperands( Collection<DataElement> dataElements, boolean includeTotals );
-
-    /**
-     * Gets the Operands for the DataElements with names like the given name.
-     * 
-     * @param name the name.
-     * @return the Operands for the DataElements with names like the given name.
-     */
-    List<DataElementOperand> getOperandsLikeName( String name );
-
-    /**
-     * 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 );
-
     List<DataElementCategory> getDataElementCategoriesBetween( int first, int max );
 
     List<DataElementCategory> getDataElementCategoriesBetweenByName( String name, int first, int max );
@@ -624,6 +580,54 @@
     List<DataElementCategoryCombo> getDataElementCategoryCombosBetweenByName( String name, int first, int max );
 
     // -------------------------------------------------------------------------
+    // DataElementOperand
+    // -------------------------------------------------------------------------
+
+    /**
+     * Populates all transient properties on each Operand in the given
+     * collection.
+     * 
+     * @param operands the collection of Operands.
+     * @return a set of Operands.
+     */
+    List<DataElementOperand> populateOperands( List<DataElementOperand> operands );
+
+    /**
+     * Gets the Operands for the given Collection of DataElements.
+     * 
+     * @param dataElements the Collection of DataElements.
+     * @return the Operands for the given Collection of DataElements.
+     */
+    List<DataElementOperand> getOperands( Collection<DataElement> dataElements );
+
+    /**
+     * Gets the Operands for the DataElements with names like the given name.
+     * 
+     * @param name the name.
+     * @return the Operands for the DataElements with names like the given name.
+     */
+    List<DataElementOperand> getOperandsLikeName( String name );
+
+    /**
+     * Gets the Operands for the given Collection of DataElements.
+     * 
+     * @param dataElements the Collection of DataElements.
+     * @param includeTotals whether to include DataElement totals in the
+     *        Collection of Operands.
+     * @return the Operands for the given Collection of DataElements.
+     */
+    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-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-17 13:53:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2015-09-22 09:35:56 +0000
@@ -717,87 +717,6 @@
     }
 
     @Override
-    public List<DataElementOperand> populateOperands( List<DataElementOperand> operands )
-    {
-        for ( DataElementOperand operand : operands )
-        {
-            DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() );
-            DataElementCategoryOptionCombo categoryOptionCombo = getDataElementCategoryOptionCombo( operand
-                .getOptionComboId() );
-
-            operand.updateProperties( dataElement, categoryOptionCombo );
-        }
-
-        return operands;
-    }
-
-    @Override
-    public List<DataElementOperand> getOperands( Collection<DataElement> dataElements )
-    {
-        return getOperands( dataElements, false );
-    }
-
-    @Override
-    public List<DataElementOperand> getOperands( Collection<DataElement> dataElements, boolean includeTotals )
-    {
-        List<DataElementOperand> operands = new ArrayList<>();
-
-        for ( DataElement dataElement : dataElements )
-        {
-            if ( dataElement != null && dataElement.getCategoryCombo() != null )
-            {
-                if ( !dataElement.getCategoryCombo().isDefault() && includeTotals )
-                {
-                    DataElementOperand operand = new DataElementOperand();
-                    operand.updateProperties( dataElement );
-    
-                    operands.add( operand );
-                }
-    
-                for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getSortedOptionCombos() )
-                {
-                    DataElementOperand operand = new DataElementOperand();
-                    operand.updateProperties( dataElement, categoryOptionCombo );
-    
-                    operands.add( operand );
-                }
-            }
-        }
-
-        return operands;
-    }
-
-    @Override
-    public List<DataElementOperand> getOperandsLikeName( String name )
-    {
-        List<DataElement> dataElements = dataElementService.getDataElementsLikeName( name );
-
-        return getOperands( dataElements );
-    }
-
-    @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;
-    }
-
-    @Override
     public void generateOptionCombos( DataElementCategoryCombo categoryCombo )
     {
         categoryCombo.generateOptionCombos();
@@ -906,7 +825,92 @@
         
         return options.size() == categoryOptionCombo.getCategoryOptions().size();
     }
-    
+
+    // -------------------------------------------------------------------------
+    // DataElementOperand
+    // -------------------------------------------------------------------------
+
+    @Override
+    public List<DataElementOperand> populateOperands( List<DataElementOperand> operands )
+    {
+        for ( DataElementOperand operand : operands )
+        {
+            DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() );
+            DataElementCategoryOptionCombo categoryOptionCombo = getDataElementCategoryOptionCombo( operand
+                .getOptionComboId() );
+
+            operand.updateProperties( dataElement, categoryOptionCombo );
+        }
+
+        return operands;
+    }
+
+    @Override
+    public List<DataElementOperand> getOperands( Collection<DataElement> dataElements )
+    {
+        return getOperands( dataElements, false );
+    }
+
+    @Override
+    public List<DataElementOperand> getOperandsLikeName( String name )
+    {
+        List<DataElement> dataElements = dataElementService.getDataElementsLikeName( name );
+
+        return getOperands( dataElements );
+    }
+
+    @Override
+    public List<DataElementOperand> getOperands( Collection<DataElement> dataElements, boolean includeTotals )
+    {
+        List<DataElementOperand> operands = new ArrayList<>();
+
+        for ( DataElement dataElement : dataElements )
+        {
+            if ( dataElement != null && dataElement.getCategoryCombo() != null )
+            {
+                if ( !dataElement.getCategoryCombo().isDefault() && includeTotals )
+                {
+                    DataElementOperand operand = new DataElementOperand();
+                    operand.updateProperties( dataElement );
+    
+                    operands.add( operand );
+                }
+    
+                for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getSortedOptionCombos() )
+                {
+                    DataElementOperand operand = new DataElementOperand();
+                    operand.updateProperties( dataElement, categoryOptionCombo );
+    
+                    operands.add( operand );
+                }
+            }
+        }
+
+        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
     // -------------------------------------------------------------------------