dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18721
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7913: local vn - Fixed bug sort order by formname after form loaded.
------------------------------------------------------------
revno: 7913
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-08-15 02:13:01 +0700
message:
local vn - Fixed bug sort order by formname after form loaded.
modified:
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/DataElementFormNameComparator.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.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/LoadFormAction.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/dataelement/DataElementFormNameComparator.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/DataElementFormNameComparator.java 2012-08-06 17:06:50 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/DataElementFormNameComparator.java 2012-08-14 19:13:01 +0000
@@ -39,9 +39,6 @@
{
public int compare( DataElement dataElement0, DataElement dataElement1 )
{
- String name0 = dataElement0.getFormNameFallback();
- String name1 = dataElement1.getFormNameFallback();
-
- return name0.compareToIgnoreCase( name1 );
+ return dataElement0.getFormNameFallback().compareToIgnoreCase( dataElement1.getFormNameFallback() );
}
}
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java 2012-05-10 16:18:43 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java 2012-08-14 19:13:01 +0000
@@ -27,12 +27,10 @@
package org.hisp.dhis.dataelement.hibernate;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
+import java.util.List;
-import org.amplecode.quick.StatementManager;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.attribute.Attribute;
@@ -41,6 +39,9 @@
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataelement.LocalDataElementStore;
import org.hisp.dhis.dataset.DataSet;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
/**
* @author Chau Thu Tran
@@ -51,20 +52,12 @@
extends HibernateIdentifiableObjectStore<DataElement>
implements LocalDataElementStore
{
- private StatementManager statementManager;
-
- public void setStatementManager( StatementManager statementManager )
- {
- this.statementManager = statementManager;
- }
-
+ @Autowired
+ private JdbcTemplate jdbcTemplate;
+
+ @Autowired
private DataElementService dataElementService;
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
@SuppressWarnings( "unchecked" )
public Collection<DataElement> getByAttributeValue( Attribute attribute, String value )
{
@@ -87,32 +80,29 @@
@Override
public Collection<DataElement> get( DataSet dataSet, String value )
{
- Collection<DataElement> result = new HashSet<DataElement>();
+ List<DataElement> result = new ArrayList<DataElement>();
try
{
- String sql = "select distinct(deav.dataelementid) from datasetmembers dsm "
+ String sql = "select de.dataelementid, de.name, de.formname from dataelement de "
+ + "inner join datasetmembers dsm on de.dataelementid = dsm.dataelementid "
+ "inner join dataelementattributevalues deav on deav.dataelementid = dsm.dataelementid "
+ "inner join attributevalue av on av.attributevalueid = deav.attributevalueid "
+ "inner join attribute att on att.attributeid = av.attributeid " + "where dsm.datasetid = "
+ dataSet.getId() + " and av.value='" + value + "'";
- ResultSet resultSet = statementManager.getHolder().getStatement().executeQuery( sql );
+ SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
- while ( resultSet.next() )
+ while ( rowSet.next() )
{
- result.add( dataElementService.getDataElement( resultSet.getInt( 1 ) ) );
+ result.add( dataElementService.getDataElement( rowSet.getInt( 1 ) ) );
}
return result;
}
- catch ( SQLException e )
+ catch ( Exception e )
{
e.printStackTrace();
- return new HashSet<DataElement>();
- }
- finally
- {
- statementManager.getHolder().close();
+ return new ArrayList<DataElement>();
}
}
}
=== 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-07-23 15:46:02 +0000
+++ local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml 2012-08-14 19:13:01 +0000
@@ -15,8 +15,6 @@
class="org.hisp.dhis.dataelement.hibernate.HibernateLocalDataElementStore">
<property name="clazz" value="org.hisp.dhis.dataelement.DataElement" />
<property name="sessionFactory" ref="sessionFactory" />
- <property name="statementManager" ref="statementManager" />
- <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
</bean>
<!-- LocalAttributeValue -->
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java'
--- local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2012-05-31 06:06:01 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2012-08-14 19:13:01 +0000
@@ -40,7 +40,6 @@
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementFormNameComparator;
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataelement.LocalDataElementService;
@@ -211,13 +210,15 @@
{
DataSet dataSet = dataSetService.getDataSet( dataSetId, true, false, false );
- List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
+ List<DataElement> dataElements = null;
if ( value != null && !value.trim().isEmpty() )
{
- Collection<DataElement> dataElementsByAttr = localDataElementService.getDataElements( dataSet, value );
-
- dataElements.retainAll( dataElementsByAttr );
+ dataElements = new ArrayList<DataElement>( localDataElementService.getDataElements( dataSet, value ) );
+ }
+ else
+ {
+ dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
}
if ( dataElements.isEmpty() )
@@ -225,8 +226,6 @@
return INPUT;
}
- Collections.sort( dataElements, new DataElementFormNameComparator() );
-
orderedDataElements = dataElementService.getGroupedDataElementsByCategoryCombo( dataElements );
orderedCategoryCombos = dataElementService.getDataElementCategoryCombos( dataElements );
@@ -354,7 +353,10 @@
{
des = (List<DataElement>) orderedDataElements.get( categoryCombo );
- Collections.sort( des, IdentifiableObjectNameComparator.INSTANCE );
+ if ( value == null || value.trim().isEmpty() )
+ {
+ Collections.sort( des, IdentifiableObjectNameComparator.INSTANCE );
+ }
orderedDataElements.put( categoryCombo, des );
}