← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13346: made it possible to get dataElementCategories based on type (ATTRIBUTE, DISAGGREGATION)

 

------------------------------------------------------------
revno: 13346
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-12-20 14:30:35 +0100
message:
  made it possible to get dataElementCategories based on type (ATTRIBUTE, DISAGGREGATION)
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementCategoriesAction.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-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementCategoriesAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementCategoriesAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementCategoriesAction.java	2013-12-20 13:30:35 +0000
@@ -28,21 +28,27 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataelement.DataElementCategory;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.paging.ActionPagingSupport;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
 /**
  * @author mortenoh
  */
 public class GetDataElementCategoriesAction
     extends ActionPagingSupport<DataElementCategory>
 {
+    static enum DataElementCategoryType
+    {
+        DISAGGREGATION,
+        ATTRIBUTE
+    }
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -65,6 +71,13 @@
         return dataElementCategories;
     }
 
+    private DataElementCategoryType type;
+
+    public void setType( DataElementCategoryType type )
+    {
+        this.type = type;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -72,8 +85,21 @@
     public String execute()
         throws Exception
     {
-        dataElementCategories = new ArrayList<DataElementCategory>(
-            dataElementCategoryService.getAllDataElementCategories() );
+        if ( type == null )
+        {
+            dataElementCategories = new ArrayList<DataElementCategory>(
+                dataElementCategoryService.getAllDataElementCategories() );
+        }
+        else if ( type.equals( DataElementCategoryType.ATTRIBUTE ) )
+        {
+            dataElementCategories = new ArrayList<DataElementCategory>(
+                dataElementCategoryService.getDisaggregationCategories() );
+        }
+        else if ( type.equals( DataElementCategoryType.DISAGGREGATION ) )
+        {
+            dataElementCategories = new ArrayList<DataElementCategory>(
+                dataElementCategoryService.getAttributeCategories() );
+        }
 
         Collections.sort( dataElementCategories, IdentifiableObjectNameComparator.INSTANCE );