← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19550: switch to using jdbc backed sessions for oauth2

 

------------------------------------------------------------
revno: 19550
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-07-07 10:14:28 +0700
message:
  switch to using jdbc backed sessions for oauth2
modified:
  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/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/security.xml
  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
  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/HsqlStatementBuilder.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-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	2015-06-11 18:44:52 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2015-07-07 03:14:28 +0000
@@ -28,13 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.sql.ResultSet;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.amplecode.quick.BatchHandler;
 import org.amplecode.quick.BatchHandlerFactory;
 import org.amplecode.quick.StatementHolder;
@@ -49,6 +42,13 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author Lars Helge Overland
  */
@@ -79,7 +79,7 @@
     public void execute()
     {
         int defaultCategoryComboId = getDefaultCategoryCombo();
-        int defaultOptionComboId =  getDefaultOptionCombo();
+        int defaultOptionComboId = getDefaultOptionCombo();
 
         // ---------------------------------------------------------------------
         // Drop outdated tables
@@ -271,7 +271,7 @@
         executeSql( "ALTER TABLE programrule ALTER condition TYPE text" );
         executeSql( "ALTER TABLE programruleaction ALTER content TYPE text" );
         executeSql( "ALTER TABLE programruleaction ALTER data TYPE text" );
-        
+
 
         executeSql( "ALTER TABLE minmaxdataelement RENAME minvalue TO minimumvalue" );
         executeSql( "ALTER TABLE minmaxdataelement RENAME maxvalue TO maximumvalue" );
@@ -484,13 +484,13 @@
         executeSql( "update reporttable set coltotals = totals where coltotals is null" );
         executeSql( "update reporttable set coltotals = true where coltotals is null" );
         executeSql( "update reporttable set rowtotals = totals where rowtotals is null" );
-        executeSql( "update reporttable set rowtotals = true where rowtotals is null" );        
+        executeSql( "update reporttable set rowtotals = true where rowtotals is null" );
         executeSql( "alter table reporttable drop column totals" );
 
         // reporttable col/row subtotals
         executeSql( "update reporttable set colsubtotals = subtotals where colsubtotals is null" );
         executeSql( "update reporttable set rowsubtotals = subtotals where rowsubtotals is null" );
-        
+
         // reporttable upgrade counttype to outputtype
         executeSql( "update eventreport set outputtype = 'EVENT' where outputtype is null and counttype = 'events'" );
         executeSql( "update eventreport set outputtype = 'TRACKED_ENTITY_INSTANCE' where outputtype is null and counttype = 'tracked_entity_instances'" );
@@ -520,7 +520,7 @@
         executeSql( "update chart set userorganisationunitgrandchildren = false where userorganisationunitgrandchildren is null" );
         executeSql( "update chart set hidetitle = false where hidetitle is null" );
         executeSql( "update chart set sortorder = 0 where sortorder is null" );
-        
+
         executeSql( "update eventreport set showhierarchy = false where showhierarchy is null" );
         executeSql( "update eventreport set counttype = 'events' where counttype is null" );
         executeSql( "update eventreport set hidenadata = false where hidenadata is null" );
@@ -530,13 +530,13 @@
         executeSql( "update eventreport set coltotals = totals where coltotals is null" );
         executeSql( "update eventreport set coltotals = true where coltotals is null" );
         executeSql( "update eventreport set rowtotals = totals where rowtotals is null" );
-        executeSql( "update eventreport set rowtotals = true where rowtotals is null" );        
+        executeSql( "update eventreport set rowtotals = true where rowtotals is null" );
         executeSql( "alter table eventreport drop column totals" );
 
         // eventreport col/row subtotals
         executeSql( "update eventreport set colsubtotals = subtotals where colsubtotals is null" );
         executeSql( "update eventreport set rowsubtotals = subtotals where rowsubtotals is null" );
-        
+
         // eventchart upgrade counttype to outputtype
         executeSql( "update eventchart set outputtype = 'EVENT' where outputtype is null and counttype = 'events'" );
         executeSql( "update eventchart set outputtype = 'TRACKED_ENTITY_INSTANCE' where outputtype is null and counttype = 'tracked_entity_instances'" );
@@ -715,7 +715,7 @@
         executeSql( "update sqlview set type = 'QUERY' where query is true" );
         executeSql( "update sqlview set type = 'VIEW' where type is null" );
         executeSql( "alter table sqlview drop column query" );
-        
+
         executeSql( "UPDATE dashboard SET publicaccess='--------' WHERE publicaccess is null" );
 
         executeSql( "UPDATE optionset SET version=0 WHERE version IS NULL" );
@@ -748,7 +748,7 @@
         executeSql( "ALTER TABLE dataelementgroupset ALTER COLUMN datadimension SET NOT NULL" );
         executeSql( "UPDATE orgunitgroupset SET datadimension=true WHERE datadimension IS NULL" );
         executeSql( "ALTER TABLE orgunitgroupset ALTER COLUMN datadimension SET NOT NULL" );
-        
+
         // set attribute defaults
         executeSql( "UPDATE attribute SET dataelementattribute=false WHERE dataelementattribute IS NULL" );
         executeSql( "UPDATE attribute SET dataelementgroupattribute=false WHERE dataelementgroupattribute IS NULL" );
@@ -773,7 +773,7 @@
 
         //update programruleaction:
         executeSql( "ALTER TABLE programruleaction DROP COLUMN name" );
-        
+
         // data approval
         executeSql( "UPDATE dataapproval SET accepted=false WHERE accepted IS NULL" );
         executeSql( "ALTER TABLE dataapproval ALTER COLUMN accepted SET NOT NULL" );
@@ -786,7 +786,7 @@
 
         // validation rule group, new column alertbyorgunits
         executeSql( "UPDATE validationrulegroup SET alertbyorgunits=false WHERE alertbyorgunits IS NULL" );
-        
+
         executeSql( "update expression set missingvaluestrategy = 'SKIP_IF_ANY_VALUE_MISSING' where missingvaluestrategy is null and (nullifblank is true or nullifblank is null)" );
         executeSql( "update expression set missingvaluestrategy = 'NEVER_SKIP' where missingvaluestrategy is null nullifblank is false" );
         executeSql( "alter table expression alter column missingvaluestrategy set not null" );
@@ -794,11 +794,11 @@
 
         executeSql( "alter table dataelementcategoryoption alter column startdate type date" );
         executeSql( "alter table dataelementcategoryoption alter column enddate type date" );
-        
+
         executeSql( "alter table dataelement drop column sortorder" );
         executeSql( "alter table indicator drop column sortorder" );
         executeSql( "alter table dataset drop column sortorder" );
-        
+
         executeSql( "alter table dataelement drop column active" );
 
         executeSql( "alter table datavalue alter column value type varchar(50000)" );
@@ -807,36 +807,62 @@
 
         executeSql( "update datavalueaudit set attributeoptioncomboid = " + defaultOptionComboId + " where attributeoptioncomboid is null" );
         executeSql( "alter table datavalueaudit alter column attributeoptioncomboid set not null;" );
-        
+
         executeSql( "update dataelementcategoryoption set shortname = substring(name,0,50) where shortname is null" );
 
         // AttributeValue
         executeSql( "UPDATE attributevalue SET created=now() WHERE created IS NULL" );
         executeSql( "UPDATE attributevalue SET lastupdated=now() WHERE lastupdated IS NULL" );
         executeSql( "ALTER TABLE attributevalue ALTER value TYPE text" );
-        
+
         executeSql( "update dashboarditem set shape = 'normal' where shape is null" );
-        
+
         executeSql( "update categoryoptioncombo set ignoreapproval = false where ignoreapproval is null" );
 
         executeSql( "alter table version alter column versionkey set not null" );
         executeSql( "alter table version add constraint version_versionkey_key unique(versionkey)" );
 
+        oauth2();
+
         upgradeDataValuesWithAttributeOptionCombo();
         upgradeCompleteDataSetRegistrationsWithAttributeOptionCombo();
         upgradeMapViewsToAnalyticalObject();
         upgradeTranslations();
 
         updateOptions();
-        
+
         upgradeAggregationType( "reporttable" );
         upgradeAggregationType( "chart" );
-        
+
         updateRelativePeriods();
 
         log.info( "Tables updated" );
     }
