dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17413
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6919: local vn - Showed the value of attribute value as order.
------------------------------------------------------------
revno: 6919
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-05-12 16:41:20 +0700
message:
local vn - Showed the value of attribute value as order.
modified:
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateLocalAttributeValueStore.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-05-10 16:18:43 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateLocalAttributeValueStore.java 2012-05-12 09:41:20 +0000
@@ -33,6 +33,7 @@
import java.util.HashSet;
import org.amplecode.quick.StatementManager;
+import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.attribute.Attribute;
@@ -56,7 +57,7 @@
{
this.statementManager = statementManager;
}
-
+
@SuppressWarnings( "unchecked" )
@Override
public Collection<AttributeValue> getByAttribute( Attribute attribute )
@@ -69,38 +70,39 @@
public Collection<String> getDistinctValuesByAttribute( Attribute attribute )
{
return getCriteria().add( Restrictions.eq( "attribute", attribute ) ).add( Restrictions.ne( "value", "" ) )
- .setProjection( Projections.distinct( Projections.property( "value" ) ) ).list();
+ .setProjection( Projections.distinct( Projections.property( "value" ) ) ).addOrder( Order.asc( "value" ) )
+ .list();
}
-
+
public boolean hasAttributesByDataSet( DataSet dataSet )
{
- String sql = "select count(*) from datasetmembers dsm " +
- "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();
-
- return ( statementManager.getHolder().queryForInteger( sql ) > 0 ) ? true : false;
+ String sql = "select count(*) from datasetmembers dsm "
+ + "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();
+
+ return (statementManager.getHolder().queryForInteger( 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 " +
- "inner join attribute att on att.attributeid = av.attributeid " +
- "where dsm.datasetid = " + dataSet.getId();
-
+ 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 "
+ + "inner join attribute att on att.attributeid = av.attributeid " + "where dsm.datasetid = "
+ + dataSet.getId();
+
ResultSet resultSet = statementManager.getHolder().getStatement().executeQuery( sql );
-
- while( resultSet.next() )
+
+ while ( resultSet.next() )
{
result.add( resultSet.getString( 1 ) );
}
-
+
return result;
}
catch ( SQLException e )
@@ -112,6 +114,6 @@
{
statementManager.getHolder().close();
}
-
+
}
}