← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 245: Changed DataElementAggregator from abstract class to interface

 

------------------------------------------------------------
revno: 245
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Thu 2009-04-23 22:16:18 +0200
message:
  Changed DataElementAggregator from abstract class to interface
modified:
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/DataElementAggregator.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/CalculatedDataElementDataMart.java

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java	2009-03-20 15:18:04 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java	2009-04-23 20:16:18 +0000
@@ -38,6 +38,8 @@
 
 import org.hisp.dhis.dataelement.Operand;
 import org.hisp.dhis.datamart.CrossTabDataValue;
+import org.hisp.dhis.datamart.DataMartStore;
+import org.hisp.dhis.datamart.aggregation.cache.AggregationCache;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
 import org.hisp.dhis.period.Period;
@@ -47,8 +49,30 @@
  * @version $Id: AverageBoolAggregator.java 6049 2008-10-28 09:36:17Z larshelg $
  */
 public class AverageBoolAggregator
-    extends DataElementAggregator
+    implements DataElementAggregator
 {
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    protected DataMartStore dataMartStore;
+    
+    public void setDataMartStore( DataMartStore dataMartStore )
+    {
+        this.dataMartStore = dataMartStore;
+    }
+    
+    protected AggregationCache aggregationCache;
+        
+    public void setAggregationCache( AggregationCache aggregationCache )
+    {
+        this.aggregationCache = aggregationCache;
+    }
+
+    // -------------------------------------------------------------------------
+    // DataElementAggregator implementation
+    // -------------------------------------------------------------------------
+
     public Map<Operand, Double> getAggregatedValues( final Map<Operand, Integer> operandIndexMap, final Period period, final OrganisationUnit unit )
     {
         final OrganisationUnitHierarchy hierarchy = aggregationCache.getLatestOrganisationUnitHierarchy();
@@ -77,7 +101,7 @@
         
     }
     
-    protected Collection<CrossTabDataValue> getCrossTabDataValues( final Map<Operand, Integer> operandIndexMap, 
+    public Collection<CrossTabDataValue> getCrossTabDataValues( final Map<Operand, Integer> operandIndexMap, 
         final Date startDate, final Date endDate, final int parentId, final OrganisationUnitHierarchy hierarchy )
     {
         final Collection<Integer> sourceIds = aggregationCache.getChildren( hierarchy, parentId );
@@ -94,7 +118,7 @@
         return dataMartStore.getCrossTabDataValues( operandIndexMap, periodIds, sourceIds );
     }
     
-    protected Map<Operand, Double[]> getAggregate( final Collection<CrossTabDataValue> crossTabValues, 
+    public Map<Operand, Double[]> getAggregate( final Collection<CrossTabDataValue> crossTabValues, 
         final Date startDate, final Date endDate, final Date aggregationStartDate, final Date aggregationEndDate )
     {
         final Map<Operand, Double[]> totalSums = new HashMap<Operand, Double[]>(); // <Operand, [total value, total relevant days]>

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java	2009-03-20 15:18:04 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java	2009-04-23 20:16:18 +0000
@@ -40,6 +40,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataelement.Operand;
 import org.hisp.dhis.datamart.CrossTabDataValue;
+import org.hisp.dhis.datamart.DataMartStore;
+import org.hisp.dhis.datamart.aggregation.cache.AggregationCache;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
 import org.hisp.dhis.period.Period;
@@ -49,10 +51,32 @@
  * @version $Id: AverageIntAggregator.java 6049 2008-10-28 09:36:17Z larshelg $
  */
 public class AverageIntAggregator
-    extends DataElementAggregator
+    implements DataElementAggregator
 {
     private static final Log log = LogFactory.getLog( AverageIntAggregator.class );
     
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    protected DataMartStore dataMartStore;
+    
+    public void setDataMartStore( DataMartStore dataMartStore )
+    {
+        this.dataMartStore = dataMartStore;
+    }
+    
+    protected AggregationCache aggregationCache;
+        
+    public void setAggregationCache( AggregationCache aggregationCache )
+    {
+        this.aggregationCache = aggregationCache;
+    }
+
+    // -------------------------------------------------------------------------
+    // DataElementAggregator implementation
+    // -------------------------------------------------------------------------
+
     public Map<Operand, Double> getAggregatedValues( final Map<Operand, Integer> operandIndexMap, final Period period, final OrganisationUnit unit )
     {
         final OrganisationUnitHierarchy hierarchy = aggregationCache.getLatestOrganisationUnitHierarchy();
@@ -88,7 +112,7 @@
         return values;
     }
     
-    protected Collection<CrossTabDataValue> getCrossTabDataValues( final Map<Operand, Integer> operandIndexMap, 
+    public Collection<CrossTabDataValue> getCrossTabDataValues( final Map<Operand, Integer> operandIndexMap, 
         final Date startDate, final Date endDate, final int parentId, final OrganisationUnitHierarchy hierarchy )
     {
         final Collection<Period> periods = aggregationCache.getIntersectingPeriods( startDate, endDate );
@@ -103,7 +127,7 @@
         return dataMartStore.getCrossTabDataValues( operandIndexMap, periodIds, parentId );
     }
     
-    protected Map<Operand, Double[]> getAggregate( final Collection<CrossTabDataValue> crossTabValues, 
+    public Map<Operand, Double[]> getAggregate( final Collection<CrossTabDataValue> crossTabValues, 
         final Date startDate, final Date endDate, final Date aggregationStartDate, final Date aggregationEndDate )
     {
         final Map<Operand, Double[]> totalSums = new HashMap<Operand, Double[]>(); // <Operand, [total value, total relevant days]>

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/DataElementAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/DataElementAggregator.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/DataElementAggregator.java	2009-04-23 20:16:18 +0000
@@ -33,8 +33,6 @@
 
 import org.hisp.dhis.dataelement.Operand;
 import org.hisp.dhis.datamart.CrossTabDataValue;
-import org.hisp.dhis.datamart.DataMartStore;
-import org.hisp.dhis.datamart.aggregation.cache.AggregationCache;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
 import org.hisp.dhis.period.Period;
@@ -43,38 +41,20 @@
  * @author Lars Helge Overland
  * @version $Id: DataElementAggregator.java 6049 2008-10-28 09:36:17Z larshelg $
  */
-public abstract class DataElementAggregator
+public interface DataElementAggregator
 {
-    protected final String TRUE = "true";
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    protected DataMartStore dataMartStore;
-    
-    public void setDataMartStore( DataMartStore dataMartStore )
-    {
-        this.dataMartStore = dataMartStore;
-    }
-    
-    protected AggregationCache aggregationCache;
-        
-    public void setAggregationCache( AggregationCache aggregationCache )
-    {
-        this.aggregationCache = aggregationCache;
-    }
-    
+    final String TRUE = "true";
+
     // -------------------------------------------------------------------------
     // DataElementAggregator
     // -------------------------------------------------------------------------
 
-    public abstract Map<Operand, Double> getAggregatedValues( 
-        final Map<Operand, Integer> operandIndexMap, final Period period, final OrganisationUnit unit );
+    Map<Operand, Double> getAggregatedValues( final Map<Operand, Integer> operandIndexMap, 
+        final Period period, final OrganisationUnit unit );
     
-    protected abstract Collection<CrossTabDataValue> getCrossTabDataValues( final Map<Operand, Integer> operandIndexMap, 
+    Collection<CrossTabDataValue> getCrossTabDataValues( final Map<Operand, Integer> operandIndexMap, 
         final Date startDate, final Date endDate, final int parentId, final OrganisationUnitHierarchy hierarchy );
     
-    protected abstract Map<Operand, Double[]> getAggregate( final Collection<CrossTabDataValue> crossTabValues, 
+    Map<Operand, Double[]> getAggregate( final Collection<CrossTabDataValue> crossTabValues, 
         final Date startDate, final Date endDate, final Date aggregationStartDate, final Date aggregationEndDate );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java	2009-03-20 15:18:04 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java	2009-04-23 20:16:18 +0000
@@ -39,6 +39,8 @@
 
 import org.hisp.dhis.dataelement.Operand;
 import org.hisp.dhis.datamart.CrossTabDataValue;
+import org.hisp.dhis.datamart.DataMartStore;
+import org.hisp.dhis.datamart.aggregation.cache.AggregationCache;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
 import org.hisp.dhis.period.Period;
@@ -48,8 +50,30 @@
  * @version $Id: SumBoolAggregator.java 6049 2008-10-28 09:36:17Z larshelg $
  */
 public class SumBoolAggregator
-    extends DataElementAggregator
+    implements DataElementAggregator
 {
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    protected DataMartStore dataMartStore;
+    
+    public void setDataMartStore( DataMartStore dataMartStore )
+    {
+        this.dataMartStore = dataMartStore;
+    }
+    
+    protected AggregationCache aggregationCache;
+        
+    public void setAggregationCache( AggregationCache aggregationCache )
+    {
+        this.aggregationCache = aggregationCache;
+    }
+
+    // -------------------------------------------------------------------------
+    // DataElementAggregator implementation
+    // -------------------------------------------------------------------------
+
     public Map<Operand, Double> getAggregatedValues( final Map<Operand, Integer> operandIndexMap, final Period period, final OrganisationUnit unit )
     {
         final OrganisationUnitHierarchy hierarchy = aggregationCache.getLatestOrganisationUnitHierarchy();
@@ -73,7 +97,7 @@
         return values;
     }
 
-    protected Collection<CrossTabDataValue> getCrossTabDataValues( final Map<Operand, Integer> operandIndexMap, 
+    public Collection<CrossTabDataValue> getCrossTabDataValues( final Map<Operand, Integer> operandIndexMap, 
         final Date startDate, final Date endDate, final int parentId, final OrganisationUnitHierarchy hierarchy )
     {
         final Collection<Integer> sourceIds = aggregationCache.getChildren( hierarchy, parentId );
@@ -90,7 +114,7 @@
         return dataMartStore.getCrossTabDataValues( operandIndexMap, periodIds, sourceIds );
     }
     
-    protected Map<Operand, Double[]> getAggregate( final Collection<CrossTabDataValue> crossTabValues, 
+    public Map<Operand, Double[]> getAggregate( final Collection<CrossTabDataValue> crossTabValues, 
         final Date startDate, final Date endDate, final Date aggregationStartDate, final Date aggregationEndDate )
     {
         final Map<Operand, Double[]> totalSums = new HashMap<Operand, Double[]>(); // <Operand, [total value, total relevant days]>

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java	2009-03-20 15:18:04 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java	2009-04-23 20:16:18 +0000
@@ -40,6 +40,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataelement.Operand;
 import org.hisp.dhis.datamart.CrossTabDataValue;
+import org.hisp.dhis.datamart.DataMartStore;
+import org.hisp.dhis.datamart.aggregation.cache.AggregationCache;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
 import org.hisp.dhis.period.Period;
@@ -49,10 +51,32 @@
  * @version $Id: SumIntAggregator.java 6049 2008-10-28 09:36:17Z larshelg $
  */
 public class SumIntAggregator
-    extends DataElementAggregator
+    implements DataElementAggregator
 {
     private static final Log log = LogFactory.getLog( SumIntAggregator.class );
     
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    protected DataMartStore dataMartStore;
+    
+    public void setDataMartStore( DataMartStore dataMartStore )
+    {
+        this.dataMartStore = dataMartStore;
+    }
+    
+    protected AggregationCache aggregationCache;
+        
+    public void setAggregationCache( AggregationCache aggregationCache )
+    {
+        this.aggregationCache = aggregationCache;
+    }
+
+    // -------------------------------------------------------------------------
+    // DataElementAggregator implementation
+    // -------------------------------------------------------------------------
+
     public Map<Operand, Double> getAggregatedValues( final Map<Operand, Integer> operandIndexMap, final Period period, final OrganisationUnit unit )
     {
         final OrganisationUnitHierarchy hierarchy = aggregationCache.getLatestOrganisationUnitHierarchy();
@@ -76,7 +100,7 @@
         return values;
     }
 
-    protected Collection<CrossTabDataValue> getCrossTabDataValues( final Map<Operand, Integer> operandIndexMap, 
+    public Collection<CrossTabDataValue> getCrossTabDataValues( final Map<Operand, Integer> operandIndexMap, 
         final Date startDate, final Date endDate, final int parentId, final OrganisationUnitHierarchy hierarchy )
     {
         final Collection<Integer> sourceIds = aggregationCache.getChildren( hierarchy, parentId );
@@ -93,7 +117,7 @@
         return dataMartStore.getCrossTabDataValues( operandIndexMap, periodIds, sourceIds );
     }
     
-    protected Map<Operand, Double[]> getAggregate( final Collection<CrossTabDataValue> crossTabValues, 
+    public Map<Operand, Double[]> getAggregate( final Collection<CrossTabDataValue> crossTabValues, 
         final Date startDate, final Date endDate, final Date aggregationStartDate, final Date aggregationEndDate )
     {
         final Map<Operand, Double[]> totalSums = new HashMap<Operand, Double[]>(); // <Operand, [total value, total relevant days]>

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/CalculatedDataElementDataMart.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/CalculatedDataElementDataMart.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/CalculatedDataElementDataMart.java	2009-04-23 20:16:18 +0000
@@ -1,9 +1,40 @@
 package org.hisp.dhis.datamart.calculateddataelement;
 
+/*
+ * Copyright (c) 2004-2007, 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.Collection;
 
 import org.hisp.dhis.dataelement.Operand;
 
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
 public interface CalculatedDataElementDataMart
 {
     int exportCalculatedDataElements( Collection<Integer> calculatedDataElementIds, 



--
Trunk
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.