← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5275: WIP on data mart for organisation unit group analysis. Added property organisationUnitGroupId to ...

 

------------------------------------------------------------
revno: 5275
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-12-03 17:15:03 +0100
message:
  WIP on data mart for organisation unit group analysis. Added property organisationUnitGroupId to AggregatedDataValue. Included new tables in TableCreator. Added new batch handlers.
added:
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValue.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedIndicatorValue.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AggregatedValue.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableCreator.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/AbstractStatementBuilder.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/AggregatedDataValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValue.java	2011-11-12 14:18:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValue.java	2011-12-03 16:15:03 +0000
@@ -53,6 +53,8 @@
     
     private int organisationUnitId;
     
+    private int organisationUnitGroupId;
+    
     private int level;
     
     private double value;
@@ -181,6 +183,16 @@
         this.organisationUnitId = organisationUnitId;
     }
 
+    public int getOrganisationUnitGroupId()
+    {
+        return organisationUnitGroupId;
+    }
+
+    public void setOrganisationUnitGroupId( int organisationUnitGroupId )
+    {
+        this.organisationUnitGroupId = organisationUnitGroupId;
+    }
+
     public int getPeriodId()
     {
         return periodId;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedIndicatorValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedIndicatorValue.java	2011-11-12 14:18:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedIndicatorValue.java	2011-12-03 16:15:03 +0000
@@ -50,6 +50,8 @@
     private int periodTypeId;
     
     private int organisationUnitId;
+
+    private int organisationUnitGroupId;
     
     private int level;
     
@@ -80,23 +82,6 @@
     }
     
     /**
-     * @deprecated this constructor is deprecated
-     */
-    public AggregatedIndicatorValue( int indicatorId, int periodId, int periodTypeId, int organisationUnitId, 
-        int level, double value, double numeratorValue, double denominatorValue )
-    {
-        this.indicatorId = indicatorId;
-        this.periodId = periodId;
-        this.periodTypeId = periodTypeId;
-        this.organisationUnitId = organisationUnitId;
-        this.level = level;
-        this.value = value;
-        this.numeratorValue = numeratorValue;
-        this.denominatorValue = denominatorValue;
-        this.modified = new Date();
-    }
-    
-    /**
      * @param indicatorId indicator id
      * @param periodId period id
      * @param periodTypeId period type id
@@ -246,6 +231,16 @@
         this.organisationUnitId = organisationUnitId;
     }
 
+    public int getOrganisationUnitGroupId()
+    {
+        return organisationUnitGroupId;
+    }
+
+    public void setOrganisationUnitGroupId( int organisationUnitGroupId )
+    {
+        this.organisationUnitGroupId = organisationUnitGroupId;
+    }
+
     public int getPeriodId()
     {
         return periodId;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AggregatedValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AggregatedValue.java	2011-06-12 08:42:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AggregatedValue.java	2011-12-03 16:15:03 +0000
@@ -40,5 +40,7 @@
     
     int getOrganisationUnitId();
     
+    int getOrganisationUnitGroupId();
+    
     double getValue();
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java	2011-10-20 13:05:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java	2011-12-03 16:15:03 +0000
@@ -54,6 +54,8 @@
     private String periodName;
 
     private int organisationUnitId;
+    
+    private int organisationUnitGroupId;
 
     // -------------------------------------------------------------------------
     // Properties 2
@@ -249,6 +251,16 @@
         this.organisationUnitId = organisationUnitId;
     }
 
+    public int getOrganisationUnitGroupId()
+    {
+        return organisationUnitGroupId;
+    }
+
+    public void setOrganisationUnitGroupId( int organisationUnitGroupId )
+    {
+        this.organisationUnitGroupId = organisationUnitGroupId;
+    }
+
     // -------------------------------------------------------------------------
     // Getters and setters 2
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableCreator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableCreator.java	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableCreator.java	2011-12-03 16:15:03 +0000
@@ -65,131 +65,69 @@
 
     public void execute()
     {
-        // -----------------------------------------------------------------
-        // AggregatedDataValue
-        // -----------------------------------------------------------------
-
-        try
-        {
-            jdbcTemplate.execute( statementBuilder.getCreateAggregatedDataValueTable() );
-            
-            log.info( "Created table aggregateddatavalue" );
-        }
-        catch ( Exception ex )
-        {
-            log.info( "Table aggregateddatavalue exists" );
-        }
-
-        // -----------------------------------------------------------------
-        // AggregatedIndicatorValue
-        // -----------------------------------------------------------------
-
-        try
-        {
-            jdbcTemplate.execute( statementBuilder.getCreateAggregatedIndicatorTable() );
-            
-            log.info( "Created table aggregatedindicatorvalue" );
-        }
-        catch ( Exception ex )
-        {
-            log.info( "Table aggregatedindicatorvalue exists" );
-        }
-        
-        // -----------------------------------------------------------------
-        // Crosstab index on DataValue table
-        // -----------------------------------------------------------------
-
-        try
-        {
-            final String sql = "CREATE INDEX crosstab ON datavalue ( periodid, sourceid )";
-            
-            jdbcTemplate.execute( sql );
-            
-            log.info( "Created index crosstab on table datavalue" );
-        }
-        catch ( Exception ex )
-        {
-            log.info( "Index crosstab exists on table datavalue" );
-        }
-        
-        // -----------------------------------------------------------------
-        // DataSetCompleteness
-        // -----------------------------------------------------------------
-
-        try
-        {
-            jdbcTemplate.execute( statementBuilder.getCreateDataSetCompletenessTable() );
-            
-            log.info( "Created table aggregateddatasetcompleteness" );
-        }
-        catch ( Exception ex )
-        {
-            log.info( "Table aggregateddatasetcompleteness exists" );
-        }
-        
-        // -----------------------------------------------------------------
-        // ArchivedDataValue
-        // -----------------------------------------------------------------
-
-        try
-        {
-            final String sql = 
-                "CREATE TABLE datavaluearchive ( " +
-                "dataelementid INTEGER NOT NULL, " +
-                "periodid INTEGER NOT NULL, " +
-                "sourceid INTEGER NOT NULL, " +
-                "categoryoptioncomboid INTEGER NOT NULL, " +
-                "value VARCHAR(255), " +
-                "storedby VARCHAR(31), " +
-                "lastupdated TIMESTAMP, " +
-                "comment VARCHAR(360), " +
-                "followup BOOLEAN, " +
-                "CONSTRAINT datavaluearchive_pkey PRIMARY KEY (dataelementid, periodid, sourceid, categoryoptioncomboid), " +
-                "CONSTRAINT fk_datavaluearchive_categoryoptioncomboid FOREIGN KEY (categoryoptioncomboid) " +
-                    "REFERENCES categoryoptioncombo (categoryoptioncomboid), " +
-                "CONSTRAINT fk_datavaluearchive_dataelementid FOREIGN KEY (dataelementid) " +
-                    "REFERENCES dataelement (dataelementid), " +
-                "CONSTRAINT fk_datavaluearchive_periodid FOREIGN KEY (periodid) " +
-                    "REFERENCES period (periodid), " +
-                "CONSTRAINT fk_datavaluearchive_sourceid FOREIGN KEY (sourceid) " +
-                    "REFERENCES organisationunit (organisationunitid) );";
-            
-            jdbcTemplate.execute( sql );
-            
-            log.info( "Created table datavaluearchive" );
-        }
-        catch ( Exception ex )
-        {
-            log.info( "Table datavaluearchive exists" );
-        }
-        
-        // -----------------------------------------------------------------
-        // ArchivedPatientDataValue
-        // -----------------------------------------------------------------
-
-        try
-        {
-            final String sql = 
-                "CREATE TABLE patientdatavaluearchive ( " +
-                 " programstageinstanceid integer NOT NULL, " +
-                 " dataelementid integer NOT NULL, " +
-                 " organisationunitid integer NOT NULL, " +
-                 " categoryoptioncomboid integer default NULL, " +
-                 " value varchar(255) default NULL, " +
-                 " providedbyanotherfacility boolean NOT NULL, " +
-                 " timestamp TIMESTAMP, " +
-                 " PRIMARY KEY  (programstageinstanceid,dataelementid,organisationunitid), " +
-                 " CONSTRAINT fk_patientdatavaluearchive_organisationunitid FOREIGN KEY (organisationunitid) REFERENCES organisationunit (organisationunitid), " +
-                 " CONSTRAINT fk_patientdatavaluearchive_programstageinstanceid FOREIGN KEY (programstageinstanceid) REFERENCES programstageinstance (programstageinstanceid) " +
-                 "        );";
-                            
-            jdbcTemplate.execute( sql );
-            
-            log.info( "Created table patientdatavaluearchive" );
-        }
-        catch ( Exception ex )
-        {
-            log.info( "Table patientdatavaluearchive exists" );
+        createSilently( statementBuilder.getCreateAggregatedDataValueTable(), "aggregateddatavalue" );
+        createSilently( statementBuilder.getCreateAggregatedOrgUnitDataValueTable(), "aggregatedorgunitdatavalue" );
+        createSilently( statementBuilder.getCreateAggregatedIndicatorTable(), "aggregatedindicatorvalue" );
+        createSilently( statementBuilder.getCreateAggregatedOrgUnitIndicatorTable(), "aggregatedorgunitindicatorvalue" );
+        createSilently( statementBuilder.getCreateDataSetCompletenessTable(), "aggregateddatasetcompleteness" );
+        createSilently( statementBuilder.getCreateOrgUnitDataSetCompletenessTable(), "aggregatedorgunitdatasetcompleteness" );
+        
+        createSilently( "CREATE INDEX crosstab ON datavalue ( periodid, sourceid )", "crosstab" );
+        
+        final String sqlDataValueArchive = 
+            "CREATE TABLE datavaluearchive ( " +
+            "dataelementid INTEGER NOT NULL, " +
+            "periodid INTEGER NOT NULL, " +
+            "sourceid INTEGER NOT NULL, " +
+            "categoryoptioncomboid INTEGER NOT NULL, " +
+            "value VARCHAR(255), " +
+            "storedby VARCHAR(31), " +
+            "lastupdated TIMESTAMP, " +
+            "comment VARCHAR(360), " +
+            "followup BOOLEAN, " +
+            "CONSTRAINT datavaluearchive_pkey PRIMARY KEY (dataelementid, periodid, sourceid, categoryoptioncomboid), " +
+            "CONSTRAINT fk_datavaluearchive_categoryoptioncomboid FOREIGN KEY (categoryoptioncomboid) " +
+                "REFERENCES categoryoptioncombo (categoryoptioncomboid), " +
+            "CONSTRAINT fk_datavaluearchive_dataelementid FOREIGN KEY (dataelementid) " +
+                "REFERENCES dataelement (dataelementid), " +
+            "CONSTRAINT fk_datavaluearchive_periodid FOREIGN KEY (periodid) " +
+                "REFERENCES period (periodid), " +
+            "CONSTRAINT fk_datavaluearchive_sourceid FOREIGN KEY (sourceid) " +
+                "REFERENCES organisationunit (organisationunitid) );";
+        
+        createSilently( sqlDataValueArchive, "datavaluearchive" );
+
+        final String sqlPatientDataValueArchive = 
+            "CREATE TABLE patientdatavaluearchive ( " +
+             " programstageinstanceid integer NOT NULL, " +
+             " dataelementid integer NOT NULL, " +
+             " organisationunitid integer NOT NULL, " +
+             " categoryoptioncomboid integer default NULL, " +
+             " value varchar(255) default NULL, " +
+             " providedbyanotherfacility boolean NOT NULL, " +
+             " timestamp TIMESTAMP, " +
+             " PRIMARY KEY  (programstageinstanceid,dataelementid,organisationunitid), " +
+             " CONSTRAINT fk_patientdatavaluearchive_organisationunitid FOREIGN KEY (organisationunitid) REFERENCES organisationunit (organisationunitid), " +
+             " CONSTRAINT fk_patientdatavaluearchive_programstageinstanceid FOREIGN KEY (programstageinstanceid) REFERENCES programstageinstance (programstageinstanceid) );";
+        
+        createSilently( sqlPatientDataValueArchive, "patientdatavaluearchive" );
+    }
+
+    // -------------------------------------------------------------------------
+    // Supportive methods
+    // -------------------------------------------------------------------------
+
+    private void createSilently( final String sql, final String name )
+    {
+        try
+        {
+            jdbcTemplate.execute( sql );
+            
+            log.info( "Created table/index " + name );
+        }
+        catch ( Exception ex )
+        {
+            log.debug( "Table/index " + name + " exists" );
         }
     }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java	2011-05-23 06:10:58 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java	2011-12-03 16:15:03 +0000
@@ -61,22 +61,37 @@
     String getPeriodIdentifierStatement( Period period );
     
     /**
-     * Creates a create table statement fot the aggregated datavalue table.
-     * @return a create table statement fot the aggregated datavalue table.
+     * Creates a create table statement for the aggregated datavalue table.
      */
     String getCreateAggregatedDataValueTable();
