← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16134: Introduced interface AnalyticalObject. Using this in service interfaces instead of base object.

 

------------------------------------------------------------
revno: 16134
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-07-15 16:36:07 +0200
message:
  Introduced interface AnalyticalObject. Using this in service interfaces instead of base object.
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObject.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java
  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/MockAnalyticsService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.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
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObject.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObject.java	2014-07-15 14:36:07 +0000
@@ -0,0 +1,55 @@
+package org.hisp.dhis.common;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+
+/**
+* @author Lars Helge Overland
+*/
+public interface AnalyticalObject
+{
+    void populateAnalyticalProperties();
+    
+    List<DimensionalObject> getColumns();
+    
+    List<DimensionalObject> getRows();
+    
+    List<DimensionalObject> getFilters();
+    
+    Map<String, String> getParentGraphMap();
+    
+    Date getRelativePeriodDate();
+    
+    OrganisationUnit getRelativeOrganisationUnit();
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java	2014-07-14 23:08:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java	2014-07-15 14:36:07 +0000
@@ -101,7 +101,8 @@
  */
 @JacksonXmlRootElement( localName = "analyticalObject", namespace = DxfNamespaces.DXF_2_0 )
 public abstract class BaseAnalyticalObject
-    extends BaseIdentifiableObject
+    extends BaseIdentifiableObject 
+    implements AnalyticalObject
 {
     public static final String NUMBER_FORMATTING_COMMA = "comma";
     public static final String NUMBER_FORMATTING_SPACE = "space";

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java	2014-07-02 11:08:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java	2014-07-15 14:36:07 +0000
@@ -33,9 +33,10 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.hisp.dhis.common.BaseAnalyticalObject;
+import org.hisp.dhis.common.AnalyticalObject;
 import org.hisp.dhis.common.DimensionalObject;
 import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.common.IllegalQueryException;
 import org.hisp.dhis.i18n.I18nFormat;
 
 /**
@@ -133,13 +134,13 @@
     /**
      * Generates a mapping where the key represents the dimensional item identifiers
      * concatenated by "-" and the value is the corresponding aggregated data value
-     * based on the given BaseAnalyticalObject.
+     * based on the given AnalyticalObject.
      * 
      * @param object the BaseAnalyticalObject.
      * @param format the I18nFormat, can be null.
      * @return a mapping of dimensional items and aggregated data values.
      */
-    Map<String, Double> getAggregatedDataValueMapping( BaseAnalyticalObject object, I18nFormat format );
+    Map<String, Double> getAggregatedDataValueMapping( AnalyticalObject object, I18nFormat format );
 
     /**
      * Creates a data query parameter object from the given URL.
@@ -168,7 +169,7 @@
      * @param format the i18n format.
      * @return a data query parameter object created based on the given BaseAnalyticalObject.
      */
-    DataQueryParams getFromAnalyticalObject( BaseAnalyticalObject object, I18nFormat format );
+    DataQueryParams getFromAnalyticalObject( AnalyticalObject object, I18nFormat format );
     
     /**
      * Returns a list of persisted DimensionalObjects generated from the given 

=== 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	2014-07-12 17:11:38 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2014-07-15 14:36:07 +0000
@@ -87,7 +87,7 @@
 import org.hisp.dhis.analytics.DataQueryParams;
 import org.hisp.dhis.analytics.DimensionItem;
 import org.hisp.dhis.analytics.QueryPlanner;
-import org.hisp.dhis.common.BaseAnalyticalObject;
+import org.hisp.dhis.common.AnalyticalObject;
 import org.hisp.dhis.common.BaseDimensionalObject;
 import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.common.CombinationGenerator;
@@ -512,7 +512,7 @@
     }
     
     @Override
-    public Map<String, Double> getAggregatedDataValueMapping( BaseAnalyticalObject object, I18nFormat format )
+    public Map<String, Double> getAggregatedDataValueMapping( AnalyticalObject object, I18nFormat format )
     {
         DataQueryParams params = getFromAnalyticalObject( object, format );
         
@@ -749,7 +749,7 @@
     }
 
     @Override
-    public DataQueryParams getFromAnalyticalObject( BaseAnalyticalObject object, I18nFormat format )
+    public DataQueryParams getFromAnalyticalObject( AnalyticalObject object, I18nFormat format )
     {
         DataQueryParams params = new DataQueryParams();
         

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java	2014-07-02 11:08:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java	2014-07-15 14:36:07 +0000
@@ -37,7 +37,7 @@
 import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.analytics.AnalyticsService;
 import org.hisp.dhis.analytics.DataQueryParams;
-import org.hisp.dhis.common.BaseAnalyticalObject;
+import org.hisp.dhis.common.AnalyticalObject;
 import org.hisp.dhis.common.DimensionalObject;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.i18n.I18nFormat;
@@ -74,7 +74,7 @@
     }
 
     @Override
-    public Map<String, Double> getAggregatedDataValueMapping( BaseAnalyticalObject object, I18nFormat format )
+    public Map<String, Double> getAggregatedDataValueMapping( AnalyticalObject object, I18nFormat format )
     {
         return valueMap;
     }
@@ -87,7 +87,7 @@
     }
 
     @Override
-    public DataQueryParams getFromAnalyticalObject( BaseAnalyticalObject object, I18nFormat format )
+    public DataQueryParams getFromAnalyticalObject( AnalyticalObject object, I18nFormat format )
     {
         throw new NotImplementedException();
     }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java	2014-07-13 09:53:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java	2014-07-15 14:36:07 +0000
@@ -31,7 +31,7 @@
 import java.util.Set;
 
 import org.hisp.dhis.analytics.SortOrder;
-import org.hisp.dhis.common.BaseAnalyticalObject;
+import org.hisp.dhis.common.AnalyticalObject;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.i18n.I18nFormat;
 
@@ -44,7 +44,7 @@
     
     Grid getAggregatedEventData( EventQueryParams params );
     
-    Grid getAggregatedEventData( BaseAnalyticalObject object, I18nFormat format );
+    Grid getAggregatedEventData( AnalyticalObject object, I18nFormat format );
     
     Grid getEvents( EventQueryParams params );
 
@@ -61,5 +61,5 @@
     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 hierarchyMeta, boolean coordinatesOnly, Integer page, Integer pageSize, I18nFormat format );
     
-    EventQueryParams getFromAnalyticalObject( BaseAnalyticalObject object, I18nFormat format );
+    EventQueryParams getFromAnalyticalObject( AnalyticalObject object, I18nFormat format );
 }

=== 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	2014-07-14 23:08:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2014-07-15 14:36:07 +0000
@@ -54,7 +54,7 @@
 import org.hisp.dhis.analytics.event.EventAnalyticsService;
 import org.hisp.dhis.analytics.event.EventQueryParams;
 import org.hisp.dhis.analytics.event.EventQueryPlanner;
-import org.hisp.dhis.common.BaseAnalyticalObject;
+import org.hisp.dhis.common.AnalyticalObject;
 import org.hisp.dhis.common.DimensionType;
 import org.hisp.dhis.common.DimensionalObject;
 import org.hisp.dhis.common.Grid;
@@ -217,7 +217,7 @@
         return grid;
     }
     
-    public Grid getAggregatedEventData( BaseAnalyticalObject object, I18nFormat format )
+    public Grid getAggregatedEventData( AnalyticalObject object, I18nFormat format )
     {
         EventQueryParams params = getFromAnalyticalObject( object, format );
         
@@ -441,7 +441,7 @@
     /**
      * TODO Generalize and change from EventChart to EventAnalyticalObject.
      */
-    public EventQueryParams getFromAnalyticalObject( BaseAnalyticalObject object_, I18nFormat format )
+    public EventQueryParams getFromAnalyticalObject( AnalyticalObject object_, I18nFormat format )
     {
         EventChart object = (EventChart) object_; //TODO temporary