← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2164: Added timestamp column to aggregatedXXXvalue tables in preparation for time based diff

 

------------------------------------------------------------
revno: 2164
committer: Bob Jolliffe bobjolliffe@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2010-11-24 23:33:43 +0000
message:
  Added timestamp column to aggregatedXXXvalue tables in preparation for time based diff
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-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedDataValueBatchHandler.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.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	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValue.java	2010-11-24 23:33:43 +0000
@@ -28,6 +28,7 @@
  */
 
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * @author Lars Helge Overland
@@ -50,6 +51,8 @@
     
     private double value;
 
+    private Date modified;
+
     // ----------------------------------------------------------------------
     // Constructors
     // ----------------------------------------------------------------------
@@ -76,6 +79,29 @@
         this.organisationUnitId = organisationUnitId;
         this.level = level;
         this.value = value;
+        this.modified = new Date();
+    }
+
+        /**
+     * @param dataElementId data element id
+     * @param categoryOptionComboId category option combo id
+     * @param periodId period id
+     * @param periodTypeId period type id
+     * @param organisationUnitId organisation unit id
+     * @param level level
+     * @param value value
+     * @param timestamp modification timestamp
+     */
+    public AggregatedDataValue( int dataElementId, int categoryOptionComboId, int periodId, int periodTypeId, int organisationUnitId, int level, double value, Date timestamp )
+    {
+        this.dataElementId = dataElementId;
+        this.categoryOptionComboId = categoryOptionComboId;
+        this.periodId = periodId;
+        this.periodTypeId = periodTypeId;
+        this.organisationUnitId = organisationUnitId;
+        this.level = level;
+        this.value = value;
+        this.modified = timestamp;
     }
 
     // ----------------------------------------------------------------------
@@ -166,7 +192,18 @@
     {
         this.value = value;
     }
-    
+
+    public Date getModified()
+    {
+        return modified;
+    }
+
+    public void setModified( Date modified )
+    {
+        this.modified = modified;
+    }
+
+
     // ----------------------------------------------------------------------
     // hashCode and equals
     // ----------------------------------------------------------------------
@@ -191,6 +228,7 @@
         AggregatedDataValue that = (AggregatedDataValue) object;
         
         return this.dataElementId == that.getDataElementId() &&
+            this.categoryOptionComboId == that.categoryOptionComboId &&
     	    this.periodId == that.getPeriodId() &&
     	    this.organisationUnitId == that.getOrganisationUnitId();
     }

=== 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	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedIndicatorValue.java	2010-11-24 23:33:43 +0000
@@ -28,6 +28,7 @@
  */
 
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * @author Lars Helge Overland
@@ -56,6 +57,8 @@
     
     private double denominatorValue;
 
+    private Date modified;
+
     // ----------------------------------------------------------------------
     // Constructors
     // ----------------------------------------------------------------------
@@ -78,6 +81,7 @@
         this.value = value;
         this.numeratorValue = numeratorValue;
         this.denominatorValue = denominatorValue;
+        this.modified = new Date();
     }
     
     /**
@@ -103,6 +107,34 @@
         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
+     * @param organisationUnitId organisation unit id
+     * @param level level
+     * @param factor factor
+     * @param value value
+     * @param numeratorValue numerator value
+     * @param denominatorValue denominator value
+     * @param timestamp modification timestamp
+     */
+    public AggregatedIndicatorValue( int indicatorId, int periodId, int periodTypeId, int organisationUnitId,
+        int level, double factor, double value, double numeratorValue, double denominatorValue, Date timestamp )
+    {
+        this.indicatorId = indicatorId;
+        this.periodId = periodId;
+        this.periodTypeId = periodTypeId;
+        this.organisationUnitId = organisationUnitId;
+        this.level = level;
+        this.factor = factor;
+        this.value = value;
+        this.numeratorValue = numeratorValue;
+        this.denominatorValue = denominatorValue;
+        this.modified = timestamp;
     }
 
     // ----------------------------------------------------------------------
@@ -226,6 +258,16 @@
         this.value = value;
     }
 
