=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java 2013-01-07 05:07:05 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java 2013-02-04 03:09:04 +0000 @@ -45,7 +45,7 @@ private List programStageDataElements = new ArrayList(); - private int sortOrder; + private Integer sortOrder; // ------------------------------------------------------------------------- // Constructors @@ -62,7 +62,7 @@ this.programStageDataElements = programStageDataElements; } - public ProgramStageSection( String name, List programStageDataElements, int sortOrder ) + public ProgramStageSection( String name, List programStageDataElements, Integer sortOrder ) { this.name = name; this.programStageDataElements = programStageDataElements; @@ -112,12 +112,12 @@ // Constructors // ------------------------------------------------------------------------- - public void setSortOrder( int sortOrder ) + public void setSortOrder( Integer sortOrder ) { this.sortOrder = sortOrder; } - public int getSortOrder() + public Integer getSortOrder() { return sortOrder; } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSectionService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSectionService.java 2012-08-24 10:09:45 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSectionService.java 2013-02-04 03:09:04 +0000 @@ -53,4 +53,7 @@ ProgramStageSection getProgramStageSectionByName( String name ); Collection getAllProgramStageSections(); + + Collection getProgramStages( ProgramStage programStage ); + } === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageSectionSortOrderComparator.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageSectionSortOrderComparator.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageSectionSortOrderComparator.java 2013-02-04 03:09:04 +0000 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.program.comparator; + +import java.util.Comparator; + +import org.hisp.dhis.program.ProgramStageSection; + +/** + * @author Chau Thu Tran + * + * @version ProgramStageSectionSortOrderComparator.java 9:32:23 AM Feb 4, 2013 $ + */ +public class ProgramStageSectionSortOrderComparator + implements Comparator +{ + @Override + public int compare( ProgramStageSection object0, ProgramStageSection object1 ) + { + if ( object0.getSortOrder() == null ) + { + return object1.getSortOrder() != null ? -1 : 0; + } + + return object0.getSortOrder().compareTo( object1.getSortOrder() ); + } +} === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageSectionService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageSectionService.java 2013-01-07 05:07:05 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageSectionService.java 2013-02-04 03:09:04 +0000 @@ -27,9 +27,12 @@ package org.hisp.dhis.program; +import static org.hisp.dhis.i18n.I18nUtils.i18n; + import java.util.Collection; import org.hisp.dhis.common.GenericIdentifiableObjectStore; +import org.hisp.dhis.i18n.I18nService; import org.springframework.transaction.annotation.Transactional; /** @@ -53,6 +56,13 @@ this.programStageSectionStore = programStageSectionStore; } + private I18nService i18nService; + + public void setI18nService( I18nService service ) + { + i18nService = service; + } + // ------------------------------------------------------------------------- // ProgramStageSection implementation // ------------------------------------------------------------------------- @@ -78,19 +88,25 @@ @Override public ProgramStageSection getProgramStageSection( int id ) { - return programStageSectionStore.get( id ); + return i18n( i18nService, programStageSectionStore.get( id ) ); } @Override public ProgramStageSection getProgramStageSectionByName( String name ) { - return programStageSectionStore.getByName( name ); + return i18n( i18nService, programStageSectionStore.getByName( name ) ); } @Override public Collection getAllProgramStageSections() { - return programStageSectionStore.getAll(); - } - + return i18n( i18nService, programStageSectionStore.getAll() ); + } + + @Override + public Collection getProgramStages( ProgramStage programStage ) + { + return i18n( i18nService, programStage.getProgramStageSections() ); + } + } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-02-01 08:40:49 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-02-04 03:09:04 +0000 @@ -220,6 +220,7 @@ + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2012-12-26 03:02:05 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2013-02-04 03:09:04 +0000 @@ -31,10 +31,8 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import org.hisp.dhis.caseentry.state.SelectedStateManager; import org.hisp.dhis.dataentryform.DataEntryForm; @@ -54,7 +52,9 @@ import org.hisp.dhis.program.ProgramStageInstance; import org.hisp.dhis.program.ProgramStageInstanceService; import org.hisp.dhis.program.ProgramStageSection; +import org.hisp.dhis.program.ProgramStageSectionService; import org.hisp.dhis.program.comparator.ProgramStageDataElementSortOrderComparator; +import org.hisp.dhis.program.comparator.ProgramStageSectionSortOrderComparator; import com.opensymphony.xwork2.Action; @@ -82,6 +82,8 @@ private PatientAttributeValueService patientAttributeValueService; + private ProgramStageSectionService programStageSectionService; + private I18nFormat format; // ------------------------------------------------------------------------- @@ -106,7 +108,7 @@ private ProgramStage programStage; - private Set sections = new HashSet(); + private List sections = new ArrayList(); private Map calAttributeValueMap = new HashMap(); @@ -119,6 +121,11 @@ this.programStageInstanceService = programStageInstanceService; } + public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService ) + { + this.programStageSectionService = programStageSectionService; + } + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) { this.patientAttributeService = patientAttributeService; @@ -139,7 +146,7 @@ this.programStageInstanceId = programStageInstanceId; } - public Set getSections() + public List getSections() { return sections; } @@ -295,7 +302,9 @@ } else if ( programStage.getDataEntryType().equals( ProgramStage.TYPE_SECTION ) ) { - sections = programStage.getProgramStageSections(); + sections = new ArrayList( programStageSectionService.getProgramStages( programStage )); + + Collections.sort( sections, new ProgramStageSectionSortOrderComparator() ); } } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-02-02 10:34:22 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-02-04 03:09:04 +0000 @@ -105,6 +105,8 @@ ref="org.hisp.dhis.patient.PatientAttributeService" /> + sections = new ArrayList(); + + public List getSections() + { + return sections; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + programStage = programStageService.getProgramStage( id ); + + sections = new ArrayList( programStageSectionService.getProgramStages( programStage ) ); + + Collections.sort( sections, new ProgramStageSectionSortOrderComparator() ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-02-01 08:40:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-02-04 03:09:04 +0000 @@ -371,6 +371,14 @@ + + + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2013-02-01 08:40:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2013-02-04 03:09:04 +0000 @@ -386,7 +386,7 @@ + class="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionListAction"> /main.vm /dhis-web-maintenance-patient/programStageSection.vm === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageSection.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageSection.vm 2013-02-03 10:13:17 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageSection.vm 2013-02-04 03:09:04 +0000 @@ -26,11 +26,12 @@ #set( $mark = false ) - #foreach( $section in $programStage.programStageSections ) + #foreach( $section in $sections ) $encoder.htmlEncode( $section.displayName ) $i18n.getString( 'edit' ) + $i18n.getString( 'translation_translate' ) $i18n.getString( 'remove' ) $i18n.getString( 'show_details' ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageSectionForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageSectionForm.vm 2013-02-03 10:13:17 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageSectionForm.vm 2013-02-04 03:09:04 +0000 @@ -30,7 +30,7 @@ - +