dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #07503
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2143: Dropped a temporary view table after used
------------------------------------------------------------
revno: 2143
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-09-17 10:44:03 +0700
message:
Dropped a temporary view table after used
modified:
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java
dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml
--
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-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java 2010-09-08 05:46:03 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java 2010-09-17 03:44:03 +0000
@@ -11,6 +11,7 @@
import org.hisp.dhis.databrowser.DataBrowserStore;
import org.hisp.dhis.databrowser.DataBrowserTable;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.sqlview.SqlViewService;
import org.hisp.dhis.system.util.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,6 +32,13 @@
private OrganisationUnitService organisationUnitService;
+ private SqlViewService sqlViewService;
+
+ public void setSqlViewService( SqlViewService sqlViewService )
+ {
+ this.sqlViewService = sqlViewService;
+ }
+
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
{
this.organisationUnitService = organisationUnitService;
@@ -535,7 +543,7 @@
Integer numResults = 0;
StringBuffer sqlsbDescentdants = new StringBuffer();
- dropView( "view_count_descentdants" );
+ sqlViewService.dropViewTable( "view_count_descentdants" );
sqlsbDescentdants.append( "CREATE VIEW view_count_descentdants AS " );
setUpQueryForDrillDownDescendants( sqlsbDescentdants, orgUnitParent, betweenPeriodIds, maxLevel );
@@ -565,9 +573,11 @@
throw new RuntimeException( "Failed to get aggregated data value", e );
}
finally
- {
+ {
holder.close();
}
+
+ sqlViewService.dropViewTable( "view_count_descentdants" );
return numResults;
}
@@ -692,8 +702,8 @@
sb
.append( "SELECT DISTINCT o.organisationunitid AS parentid, o.name AS organisationunit, COUNT(value) as countdv_descendants, p.periodid AS periodid, p.startdate AS columnheader " );
sb.append( "FROM organisationunit o " );
- sb.append( "JOIN datavalue dv ON ( dv.sourceid = o.organisationunitid ) " );
- sb.append( "JOIN period p ON ( p.periodid = dv.periodid ) " );
+ sb.append( "JOIN datavalue dv ON (dv.sourceid = o.organisationunitid) " );
+ sb.append( "JOIN period p ON (dv.periodid = p.periodid) " );
sb.append( "WHERE o.parentid = '" + orgUnitSelected + "' " );
sb.append( "AND dv.periodid = '" + periodid + "' " );
sb.append( "GROUP BY o.organisationunitid, organisationunit, p.periodid, p.startdate " );
@@ -709,9 +719,9 @@
+ orgIndex
+ ".name AS organisationunit, COUNT(value) as countdv_descendants, p.periodid AS periodid, p.startdate AS columnheader " );
sb.append( "FROM datavalue dv " );
- sb.append( "JOIN organisationunit ou ON ( ou.organisationunitid = dv.sourceid ) " );
+ sb.append( "JOIN organisationunit ou ON (ou.organisationunitid = dv.sourceid) " );
this.setUpQueryForJOINTable( sb, diffLevel );
- sb.append( "JOIN period p ON ( p.periodid = dv.periodid ) " );
+ sb.append( "JOIN period p ON (dv.periodid = p.periodid) " );
sb.append( "WHERE dv.periodid = '" + periodid + "' " );
sb.append( "AND dv.sourceid IN " );
sb.append( "( " );
@@ -771,22 +781,4 @@
return (index == 0) ? "" : index + "";
}
-
- private void dropView( String view )
- {
- final StatementHolder holder = statementManager.getHolder();
-
- try
- {
- holder.getStatement().executeUpdate( "DROP VIEW IF EXISTS " + view );
- }
- catch ( SQLException ex )
- {
- throw new RuntimeException( "Failed to drop view: " + view, ex );
- }
- finally
- {
- holder.close();
- }
- }
}
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml 2010-08-25 06:53:37 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml 2010-09-17 03:44:03 +0000
@@ -84,6 +84,8 @@
class="org.hisp.dhis.databrowser.jdbc.StatementManagerDataBrowserStore">
<property name="organisationUnitService"
ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ <property name="sqlViewService"
+ ref="org.hisp.dhis.sqlview.SqlViewService"/>
</bean>
<bean id="org.hisp.dhis.databrowser.DataBrowserService"