← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19381: Analytics, meta-data, including element with ordered items for dimensions where all items were re...

 

------------------------------------------------------------
revno: 19381
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-06-13 16:19:23 +0200
message:
  Analytics, meta-data, including element with ordered items for dimensions where all items were requested
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseDimensionalObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.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/common/BaseDimensionalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseDimensionalObject.java	2015-06-13 13:55:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseDimensionalObject.java	2015-06-13 14:19:23 +0000
@@ -66,6 +66,11 @@
      * The dimensional items for this dimension.
      */
     private List<NameableObject> items = new ArrayList<>();
+    
+    /**
+     * Indicates whether all available items in this dimension are included.
+     */
+    private boolean allItems;
 
     /**
      * The legend set for this dimension.
@@ -110,11 +115,15 @@
 
     public BaseDimensionalObject( String dimension, DimensionType dimensionType, String dimensionName, String displayName, List<? extends NameableObject> items )
     {
-        this.uid = dimension;
-        this.dimensionType = dimensionType;
+        this( dimension, dimensionType, items );
         this.dimensionName = dimensionName;
         this.displayName = displayName;
-        this.items = new ArrayList<>( items );
+    }
+
+    public BaseDimensionalObject( String dimension, DimensionType dimensionType, String dimensionName, String displayName, List<? extends NameableObject> items, boolean allItems )
+    {
+        this( dimension, dimensionType, dimensionName, displayName, items );
+        this.allItems = allItems;
     }
 
     public BaseDimensionalObject( String dimension, DimensionType dimensionType, String dimensionName, String displayName, LegendSet legendSet, String filter )
@@ -229,6 +238,21 @@
 
     @Override
     @JsonProperty
+    @JsonView( { DimensionalView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public boolean isAllItems()
+    {
+        return allItems;
+    }
+
+    public void setAllItems( boolean allItems )
+    {
+        this.allItems = allItems;
+    }
+
+
+    @Override
+    @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( { DimensionalView.class, DetailedView.class, ExportView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
@@ -313,6 +337,7 @@
             .add( "dimension name", dimensionName )
             .add( "display name", displayName )
             .add( "items", items )
+            .add( "all items", allItems )
             .add( "legend set", legendSet )
             .add( "filter", filter ).toString();
     }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java	2015-06-13 13:55:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java	2015-06-13 14:19:23 +0000
@@ -110,6 +110,11 @@
     List<NameableObject> getItems();
 
     /**
+     * Indicates whether all available items in this dimension are included.
+     */
+    boolean isAllItems();
+    
+    /**
      * Indicates whether this dimension has any dimension items.
      */
     boolean hasItems();

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2015-06-13 12:41:24 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2015-06-13 14:19:23 +0000
@@ -466,7 +466,11 @@
         if ( !params.isSkipMeta() )
         {
             Map<Object, Object> metaData = new HashMap<>();
-            
+
+            // -----------------------------------------------------------------
+            // Names element
+            // -----------------------------------------------------------------
+
             Map<String, String> uidNameMap = getUidNameMap( params );
             Map<String, String> cocNameMap = getCocNameMap( params );
             uidNameMap.putAll( cocNameMap );
@@ -474,6 +478,10 @@
 
             metaData.put( NAMES_META_KEY, uidNameMap );
 
+            // -----------------------------------------------------------------
+            // Item order elements
+            // -----------------------------------------------------------------
+
             Calendar calendar = PeriodType.getCalendar();
 
             List<String> periodUids = calendar.isIso8601() ? 
@@ -499,6 +507,14 @@
                 metaData.put( OU_NAME_HIERARCHY_KEY, getParentNameGraphMap( organisationUnits, roots, true, params.getDisplayProperty() ) );
             }
 
+            for ( DimensionalObject dim : params.getDimensionsAndFilters() )
+            {
+                if ( dim.isAllItems() )
+                {
+                    metaData.put( dim.getDimension(), getUids( dim.getItems() ) );
+                }
+            }
+            
             grid.setMetaData( metaData );
         }
     }
@@ -1157,7 +1173,7 @@
         {
             List<NameableObject> ous = !allItems ? asList( idObjectManager.getByUidOrdered( OrganisationUnitGroup.class, items ) ) : ougs.getItems();
 
-            DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.ORGANISATIONUNIT_GROUPSET, null, ougs.getDisplayName(), ous );
+            DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.ORGANISATIONUNIT_GROUPSET, null, ougs.getDisplayName(), ous, allItems );
 
             return ListUtils.getList( object );
         }
@@ -1168,7 +1184,7 @@
         {
             List<NameableObject> des = !allItems ? asList( idObjectManager.getByUidOrdered( DataElementGroup.class, items ) ) : degs.getItems();
 
-            DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.DATAELEMENT_GROUPSET, null, degs.getDisplayName(), des );
+            DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.DATAELEMENT_GROUPSET, null, degs.getDisplayName(), des, allItems );
 
             return ListUtils.getList( object );
         }
@@ -1179,7 +1195,7 @@
         {
             List<NameableObject> cogz = !allItems ? asList( idObjectManager.getByUidOrdered( CategoryOptionGroup.class, items ) ) : cogs.getItems();
 
-            DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.CATEGORYOPTION_GROUPSET, null, cogs.getDisplayName(), cogz );
+            DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.CATEGORYOPTION_GROUPSET, null, cogs.getDisplayName(), cogz, allItems );
 
             return ListUtils.getList( object );
         }
@@ -1190,7 +1206,7 @@
         {
             List<NameableObject> decos = !allItems ? asList( idObjectManager.getByUidOrdered( DataElementCategoryOption.class, items ) ) : dec.getItems();
 
-            DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.CATEGORY, null, dec.getDisplayName(), decos );
+            DimensionalObject object = new BaseDimensionalObject( dimension, DimensionType.CATEGORY, null, dec.getDisplayName(), decos, allItems );
 
             return ListUtils.getList( object );
         }