-    
+
+    public void oauth2()
+    {
+        // OAuth2
+        executeSql( "CREATE TABLE oauth_code (" +
+            "  code VARCHAR(256), authentication " + statementBuilder.getLongVarBinaryType() +
+            ")" );
+
+        executeSql( "CREATE TABLE oauth_access_token (" +
+            "  token_id VARCHAR(256)," +
+            "  token " + statementBuilder.getLongVarBinaryType() + "," +
+            "  authentication_id VARCHAR(256) PRIMARY KEY," +
+            "  user_name VARCHAR(256)," +
+            "  client_id VARCHAR(256)," +
+            "  authentication " + statementBuilder.getLongVarBinaryType() + "," +
+            "  refresh_token VARCHAR(256)" +
+            ")" );
+
+        executeSql( "CREATE TABLE oauth_refresh_token (" +
+            "  token_id VARCHAR(256)," +
+            "  token " + statementBuilder.getLongVarBinaryType() + "," +
+            "  authentication " + statementBuilder.getLongVarBinaryType() +
+            ")" );
+    }
+
     private void upgradeAggregationType( String table )
     {
         executeSql( "update " + table + " set aggregationtype='SUM' where aggregationtype='sum'" );
@@ -871,7 +897,7 @@
         executeSql( "update relativeperiods set lastsixmonth = false where lastsixmonth is null" );
         executeSql( "update relativeperiods set lastweek = false where lastweek is null" );
     }
