dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26822
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13275: Removing some data entry upgrade routines for program stage custom forms, done their job
------------------------------------------------------------
revno: 13275
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-12-17 12:49:26 +0100
message:
Removing some data entry upgrade routines for program stage custom forms, done their job
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormUpgrader.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/dataentryform/DataEntryFormUpgrader.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormUpgrader.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormUpgrader.java 2013-12-17 11:49:26 +0000
@@ -50,19 +50,6 @@
private final static Pattern ID_PATTERN = Pattern.compile( ID_EXPRESSION );
- private final Pattern SELECT_PATTERN = Pattern.compile( "(<select.*?)[/]?</select>", Pattern.DOTALL );
-
- private final Pattern ID_PROGRAM_ENTRY_TEXTBOX = Pattern
- .compile( "id=\"value\\[(\\d+)\\].value:value\\[(\\d+)\\].value:value\\[(\\d+)\\].value\"" );
-
- private final Pattern ID_PROGRAM_ENTRY_OPTION = Pattern
- .compile( "id=\"value\\[(\\d+)\\].(combo|boolean){1}:value\\[(\\d+)\\].(combo|boolean){1}\"" );
-
- private final Pattern ID_PROGRAM_ENTRY_DATE = Pattern
- .compile( "id=\"value\\[(\\d+)\\].date:value\\[(\\d+)\\].date\"" );
-
- private final Pattern IDENTIFIER_PATTERN_TEXTBOX = Pattern.compile( "id=\"(\\d+)-(\\d+)-(\\d+)-val\"" );
-
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -84,28 +71,26 @@
{
Collection<DataEntryForm> dataEntryForms = dataEntryFormService.getAllDataEntryForms();
- int i = 0;
-
- for ( DataEntryForm programDataEntryForm : dataEntryForms )
+ for ( DataEntryForm form : dataEntryForms )
{
- String customForm = upgradeDataEntryForm( programDataEntryForm.getHtmlCode() );
-
- customForm = upgradeProgramDataEntryFormForTextBox( customForm );
-
- customForm = upgradeProgramDataEntryFormForDate( customForm );
-
- customForm = upgradeProgramDataEntryFormForOption( customForm );
-
- customForm = upgradeProgramDataEntryForm( customForm );
-
- programDataEntryForm.setHtmlCode( customForm );
-
- dataEntryFormService.updateDataEntryForm( programDataEntryForm );
-
- i++;
+ try
+ {
+ String customForm = upgradeDataEntryForm( form.getHtmlCode() );
+
+ if ( customForm != null && !customForm.equals( form.getHtmlCode() ) )
+ {
+ form.setHtmlCode( customForm );
+ dataEntryFormService.updateDataEntryForm( form );
+ }
+ }
+ catch ( Exception ex )
+ {
+ log.error( "Upgrading data entry form failed: " + form.getName() );
+ log.error( ex ); // Log and continue
+ }
}
-
- log.info( "Upgraded custom case entry form identifiers: " + i );
+
+ log.info( "Upgraded custom case entry form identifiers" );
}
// -------------------------------------------------------------------------
@@ -129,85 +114,4 @@
return out.toString().replaceAll( "view=\"@@deshortname@@\"", "" );
}
-
- private String upgradeProgramDataEntryFormForTextBox( String htmlCode )
- {
- Matcher matcher = ID_PROGRAM_ENTRY_TEXTBOX.matcher( htmlCode );
-
- StringBuffer out = new StringBuffer();
-
- while ( matcher.find() )
- {
- String upgradedId = "id=\"" + matcher.group( 1 ) + "-" + matcher.group( 2 ) + "-" + matcher.group( 3 )
- + "-val\"";
-
- matcher.appendReplacement( out, upgradedId );
- }
-
- matcher.appendTail( out );
-
- return out.toString().replaceAll( "view=\"@@deshortname@@\"", "" );
- }
-
- private String upgradeProgramDataEntryFormForOption( String htmlCode )
- {
- StringBuffer out = new StringBuffer();
- Matcher inputMatcher = SELECT_PATTERN.matcher( htmlCode );
-
- while ( inputMatcher.find() )
- {
- String inputHtml = inputMatcher.group();
-
- Matcher matcher = ID_PROGRAM_ENTRY_OPTION.matcher( inputHtml );
-
- if ( matcher.find() )
- {
- String upgradedId = matcher.group( 1 ) + "-" + matcher.group( 3 ) + "-val";
-
- inputHtml = "<input name=\"entryselect\" id=\"" + upgradedId + "\" >";
- }
-
- inputMatcher.appendReplacement( out, inputHtml );
- }
-
- inputMatcher.appendTail( out );
-
- return out.toString().replaceAll( "view=\"@@deshortname@@\"", "" );
- }
-
- private String upgradeProgramDataEntryFormForDate( String htmlCode )
- {
- Matcher matcher = ID_PROGRAM_ENTRY_DATE.matcher( htmlCode );
-
- StringBuffer out = new StringBuffer();
-
- while ( matcher.find() )
- {
- String upgradedId = "id=\"" + matcher.group( 1 ) + "-" + matcher.group( 2 ) + "-val\" ";
-
- matcher.appendReplacement( out, upgradedId );
- }
-
- matcher.appendTail( out );
-
- return out.toString().replaceAll( "view=\"@@deshortname@@\"", "" );
- }
-
- private String upgradeProgramDataEntryForm( String htmlCode )
- {
- Matcher matcher = IDENTIFIER_PATTERN_TEXTBOX.matcher( htmlCode );
-
- StringBuffer out = new StringBuffer();
-
- while ( matcher.find() )
- {
- String upgradedId = "id=\"" + matcher.group( 1 ) + "-" + matcher.group( 2 ) + "-val\"";
-
- matcher.appendReplacement( out, upgradedId );
- }
-
- matcher.appendTail( out );
-
- return out.toString();
- }
}
\ No newline at end of file