dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13173
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4169: Fix bug: Error when upgrading data entry forms.
------------------------------------------------------------
revno: 4169
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-07-20 10:42:08 +0700
message:
Fix bug: Error when upgrading data entry forms.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormStore.java
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/DefaultDataEntryFormService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/hibernate/HibernateDataEntryFormStore.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/dataentryform/DataEntryFormService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java 2011-07-18 07:54:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java 2011-07-20 03:42:08 +0000
@@ -140,6 +140,4 @@
Collection<DataEntryForm> listDisctinctDataEntryFormByProgramStageIds( List<Integer> programStageIds );
Collection<DataEntryForm> listDisctinctDataEntryFormByDataSetIds( List<Integer> dataSetIds );
-
- Collection<DataEntryForm> getProgramDataEntryForms();
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormStore.java 2011-07-18 07:54:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormStore.java 2011-07-20 03:42:08 +0000
@@ -86,6 +86,4 @@
Collection<DataEntryForm> listDisctinctDataEntryFormByProgramStageIds( List<Integer> programStageIds );
Collection<DataEntryForm> listDisctinctDataEntryFormByDataSetIds( List<Integer> dataSetIds );
-
- Collection<DataEntryForm> get();
}
=== 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 2011-07-18 07:54:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormUpgrader.java 2011-07-20 03:42:08 +0000
@@ -43,7 +43,7 @@
{
this.dataEntryFormService = dataEntryFormService;
}
-
+
// -------------------------------------------------------------------------
// Implementation method
// -------------------------------------------------------------------------
@@ -54,61 +54,18 @@
{
Collection<DataEntryForm> dataEntryForms = dataEntryFormService.getAllDataEntryForms();
- Collection<DataEntryForm> programDataEntryForms = dataEntryFormService.getProgramDataEntryForms();
-
- dataEntryForms.removeAll( programDataEntryForms );
-
- upgradeDataEntryForm( dataEntryForms );
-
- upgradeProgramDataEntryForm( programDataEntryForms );
- }
-
- // -------------------------------------------------------------------------
- // Supportive methods
- // -------------------------------------------------------------------------
-
- private void upgradeDataEntryForm( Collection<DataEntryForm> dataEntryForms )
- {
- int i = 0;
-
- for ( DataEntryForm form : dataEntryFormService.getAllDataEntryForms() )
- {
- Matcher matcher = ID_PATTERN.matcher( form.getHtmlCode() );
-
- StringBuffer out = new StringBuffer();
-
- while ( matcher.find() )
- {
- String upgradedId = "id=\"" + matcher.group( 1 ) + "-" + matcher.group( 2 ) + "-val\"";
-
- matcher.appendReplacement( out, upgradedId );
-
- i++;
- }
-
- matcher.appendTail( out );
-
- form.setHtmlCode( out.toString() );
- form.setHtmlCode( form.getHtmlCode().replaceAll( "view=\"@@deshortname@@\"", "" ) );
-
- dataEntryFormService.updateDataEntryForm( form );
- }
-
- log.info( "Upgraded custom data entry form identifiers: " + i );
- }
-
- private void upgradeProgramDataEntryForm( Collection<DataEntryForm> programDataEntryForms )
- {
- int i = 0;
-
- for ( DataEntryForm programDataEntryForm : programDataEntryForms )
- {
- String customForm = upgradeProgramDataEntryFormForTextBox( programDataEntryForm.getHtmlCode() );
+ int i = 0;
+
+ for ( DataEntryForm programDataEntryForm : dataEntryForms )
+ {
+ String customForm = upgradeDataEntryForm( programDataEntryForm.getHtmlCode() );
+
+ customForm = upgradeProgramDataEntryFormForTextBox( customForm );
customForm = upgradeProgramDataEntryFormForDate( customForm );
customForm = upgradeProgramDataEntryFormForOption( customForm );
-
+
programDataEntryForm.setHtmlCode( customForm );
dataEntryFormService.updateDataEntryForm( programDataEntryForm );
@@ -119,6 +76,28 @@
log.info( "Upgraded custom case entry form identifiers: " + i );
}
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ private String upgradeDataEntryForm( String htmlCode )
+ {
+ Matcher matcher = ID_PATTERN.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 upgradeProgramDataEntryFormForTextBox( String htmlCode )
{
int i = 0;
@@ -146,7 +125,7 @@
{
StringBuffer out = new StringBuffer();
Matcher inputMatcher = SELECT_PATTERN.matcher( htmlCode );
-
+
while ( inputMatcher.find() )
{
String inputHtml = inputMatcher.group();
@@ -156,7 +135,7 @@
if ( matcher.find() )
{
String upgradedId = matcher.group( 1 ) + "-" + matcher.group( 3 ) + "-val";
-
+
inputHtml = "<input name=\"entryselect\" id=\"" + upgradedId + "\" >";
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-07-18 07:54:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-07-20 03:42:08 +0000
@@ -127,12 +127,6 @@
{
return dataEntryFormStore.getAllDataEntryForms();
}
-
- @Override
- public Collection<DataEntryForm> getProgramDataEntryForms()
- {
- return dataEntryFormStore.get();
- }
public String prepareDataEntryFormForSave( String htmlCode )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/hibernate/HibernateDataEntryFormStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/hibernate/HibernateDataEntryFormStore.java 2011-07-18 07:54:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/hibernate/HibernateDataEntryFormStore.java 2011-07-20 03:42:08 +0000
@@ -143,14 +143,4 @@
return criteria.list();
}
-
- @SuppressWarnings("unchecked")
- @Override
- public Collection<DataEntryForm> get()
- {
- String hql = "select DISTINCT( p.dataEntryForm ) from ProgramStage p";
-
- return sessionFactory.getCurrentSession().createQuery( hql ).list();
- }
-
}