← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1957: Minor fixes to speed up data entry screen loading

 

------------------------------------------------------------
revno: 1957
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Thu 2010-06-03 12:32:02 +0200
message:
  Minor fixes to speed up data entry screen loading
removed:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/StandardCommentsManagerException.java
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/customvalue/DefaultCustomValueService.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/DefaultStandardCommentsManager.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/StandardCommentsManager.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml


--
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/customvalue/DefaultCustomValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/customvalue/DefaultCustomValueService.java	2009-07-05 20:32:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/customvalue/DefaultCustomValueService.java	2010-06-03 10:32:02 +0000
@@ -61,9 +61,7 @@
 
     public int addCustomValue( CustomValue customValue )
     {
-        int id = customValueStore.save( customValue );
-
-        return id;
+        return customValueStore.save( customValue );
     }
 
     public void deleteCustomValue( CustomValue customValue )

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2010-06-03 09:22:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2010-06-03 10:32:02 +0000
@@ -46,7 +46,6 @@
 import org.hisp.dhis.datalock.DataSetLock;
 import org.hisp.dhis.datalock.DataSetLockService;
 import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.de.comments.StandardCommentsManager;
@@ -60,7 +59,6 @@
 import org.hisp.dhis.order.manager.DataElementOrderManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
-import org.hisp.dhis.system.util.TimeUtils;
 
 import com.opensymphony.xwork2.Action;
 
@@ -164,13 +162,6 @@
         this.categoryService = categoryService;
     }
 
-    private DataSetService dataSetService;
-
-    public void setDataSetService( DataSetService dataSetService )
-    {
-        this.dataSetService = dataSetService;
-    }
-
     // -------------------------------------------------------------------------
     // DisplayPropertyHandler
     // -------------------------------------------------------------------------
@@ -309,7 +300,6 @@
     public String execute()
         throws Exception
     {
-        TimeUtils.markHMS( "1" );
         zeroValueSaveMode = (Boolean) systemSettingManager.getSystemSetting( KEY_ZERO_VALUE_SAVE_MODE, false );
 
         OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
@@ -318,20 +308,17 @@
 
         customValues = (List<CustomValue>) customValueService.getCustomValuesByDataSet( dataSet );
 
-        TimeUtils.markHMS( "2" );
         Period period = selectedStateManager.getSelectedPeriod();
 
         DataSetLock dataSetLock = dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period );
 
-        TimeUtils.markHMS( "3" );
         if ( dataSetLock != null && dataSetLock.getSources().contains( organisationUnit ) )
         {
             disabled = "disabled";
         }
 
-        Collection<DataElement> dataElements = new ArrayList<DataElement>( dataSetService.getDataElements( dataSet ) );
+        Collection<DataElement> dataElements = dataSet.getDataElements();
 
