dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22723
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11014: Expressions, catching exception
------------------------------------------------------------
revno: 11014
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-05-27 13:57:19 +0200
message:
Expressions, catching exception
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.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 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2013-05-27 11:07:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2013-05-27 11:57:19 +0000
@@ -33,6 +33,8 @@
import java.util.HashSet;
import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
@@ -45,17 +47,18 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.system.util.ConversionUtils;
import org.hisp.dhis.system.util.TextUtils;
+import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.jdbc.core.RowCallbackHandler;
/**
* @author Torgeir Lorange Ostby
- * @version $Id: HibernateDataElementStore.java 5243 2008-05-25 10:18:58Z
- * larshelg $
*/
public class HibernateDataElementStore
extends HibernateIdentifiableObjectStore<DataElement>
implements DataElementStore
{
+ private static final Log log = LogFactory.getLog( HibernateDataElementStore.class );
+
// -------------------------------------------------------------------------
// DataElement
// -------------------------------------------------------------------------
@@ -233,18 +236,26 @@
final ListMap<String, String> map = new ListMap<String, String>();
- jdbcTemplate.query( sql, new RowCallbackHandler()
+ try
{
- @Override
- public void processRow( ResultSet rs )
- throws SQLException
+ jdbcTemplate.query( sql, new RowCallbackHandler()
{
- String de = rs.getString( 1 );
- String coc = rs.getString( 2 );
-
- map.putValue( de, coc );
- }
- } );
+ @Override
+ public void processRow( ResultSet rs )
+ throws SQLException
+ {
+ String de = rs.getString( 1 );
+ String coc = rs.getString( 2 );
+
+ map.putValue( de, coc );
+ }
+ } );
+ }
+ catch ( BadSqlGrammarException ex )
+ {
+ log.error( "Resource table _dataelementcategoryoptioncomboname does not exist, please generate it" );
+ return new ListMap<String, String>();
+ }
return map;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2013-05-27 11:07:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2013-05-27 11:57:19 +0000
@@ -487,10 +487,13 @@
{
final ListMap<String, String> dataElementMap = dataElementService.getDataElementCategoryOptionComboMap( dataElementTotals );
- for ( Indicator indicator : indicators )
+ if ( !dataElementMap.isEmpty() )
{
- indicator.setExplodedNumerator( explodeExpression( indicator.getExplodedNumerator() != null ? indicator.getExplodedNumerator() : "", dataElementMap ) );
- indicator.setExplodedDenominator( explodeExpression( indicator.getExplodedDenominator() != null ? indicator.getExplodedDenominator() : "", dataElementMap ) );
+ for ( Indicator indicator : indicators )
+ {
+ indicator.setExplodedNumerator( explodeExpression( indicator.getExplodedNumerator() != null ? indicator.getExplodedNumerator() : "", dataElementMap ) );
+ indicator.setExplodedDenominator( explodeExpression( indicator.getExplodedDenominator() != null ? indicator.getExplodedDenominator() : "", dataElementMap ) );
+ }
}
}
}