← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21194: EventQuery, using enum OrganisationUnitSelectionMode

 

------------------------------------------------------------
revno: 21194
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-11-25 21:23:53 +0100
message:
  EventQuery, using enum OrganisationUnitSelectionMode
modified:
  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/event/EventDataQueryService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventDataQueryService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.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/DimensionalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java	2015-10-19 14:29:04 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java	2015-11-25 20:23:53 +0000
@@ -64,11 +64,6 @@
     String ORGUNIT_GROUP_DIM_ID = "oug"; // Used for org unit target
     String ITEM_DIM_ID = "item";
 
-    String OU_MODE_SELECTED = "selected"; //TODO replace with OrganisationUnitSelectionMode
-    String OU_MODE_CHILDREN = "children";
-    String OU_MODE_DESCENDANTS = "descendants";
-    String OU_MODE_ALL = "all";
-    
     String DIMENSION_SEP = "-";
 
     String LONGITUDE_DIM_ID = "longitude";

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventDataQueryService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventDataQueryService.java	2015-11-05 02:57:57 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventDataQueryService.java	2015-11-25 20:23:53 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.analytics.SortOrder;
 import org.hisp.dhis.common.DisplayProperty;
 import org.hisp.dhis.common.EventAnalyticalObject;
+import org.hisp.dhis.common.OrganisationUnitSelectionMode;
 import org.hisp.dhis.i18n.I18nFormat;
 
 /**
@@ -97,7 +98,7 @@
      * @param format the i18n format.
      */
     EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate, Set<String> dimension, Set<String> filter, 
-        String ouMode, Set<String> asc, Set<String> desc, boolean skipMeta, boolean skipData, boolean completedOnly, boolean hierarchyMeta, boolean coordinatesOnly, 
+        OrganisationUnitSelectionMode ouMode, Set<String> asc, Set<String> desc, boolean skipMeta, boolean skipData, boolean completedOnly, boolean hierarchyMeta, boolean coordinatesOnly, 
         DisplayProperty displayProperty, String userOrgUnit, Integer page, Integer pageSize, I18nFormat format );
     
     EventQueryParams getFromAnalyticalObject( EventAnalyticalObject object, I18nFormat format );

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java	2015-09-09 14:56:40 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java	2015-11-25 20:23:53 +0000
@@ -46,6 +46,7 @@
 import org.hisp.dhis.common.DimensionalObject;
 import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.common.NameableObjectUtils;
+import org.hisp.dhis.common.OrganisationUnitSelectionMode;
 import org.hisp.dhis.common.QueryItem;
 import org.hisp.dhis.commons.collection.ListUtils;
 import org.hisp.dhis.dataelement.DataElement;
@@ -80,22 +81,48 @@
 
     private List<String> desc = new ArrayList<>();
     
-    private String organisationUnitMode;
+    private OrganisationUnitSelectionMode organisationUnitMode;
 
+    /**
+     * The page number.
+     */
     private Integer page;
 
+    /**
+     * The page size.
+     */
     private Integer pageSize;
 
+    /**
+     * The value sort order.
+     */
     private SortOrder sortOrder;
 
+    /**
+     * The max limit of records to return.
+     */
     private Integer limit;
 
+    /**
+     * Indicates the event output type which can be by event, enrollment type
+     * or tracked entity instance.
+     */
     private EventOutputType outputType;
 
+    /**
+     * Indicates whether the data dimension items should be collapsed into a
+     * single dimension.
+     */
     private boolean collapseDataDimensions;
 
+    /**
+     * Indicates whether request is intended to fetch coordinates only.
+     */
     private boolean coordinatesOnly;
 
+    /**
+     * Indicates whether the query originates from an aggregate data query.
+     */
     private boolean aggregateData;
 
     // -------------------------------------------------------------------------
@@ -348,9 +375,9 @@
     /**
      * Indicates whether this query is of the given organisation unit mode.
      */
