dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18316
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7674: local vn - Should not load the attribute values of attribute-column-index in entry form.
------------------------------------------------------------
revno: 7674
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-07-23 22:46:02 +0700
message:
local vn - Should not load the attribute values of attribute-column-index in entry form.
modified:
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateLocalAttributeValueStore.java
local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml
local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadAttributeValuesAction.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 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateLocalAttributeValueStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateLocalAttributeValueStore.java 2012-07-06 19:43:15 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateLocalAttributeValueStore.java 2012-07-23 15:46:02 +0000
@@ -27,12 +27,9 @@
package org.hisp.dhis.attribute.hibernate;
-import java.sql.ResultSet;
-import java.sql.SQLException;
import java.util.Collection;
import java.util.HashSet;
-import org.amplecode.quick.StatementManager;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
@@ -41,6 +38,8 @@
import org.hisp.dhis.attribute.LocalAttributeValueStore;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
/**
* @author Chau Thu Tran
@@ -51,11 +50,11 @@
extends HibernateGenericStore<AttributeValue>
implements LocalAttributeValueStore
{
- private StatementManager statementManager;
+ private JdbcTemplate jdbcTemplate;
- public void setStatementManager( StatementManager statementManager )
+ public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
{
- this.statementManager = statementManager;
+ this.jdbcTemplate = jdbcTemplate;
}
@SuppressWarnings( "unchecked" )
@@ -81,36 +80,34 @@
+ "inner join attributevalue av on av.attributevalueid = deav.attributevalueid "
+ "where dsm.datasetid = " + dataSet.getId();
- return (statementManager.getHolder().queryForInteger( sql ) > 0) ? true : false;
+ return (jdbcTemplate.queryForInt( sql ) > 0) ? true : false;
}
public Collection<String> getByDataSet( DataSet dataSet )
{
Collection<String> result = new HashSet<String>();
+
try
{
String sql = "select distinct(av.value) from datasetmembers dsm "
+ "inner join dataelementattributevalues deav on deav.dataelementid = dsm.dataelementid "
+ "inner join attributevalue av on av.attributevalueid = deav.attributevalueid "
- + "where dsm.datasetid = " + dataSet.getId();
-
- ResultSet resultSet = statementManager.getHolder().getStatement().executeQuery( sql );
-
- while ( resultSet.next() )
+ + "inner join attribute a on av.attributeid = a.attributeid "
+ + "where dsm.datasetid = " + dataSet.getId() + " "
+ + "and a.name <> 'attribute_column_index'";
+
+ SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
+
+ while ( rowSet.next() )
{
- result.add( resultSet.getString( 1 ) );
- }
-
- return result;
+ result.add( rowSet.getString( 1 ) );
+ }
}
- catch ( SQLException e )
+ catch ( Exception e )
{
e.printStackTrace();
- return new HashSet<String>();
- }
- finally
- {
- statementManager.getHolder().close();
- }
+ }
+
+ return result;
}
}
=== modified file 'local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml'
--- local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml 2012-05-10 16:18:43 +0000
+++ local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml 2012-07-23 15:46:02 +0000
@@ -30,7 +30,7 @@
class="org.hisp.dhis.attribute.hibernate.HibernateLocalAttributeValueStore">
<property name="clazz" value="org.hisp.dhis.attribute.AttributeValue" />
<property name="sessionFactory" ref="sessionFactory" />
- <property name="statementManager" ref="statementManager" />
+ <property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
<!-- LocalDataSet -->
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadAttributeValuesAction.java'
--- local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadAttributeValuesAction.java 2012-05-10 16:18:43 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadAttributeValuesAction.java 2012-07-23 15:46:02 +0000
@@ -49,8 +49,18 @@
private LocalAttributeValueService localAttributeValueService;
+ public void setLocalAttributeValueService( LocalAttributeValueService localAttributeValueService )
+ {
+ this.localAttributeValueService = localAttributeValueService;
+ }
+
private DataSetService dataSetService;
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
// -------------------------------------------------------------------------
// Input && Output
// -------------------------------------------------------------------------
@@ -64,16 +74,6 @@
return values;
}
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
- public void setLocalAttributeValueService( LocalAttributeValueService localAttributeValueService )
- {
- this.localAttributeValueService = localAttributeValueService;
- }
-
public void setDataSetId( Integer dataSetId )
{
this.dataSetId = dataSetId;
@@ -88,9 +88,9 @@
throws Exception
{
DataSet dataset = dataSetService.getDataSet( dataSetId );
-
+
values = localAttributeValueService.getValuesByDataSet( dataset );
-
+
return SUCCESS;
}
}