dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02315
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 778: Minor performance improvement in data entry screen population.
------------------------------------------------------------
revno: 778
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Sun 2009-09-27 21:55:48 +0200
message:
Minor performance improvement in data entry screen population.
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-05-04 12:51:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java 2009-09-27 19:55:48 +0000
@@ -326,35 +326,36 @@
// Pattern to match data elements in the HTML code.
// ---------------------------------------------------------------------
- Pattern patDataElement = Pattern.compile( "(<input.*?)[/]?>", Pattern.DOTALL );
- Matcher matDataElement = patDataElement.matcher( dataEntryFormCode );
-
+ Pattern dataElementPattern = Pattern.compile( "(<input.*?)[/]?>", Pattern.DOTALL );
+ Matcher dataElementMatcher = dataElementPattern.matcher( dataEntryFormCode );
+
+ // ---------------------------------------------------------------------
+ // Pattern to extract data element ID from data element field
+ // ---------------------------------------------------------------------
+
+ Pattern identifierPattern = Pattern.compile( "value\\[(.*)\\].value:value\\[(.*)\\].value" );
+
// ---------------------------------------------------------------------
// Iterate through all matching data element fields.
// ---------------------------------------------------------------------
- boolean result = matDataElement.find();
-
- while ( result )
+ while ( dataElementMatcher.find() )
{
// Get input HTML code (HTML input field code).
- String dataElementCode = matDataElement.group( 1 );
-
- // Pattern to extract data element ID from data element field
- Pattern patDataElementId = Pattern.compile( "value\\[(.*)\\].value:value\\[(.*)\\].value" );
-
- Matcher matDataElementId = patDataElementId.matcher( dataElementCode );
-
- if ( matDataElementId.find() && matDataElementId.groupCount() > 0 )
+ String dataElementCode = dataElementMatcher.group( 1 );
+
+ Matcher identifierMatcher = identifierPattern.matcher( dataElementCode );
+
+ if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
{
// -------------------------------------------------------------
// Get data element ID of data element.
// -------------------------------------------------------------
- int dataElementId = Integer.parseInt( matDataElementId.group( 1 ) );
+ int dataElementId = Integer.parseInt( identifierMatcher.group( 1 ) );
DataElement dataElement = dataElementService.getDataElement( dataElementId );
- int optionComboId = Integer.parseInt( matDataElementId.group( 2 ) );
+ int optionComboId = Integer.parseInt( identifierMatcher.group( 2 ) );
// -------------------------------------------------------------
// Find type of data element
@@ -405,10 +406,10 @@
// -------------------------------------------------------------
int count = 0;
+
for ( CustomValue customValue : customValues )
{
- if ( dataElementId == customValue.getDataElement().getId()
- && optionComboId == customValue.getOptionCombo().getId() )
+ if ( dataElementId == customValue.getDataElement().getId() && optionComboId == customValue.getOptionCombo().getId() )
{
count += 1;
}
@@ -571,15 +572,12 @@
appendCode = appendCode.replace( "$MAX", String.valueOf( minMaxDataElement.getMax() ) );
}
- matDataElement.appendReplacement( sb, appendCode );
+ dataElementMatcher.appendReplacement( sb, appendCode );
}
-
- // Go to next data entry field
- result = matDataElement.find();
}
// Add remaining code (after the last match), and return formatted code.
- matDataElement.appendTail( sb );
+ dataElementMatcher.appendTail( sb );
return sb.toString();
@@ -619,34 +617,35 @@
// Pattern to match data elements in the HTML code.
// ---------------------------------------------------------------------
- Pattern patDataElement = Pattern.compile( "(<input.*?)[/]?>", Pattern.DOTALL );
- Matcher matDataElement = patDataElement.matcher( dataEntryFormCode );
+ Pattern dataElementPattern = Pattern.compile( "(<input.*?)[/]?>", Pattern.DOTALL );
+ Matcher dataElementMatcher = dataElementPattern.matcher( dataEntryFormCode );
+
+ // ---------------------------------------------------------------------
+ // Pattern to extract data element ID from data element field
+ // ---------------------------------------------------------------------
+
+ Pattern identifierPattern = Pattern.compile( "value\\[(.*)\\].value:value\\[(.*)\\].value" );
// ---------------------------------------------------------------------
// Iterate through all matching data element fields.
// ---------------------------------------------------------------------
- boolean result = matDataElement.find();
-
- while ( result )
+ while ( dataElementMatcher.find() )
{
// Get input HTML code (HTML input field code).
- String dataElementCode = matDataElement.group( 1 );
-
- // Pattern to extract data element ID from data element field
- Pattern patDataElementId = Pattern.compile( "value\\[(.*)\\].value:value\\[(.*)\\].value" );
-
- Matcher matDataElementId = patDataElementId.matcher( dataElementCode );
-
- if ( matDataElementId.find() && matDataElementId.groupCount() > 0 )
+ String dataElementCode = dataElementMatcher.group( 1 );
+
+ Matcher identifierMatcher = identifierPattern.matcher( dataElementCode );
+
+ if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
{
// -------------------------------------------------------------
// Get data element ID of data element.
// -------------------------------------------------------------
- int dataElementId = Integer.parseInt( matDataElementId.group( 1 ) );
+ int dataElementId = Integer.parseInt( identifierMatcher.group( 1 ) );
DataElement dataElement = dataElementService.getDataElement( dataElementId );
- int optionComboId = Integer.parseInt( matDataElementId.group( 2 ) );
+ int optionComboId = Integer.parseInt( identifierMatcher.group( 2 ) );
// -------------------------------------------------------------
// Find type of data element
@@ -699,10 +698,10 @@
// -------------------------------------------------------------
int count = 0;
+
for ( CustomValue customValue : customValues )
{
- if ( dataElementId == customValue.getDataElement().getId()
- && optionComboId == customValue.getOptionCombo().getId() )
+ if ( dataElementId == customValue.getDataElement().getId() && optionComboId == customValue.getOptionCombo().getId() )
{
count += 1;
}
@@ -863,15 +862,12 @@
appendCode = appendCode.replace( "$MAX", String.valueOf( minMaxDataElement.getMax() ) );
}
- matDataElement.appendReplacement( sb, appendCode );
+ dataElementMatcher.appendReplacement( sb, appendCode );
}
-
- // Go to next data entry field
- result = matDataElement.find();
}
// Add remaining code (after the last match), and return formatted code.
- matDataElement.appendTail( sb );
+ dataElementMatcher.appendTail( sb );
return sb.toString();
}