+
+    /**
+     * Creates a create table statement for the aggregated organisation unit
+     * group datavalue table.
+     */
+    String getCreateAggregatedOrgUnitDataValueTable();
     
     /**
      * Creates a create table statement for the aggregated indicatorvalue table.
-     * @return a create table statement for the aggregated indicatorvalue table.
-     */    
+     */
     String getCreateAggregatedIndicatorTable();
 
     /**
+     * Creates a create table statement for the aggregated organisation unit
+     * group indicatorvalue table.
+     */
+    String getCreateAggregatedOrgUnitIndicatorTable();
+
+    /**
      * Creates a create table statement for the aggregated datasetcompleteness table.
-     * @return a create table statement for the aggregated datasetcompleteness table.
      */
     String getCreateDataSetCompletenessTable();
+
+    /**
+     * Creates a create table statement for the aggregated organisation unit
+     * group datasetcompleteness table.
+     */
+    String getCreateOrgUnitDataSetCompletenessTable();
     
     /**
      * Creates a delete datavalue statement.

=== added file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java	2011-12-03 16:15:03 +0000
@@ -0,0 +1,97 @@
+package org.hisp.dhis.jdbc.batchhandler;
+
+/*
+ * 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 org.amplecode.quick.JdbcConfiguration;
+import org.amplecode.quick.batchhandler.AbstractBatchHandler;
+import org.hisp.dhis.aggregation.AggregatedDataValue;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class AggregatedOrgUnitDataValueBatchHandler
+    extends AbstractBatchHandler<AggregatedDataValue>
+{
+    // -------------------------------------------------------------------------
+    // Constructor
+    // -------------------------------------------------------------------------
+    
+    public AggregatedOrgUnitDataValueBatchHandler( JdbcConfiguration config )
+    {
+        super( config, true, true );
+    }
+
+    // -------------------------------------------------------------------------
+    // AbstractBatchHandler implementation
+    // -------------------------------------------------------------------------
+    
+    protected void setTableName()
+    {
+        statementBuilder.setTableName( "aggregatedorgunitdatavalue" );
+    }
+    
+    protected void setUniqueColumns()
+    {
+        statementBuilder.setUniqueColumn( "dataelementid" );
+        statementBuilder.setUniqueColumn( "periodid" );
+        statementBuilder.setUniqueColumn( "organisationunitid" );
+        statementBuilder.setUniqueColumn( "organisationunitgroupid" );
+    }
+    
+    protected void setUniqueValues( AggregatedDataValue value )
+    {        
+        statementBuilder.setUniqueValue( value.getDataElementId() );
+        statementBuilder.setUniqueValue( value.getPeriodId() );
+        statementBuilder.setUniqueValue( value.getOrganisationUnitId() );
+        statementBuilder.setUniqueValue( value.getOrganisationUnitGroupId() );
+    }
+    
+    protected void setColumns()
+    {
+        statementBuilder.setColumn( "dataelementid" );
+        statementBuilder.setColumn( "categoryoptioncomboid" );
+        statementBuilder.setColumn( "periodid" );
+        statementBuilder.setColumn( "periodtypeid" );
+        statementBuilder.setColumn( "organisationunitid" );
+        statementBuilder.setColumn( "organisationunitgroupid" );
+        statementBuilder.setColumn( "level" );
+        statementBuilder.setColumn( "value" );
+    }
+    
+    protected void setValues( AggregatedDataValue value )
+    {        
+        statementBuilder.setValue( value.getDataElementId() );
+        statementBuilder.setValue( value.getCategoryOptionComboId() );
+        statementBuilder.setValue( value.getPeriodId() );
+        statementBuilder.setValue( value.getPeriodTypeId() );
+        statementBuilder.setValue( value.getOrganisationUnitId() );
+        statementBuilder.setValue( value.getOrganisationUnitGroupId() );
+        statementBuilder.setValue( value.getLevel() );
+        statementBuilder.setValue( value.getValue() );
+    }    
+}

=== added file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.java	2011-12-03 16:15:03 +0000
@@ -0,0 +1,103 @@
+package org.hisp.dhis.jdbc.batchhandler;
+
+/*
+ * 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 org.amplecode.quick.JdbcConfiguration;
+import org.amplecode.quick.batchhandler.AbstractBatchHandler;
+import org.hisp.dhis.aggregation.AggregatedIndicatorValue;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class AggregatedOrgUnitIndicatorValueBatchHandler
+    extends AbstractBatchHandler<AggregatedIndicatorValue>
+{
+    // -------------------------------------------------------------------------
+    // Constructor
+    // -------------------------------------------------------------------------
+
+    public AggregatedOrgUnitIndicatorValueBatchHandler( JdbcConfiguration config )
+    {
+        super( config, true, true );
+    }
+
+    // -------------------------------------------------------------------------
+    // AbstractBatchHandler implementation
+    // -------------------------------------------------------------------------
+
+    protected void setTableName()
+    {
+        statementBuilder.setTableName( "aggregatedindicatorvalue" );
+    }
+
+    protected void setUniqueColumns()
+    {
+        statementBuilder.setUniqueColumn( "indicatorid" );
+        statementBuilder.setUniqueColumn( "periodid" );
+        statementBuilder.setUniqueColumn( "organisationunitid" );
+        statementBuilder.setUniqueColumn( "organisationunitgroupid" );
+    }
+    
+    protected void setUniqueValues( AggregatedIndicatorValue value )
+    {        
+        statementBuilder.setUniqueValue( value.getIndicatorId() );
+        statementBuilder.setUniqueValue( value.getPeriodId() );
+        statementBuilder.setUniqueValue( value.getOrganisationUnitId() );
+        statementBuilder.setUniqueValue( value.getOrganisationUnitGroupId() );
+    }
+    
+    protected void setColumns()
+    {
+        statementBuilder.setColumn( "indicatorid" );
+        statementBuilder.setColumn( "periodid" );
+        statementBuilder.setColumn( "periodtypeid" );
+        statementBuilder.setColumn( "organisationunitid" );
+        statementBuilder.setColumn( "organisationunitgroupid" );
+        statementBuilder.setColumn( "level" );
+        statementBuilder.setColumn( "annualized" );
+        statementBuilder.setColumn( "factor" );
+        statementBuilder.setColumn( "value" );
+        statementBuilder.setColumn( "numeratorvalue" );
+        statementBuilder.setColumn( "denominatorvalue" );
+    }
+
+    protected void setValues( AggregatedIndicatorValue value )
+    {        
+        statementBuilder.setValue( value.getIndicatorId() );
+        statementBuilder.setValue( value.getPeriodId() );
+        statementBuilder.setValue( value.getPeriodTypeId() );
+        statementBuilder.setValue( value.getOrganisationUnitId() );
+        statementBuilder.setValue( value.getOrganisationUnitGroupId() );
+        statementBuilder.setValue( value.getLevel() );
+        statementBuilder.setValue( value.getAnnualized() );
+        statementBuilder.setValue( value.getFactor() );
+        statementBuilder.setValue( value.getValue() );
+        statementBuilder.setValue( value.getNumeratorValue() );
+        statementBuilder.setValue( value.getDenominatorValue() );
+    }
+}

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/AbstractStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/AbstractStatementBuilder.java	2011-12-03 14:23:43 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/AbstractStatementBuilder.java	2011-12-03 16:15:03 +0000
@@ -58,6 +58,20 @@
             "level INTEGER, " +
             "value " + getDoubleColumnType() + " );";
     }
+
+    public String getCreateAggregatedOrgUnitDataValueTable()
+    {
+        return
+            "CREATE TABLE aggregatedorgunitdatavalue ( " +
+            "dataelementid INTEGER, " +
+            "categoryoptioncomboid INTEGER, " +
+            "periodid INTEGER, " +
+            "organisationunitid INTEGER, " +
+            "organisationunitgroupid INTEGER, " +
+            "periodtypeid INTEGER, " +
+            "level INTEGER, " +
+            "value " + getDoubleColumnType() + " );";
+    }
     
     public String getCreateAggregatedIndicatorTable()
     {
@@ -75,6 +89,23 @@
             "denominatorvalue " + getDoubleColumnType() + " );";
     }
 
+    public String getCreateAggregatedOrgUnitIndicatorTable()
+    {
+        return
+            "CREATE TABLE aggregatedorgunitindicatorvalue ( " +
+            "indicatorid INTEGER, " +
+            "periodid INTEGER, " +
+            "organisationunitid INTEGER, " +
+            "organisationunitgroupid INTEGER, " +
+            "periodtypeid INTEGER, " +
+            "level INTEGER, " +
+            "annualized VARCHAR( 10 ), " +
+            "factor " + getDoubleColumnType() + ", " +
+            "value " + getDoubleColumnType() + ", " +
+            "numeratorvalue " + getDoubleColumnType() + ", " +
+            "denominatorvalue " + getDoubleColumnType() + " );";
+    }
+
     public String getCreateDataSetCompletenessTable()
     {
         return
@@ -89,4 +120,20 @@
             "value " + getDoubleColumnType() + ", " +
             "valueOnTime " + getDoubleColumnType() + " );";
     }
+    
+    public String getCreateOrgUnitDataSetCompletenessTable()
+    {
+        return
+            "CREATE TABLE aggregatedorgunitdatasetcompleteness ( " +
+            "datasetid INTEGER, " +
+            "periodid INTEGER, " +
+            "periodname VARCHAR( 30 ), " +
+            "organisationunitid INTEGER, " +
+            "organisationunitgroupid INTEGER, " +
+            "sources INTEGER, " +
+            "registrations INTEGER, " +
+            "registrationsOnTime INTEGER, " +
+            "value " + getDoubleColumnType() + ", " +
+            "valueOnTime " + getDoubleColumnType() + " );";
+    }
 }