-        TimeUtils.markHMS( "4" );
         if ( dataElements.size() == 0 )
         {
             return SUCCESS;
@@ -341,7 +328,6 @@
 
         optionComboId = defaultOptionCombo.getId();
 
-        TimeUtils.markHMS( "5" );
         // ---------------------------------------------------------------------
         // Get the min/max values
         // ---------------------------------------------------------------------
@@ -349,7 +335,6 @@
         Collection<MinMaxDataElement> minMaxDataElements = minMaxDataElementService.getMinMaxDataElements(
             organisationUnit, dataElements );
 
-        TimeUtils.markHMS( "6" );
         minMaxMap = new HashMap<Integer, MinMaxDataElement>( minMaxDataElements.size() );
 
         for ( MinMaxDataElement minMaxDataElement : minMaxDataElements )
@@ -361,10 +346,8 @@
         // Get the DataValues and create a map
         // ---------------------------------------------------------------------
 
-        TimeUtils.markHMS( "7" );
         Collection<DataValue> dataValues = dataValueService.getDataValues( organisationUnit, period, dataElements );
 
-        TimeUtils.markHMS( "8" );
         dataValueMap = new HashMap<Integer, DataValue>( dataValues.size() );
 
         for ( DataValue dataValue : dataValues )
@@ -376,18 +359,15 @@
         // Prepare values for unsaved CalculatedDataElements
         // ---------------------------------------------------------------------
 
-        TimeUtils.markHMS( "9" );
         calculatedValueMap = dataEntryScreenManager.populateValuesForCalculatedDataElements( organisationUnit, dataSet,
             period );
 
-        TimeUtils.markHMS( "10" );
         // ---------------------------------------------------------------------
         // Make the standard comments available
         // ---------------------------------------------------------------------
 
         standardComments = standardCommentsManager.getStandardComments();
 
-        TimeUtils.markHMS( "11" );
         // ---------------------------------------------------------------------
         // Make the DataElement types available
         // ---------------------------------------------------------------------
@@ -405,7 +385,6 @@
         dataEntryForm = dataEntryFormService.getDataEntryFormByDataSet( dataSet );
         cdeFormExists = (dataEntryForm != null);
 
-        TimeUtils.markHMS( "12" );
         if ( cdeFormExists )
         {
             customDataEntryFormCode = dataEntryScreenManager.populateCustomDataEntryScreen(
@@ -413,7 +392,6 @@
                 i18n, dataSet );
         }
 
-        TimeUtils.markHMS( "13" );
         // ---------------------------------------------------------------------
         // Working on the display of dataelements
         // ---------------------------------------------------------------------
@@ -422,7 +400,6 @@
 
         displayPropertyHandler.handle( orderedDataElements );
 
-        TimeUtils.markHMS( "14" );
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java	2010-05-28 09:12:03 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java	2010-06-03 10:32:02 +0000
@@ -53,7 +53,6 @@
 import org.hisp.dhis.datalock.DataSetLock;
 import org.hisp.dhis.datalock.DataSetLockService;
 import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.de.comments.StandardCommentsManager;
@@ -169,13 +168,6 @@
         this.dataSetLockService = dataSetLockService;
     }
 
-    private DataSetService dataSetService;
-
-    public void setDataSetService( DataSetService dataSetService )
-    {
-        this.dataSetService = dataSetService;
-    }
-
     // -------------------------------------------------------------------------
     // Comparator
     // -------------------------------------------------------------------------
@@ -393,7 +385,7 @@
             disabled = "disabled";
         }
 