+    public Date getModified()
+    {
+        return modified;
+    }
+
+    public void setModified( Date modified )
+    {
+        this.modified = modified;
+    }
+
     // ----------------------------------------------------------------------
     // hashCode and equals
     // ----------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2010-11-22 08:51:47 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2010-11-24 23:33:43 +0000
@@ -195,6 +195,16 @@
 
         executeSql( "UPDATE dataelement set numbertype='number' where numbertype is null and valuetype='int'" );
 
+        // prepare aggregateXXXValue tables for offline diffs
+
+        executeSql( "ALTER TABLE aggregateddatavalue ADD COLUMN modified timestamp with time zone not null default now();");
+
+        executeSql( "create index adv_diff on aggregateddatavalue(modified);");
+
+        executeSql( "ALTER TABLE aggregatedindicatorvalue ADD COLUMN modified timestamp with time zone not null default now();");
+
+        executeSql( "create index aiv_diff on aggregatedindicatorvalue(modified);");
+
         log.info( "Tables updated" );
     }
 

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedDataValueBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedDataValueBatchHandler.java	2010-11-23 16:12:57 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedDataValueBatchHandler.java	2010-11-24 23:33:43 +0000
@@ -79,6 +79,7 @@
         statementBuilder.setColumn( "organisationunitid" );
         statementBuilder.setColumn( "level" );
         statementBuilder.setColumn( "value" );
+        statementBuilder.setColumn( "modified" );
     }
     
     protected void setValues( AggregatedDataValue value )
@@ -90,5 +91,6 @@
         statementBuilder.setValue( value.getOrganisationUnitId() );
         statementBuilder.setValue( value.getLevel() );
         statementBuilder.setValue( value.getValue() );
+        statementBuilder.setValue( value.getModified() );
     }    
 }

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2010-11-24 09:49:54 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2010-11-24 23:33:43 +0000
@@ -73,7 +73,8 @@
             "organisationunitid INTEGER, " +
             "periodtypeid INTEGER, " +
             "level INTEGER, " +
-            "value DOUBLE );";
+            "value DOUBLE, " +
+            "modified TIMESTAMP DEFAULT now() );";
     }
     
     public String getCreateAggregatedIndicatorTable()
@@ -89,7 +90,8 @@
             "factor DOUBLE, " +
             "value DOUBLE, " +
             "numeratorvalue DOUBLE, " +
-            "denominatorvalue DOUBLE );";
+            "denominatorvalue DOUBLE, " +
+            "modified TIMESTAMP DEFAULT now() );";
     }
 
     public String getCreateDataSetCompletenessTable()

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2010-11-24 09:49:54 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2010-11-24 23:33:43 +0000
@@ -73,7 +73,8 @@
             "organisationunitid INTEGER, " +
             "periodtypeid INTEGER, " +
             "level INTEGER, " +
-            "value DOUBLE );";
+            "value DOUBLE, " +
+            "modified TIMESTAMP);";
     }
     
     public String getCreateAggregatedIndicatorTable()
@@ -89,7 +90,8 @@
             "factor DOUBLE, " +
             "value DOUBLE, " +
             "numeratorvalue DOUBLE, " +
-            "denominatorvalue DOUBLE );";
+            "denominatorvalue DOUBLE, " +
+            "modified TIMESTAMP);";
     }
 
     public String getCreateDataSetCompletenessTable()

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2010-11-24 09:49:54 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2010-11-24 23:33:43 +0000
@@ -73,7 +73,8 @@
             "organisationunitid INTEGER, " +
             "periodtypeid INTEGER, " +
             "level INTEGER, " +
-            "value DOUBLE PRECISION );";
+            "value DOUBLE PRECISION, " +
+            "modified TIMESTAMP WITH TIME ZONE DEFAULT now() );";
     }
     
     public String getCreateAggregatedIndicatorTable()
@@ -89,7 +90,8 @@
             "factor DOUBLE PRECISION, " +
             "value DOUBLE PRECISION, " +
             "numeratorvalue DOUBLE PRECISION, " +
-            "denominatorvalue DOUBLE PRECISION );";
+            "denominatorvalue DOUBLE PRECISION, " +
+            "modified TIMESTAMP WITH TIME ZONE DEFAULT now());";
     }
 
     public String getCreateDataSetCompletenessTable()