-    
+
     private void upgradeDataValuesWithAttributeOptionCombo()
     {
         final String sql = statementBuilder.getNumberOfColumnsInPrimaryKey( "datavalue" );
@@ -1272,7 +1298,7 @@
         }
         catch ( Exception ex )
         {
-            log.debug( ex );
+            log.warn( ex );
 
             return -1;
         }
@@ -1299,9 +1325,9 @@
         String sql = "insert into optionvalue(optionvalueid, code, name, optionsetid, sort_order) "
             + "select " + statementBuilder.getAutoIncrementValue() + ", optionvalue, optionvalue, optionsetid, ( sort_order + 1 ) "
             + "from optionsetmembers";
-        
+
         int result = executeSql( sql );
-        
+
         if ( result != -1 )
         {
             executeSql( "drop table optionsetmembers" );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2015-07-06 05:55:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2015-07-07 03:14:28 +0000
@@ -200,6 +200,8 @@
             hql += ")";
         }
 
+        System.err.println( "hql: " + hql );
+
         return hql;
     }
 
@@ -438,6 +440,8 @@
             sql = removeLastAnd( sql ) + ") ";
         }
 
+        System.err.println( "sql: " + sql );
+
         return sql;
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/security.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/security.xml	2015-06-24 09:17:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/security.xml	2015-07-07 03:14:28 +0000
@@ -76,9 +76,13 @@
   <!-- OAuth2 -->
   <bean id="clientDetailsService" class="org.hisp.dhis.security.oauth2.DefaultClientDetailsService" />
 
-  <bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore" />
+  <bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.store.JdbcTokenStore">
+    <constructor-arg name="dataSource" ref="dataSource" />
+  </bean>
 
-  <bean id="authorizationCodeServices" class="org.springframework.security.oauth2.provider.code.InMemoryAuthorizationCodeServices" />
+  <bean id="authorizationCodeServices" class="org.springframework.security.oauth2.provider.code.JdbcAuthorizationCodeServices">
+    <constructor-arg name="dataSource" ref="dataSource" />
+  </bean>
 
   <bean id="tokenServices" class="org.springframework.security.oauth2.provider.token.DefaultTokenServices">
     <property name="tokenStore" ref="tokenStore" />

=== 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	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java	2015-07-07 03:14:28 +0000
@@ -115,7 +115,9 @@
      * @return the name of a double column type.
      */
     String getDoubleColumnType();
-    
+
+    String getLongVarBinaryType();
+
     /**
      * Returns the value used to match a column to a regular expression. Matching
      * is case insensitive.

=== 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	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/AbstractStatementBuilder.java	2015-07-07 03:14:28 +0000
@@ -28,11 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.system.util.DateUtils.getSqlDateString;
-
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.period.Period;
 
+import static org.hisp.dhis.system.util.DateUtils.getSqlDateString;
+
 /**
  * @author Lars Helge Overland
  */
@@ -44,7 +44,7 @@
     {
         return encode( value, true );
     }
-    
+
     @Override
     public String encode( String value, boolean quote )
     {
@@ -53,14 +53,14 @@
             value = value.endsWith( "\\" ) ? value.substring( 0, value.length() - 1 ) : value;
             value = value.replaceAll( QUOTE, QUOTE + QUOTE );
         }
-        
-        return quote ? ( QUOTE + value + QUOTE ) : value;
+
+        return quote ? (QUOTE + value + QUOTE) : value;
     }
-    
+
     @Override
     public String columnQuote( String column )
     {
-        return column != null ? ( getColumnQuote() + column + getColumnQuote() ) : null;
+        return column != null ? (getColumnQuote() + column + getColumnQuote()) : null;
     }
 
     @Override
@@ -76,76 +76,82 @@
     }
 
     @Override
