=== 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 listDisctinctDataEntryFormByProgramStageIds( List programStageIds ); Collection listDisctinctDataEntryFormByDataSetIds( List dataSetIds ); - - Collection 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 listDisctinctDataEntryFormByProgramStageIds( List programStageIds ); Collection listDisctinctDataEntryFormByDataSetIds( List dataSetIds ); - - Collection 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 dataEntryForms = dataEntryFormService.getAllDataEntryForms(); - Collection programDataEntryForms = dataEntryFormService.getProgramDataEntryForms(); - - dataEntryForms.removeAll( programDataEntryForms ); - - upgradeDataEntryForm( dataEntryForms ); - - upgradeProgramDataEntryForm( programDataEntryForms ); - } - - // ------------------------------------------------------------------------- - // Supportive methods - // ------------------------------------------------------------------------- - - private void upgradeDataEntryForm( Collection 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 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 = ""; } === 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 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 get() - { - String hql = "select DISTINCT( p.dataEntryForm ) from ProgramStage p"; - - return sessionFactory.getCurrentSession().createQuery( hql ).list(); - } - }