=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueService.java 2010-11-09 02:09:53 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueService.java 2011-07-21 09:03:49 +0000 @@ -30,6 +30,7 @@ import java.util.Collection; import org.hisp.dhis.program.ProgramAttribute; +import org.hisp.dhis.program.ProgramAttributeOption; import org.hisp.dhis.program.ProgramInstance; /** @@ -59,6 +60,10 @@ Collection getProgramAttributeValues( ProgramAttribute programAttribute ); - Collection searchProgramAttributeValues( ProgramAttribute programAttribute, String searchText ); + Collection searchProgramAttributeValues( ProgramAttribute programAttribute, String searchText ); + + + int countByProgramAttributeOption( ProgramAttributeOption attributeOption ); + } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueStore.java 2010-11-09 02:09:53 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/programattributevalue/ProgramAttributeValueStore.java 2011-07-21 09:03:49 +0000 @@ -31,6 +31,7 @@ import org.hisp.dhis.common.GenericStore; import org.hisp.dhis.program.ProgramAttribute; +import org.hisp.dhis.program.ProgramAttributeOption; import org.hisp.dhis.program.ProgramInstance; /** @@ -41,7 +42,6 @@ public interface ProgramAttributeValueStore extends GenericStore { - void saveVoid( ProgramAttributeValue programAttributeValue ); int delete( ProgramAttribute programAttribute ); @@ -56,4 +56,5 @@ Collection search( ProgramAttribute programAttribute, String searchText ); + int countByProgramAttributeoption( ProgramAttributeOption attributeOption ); } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/DefaultProgramAttributeValueService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/DefaultProgramAttributeValueService.java 2011-07-06 08:04:17 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/DefaultProgramAttributeValueService.java 2011-07-21 09:03:49 +0000 @@ -30,6 +30,7 @@ import java.util.Collection; import org.hisp.dhis.program.ProgramAttribute; +import org.hisp.dhis.program.ProgramAttributeOption; import org.hisp.dhis.program.ProgramInstance; import org.springframework.transaction.annotation.Transactional; @@ -111,4 +112,10 @@ { return programAttributeValueStore.search( programAttribute, searchText ); } + + @Override + public int countByProgramAttributeOption( ProgramAttributeOption attributeOption ) + { + return programAttributeValueStore.countByProgramAttributeoption( attributeOption ); + } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/hibernate/HibernateProgramAttributeValueStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/hibernate/HibernateProgramAttributeValueStore.java 2010-11-30 08:39:40 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/programattributevalue/hibernate/HibernateProgramAttributeValueStore.java 2011-07-21 09:03:49 +0000 @@ -30,9 +30,11 @@ import java.util.Collection; import org.hibernate.Query; +import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; import org.hisp.dhis.hibernate.HibernateGenericStore; import org.hisp.dhis.program.ProgramAttribute; +import org.hisp.dhis.program.ProgramAttributeOption; import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.programattributevalue.ProgramAttributeValue; import org.hisp.dhis.programattributevalue.ProgramAttributeValueStore; @@ -91,4 +93,12 @@ return getCriteria( Restrictions.eq( "programAttribute", programAttribute ), Restrictions.ilike( "value", "%" + searchText + "%" ) ).list(); } + + @Override + public int countByProgramAttributeoption( ProgramAttributeOption attributeOption ) + { + Number rs = (Number) getCriteria( Restrictions.eq( "programAttributeOption", attributeOption ) ).setProjection( + Projections.rowCount() ).uniqueResult(); + return rs != null ? rs.intValue() : 0; + } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/RemoveProgramAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/RemoveProgramAttributeAction.java 2011-03-31 01:42:05 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/RemoveProgramAttributeAction.java 2011-07-21 09:03:49 +0000 @@ -57,10 +57,6 @@ private Integer id; - // ------------------------------------------------------------------------- - // Setters - // ------------------------------------------------------------------------- - public void setId( Integer id ) { this.id = id; === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/RemoveProgramAttributeOptionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/RemoveProgramAttributeOptionAction.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/program/RemoveProgramAttributeOptionAction.java 2011-07-21 09:03:49 +0000 @@ -0,0 +1,124 @@ +/* + * 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.program; + +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.program.ProgramAttributeOption; +import org.hisp.dhis.program.ProgramAttributeOptionService; +import org.hisp.dhis.programattributevalue.ProgramAttributeValueService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ RemoveProgramAttributeOptionAction.java Jul 21, 2011 3:32:15 PM $ + * + */ +public class RemoveProgramAttributeOptionAction +implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramAttributeOptionService programAttributeOptionService; + + private ProgramAttributeValueService programAttributeValueService; + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private int id; + + private String message; + + private I18n i18n; + + // ------------------------------------------------------------------------- + // Getter && Setter + // ------------------------------------------------------------------------- + + public void setProgramAttributeOptionService( ProgramAttributeOptionService programAttributeOptionService ) + { + this.programAttributeOptionService = programAttributeOptionService; + } + + public void setProgramAttributeValueService( ProgramAttributeValueService programAttributeValueService ) + { + this.programAttributeValueService = programAttributeValueService; + } + + public void setId( int id ) + { + this.id = id; + } + + + public String getMessage() + { + return message; + } + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + ProgramAttributeOption attributeOption = programAttributeOptionService.get( id ); + + if ( attributeOption != null ) + { + int count = programAttributeValueService.countByProgramAttributeOption( attributeOption ); + if ( count > 0 ) + { + message = i18n.getString( "warning_delete_rogram_attribute_option" ); + return INPUT; + } + else + { + programAttributeOptionService.deleteProgramAttributeOption( attributeOption ); + message = i18n.getString( "success_delete_program_attribute_option" ); + return SUCCESS; + } + } + else + { + message = i18n.getString( "error_delete_program_attribute_option" ); + return ERROR; + } + } + +} \ No newline at end of file === 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-07-20 09:15:06 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-07-21 09:03:49 +0000 @@ -695,6 +695,16 @@ + + + + + === 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-07-21 07:54:54 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-07-21 09:03:49 +0000 @@ -296,7 +296,7 @@ child_contact_name = Child contact name patient_system_id = System generated ID warning_delete_patient_attribute_option = This option has relationship with BeneficiaryAttributeValue. You must not delete it. -success_delete_patient_attribute_option = Delete option successfully. +success_delete_patient_attribute_option = Delete patient attribute option successfully. error_delete_patient_attribute_option = Can not find BeneficiaryAttributeOption to delete. attribute_combo_type = Predefined value at_least_2_option = Please add at least two attribute options @@ -470,4 +470,6 @@ patient_attribute_group_sort_order = Beneficiary Attribute Group Sort Order enrol_success = Enrol successfully. beneficiary_attribute_group_sort_order = Beneficiary Attribute Group Sort Order -min_days_from_start = Mininum number of days from start \ No newline at end of file +min_days_from_start = Mininum number of days from start +warning_delete_program_attribute_option = This option has relationship with ProgramAttributeValue. You must not delete it. +success_delete_program_attribute_option = Delete program attribute option successfully. \ 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-07-19 03:48:05 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2011-07-21 09:03:49 +0000 @@ -657,6 +657,17 @@ plainTextError + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + /dhis-web-commons/ajax/jsonResponseError.vm + + /dhis-web-commons/ajax/jsonResponseInput.vm + F_PATIENTATTRIBUTE_DELETE + +