=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/RemoveDataElementCategoryOptionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/RemoveDataElementCategoryOptionAction.java 2014-10-16 06:17:19 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/RemoveDataElementCategoryOptionAction.java 2014-12-20 13:36:31 +0000 @@ -31,6 +31,7 @@ import org.hisp.dhis.common.DeleteNotAllowedException; import org.hisp.dhis.dataelement.DataElementCategoryOption; import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.i18n.I18n; import com.opensymphony.xwork2.Action; @@ -51,6 +52,13 @@ this.dataElementCategoryService = dataElementCategoryService; } + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -90,7 +98,12 @@ } catch ( DeleteNotAllowedException ex ) { - message = ex.getMessage(); + if ( ex.getErrorCode().equals( DeleteNotAllowedException.ERROR_ASSOCIATED_BY_OTHER_OBJECTS ) ) + { + message = i18n.getString( "object_not_deleted_associated_by_objects" ) + " " + ex.getMessage(); + + return ERROR; + } return ERROR; } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/categoryoptiongroupset/RemoveCategoryOptionGroupSetAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/categoryoptiongroupset/RemoveCategoryOptionGroupSetAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/categoryoptiongroupset/RemoveCategoryOptionGroupSetAction.java 2014-12-20 13:36:31 +0000 @@ -28,8 +28,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.hisp.dhis.common.DeleteNotAllowedException; import org.hisp.dhis.dataelement.CategoryOptionGroupSet; import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.i18n.I18n; import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -49,6 +51,13 @@ @Autowired private DataElementCategoryService dataElementCategoryService; + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -61,6 +70,17 @@ } // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private String message; + + public String getMessage() + { + return message; + } + + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -68,11 +88,22 @@ public String execute() throws Exception { - CategoryOptionGroupSet categoryOptionGroupSet = dataElementCategoryService.getCategoryOptionGroupSet( id ); - - dataElementCategoryService.deleteCategoryOptionGroupSet( categoryOptionGroupSet ); - + try + { + CategoryOptionGroupSet categoryOptionGroupSet = dataElementCategoryService.getCategoryOptionGroupSet( id ); + + dataElementCategoryService.deleteCategoryOptionGroupSet( categoryOptionGroupSet ); + } + catch ( DeleteNotAllowedException ex ) + { + if ( ex.getErrorCode().equals( DeleteNotAllowedException.ERROR_ASSOCIATED_BY_OTHER_OBJECTS ) ) + { + message = i18n.getString( "object_not_deleted_associated_by_objects" ) + " " + ex.getMessage(); + + return ERROR; + } + } + return SUCCESS; } - } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml 2014-11-15 13:26:06 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml 2014-12-20 13:36:31 +0000 @@ -504,7 +504,8 @@ /dhis-web-commons/ajax/jsonResponseSuccess.vm - + /dhis-web-commons/ajax/jsonResponseError.vm + F_CATEGORY_OPTION_DELETE @@ -590,6 +591,7 @@ /dhis-web-commons/ajax/jsonResponseSuccess.vm + /dhis-web-commons/ajax/jsonResponseError.vm F_CATEGORY_OPTION_GROUP_DELETE @@ -647,7 +649,8 @@ - /dhis-web-commons/ajax/jsonResponseSuccess.vm + /dhis-web-commons/ajax/jsonResponseSuccess.vm + /dhis-web-commons/ajax/jsonResponseError.vm F_CATEGORY_OPTION_GROUP_SET_DELETE