dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20846
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9701: translation program-stage-section.
------------------------------------------------------------
revno: 9701
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-02-04 10:09:04 +0700
message:
translation program-stage-section.
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageSectionSortOrderComparator.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageSectionListAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSectionService.java
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/resources/META-INF/dhis/beans.xml
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/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
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/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/updateProgramStageSectionForm.vm
--
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/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<ProgramStageDataElement> programStageDataElements = new ArrayList<ProgramStageDataElement>();
- private int sortOrder;
+ private Integer sortOrder;
// -------------------------------------------------------------------------
// Constructors
@@ -62,7 +62,7 @@
this.programStageDataElements = programStageDataElements;
}
- public ProgramStageSection( String name, List<ProgramStageDataElement> programStageDataElements, int sortOrder )
+ public ProgramStageSection( String name, List<ProgramStageDataElement> 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<ProgramStageSection> getAllProgramStageSections();
+
+ Collection<ProgramStageSection> 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<ProgramStageSection>
+{
+ @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<ProgramStageSection> getAllProgramStageSections()
{
- return programStageSectionStore.getAll();
- }
-
+ return i18n( i18nService, programStageSectionStore.getAll() );
+ }
+
+ @Override
+ public Collection<ProgramStageSection> 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 @@
<bean id="org.hisp.dhis.program.ProgramStageSectionService" class="org.hisp.dhis.program.DefaultProgramStageSectionService">
<property name="programStageSectionStore"
ref="org.hisp.dhis.program.ProgramStageSectionStore" />
+ <property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
</bean>
<bean id="org.hisp.dhis.program.ProgramService" class="org.hisp.dhis.program.DefaultProgramService">
=== 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<ProgramStageSection> sections = new HashSet<ProgramStageSection>();
+ private List<ProgramStageSection> sections = new ArrayList<ProgramStageSection>();
private Map<String, Double> calAttributeValueMap = new HashMap<String, Double>();
@@ -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<ProgramStageSection> getSections()
+ public List<ProgramStageSection> getSections()
{
return sections;
}
@@ -295,7 +302,9 @@
}
else if ( programStage.getDataEntryType().equals( ProgramStage.TYPE_SECTION ) )
{
- sections = programStage.getProgramStageSections();
+ sections = new ArrayList<ProgramStageSection>( 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" />
<property name="patientAttributeValueService"
ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+ <property name="programStageSectionService"
+ ref="org.hisp.dhis.program.ProgramStageSectionService" />
</bean>
<bean
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageSectionListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageSectionListAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageSectionListAction.java 2013-02-04 03:09:04 +0000
@@ -0,0 +1,112 @@
+/*
+ * 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.patient.action.programstage;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageSection;
+import org.hisp.dhis.program.ProgramStageSectionService;
+import org.hisp.dhis.program.ProgramStageService;
+import org.hisp.dhis.program.comparator.ProgramStageSectionSortOrderComparator;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version ProgramStageSectionSortOrderComparator.java 9:50:09 AM Feb 4, 2013 $
+ */
+public class GetProgramStageSectionListAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramStageService programStageService;
+
+ public void setProgramStageService( ProgramStageService programStageService )
+ {
+ this.programStageService = programStageService;
+ }
+
+ private ProgramStageSectionService programStageSectionService;
+
+ public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService )
+ {
+ this.programStageSectionService = programStageSectionService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input/Output
+ // -------------------------------------------------------------------------
+
+ private int id;
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+ private ProgramStage programStage;
+
+ public ProgramStage getProgramStage()
+ {
+ return programStage;
+ }
+
+ private List<ProgramStageSection> sections = new ArrayList<ProgramStageSection>();
+
+ public List<ProgramStageSection> getSections()
+ {
+ return sections;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ programStage = programStageService.getProgramStage( id );
+
+ sections = new ArrayList<ProgramStageSection>( 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 @@
<property name="programStageSectionService"
ref="org.hisp.dhis.program.ProgramStageSectionService" />
</bean>
+
+ <bean
+ id="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionListAction"
+ class="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionListAction"
+ scope="prototype">
+ <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+ <property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService" />
+ </bean>
<!-- Data Entry Form -->
=== 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 @@
<!-- Program stage section -->
<action name="programStageSectionList"
- class="org.hisp.dhis.patient.action.programstage.GetProgramStageAction">
+ class="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionListAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">
/dhis-web-maintenance-patient/programStageSection.vm</param>
=== 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 @@
<tbody id="list">
#set( $mark = false )
- #foreach( $section in $programStage.programStageSections )
+ #foreach( $section in $sections )
<tr id="tr${section.id}" #alternate( $mark )>
<td onclick="showSectionDetails( $section.id )">$encoder.htmlEncode( $section.displayName )</td>
<td style="text-align:center"#alternate( $mark )>
<a href="showUpdateProgramStageSectionForm.action?programStageId=$programStage.id&id=$section.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
+ <a href="javascript:translate( 'ProgramStageSection', '$section.id' )" title="$i18n.getString( 'translation_translate' )"><img src="../images/i18n.png" alt="$i18n.getString( 'translation_translate' )"/></a>
<a href="javascript:removeSection( '$section.id', '$section.displayName' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
<a href="javascript:showSectionDetails( $section.id )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
</td>
=== 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 @@
<tbody>
<tr>
<td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="name" name="name" class="{validate:{required:true,rangelength:[2,160]}}" value='$section.displayName'/></td>
+ <td><input type="text" id="name" name="name" class="{validate:{required:true,rangelength:[2,160]}}" value='$section.name'/></td>
</tr>
</tbody>
</table>