=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroup.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroup.java 2011-05-05 21:14:56 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroup.java 2011-07-05 05:23:57 +0000 @@ -48,6 +48,8 @@ private String description; + private Integer sortOrder; + private List attributes = new ArrayList(); // ------------------------------------------------------------------------- @@ -141,5 +143,13 @@ this.attributes = attributes; } + public Integer getSortOrder() + { + return sortOrder; + } + public void setSortOrder( Integer sortOrder ) + { + this.sortOrder = sortOrder; + } } === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comparator/PatientAttributeGroupSortOrderComparator.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comparator/PatientAttributeGroupSortOrderComparator.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comparator/PatientAttributeGroupSortOrderComparator.java 2011-07-05 05:23:57 +0000 @@ -0,0 +1,55 @@ +package org.hisp.dhis.patient.comparator; + +/* + * Copyright (c) 2004-2010, 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. + */ + +import java.util.Comparator; + +import org.hisp.dhis.patient.PatientAttributeGroup; + +/** + * @author Chau Thu Tran + * @version $Id$ + */ +public class PatientAttributeGroupSortOrderComparator + implements Comparator +{ + public int compare( PatientAttributeGroup patientAttributeGroup0, PatientAttributeGroup patientAttributeGroup1 ) + { + if ( patientAttributeGroup0.getSortOrder() == null || patientAttributeGroup0.getSortOrder() == 0 ) + { + return patientAttributeGroup0.getName().compareTo( patientAttributeGroup1.getName() ); + } + + if ( patientAttributeGroup1.getSortOrder() == null || patientAttributeGroup1.getSortOrder() == 0 ) + { + return patientAttributeGroup0.getName().compareTo( patientAttributeGroup1.getName() ); + } + + return patientAttributeGroup0.getSortOrder() - patientAttributeGroup1.getSortOrder(); + } +} === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAttributeGroup.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAttributeGroup.hbm.xml 2011-05-28 21:25:46 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAttributeGroup.hbm.xml 2011-07-05 05:23:57 +0000 @@ -13,7 +13,9 @@ - + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientAction.java 2011-05-26 03:19:50 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientAction.java 2011-07-05 05:23:57 +0000 @@ -26,8 +26,11 @@ */ package org.hisp.dhis.patient.action.patient; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.hisp.dhis.patient.Patient; @@ -40,6 +43,7 @@ import org.hisp.dhis.patient.PatientIdentifierType; import org.hisp.dhis.patient.PatientIdentifierTypeService; import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator; import org.hisp.dhis.patientattributevalue.PatientAttributeValue; import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; import org.hisp.dhis.program.Program; @@ -88,7 +92,7 @@ private Collection noGroupAttributes; - private Collection attributeGroups; + private List attributeGroups; private Collection identifierTypes; @@ -174,7 +178,9 @@ noGroupAttributes = patientAttributeService.getPatientAttributesNotGroup(); - attributeGroups = patientAttributeGroupService.getAllPatientAttributeGroups(); + attributeGroups = new ArrayList( patientAttributeGroupService + .getAllPatientAttributeGroups() ); + Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() ); return SUCCESS; @@ -254,7 +260,7 @@ return noGroupAttributes; } - public Collection getAttributeGroups() + public List getAttributeGroups() { return attributeGroups; } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ShowAddPatientFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ShowAddPatientFormAction.java 2011-05-25 02:34:58 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ShowAddPatientFormAction.java 2011-07-05 05:23:57 +0000 @@ -28,8 +28,11 @@ package org.hisp.dhis.patient.action.patient; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Date; +import java.util.List; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; @@ -39,6 +42,7 @@ import org.hisp.dhis.patient.PatientAttributeService; import org.hisp.dhis.patient.PatientIdentifierType; import org.hisp.dhis.patient.PatientIdentifierTypeService; +import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator; import com.opensymphony.xwork2.Action; @@ -87,14 +91,14 @@ private Collection noGroupAttributes; - private Collection attributeGroups; + private List attributeGroups; private Collection identifierTypes; private OrganisationUnit organisationUnit; private String year; - + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -105,15 +109,16 @@ noGroupAttributes = patientAttributeService.getPatientAttributesNotGroup(); - attributeGroups = patientAttributeGroupService.getAllPatientAttributeGroups(); + attributeGroups = new ArrayList( patientAttributeGroupService + .getAllPatientAttributeGroups() ); + Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() ); organisationUnit = selectionManager.getSelectedOrganisationUnit(); - SimpleDateFormat dataFormat = new SimpleDateFormat( "y" ); - + year = dataFormat.format( new Date() ); - + return SUCCESS; } @@ -126,7 +131,7 @@ return identifierTypes; } - public Collection getAttributeGroups() + public List getAttributeGroups() { return attributeGroups; } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattributegroup/GetPatientAttributeGroupListAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattributegroup/GetPatientAttributeGroupListAction.java 2011-03-20 17:57:30 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattributegroup/GetPatientAttributeGroupListAction.java 2011-07-05 05:23:57 +0000 @@ -33,7 +33,7 @@ import org.hisp.dhis.patient.PatientAttributeGroup; import org.hisp.dhis.patient.PatientAttributeGroupService; -import org.hisp.dhis.patient.comparator.PatientAttributeGroupComparator; +import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator; import com.opensymphony.xwork2.Action; @@ -81,7 +81,7 @@ patientAttributeGroups = new ArrayList( patientAttributeGroupService .getAllPatientAttributeGroups() ); - Collections.sort( patientAttributeGroups, new PatientAttributeGroupComparator() ); + Collections.sort( patientAttributeGroups, new PatientAttributeGroupSortOrderComparator() ); return SUCCESS; } === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattributegroup/SavePatientAttributeGroupSortOrderAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattributegroup/SavePatientAttributeGroupSortOrderAction.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/patientattributegroup/SavePatientAttributeGroupSortOrderAction.java 2011-07-05 05:23:57 +0000 @@ -0,0 +1,94 @@ +/* + * 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.patientattributegroup; + +import java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.patient.PatientAttributeGroup; +import org.hisp.dhis.patient.PatientAttributeGroupService; +import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.program.ProgramStage; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ SavePatientAttributeGroupSortOrderAction.java Jul 5, 2011 11:07:38 AM $ + * + */ +public class SavePatientAttributeGroupSortOrderAction +implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private PatientAttributeGroupService patientAttributeGroupService; + + public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService ) + { + this.patientAttributeGroupService = patientAttributeGroupService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private List patientAttributeGroupIds = new ArrayList(); + + public void setPatientAttributeGroupIds( List patientAttributeGroupIds ) + { + this.patientAttributeGroupIds = patientAttributeGroupIds; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + int sortOrder = 1; + + List groups = new ArrayList( patientAttributeGroupIds.size() ); + + for ( Integer patientAttributeGroupId : patientAttributeGroupIds ) + { + PatientAttributeGroup patientAttributeGroup = patientAttributeGroupService.getPatientAttributeGroup( patientAttributeGroupId ); + + groups.add( patientAttributeGroup ); + + patientAttributeGroup.setSortOrder( sortOrder++ ); + + patientAttributeGroupService.updatePatientAttributeGroup( patientAttributeGroup ); + } + + 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 2011-06-22 02:51:13 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-07-05 05:23:57 +0000 @@ -918,6 +918,14 @@ + + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-06-01 09:12:50 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-07-05 05:23:57 +0000 @@ -466,4 +466,5 @@ add_new_multi_validation = Add New Multi Validation save_success = Save successfully configuration_xml_file_null = Configuration of folder where contains xml file is null -there_is_no_defination_xml_file_in_user_home = There is no any definition related XML file in the user home \ No newline at end of file +there_is_no_defination_xml_file_in_user_home = There is no any definition related XML file in the user home +patient_attribute_group_sort_order = Beneficiary Attribute Group Sort Order \ No newline at end of file === 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 2011-06-28 04:00:08 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2011-07-05 05:23:57 +0000 @@ -875,6 +875,22 @@ /dhis-web-commons/ajax/jsonResponseInput.vm plainTextError + + + /main.vm + /dhis-web-maintenance-patient/sortPatientAttributeGroupForm.vm + /dhis-web-maintenance-patient/patientAndProgramMenu.vm + javascript/patientAttributeGroup.js + style/basic.css + F_PATIENTATTRIBUTE_ADD + + + + patientAttributeGroup.action + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttributeGroup.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttributeGroup.vm 2011-05-19 08:14:24 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttributeGroup.vm 2011-07-05 05:23:57 +0000 @@ -12,7 +12,10 @@ - + +
+ + $i18n.getString( "attribute_name" ) === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/sortPatientAttributeGroupForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/sortPatientAttributeGroupForm.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/sortPatientAttributeGroupForm.vm 2011-07-05 05:23:57 +0000 @@ -0,0 +1,27 @@ +

$i18n.getString( "beneficiary_attribute_group_sort_order" )

+ +
+ + + + + + + +
+ + +

+ +
+ +

+ + +

+ +