← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4510: Data entry, improved load time for meta data

 

------------------------------------------------------------
revno: 4510
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-09-03 13:29:44 +0200
message:
  Data entry, improved load time for meta data
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.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-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java	2011-07-01 07:37:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java	2011-09-03 11:29:44 +0000
@@ -181,6 +181,18 @@
     String getExpressionDescription( String expression );
 
     /**
+     * Populates the explodedNumerator and explodedDenominator property on all
+     * indicators in the given collection. This method uses
+     * explodeExpression( String ) internally to generate the exploded expressions.
+     * This method will perform compared to calling explodeExpression( String )
+     * multiple times outside a transactional context as the transactional
+     * overhead is avoided.
+     * 
+     * @param indicators the collection of indicators.
+     */
+    void explodeExpressions( Collection<Indicator> indicators );
+    
+    /**
      * Replaces references to data element totals with references to all
      * category option combos in the category combo for that data element.
      * 

=== 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	2011-07-01 07:37:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java	2011-09-03 11:29:44 +0000
@@ -426,6 +426,18 @@
         return buffer != null ? buffer.toString() : null;
     }
 
+    public void explodeExpressions( Collection<Indicator> indicators )
+    {
+        if ( indicators != null )
+        {
+            for ( Indicator indicator : indicators )
+            {
+                indicator.setExplodedNumerator( explodeExpression( indicator.getNumerator() ) );
+                indicator.setExplodedDenominator( explodeExpression( indicator.getDenominator() ) );
+            }
+        }
+    }
+    
     public String explodeExpression( String expression )
     {
         StringBuffer buffer = null;

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2011-08-17 13:41:04 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2011-09-03 11:29:44 +0000
@@ -147,6 +147,8 @@
         
         indicators = indicatorService.getIndicatorsWithDataSets();
         
+        expressionService.explodeExpressions( indicators );
+        
         OrganisationUnitDataSetAssociationSet organisationUnitSet = organisationUnitService.getOrganisationUnitDataSetAssociationSet();
         
         dataSetAssociationSets = organisationUnitSet.getDataSetAssociationSets();
@@ -155,12 +157,6 @@
         
         dataSets = dataSetService.getDataSets( organisationUnitSet.getDistinctDataSets() );
         
-        for ( Indicator indicator : indicators )
-        {
-            indicator.setExplodedNumerator( expressionService.explodeExpression( indicator.getNumerator() ) );
-            indicator.setExplodedDenominator( expressionService.explodeExpression( indicator.getDenominator() ) );
-        }
-
         return SUCCESS;
     }
 }