← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2489: Using generic store iterator

 

------------------------------------------------------------
revno: 2489
committer: Bob Jolliffe bobjolliffe@xxxxxxxxx
branch nick: trunk
timestamp: Sat 2011-01-08 01:23:07 +0000
message:
  Using generic store iterator
removed:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStoreIterator.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStoreIterator.java
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/StoreIterator.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcStoreIterator.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/synchronous/ExportPivotViewService.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/ExportDataMartAction.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/aggregation/AggregatedDataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java	2010-12-19 00:24:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java	2011-01-08 01:23:07 +0000
@@ -112,7 +112,7 @@
      * @param periods the periods to retrieve values for
      * @return an iterator type object for retrieving the values
      */
-    public AggregatedDataValueStoreIterator getAggregateDataValuesAtLevel(OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods);
+    public StoreIterator<AggregatedDataValue> getAggregateDataValuesAtLevel(OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods);
 
     // ----------------------------------------------------------------------
     // AggregatedDataMapValue

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java	2010-12-19 00:24:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java	2011-01-08 01:23:07 +0000
@@ -155,7 +155,7 @@
      * @param periods the period to retrieve values for
      * @return an iterator type object for retrieving the values
      */
-    public AggregatedDataValueStoreIterator getAggregateDataValuesAtLevel(OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods);
+    public StoreIterator<AggregatedDataValue> getAggregateDataValuesAtLevel(OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods);
 
 
     // ----------------------------------------------------------------------

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStoreIterator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStoreIterator.java	2010-12-19 00:24:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStoreIterator.java	1970-01-01 00:00:00 +0000
@@ -1,55 +0,0 @@
-package org.hisp.dhis.aggregation;
-
-/*
- * Copyright (c) 2004-2010, 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.
- */
-
-/**
- * @interface AggregatedDataValueStoreIterator
- * Provides an object for processing a collection of Aggregateddatavalues, such
- *  as from a jdbc resultset
- *
- * @author bobj
- */
-public interface AggregatedDataValueStoreIterator {
-
-    // ----------------------------------------------------------------------
-    // AggregatedDataValueStoreIterator
-    // ----------------------------------------------------------------------
-
-    /**
-     * Gets the next AggregatedDataValue
-     *
-     * @return the aggregated value or null.
-     */
-    AggregatedDataValue next();
-
-    /**
-     * Close any underlying resources
-     *
-     */
-    void close();
-}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/StoreIterator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/StoreIterator.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/StoreIterator.java	2011-01-08 01:23:07 +0000
@@ -0,0 +1,59 @@
+package org.hisp.dhis.aggregation;
+
+/*
+ * Copyright (c) 2004-2010, 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.
+ */
+
+/**
+ * @interface AggregatedDataValueStoreIterator
+ * Provides an object for processing a collection of Aggregateddatavalues, such
+ *  as from a jdbc resultset
+ *
+ * @author bobj
+ */
+public interface StoreIterator<T> {
+
+    // ----------------------------------------------------------------------
+    // AggregatedDataValueStoreIterator
+    // ----------------------------------------------------------------------
+
+    /**
+     * Gets the next object
+     *
+     * @return the object or null.
+     */
+    T next();
+
+    /**
+     * Close any underlying resources
+     *
+     * Note: if you do not iterate through the entire resultset, ie. until next()
+     *  returns NULL, you have the responsibility to call close() in order to release
+     *  the underlying resultset, connection etc
+     *
+     */
+    void close();
+}

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java	2010-12-19 00:24:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java	2011-01-08 01:23:07 +0000
@@ -73,7 +73,7 @@
         return aggregatedDataValueStore.deleteAggregatedDataValues();
     }
 
-    public AggregatedDataValueStoreIterator getAggregateDataValuesAtLevel(OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods)
+    public StoreIterator<AggregatedDataValue> getAggregateDataValuesAtLevel(OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods)
     {
        return aggregatedDataValueStore.getAggregateDataValuesAtLevel(orgunit, level, periods);
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java	2010-12-19 00:24:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java	2011-01-08 01:23:07 +0000
@@ -1,6 +1,5 @@
 package org.hisp.dhis.aggregation.jdbc;
 
-import org.hisp.dhis.aggregation.AggregatedDataValueStoreIterator;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
 import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
@@ -15,12 +14,14 @@
 import org.amplecode.quick.StatementHolder;
 import org.amplecode.quick.StatementManager;
 import org.amplecode.quick.mapper.ObjectMapper;
+import org.amplecode.quick.mapper.RowMapper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.aggregation.AggregatedDataValue;
 import org.hisp.dhis.aggregation.AggregatedDataValueStore;
 import org.hisp.dhis.aggregation.AggregatedIndicatorValue;
 import org.hisp.dhis.aggregation.AggregatedMapValue;
+import org.hisp.dhis.aggregation.StoreIterator;
 import org.hisp.dhis.caseaggregation.CaseAggregationCondition;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -140,7 +141,7 @@
     }
 
     @Override
