← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2815: Simplification in AggregatedDataValueStore

 

------------------------------------------------------------
revno: 2815
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-02-03 21:31:06 +0100
message:
  Simplification in AggregatedDataValueStore
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.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-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	2011-01-31 19:47:04 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java	2011-02-03 20:31:06 +0000
@@ -218,39 +218,17 @@
     @Override
     public int countDataValuesAtLevel( OrganisationUnit rootOrgunit, OrganisationUnitLevel level, Collection<Period> periods )
     {
-        final StatementHolder holder = statementManager.getHolder();
-
-        try
-        {
-            int rootlevel = rootOrgunit.getLevel();
-
-            String periodids = getCommaDelimitedString( getIdentifiers(Period.class, periods));
-
-            final String sql =
-                "SELECT count(*) as rowcount " +
-                "FROM aggregateddatavalue AS adv " +
-                "INNER JOIN _orgunitstructure AS ous on adv.organisationunitid=ous.organisationunitid " +
-                "WHERE adv.level = " + level.getLevel() +
-                " AND ous.idlevel" + rootlevel + "=" + rootOrgunit.getId() +
-                " AND adv.periodid IN (" + periodids + ") ";
-
-            Statement statement = holder.getStatement();
-
-            final ResultSet resultSet = statement.executeQuery( sql );
-
-            resultSet.next();
-
-            return resultSet.getInt("rowcount");
-
-        }
-        catch ( SQLException ex )
-        {
-            throw new RuntimeException( "Failed to get aggregated data values", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
+        final String periodids = getCommaDelimitedString( getIdentifiers(Period.class, periods));
+
+        final String sql =
+            "SELECT count(*) " +
+            "FROM aggregateddatavalue AS adv " +
+            "INNER JOIN _orgunitstructure AS ous on adv.organisationunitid=ous.organisationunitid " +
+            "WHERE adv.level = " + level.getLevel() +
+            " AND ous.idlevel" + rootOrgunit.getLevel() + "=" + rootOrgunit.getId() +
+            " AND adv.periodid IN (" + periodids + ") ";
+
+        return statementManager.getHolder().queryForInteger( sql );
     }
 
     public int deleteAggregatedDataValues( Collection<Integer> dataElementIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds )

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java	2011-01-11 01:56:03 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java	2011-02-03 20:31:06 +0000
@@ -100,7 +100,6 @@
             "periodid INTEGER, " +
             "periodname VARCHAR( 30 ), " +
             "organisationunitid INTEGER, " +
-            "reporttableid INTEGER, " +
             "sources INTEGER, " +
             "registrations INTEGER, " +
             "registrationsOnTime INTEGER, " +

=== 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	2011-01-11 01:56:03 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2011-02-03 20:31:06 +0000
@@ -102,7 +102,6 @@
             "periodid INTEGER, " +
             "periodname VARCHAR( 30 ), " +
             "organisationunitid INTEGER, " +
-            "reporttableid INTEGER, " +
             "sources INTEGER, " +
             "registrations INTEGER, " +
             "registrationsOnTime INTEGER, " +

=== 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	2011-01-11 01:56:03 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2011-02-03 20:31:06 +0000
@@ -102,7 +102,6 @@
             "periodid INTEGER, " +
             "periodname VARCHAR( 30 ), " +
             "organisationunitid INTEGER, " +
-            "reporttableid INTEGER, " +
             "sources INTEGER, " +
             "registrations INTEGER, " +
             "registrationsOnTime INTEGER, " +

=== 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	2011-01-11 01:56:03 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2011-02-03 20:31:06 +0000
@@ -100,7 +100,6 @@
             "periodid INTEGER, " +
             "periodname VARCHAR( 30 ), " +
             "organisationunitid INTEGER, " +
-            "reporttableid INTEGER, " +
             "sources INTEGER, " +
             "registrations INTEGER, " +
             "registrationsOnTime INTEGER, " +