-    public boolean isOrganisationUnitMode( String mode )
+    public boolean isOrganisationUnitMode( OrganisationUnitSelectionMode mode )
     {
-        return organisationUnitMode != null && organisationUnitMode.equalsIgnoreCase( mode );
+        return organisationUnitMode != null && organisationUnitMode == mode;
     }
 
     /**
@@ -568,12 +595,12 @@
         this.desc = desc;
     }
 
-    public String getOrganisationUnitMode()
+    public OrganisationUnitSelectionMode getOrganisationUnitMode()
     {
         return organisationUnitMode;
     }
 
-    public void setOrganisationUnitMode( String organisationUnitMode )
+    public void setOrganisationUnitMode( OrganisationUnitSelectionMode organisationUnitMode )
     {
         this.organisationUnitMode = organisationUnitMode;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2015-11-17 13:49:52 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2015-11-25 20:23:53 +0000
@@ -141,7 +141,7 @@
                     grid.addHeader( new GridHeader( item.getItem().getUid(), item.getItem().getName(), item.getTypeAsString(), false, true, item.getOptionSetUid(), legendSet ) );
                 }
             }
-    
+            
             for ( DimensionalObject dimension : params.getDimensions() )
             {
                 grid.addHeader( new GridHeader( dimension.getDimension(), dimension.getDisplayName(), String.class.getName(), false, true ) );

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventDataQueryService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventDataQueryService.java	2015-11-15 20:30:50 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventDataQueryService.java	2015-11-25 20:23:53 +0000
@@ -53,6 +53,7 @@
 import org.hisp.dhis.common.DisplayProperty;
 import org.hisp.dhis.common.EventAnalyticalObject;
 import org.hisp.dhis.common.IllegalQueryException;
+import org.hisp.dhis.common.OrganisationUnitSelectionMode;
 import org.hisp.dhis.common.QueryFilter;
 import org.hisp.dhis.common.QueryItem;
 import org.hisp.dhis.common.QueryOperator;
@@ -134,7 +135,7 @@
 
     @Override
     public EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate,
-        Set<String> dimension, Set<String> filter, String ouMode, Set<String> asc, Set<String> desc,
+        Set<String> dimension, Set<String> filter, OrganisationUnitSelectionMode ouMode, Set<String> asc, Set<String> desc,
         boolean skipMeta, boolean skipData, boolean completedOnly, boolean hierarchyMeta, boolean coordinatesOnly, 
         DisplayProperty displayProperty, String userOrgUnit, Integer page, Integer pageSize, I18nFormat format )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2015-10-20 14:07:43 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2015-11-25 20:23:53 +0000
@@ -55,6 +55,7 @@
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.GridHeader;
 import org.hisp.dhis.common.NameableObject;
+import org.hisp.dhis.common.OrganisationUnitSelectionMode;
 import org.hisp.dhis.common.QueryFilter;
 import org.hisp.dhis.common.QueryItem;
 import org.hisp.dhis.commons.collection.ListUtils;
@@ -544,11 +545,11 @@
         // Organisation units
         // ---------------------------------------------------------------------
 
-        if ( params.isOrganisationUnitMode( DimensionalObject.OU_MODE_SELECTED ) )
+        if ( params.isOrganisationUnitMode( OrganisationUnitSelectionMode.SELECTED ) )
         {
             sql += "and ou in (" + getQuotedCommaDelimitedString( getUids( params.getDimensionOrFilterItems( ORGUNIT_DIM_ID ) ) ) + ") ";
         }
-        else if ( params.isOrganisationUnitMode( DimensionalObject.OU_MODE_CHILDREN ) )
+        else if ( params.isOrganisationUnitMode( OrganisationUnitSelectionMode.CHILDREN ) )
         {
             sql += "and ou in (" + getQuotedCommaDelimitedString( getUids( params.getOrganisationUnitChildren() ) ) + ") ";
         }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.java	2015-11-05 02:57:57 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.java	2015-11-25 20:23:53 +0000
@@ -43,6 +43,7 @@
 import org.hisp.dhis.analytics.event.EventQueryParams;
 import org.hisp.dhis.common.DisplayProperty;
 import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.common.OrganisationUnitSelectionMode;
 import org.hisp.dhis.i18n.I18nManager;
 import org.hisp.dhis.system.grid.GridUtils;
 import org.hisp.dhis.webapi.utils.ContextUtils;
@@ -303,7 +304,7 @@
         @RequestParam( required = false ) String endDate,
         @RequestParam Set<String> dimension,
         @RequestParam( required = false ) Set<String> filter,
-        @RequestParam( required = false ) String ouMode,
+        @RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
         @RequestParam( required = false ) Set<String> asc,
         @RequestParam( required = false ) Set<String> desc,
         @RequestParam( required = false ) boolean skipMeta,
@@ -336,7 +337,7 @@
         @RequestParam( required = false ) String endDate,
         @RequestParam Set<String> dimension,
         @RequestParam( required = false ) Set<String> filter,
-        @RequestParam( required = false ) String ouMode,
+        @RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
         @RequestParam( required = false ) Set<String> asc,
         @RequestParam( required = false ) Set<String> desc,
         @RequestParam( required = false ) boolean skipMeta,
@@ -367,7 +368,7 @@
         @RequestParam( required = false ) String endDate,
         @RequestParam Set<String> dimension,
         @RequestParam( required = false ) Set<String> filter,
-        @RequestParam( required = false ) String ouMode,
+        @RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
         @RequestParam( required = false ) Set<String> asc,
         @RequestParam( required = false ) Set<String> desc,
         @RequestParam( required = false ) boolean skipMeta,
@@ -398,7 +399,7 @@
         @RequestParam( required = false ) String endDate,
         @RequestParam Set<String> dimension,
         @RequestParam( required = false ) Set<String> filter,
-        @RequestParam( required = false ) String ouMode,
+        @RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
         @RequestParam( required = false ) Set<String> asc,
         @RequestParam( required = false ) Set<String> desc,
         @RequestParam( required = false ) boolean skipMeta,
@@ -429,7 +430,7 @@
         @RequestParam( required = false ) String endDate,
         @RequestParam Set<String> dimension,
         @RequestParam( required = false ) Set<String> filter,
-        @RequestParam( required = false ) String ouMode,
+        @RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
         @RequestParam( required = false ) Set<String> asc,
         @RequestParam( required = false ) Set<String> desc,
         @RequestParam( required = false ) boolean skipMeta,
@@ -460,7 +461,7 @@
         @RequestParam( required = false ) String endDate,
         @RequestParam Set<String> dimension,
         @RequestParam( required = false ) Set<String> filter,
-        @RequestParam( required = false ) String ouMode,
+        @RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
         @RequestParam( required = false ) Set<String> asc,
         @RequestParam( required = false ) Set<String> desc,
         @RequestParam( required = false ) boolean skipMeta,