=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeDetailsAction.java' --- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeDetailsAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeDetailsAction.java 2012-04-25 09:03:17 +0000 @@ -0,0 +1,70 @@ +package org.hisp.dhis.coldchain.catalog.action; + +import java.util.Collection; + +import org.hisp.dhis.coldchain.catalog.CatalogType; +import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute; +import org.hisp.dhis.coldchain.catalog.CatalogTypeService; + +import com.opensymphony.xwork2.Action; + +public class GetCatalogTypeDetailsAction +implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private CatalogTypeService catalogTypeService; + + public void setCatalogTypeService( CatalogTypeService catalogTypeService ) + { + this.catalogTypeService = catalogTypeService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private int id; + + public int getId() + { + return id; + } + + public void setId( int id ) + { + this.id = id; + } + + private CatalogType catalogType; + + public CatalogType getCatalogType() + { + return catalogType; + } + + private Collection catalogTypeAttributes; + + public Collection getCatalogTypeAttributes() + { + return catalogTypeAttributes; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + + catalogType = catalogTypeService.getCatalogType( id ); + + catalogTypeAttributes = catalogType.getCatalogTypeAttributes(); + + return SUCCESS; + } +} + === added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/RemoveCatalogTypeAction.java' --- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/RemoveCatalogTypeAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/RemoveCatalogTypeAction.java 2012-04-25 09:03:17 +0000 @@ -0,0 +1,84 @@ +package org.hisp.dhis.coldchain.catalog.action; + +import org.hisp.dhis.coldchain.catalog.CatalogType; +import org.hisp.dhis.coldchain.catalog.CatalogTypeService; +import org.hisp.dhis.common.DeleteNotAllowedException; +import org.hisp.dhis.i18n.I18n; + +import com.opensymphony.xwork2.Action; + +public class RemoveCatalogTypeAction +implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private CatalogTypeService catalogTypeService; + + public void setCatalogTypeService( CatalogTypeService catalogTypeService ) + { + this.catalogTypeService = catalogTypeService; + } + + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private int id; + + public void setId( int id ) + { + this.id = id; + } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private String message; + + public String getMessage() + { + return message; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() throws Exception + { + try + { + CatalogType catalogType = catalogTypeService.getCatalogType( id ); + + if( catalogType != null) + { + catalogType.getCatalogTypeAttributes().clear(); + } + + catalogTypeService.deleteCatalogType( catalogType ); + + } + 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 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogTypeAction.java' --- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogTypeAction.java 2012-04-25 05:52:37 +0000 +++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogTypeAction.java 2012-04-25 09:03:17 +0000 @@ -9,9 +9,6 @@ import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute; import org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeService; import org.hisp.dhis.coldchain.catalog.CatalogTypeService; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.program.ProgramStage; -import org.hisp.dhis.program.ProgramStageDataElement; import com.opensymphony.xwork2.Action; === added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ValidateCatalogTypeAction.java' --- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ValidateCatalogTypeAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ValidateCatalogTypeAction.java 2012-04-25 09:03:17 +0000 @@ -0,0 +1,81 @@ +package org.hisp.dhis.coldchain.catalog.action; + +import org.hisp.dhis.coldchain.catalog.CatalogType; +import org.hisp.dhis.coldchain.catalog.CatalogTypeService; +import org.hisp.dhis.i18n.I18n; + +import com.opensymphony.xwork2.Action; + +public class ValidateCatalogTypeAction +implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + private CatalogTypeService catalogTypeService; + + public void setCatalogTypeService( CatalogTypeService catalogTypeService ) + { + this.catalogTypeService = catalogTypeService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private String message; + + public String getMessage() + { + return message; + } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + + CatalogType match = catalogTypeService.getCatalogTypeByName( name ); + + if ( match != null && (id == null || match.getId() != id.intValue()) ) + { + message = i18n.getString( "duplicate_names" ); + + return ERROR; + } + + // --------------------------------------------------------------------- + // Validation success + // --------------------------------------------------------------------- + + message = i18n.getString( "everything_is_ok" ); + + return SUCCESS; + } +} + === modified file 'local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml' --- local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-04-25 05:52:37 +0000 +++ local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-04-25 09:03:17 +0000 @@ -137,7 +137,31 @@ - + + + + + + + + + + + + + + + + catalogType.action - + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + ../dhis-web-commons/ajax/jsonResponseError.vm + plainTextError + + + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + ../dhis-web-commons/ajax/jsonResponseError.vm + plainTextError + + + + + + /dhis-web-coldchain/jsonCatalogType.vm + plainTextError + + /main.vm === modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm 2012-04-25 05:52:37 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm 2012-04-25 09:03:17 +0000 @@ -36,7 +36,7 @@ $encoder.htmlEncode( $catalogType.name ) $i18n.getString( 'edit' ) - $i18n.getString( 'remove' ) + $i18n.getString( $i18n.getString( 'show_details' ) @@ -57,6 +57,7 @@



+