-    public AggregatedDataValueStoreIterator getAggregateDataValuesAtLevel(OrganisationUnit rootOrgunit, OrganisationUnitLevel level, Collection<Period> periods)
+    public StoreIterator<AggregatedDataValue> getAggregateDataValuesAtLevel(OrganisationUnit rootOrgunit, OrganisationUnitLevel level, Collection<Period> periods)
     {
         final StatementHolder holder = statementManager.getHolder();
 
@@ -166,7 +167,8 @@
 
             final ResultSet resultSet = statement.executeQuery( sql );
 
-            return new JdbcAggregatedDataValueStoreIterator(resultSet, holder);
+            RowMapper<AggregatedDataValue> rm = new AggregatedDataValueRowMapper();
+            return new JdbcStoreIterator(resultSet, holder, rm);
         }
         catch ( SQLException ex )
         {

=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStoreIterator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStoreIterator.java	2010-12-19 00:24:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStoreIterator.java	1970-01-01 00:00:00 +0000
@@ -1,103 +0,0 @@
-package org.hisp.dhis.aggregation.jdbc;
-
-/*
- * Copyright (c) 2004-2010, 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.sql.ResultSet;
-import java.sql.SQLException;
-import org.amplecode.quick.StatementHolder;
-import org.amplecode.quick.mapper.RowMapper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.aggregation.AggregatedDataValue;
-import org.hisp.dhis.aggregation.AggregatedDataValueStoreIterator;
-import org.hisp.dhis.system.objectmapper.AggregatedDataValueRowMapper;
-
-/**
- *
- * @author bobj
- */
-public class JdbcAggregatedDataValueStoreIterator implements AggregatedDataValueStoreIterator {
-
-    private static final Log log = LogFactory.getLog(AggregatedDataValueStoreIterator.class);
-
-    static RowMapper<AggregatedDataValue> rowmapper = new AggregatedDataValueRowMapper();
-
-    private ResultSet resultSet;
-
-    public ResultSet getResultSet() {
-        return resultSet;
-    }
-
-    public void setResultSet(ResultSet resultSet) {
-        this.resultSet = resultSet;
-    }
-
-    private StatementHolder holder;
-
-    public StatementHolder getHolder()
-    {
-        return holder;
-    }
-
-    public void setHolder( StatementHolder holder )
-    {
-        this.holder = holder;
-    }
-
-    public JdbcAggregatedDataValueStoreIterator(ResultSet resultSet, StatementHolder holder) {
-        this.resultSet = resultSet;
-        this.holder = holder;
-    }
-
-    @Override
-    public AggregatedDataValue next() {
-        AggregatedDataValue row = null;
-        try {
-            if (resultSet.next()) {
-                row = rowmapper.mapRow(resultSet);
-            } else {
-                this.close();
-            }
-        } catch (SQLException ex) {
-            log.warn("Error reading aggregateddatavalue row: " + ex);
-        }
-        return row;
-    }
-
-    @Override
-    public void close() {
-        try {
-            if (!resultSet.isClosed()) {
-                resultSet.close();
-            }
-        } catch (SQLException ex) {
-            log.warn("Error closing resultset: " + ex);
-        }
-
-        holder.close();
-    }
-}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcStoreIterator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcStoreIterator.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcStoreIterator.java	2011-01-08 01:23:07 +0000
@@ -0,0 +1,103 @@
+package org.hisp.dhis.aggregation.jdbc;
+
+/*
+ * Copyright (c) 2004-2010, 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.sql.ResultSet;
+import java.sql.SQLException;
+import org.amplecode.quick.StatementHolder;
+import org.amplecode.quick.mapper.RowMapper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.aggregation.StoreIterator;
+
+/**
+ *
+ * @param <T>
+ * @author bobj
+ */
+public class JdbcStoreIterator<T> implements StoreIterator<T> {
+
+    private static final Log log = LogFactory.getLog(JdbcStoreIterator.class);
+
+    private RowMapper<T> rowmapper;
+
+    private ResultSet resultSet;
+
+    public ResultSet getResultSet() {
+        return resultSet;
+    }
+
+    public void setResultSet(ResultSet resultSet) {
+        this.resultSet = resultSet;
+    }
+
+    private StatementHolder holder;
+
+    public StatementHolder getHolder()
+    {
+        return holder;
+    }
+
+    public void setHolder( StatementHolder holder )
+    {
+        this.holder = holder;
+    }
+
+    public JdbcStoreIterator(ResultSet resultSet, StatementHolder holder, RowMapper<T> rowmapper) {
+        this.resultSet = resultSet;
+        this.holder = holder;
+        this.rowmapper = rowmapper;
+    }
+
+    @Override
+    public T next() {
+        T row = null;
+        try {
+            if (resultSet.next()) {
+                row = rowmapper.mapRow(resultSet);
+            } else {
+                this.close();
+            }
+        } catch (SQLException ex) {
+            log.warn("Error reading aggregateddatavalue row: " + ex);
+        }
+        return row;
+    }
+
+    @Override
+    public void close() {
+        try {
+            if (!resultSet.isClosed()) {
+                resultSet.close();
+            }
+        } catch (SQLException ex) {
+            log.warn("Error closing resultset: " + ex);
+        }
+
+        holder.close();
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/synchronous/ExportPivotViewService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/synchronous/ExportPivotViewService.java	2010-12-26 21:40:52 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/synchronous/ExportPivotViewService.java	2011-01-08 01:23:07 +0000
@@ -39,7 +39,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.aggregation.AggregatedDataValue;
 import org.hisp.dhis.aggregation.AggregatedDataValueService;
-import org.hisp.dhis.aggregation.AggregatedDataValueStoreIterator;
+import org.hisp.dhis.aggregation.StoreIterator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -59,6 +59,9 @@
 
     private static final Log log = LogFactory.getLog( ExportPivotViewService.class );
 
+    // service can export either aggregated datavalues or aggregated indicator values
+    public enum RequestType { DATAVALUE, INDICATORVALUE };
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -84,7 +87,7 @@
         this.periodService = periodService;
     }
 
-    public void execute (OutputStream out, Date startDate, Date endDate, int level, int root)
+    public void execute (OutputStream out, RequestType requestType, Date startDate, Date endDate, int level, int root)
         throws IOException
     {
         Writer writer = new BufferedWriter(new OutputStreamWriter(out));
@@ -92,7 +95,7 @@
         Collection<Period> periods 
             = periodService.getIntersectingPeriodsByPeriodType( new MonthlyPeriodType(), startDate, endDate );
 
-        if (periods.size() == 0)
+        if (periods.isEmpty())
         {
             log.info( "no periods to export");
             return;
@@ -121,7 +124,8 @@
 
         log.info( "Exporting for " + rootOrgUnit.getName() + " at level: " + orgUnitLevel.getName());
 
-        AggregatedDataValueStoreIterator advIterator = aggregatedDataValueService.getAggregateDataValuesAtLevel( rootOrgUnit , orgUnitLevel, periods );
+        StoreIterator<AggregatedDataValue> advIterator
+            = aggregatedDataValueService.getAggregateDataValuesAtLevel( rootOrgUnit , orgUnitLevel, periods );
 
         AggregatedDataValue adv = advIterator.next();
 

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/ExportDataMartAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/ExportDataMartAction.java	2011-01-07 15:48:39 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/ExportDataMartAction.java	2011-01-08 01:23:07 +0000
@@ -31,6 +31,11 @@
 import java.util.Date;
 
 import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.importexport.synchronous.ExportPivotViewService;
+import org.hisp.dhis.importexport.synchronous.ExportPivotViewService.RequestType;
+
+import org.hisp.dhis.system.util.DateUtils;
+import org.hisp.dhis.system.util.StreamUtils;
 
 import com.opensymphony.xwork2.Action;
 import java.io.IOException;
@@ -42,9 +47,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.importexport.synchronous.ExportPivotViewService;
-import org.hisp.dhis.system.util.DateUtils;
-import org.hisp.dhis.system.util.StreamUtils;
 import java.util.zip.GZIPOutputStream;
 
 /**
@@ -61,7 +63,7 @@
     implements Action
 {
     // TODO: experiment with different sizes for this to stop data dribbling out
-    private static int GZIPBUFFER = 8192;
+    private static final int GZIPBUFFER = 8192;
 
     private static final Log log = LogFactory.getLog( ExportDataMartAction.class );
 
@@ -142,7 +144,7 @@
         // do a basic audit log
         HttpServletRequest request = ServletActionContext.getRequest();
 
-        log.info( "PivotView export request from " + currentUserService.getCurrentUsername() +
+        log.info( "DataMart export request from " + currentUserService.getCurrentUsername() +
             " @ " + request.getRemoteAddr() );
 
         HttpServletResponse response = ServletActionContext.getResponse();
@@ -151,12 +153,14 @@
         // Check all parameters
         // ---------------------------------------------------------------------
 
-
-        // first see how we action was called
+        // first see how action was called
         String servletPath = request.getServletPath();
-        String requestType = servletPath.substring(servletPath.lastIndexOf( '/') + 1 );
-
-        log.info( "Request type : " + requestType );
+        String requestTypeStr = servletPath.substring(servletPath.lastIndexOf( '/') + 1 );
+
+        log.info( "Request type : " + requestTypeStr );
+
+        RequestType requestType
+            = requestTypeStr.equals( "dataValues") ? RequestType.DATAVALUE : RequestType.INDICATORVALUE ;
 
         String paramError = null;
 
@@ -224,7 +228,7 @@
         try
         {
             out = new GZIPOutputStream(response.getOutputStream(), GZIPBUFFER);
-            exportPivotViewService.execute(out, start, end, dataSourceLevel, dataSourceRoot);
+            exportPivotViewService.execute(out, requestType, start, end, dataSourceLevel, dataSourceRoot);
         }
         finally
         {