+    public String getLongVarBinaryType()
+    {
+        return "VARBINARY(1000000)";
+    }
+
+    @Override
     public String getPeriodIdentifierStatement( Period period )
     {
         return
-            "SELECT periodid FROM period WHERE periodtypeid=" + period.getPeriodType().getId() + " " + 
-            "AND startdate='" + getSqlDateString( period.getStartDate() ) + "' " +
-            "AND enddate='" + getSqlDateString( period.getEndDate() ) + "'";
+            "SELECT periodid FROM period WHERE periodtypeid=" + period.getPeriodType().getId() + " " +
+                "AND startdate='" + getSqlDateString( period.getStartDate() ) + "' " +
+                "AND enddate='" + getSqlDateString( period.getEndDate() ) + "'";
     }
 
     @Override
     public String getCreateAggregatedDataValueTable( boolean temp )
     {
         return
-            "CREATE TABLE aggregateddatavalue" + ( temp ? "_temp" : "" ) + " ( " +
-            "dataelementid INTEGER, " +
-            "categoryoptioncomboid INTEGER, " +
-            "periodid INTEGER, " +
-            "organisationunitid INTEGER, " +
-            "periodtypeid INTEGER, " +
-            "level INTEGER, " +
-            "value " + getDoubleColumnType() + " );";
+            "CREATE TABLE aggregateddatavalue" + (temp ? "_temp" : "") + " ( " +
+                "dataelementid INTEGER, " +
+                "categoryoptioncomboid INTEGER, " +
+                "periodid INTEGER, " +
+                "organisationunitid INTEGER, " +
+                "periodtypeid INTEGER, " +
+                "level INTEGER, " +
+                "value " + getDoubleColumnType() + " );";
     }
 
     @Override
     public String getCreateAggregatedOrgUnitDataValueTable( boolean temp )
     {
         return
-            "CREATE TABLE aggregatedorgunitdatavalue" + ( temp ? "_temp" : "" ) + " ( " +
-            "dataelementid INTEGER, " +
-            "categoryoptioncomboid INTEGER, " +
-            "periodid INTEGER, " +
-            "organisationunitid INTEGER, " +
-            "organisationunitgroupid INTEGER, " +
-            "periodtypeid INTEGER, " +
-            "level INTEGER, " +
-            "value " + getDoubleColumnType() + " );";
+            "CREATE TABLE aggregatedorgunitdatavalue" + (temp ? "_temp" : "") + " ( " +
+                "dataelementid INTEGER, " +
+                "categoryoptioncomboid INTEGER, " +
+                "periodid INTEGER, " +
+                "organisationunitid INTEGER, " +
+                "organisationunitgroupid INTEGER, " +
+                "periodtypeid INTEGER, " +
+                "level INTEGER, " +
+                "value " + getDoubleColumnType() + " );";
     }
 
     @Override
     public String getCreateAggregatedIndicatorTable( boolean temp )
     {
         return
-            "CREATE TABLE aggregatedindicatorvalue" + ( temp ? "_temp" : "" ) + " ( " +
-            "indicatorid INTEGER, " +
-            "periodid INTEGER, " +
-            "organisationunitid INTEGER, " +
-            "periodtypeid INTEGER, " +
-            "level INTEGER, " +
-            "annualized VARCHAR( 10 ), " +
-            "factor " + getDoubleColumnType() + ", " +
-            "value " + getDoubleColumnType() + ", " +
-            "numeratorvalue " + getDoubleColumnType() + ", " +
-            "denominatorvalue " + getDoubleColumnType() + " );";
+            "CREATE TABLE aggregatedindicatorvalue" + (temp ? "_temp" : "") + " ( " +
+                "indicatorid INTEGER, " +
+                "periodid INTEGER, " +
+                "organisationunitid INTEGER, " +
+                "periodtypeid INTEGER, " +
+                "level INTEGER, " +
+                "annualized VARCHAR( 10 ), " +
+                "factor " + getDoubleColumnType() + ", " +
+                "value " + getDoubleColumnType() + ", " +
+                "numeratorvalue " + getDoubleColumnType() + ", " +
+                "denominatorvalue " + getDoubleColumnType() + " );";
     }
 
     @Override
     public String getCreateAggregatedOrgUnitIndicatorTable( boolean temp )
     {
         return
-            "CREATE TABLE aggregatedorgunitindicatorvalue" + ( temp ? "_temp" : "" ) + " ( " +
-            "indicatorid INTEGER, " +
-            "periodid INTEGER, " +
-            "organisationunitid INTEGER, " +
-            "organisationunitgroupid INTEGER, " +
-            "periodtypeid INTEGER, " +
-            "level INTEGER, " +
-            "annualized VARCHAR( 10 ), " +
-            "factor " + getDoubleColumnType() + ", " +
-            "value " + getDoubleColumnType() + ", " +
-            "numeratorvalue " + getDoubleColumnType() + ", " +
-            "denominatorvalue " + getDoubleColumnType() + " );";
+            "CREATE TABLE aggregatedorgunitindicatorvalue" + (temp ? "_temp" : "") + " ( " +
+                "indicatorid INTEGER, " +
+                "periodid INTEGER, " +
+                "organisationunitid INTEGER, " +
+                "organisationunitgroupid INTEGER, " +
+                "periodtypeid INTEGER, " +
+                "level INTEGER, " +
+                "annualized VARCHAR( 10 ), " +
+                "factor " + getDoubleColumnType() + ", " +
+                "value " + getDoubleColumnType() + ", " +
+                "numeratorvalue " + getDoubleColumnType() + ", " +
+                "denominatorvalue " + getDoubleColumnType() + " );";
     }
 
     @Override
