dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04166
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1381: Simplified jdbc methods.
------------------------------------------------------------
revno: 1381
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-02-02 14:28:31 +0100
message:
Simplified jdbc methods.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessStore.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.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/completeness/DataSetCompletenessStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessStore.java 2010-02-02 13:21:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessStore.java 2010-02-02 13:28:31 +0000
@@ -58,9 +58,8 @@
* @param dataSetIds the DataSet identifiers.
* @param periodIds the Period identifiers.
* @param sourceIds the Source identifiers.
- * @return the number of deleted entries.
*/
- int deleteDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds, Collection<Integer> sourceIds );
+ void deleteDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds, Collection<Integer> sourceIds );
/**
* Deletes all datasetcompleteness entries.
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java 2010-02-02 13:21:02 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java 2010-02-02 13:28:31 +0000
@@ -29,12 +29,9 @@
import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
-import java.sql.ResultSet;
-import java.sql.SQLException;
import java.util.Collection;
import java.util.Date;
-import org.amplecode.quick.StatementHolder;
import org.amplecode.quick.StatementManager;
import org.hisp.dhis.completeness.DataSetCompletenessStore;
import org.hisp.dhis.dataset.DataSet;
@@ -66,77 +63,34 @@
// DataSetCompletenessStore
// -------------------------------------------------------------------------
- //TODO implement this with improved quick API
-
public double getPercentage( int dataSetId, int periodId, int organisationUnitId )
{
- StatementHolder holder = statementManager.getHolder();
+ final String sql =
+ "SELECT value " +
+ "FROM aggregateddatasetcompleteness " +
+ "WHERE datasetid = " + dataSetId + " " +
+ "AND periodid = " + periodId + " " +
+ "AND organisationunitid = " + organisationUnitId;
- try
- {
- String sql =
- "SELECT value " +
- "FROM aggregateddatasetcompleteness " +
- "WHERE datasetid = " + dataSetId + " " +
- "AND periodid = " + periodId + " " +
- "AND organisationunitid = " + organisationUnitId;
-
- ResultSet resultSet = holder.getStatement().executeQuery( sql );
-
- return resultSet.next() ? resultSet.getDouble( 1 ) : -1;
- }
- catch ( SQLException ex )
- {
- throw new RuntimeException( "Failed to get datasetcompleteness", ex );
- }
- finally
- {
- holder.close();
- }
+ return statementManager.getHolder().queryForDouble( sql );
}
- public int deleteDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds )
+ public void deleteDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds )
{
- StatementHolder holder = statementManager.getHolder();
+ final String sql =
+ "DELETE FROM aggregateddatasetcompleteness " +
+ "WHERE datasetid IN ( " + getCommaDelimitedString( dataSetIds ) + " ) " +
+ "AND periodid IN ( " + getCommaDelimitedString( periodIds ) + " ) " +
+ "AND organisationunitid IN ( " + getCommaDelimitedString( organisationUnitIds ) + " )";
- try
- {
- String sql =
- "DELETE FROM aggregateddatasetcompleteness " +
- "WHERE datasetid IN ( " + getCommaDelimitedString( dataSetIds ) + " ) " +
- "AND periodid IN ( " + getCommaDelimitedString( periodIds ) + " ) " +
- "AND organisationunitid IN ( " + getCommaDelimitedString( organisationUnitIds ) + " )";
-
- return holder.getStatement().executeUpdate( sql );
- }
- catch ( SQLException ex )
- {
- throw new RuntimeException( "Failed to delete datasetcompleteness", ex );
- }
- finally
- {
- holder.close();
- }
+ statementManager.getHolder().executeUpdate( sql );
}
public void deleteDataSetCompleteness()
{
- StatementHolder holder = statementManager.getHolder();
+ final String sql = "DELETE FROM aggregateddatasetcompleteness";
- try
- {
- String sql = "DELETE FROM aggregateddatasetcompleteness";
-
- holder.getStatement().executeUpdate( sql );
- }
- catch ( SQLException ex )
- {
- throw new RuntimeException( "Failed to delete datasetcompleteness", ex );
- }
- finally
- {
- holder.close();
- }
+ statementManager.getHolder().executeUpdate( sql );
}
public int getRegistrations( DataSet dataSet, Collection<? extends Source> children, Period period )