dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02320
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 783: Significant performance improvement in data entry screen loading.
------------------------------------------------------------
revno: 783
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Mon 2009-09-28 01:00:48 +0200
message:
Significant performance improvement in data entry screen loading.
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.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-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 2009-09-27 22:48:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java 2009-09-27 23:00:48 +0000
@@ -58,6 +58,7 @@
import org.hisp.dhis.minmax.MinMaxDataElement;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.system.util.TimeUtils;
/**
* @author Abyot Asalefew
@@ -337,6 +338,8 @@
// Iterate through all matching data element fields
// ---------------------------------------------------------------------
+ Map<Integer, DataElement> dataElementMap = getDataElementMap( dataSet );
+
while ( dataElementMatcher.find() )
{
// -----------------------------------------------------------------
@@ -354,10 +357,10 @@
// -------------------------------------------------------------
int dataElementId = Integer.parseInt( identifierMatcher.group( 1 ) );
- DataElement dataElement = dataElementService.getDataElement( dataElementId );
-
int optionComboId = Integer.parseInt( identifierMatcher.group( 2 ) );
+ DataElement dataElement = dataElementMap.get( dataElementId ); //dataElementService.getDataElement( dataElementId );
+
// -------------------------------------------------------------
// Find type of data element
// -------------------------------------------------------------
@@ -608,6 +611,8 @@
// Iterate through all matching data element fields
// ---------------------------------------------------------------------
+ Map<Integer, DataElement> dataElementMap = getDataElementMap( dataSet );
+ TimeUtils.start();
while ( dataElementMatcher.find() )
{
// -----------------------------------------------------------------
@@ -625,9 +630,10 @@
// -------------------------------------------------------------
int dataElementId = Integer.parseInt( identifierMatcher.group( 1 ) );
- DataElement dataElement = dataElementService.getDataElement( dataElementId );
int optionComboId = Integer.parseInt( identifierMatcher.group( 2 ) );
+ DataElement dataElement = dataElementMap.get( dataElementId ); //dataElementService.getDataElement( dataElementId );
+
// -------------------------------------------------------------
// Find type of data element
// -------------------------------------------------------------
@@ -822,7 +828,7 @@
dataElementMatcher.appendReplacement( sb, appendCode );
}
}
-
+TimeUtils.markHMS( "done" );
dataElementMatcher.appendTail( sb );
return sb.toString();
@@ -882,4 +888,20 @@
return EMPTY;
}
+
+ /**
+ * Returns a Map of all DataElements in the given DataSet where the key is
+ * the DataElement identifier and the value is the DataElement.
+ */
+ private Map<Integer, DataElement> getDataElementMap( DataSet dataSet )
+ {
+ Map<Integer, DataElement> map = new HashMap<Integer, DataElement>();
+
+ for ( DataElement element : dataSet.getDataElements() )
+ {
+ map.put( element.getId(), element );
+ }
+
+ return map;
+ }
}