← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7671: Impl data marked for follow up analysis using jdbc template

 

------------------------------------------------------------
revno: 7671
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-07-23 14:33:49 +0200
message:
  Impl data marked for follow up analysis using jdbc template
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm
  resources/sql/div.sql


--
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/dataanalysis/jdbc/JdbcDataAnalysisStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java	2012-07-20 07:29:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java	2012-07-23 12:33:49 +0000
@@ -44,6 +44,7 @@
 import org.hisp.dhis.system.objectmapper.DeflatedDataValueNameMinMaxRowMapper;
 import org.hisp.dhis.system.util.ConversionUtils;
 import org.hisp.dhis.system.util.TextUtils;
+import org.springframework.jdbc.core.JdbcTemplate;
 
 /**
  * @author Lars Helge Overland
@@ -68,6 +69,13 @@
     {
         this.statementBuilder = statementBuilder;
     }
+    
+    private JdbcTemplate jdbcTemplate;
+
+    public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
+    {
+        this.jdbcTemplate = jdbcTemplate;
+    }
 
     // -------------------------------------------------------------------------
     // OutlierAnalysisStore implementation
@@ -117,8 +125,6 @@
     
     public Collection<DeflatedDataValue> getDataValuesMarkedForFollowup()
     {
-        final StatementHolder holder = statementManager.getHolder();
-        
         final String sql =
             "SELECT dv.dataelementid, dv.periodid, dv.sourceid, dv.categoryoptioncomboid, dv.value, " +
             "dv.storedby, dv.lastupdated, dv.comment, dv.followup, mm.minvalue, mm.maxvalue, de.name AS dataelementname, " +
@@ -132,19 +138,6 @@
             "LEFT JOIN _categoryoptioncomboname AS cc ON (dv.categoryoptioncomboid = cc.categoryoptioncomboid) " +
             "WHERE dv.followup=true";
         
-        try
-        {
-            final ResultSet resultSet = holder.getStatement().executeQuery( sql );
-            
-            return new ObjectMapper<DeflatedDataValue>().getCollection( resultSet, new DeflatedDataValueNameMinMaxRowMapper() );
-        }
-        catch ( SQLException ex )
-        {
-            throw new RuntimeException( "Failed to get deflated data values for followup", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
+        return jdbcTemplate.query( sql, new DeflatedDataValueNameMinMaxRowMapper() );        
     }        
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-07-20 11:41:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-07-23 12:33:49 +0000
@@ -190,6 +190,7 @@
   <bean id="org.hisp.dhis.dataanalysis.jdbc.DataAnalysisStore" class="org.hisp.dhis.dataanalysis.jdbc.JdbcDataAnalysisStore">
     <property name="statementManager" ref="statementManager" />
     <property name="statementBuilder" ref="statementBuilder" />
+	<property name="jdbcTemplate" ref="jdbcTemplate" />
   </bean>
 
   <bean id="org.hisp.dhis.datavalue.DataValueAuditStore" class="org.hisp.dhis.datavalue.hibernate.HibernateDataValueAuditStore">

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2012-06-09 22:56:39 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2012-07-23 12:33:49 +0000
@@ -10,7 +10,7 @@
 <table>
 	<tr>		
 		<!-- Comment -->
-		<td valign="top">
+		<td style="height:24px" valign="bottom">
 			<h4>$i18n.getString( "dataelement_comment" )
 			
 			#if ( $dataValue && $dataValue.isFollowup() )
@@ -21,13 +21,18 @@
 			    <img id="followup" src="../images/unmarked.png"/>
 			#end			
 			</h4>
+		</td>
+		<!-- Min-max -->        
+		<td style="height:24px" valign="bottom">       
+            <h4>$encoder.htmlEncode( $i18n.getString( "min_max_limits" ) )</h4>
+        </td>
+    </tr>
+    <tr>
+		<td valign="top">
 			<textarea id="commentTextArea" style="height:130px;width:240px">$!encoder.htmlEncode( $dataValue.comment )</textarea><br>
 			<input type="button" value="$i18n.getString( 'save_comment' )" style="width:130px" onclick="saveComment()">
-		</td>
-		
-		<!-- Min-max -->
-        <td valign="top">       
-            <h4>$encoder.htmlEncode( $i18n.getString( "min_max_limits" ) )</h4>
+		</td>		
+        <td valign="top">
             <table>
                 <tr>
                     <td style="background-color:#88be3b; height:26px;">&nbsp;</td>

=== modified file 'resources/sql/div.sql'
--- resources/sql/div.sql	2012-07-02 10:21:54 +0000
+++ resources/sql/div.sql	2012-07-23 12:33:49 +0000
@@ -59,15 +59,16 @@
 
 -- Facility overview --
 
-select ou.name, ou.uid, ou.code, ou.coordinates, oustr.level, gsstr.type, gsstr.ownership,
-  (select name from organisationunit where organisationunitid=oustr.idlevel2) as province,
-  (select name from organisationunit where organisationunitid=oustr.idlevel3) as county,
-  (select name from organisationunit where organisationunitid=oustr.idlevel4) as district
-from _orgunitstructure as oustr
-join organisationunit as ou on oustr.organisationunitid=ou.organisationunitid
-join _organisationunitgroupsetstructure as gsstr on ou.organisationunitid=gsstr.organisationunitid
-where oustr.level >= 5
-order by province, county, district, type, ownership, ou.name;
+select distinct ous.idlevel5 as internalid, ou.uid, ou.code, ou.name, ougs.type, ougs.ownership,
+ou2.name as province, ou3.name as county, ou4.name as district, ou.coordinates as longitide_latitude
+from _orgunitstructure ous
+left join organisationunit ou on ous.organisationunitid=ou.organisationunitid
+left join organisationunit ou2 on ous.idlevel2=ou2.organisationunitid
+left join organisationunit ou3 on ous.idlevel3=ou3.organisationunitid
+left join organisationunit ou4 on ous.idlevel4=ou4.organisationunitid
+left join _organisationunitgroupsetstructure ougs on ous.organisationunitid=ougs.organisationunitid
+where ous.level=5
+order by province, county, district, ou.name;
 
 -- Compare user roles --