-        List<DataElement> dataElements = new ArrayList<DataElement>( dataSetService.getDataElements( dataSet ) );
+        List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
 
         if ( dataElements.isEmpty() )
         {
@@ -509,8 +501,7 @@
         // Prepare values for unsaved CalculatedDataElements
         // ---------------------------------------------------------------------
 
-        calculatedValueMap = dataEntryScreenManager.populateValuesForCalculatedDataElements( organisationUnit, dataSet,
-            period );
+        calculatedValueMap = dataEntryScreenManager.populateValuesForCalculatedDataElements( organisationUnit, dataSet, period );
 
         // ---------------------------------------------------------------------
         // Make the standard comments available

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/DefaultStandardCommentsManager.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/DefaultStandardCommentsManager.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/DefaultStandardCommentsManager.java	2010-06-03 10:32:02 +0000
@@ -34,6 +34,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import com.thoughtworks.xstream.XStream;
 
 /**
@@ -43,6 +46,8 @@
 public class DefaultStandardCommentsManager
     implements StandardCommentsManager
 {
+    private static final Log log = LogFactory.getLog( DefaultStandardCommentsManager.class );
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -54,38 +59,38 @@
         this.standardCommentsFile = standardCommentsFile;
     }
 
-    // -------------------------------------------------------------------------
-    // StandardCommentsManager implementation
-    // -------------------------------------------------------------------------
-
     private List<String> standardComments;
 
     @SuppressWarnings("unchecked")
-    public List<String> getStandardComments() throws StandardCommentsManagerException
+    public void init()
     {
-        if ( standardComments == null )
-        {
-            Reader reader = null;
-            try 
-            {
-                reader = new BufferedReader( new InputStreamReader( getClass().getClassLoader().getResourceAsStream( standardCommentsFile ), "UTF-8" ) );
-            }
-            catch ( UnsupportedEncodingException e )
-            {
-                throw new StandardCommentsManagerException( "Unsupported encoding", e );
-            }
-            
-            if ( reader != null )
-            {
-                XStream xStream = new XStream();
-                standardComments = (List<String>) xStream.fromXML( reader );
-            }
-            else
-            {
-                standardComments = new ArrayList<String>();
-            }
-        }
+        Reader reader = null;
+        try 
+        {
+            reader = new BufferedReader( new InputStreamReader( getClass().getClassLoader().getResourceAsStream( standardCommentsFile ), "UTF-8" ) );
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            log.warn( "Unsupported encoding", e );
+        }
+        
+        if ( reader != null )
+        {
+            XStream xStream = new XStream();
+            standardComments = (List<String>) xStream.fromXML( reader );
+        }
+        else
+        {
+            standardComments = new ArrayList<String>();
+        }
+    }
+    
+    // -------------------------------------------------------------------------
+    // StandardCommentsManager implementation
+    // -------------------------------------------------------------------------
 
+    public List<String> getStandardComments()
+    {
         return standardComments;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/StandardCommentsManager.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/StandardCommentsManager.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/StandardCommentsManager.java	2010-06-03 10:32:02 +0000
@@ -37,5 +37,5 @@
 {
     String ID = StandardCommentsManager.class.getName();
 
-    List<String> getStandardComments() throws StandardCommentsManagerException;
+    List<String> getStandardComments();
 }

=== removed file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/StandardCommentsManagerException.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/StandardCommentsManagerException.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/comments/StandardCommentsManagerException.java	1970-01-01 00:00:00 +0000
@@ -1,46 +0,0 @@
-package org.hisp.dhis.de.comments;
-
-/*
- * Copyright (c) 2004-2010, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @author Torgeir Lorange Ostby
- * @version $Id: StandardCommentsManagerException.java 2869 2007-02-20 14:26:09Z andegje $
- */
-public class StandardCommentsManagerException
-    extends Exception
-{
-    public StandardCommentsManagerException( String message )
-    {
-        super( message );
-    }
-
-    public StandardCommentsManagerException( String message, Throwable throwable )
-    {
-        super( message, throwable );
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java	2010-06-03 10:32:02 +0000
@@ -616,9 +616,7 @@
                 int dataElementId = Integer.parseInt( identifierMatcher.group( 1 ) );
                 int optionComboId = Integer.parseInt( identifierMatcher.group( 2 ) );
 
-                DataElement dataElement = dataElementMap.get( dataElementId ); // dataElementService.getDataElement(
-                                                                               // dataElementId
-                                                                               // );
+                DataElement dataElement = dataElementMap.get( dataElementId ); 
 
                 if ( dataElement == null )
                 {

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2010-05-28 09:12:03 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2010-06-03 10:32:02 +0000
@@ -7,7 +7,7 @@
 	<bean id="org.hisp.dhis.de.action.EmptyAction" class="org.hisp.dhis.de.action.EmptyAction" />
 
 	<bean id="org.hisp.dhis.de.comments.StandardCommentsManager"
-		class="org.hisp.dhis.de.comments.DefaultStandardCommentsManager">
+		class="org.hisp.dhis.de.comments.DefaultStandardCommentsManager" init-method="init">
 		<property name="standardCommentsFile">
 			<value>standard_comments.xml</value>
 		</property>
@@ -75,7 +75,6 @@
 		<property name="dataSetLockService" ref="org.hisp.dhis.datalock.DataSetLockService" />
 		<property name="dataElementOrderManager"
 			ref="org.hisp.dhis.order.manager.DataElementOrderManager" />
-		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
 		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
 		<property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
 		<property name="standardCommentsManager"
@@ -95,8 +94,7 @@
 		class="org.hisp.dhis.de.action.multidimensional.FormAction" scope="prototype">
 		<property name="dataSetLockService" ref="org.hisp.dhis.datalock.DataSetLockService" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
-		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />    
-		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />    
+		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
 		<property name="dataEntryScreenManager"
 			ref="org.hisp.dhis.de.screen.DataEntryScreenManager" />
 		<property name="standardCommentsManager"