@@ -153,15 +159,15 @@
     {
         return
             "CREATE TABLE aggregateddatasetcompleteness ( " +
-            "datasetid INTEGER, " +
-            "periodid INTEGER, " +
-            "periodname VARCHAR( 30 ), " +
-            "organisationunitid INTEGER, " +
-            "sources INTEGER, " +
-            "registrations INTEGER, " +
-            "registrationsOnTime INTEGER, " +
-            "value " + getDoubleColumnType() + ", " +
-            "valueOnTime " + getDoubleColumnType() + " );";
+                "datasetid INTEGER, " +
+                "periodid INTEGER, " +
+                "periodname VARCHAR( 30 ), " +
+                "organisationunitid INTEGER, " +
+                "sources INTEGER, " +
+                "registrations INTEGER, " +
+                "registrationsOnTime INTEGER, " +
+                "value " + getDoubleColumnType() + ", " +
+                "valueOnTime " + getDoubleColumnType() + " );";
     }
 
     @Override
@@ -169,16 +175,16 @@
     {
         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() + " );";
+                "datasetid INTEGER, " +
+                "periodid INTEGER, " +
+                "periodname VARCHAR( 30 ), " +
+                "organisationunitid INTEGER, " +
+                "organisationunitgroupid INTEGER, " +
+                "sources INTEGER, " +
+                "registrations INTEGER, " +
+                "registrationsOnTime INTEGER, " +
+                "value " + getDoubleColumnType() + ", " +
+                "valueOnTime " + getDoubleColumnType() + " );";
     }
 
     @Override
@@ -186,14 +192,14 @@
     {
         return
             "select count(cu.column_name) from information_schema.key_column_usage cu " +
-            "inner join information_schema.table_constraints tc  " +
-            "on cu.constraint_catalog=tc.constraint_catalog " +
+                "inner join information_schema.table_constraints tc  " +
+                "on cu.constraint_catalog=tc.constraint_catalog " +
                 "and cu.constraint_schema=tc.constraint_schema " +
                 "and cu.constraint_name=tc.constraint_name " +
                 "and cu.table_schema=tc.table_schema " +
                 "and cu.table_name=tc.table_name " +
-            "where tc.constraint_type='PRIMARY KEY' " +
-            "and cu.table_name='" + table + "';";
+                "where tc.constraint_type='PRIMARY KEY' " +
+                "and cu.table_name='" + table + "';";
     }
 
     @Override
@@ -207,7 +213,7 @@
     {
         return "alter table " + table + " add column " + column + " integer auto_increment primary key not null;";
     }
-    
+
     @Override
     public String getDropNotNullConstraint( String table, String column, String type )
     {

=== 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	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2015-07-07 03:14:28 +0000
@@ -41,7 +41,7 @@
     {
         return "double";
     }
-    
+
     @Override
     public String getColumnQuote()
     {

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/HsqlStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/HsqlStatementBuilder.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/HsqlStatementBuilder.java	2015-07-07 03:14:28 +0000
@@ -41,7 +41,7 @@
     {
         return "double";
     }
-    
+
     @Override
     public String getColumnQuote()
     {

=== 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	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2015-07-07 03:14:28 +0000
@@ -43,6 +43,12 @@
     }
 
     @Override
+    public String getLongVarBinaryType()
+    {
+        return "BLOB";
+    }
+
+    @Override
     public String getColumnQuote()
     {
         return "`";

=== 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	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2015-07-07 03:14:28 +0000
@@ -43,6 +43,12 @@
     }
 
     @Override
+    public String getLongVarBinaryType()
+    {
+        return "BYTEA";
+    }
+
+    @Override
     public String getColumnQuote()
     {
         return "\"";