dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17276
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6812: CCME_Catalog work in progress
------------------------------------------------------------
revno: 6812
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-04-30 16:54:11 +0530
message:
CCME_Catalog work in progress
added:
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddCatalogAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddCatalogFormAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogListAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogDetailsAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/RemoveCatalogAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ShowAddCatalogFormAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogFormAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ValidateCatalogAction.java
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogDetails.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogList.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/updateCatalogForm.js
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalog.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/showAddCatalogForm.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogForm.vm
modified:
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogTypeListAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeAttributesAction.java
local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml
local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties
local/in/dhis-web-coldchain/src/main/resources/struts.xml
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonInventoryTypeAttribute.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogTypeForm.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
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddCatalogAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddCatalogAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddCatalogAction.java 2012-04-30 11:24:11 +0000
@@ -0,0 +1,190 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.coldchain.catalog.Catalog;
+import org.hisp.dhis.coldchain.catalog.CatalogDataValue;
+import org.hisp.dhis.coldchain.catalog.CatalogService;
+import org.hisp.dhis.coldchain.catalog.CatalogType;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeOption;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeOptionService;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
+
+import com.opensymphony.xwork2.Action;
+
+public class AddCatalogAction
+implements Action
+{
+ public static final String PREFIX_ATTRIBUTE = "attr";
+
+ //public static final String PREFIX_IDENTIFIER = "iden";
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private CatalogService catalogService;
+
+ public void setCatalogService( CatalogService catalogService )
+ {
+ this.catalogService = catalogService;
+ }
+
+ private CatalogTypeService catalogTypeService;
+
+ public void setCatalogTypeService( CatalogTypeService catalogTypeService )
+ {
+ this.catalogTypeService = catalogTypeService;
+ }
+
+ private CatalogTypeAttributeOptionService catalogTypeAttributeOptionService;
+
+ public void setCatalogTypeAttributeOptionService( CatalogTypeAttributeOptionService catalogTypeAttributeOptionService )
+ {
+ this.catalogTypeAttributeOptionService = catalogTypeAttributeOptionService;
+ }
+ /*
+ private CatalogDataValueService catalogDataValueService;
+
+ public void setCatalogDataValueService( CatalogDataValueService catalogDataValueService )
+ {
+ this.catalogDataValueService = catalogDataValueService;
+ }
+ */
+
+ // -------------------------------------------------------------------------
+ // Input/output Getter/Setter
+ // -------------------------------------------------------------------------
+
+
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private String description;
+
+ public void setDescription( String description )
+ {
+ this.description = description;
+ }
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ private int catalogType;
+
+ public void setCatalogType( int catalogType )
+ {
+ this.catalogType = catalogType;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute() throws Exception
+ {
+ // ---------------------------------------------------------------------
+ // Set Name, Description, CatalogType
+ // ---------------------------------------------------------------------
+
+ Catalog catalog = new Catalog();
+ catalog.setName( name );
+ catalog.setDescription( description );
+
+ CatalogType tempcatalogType = catalogTypeService.getCatalogType( catalogType );
+ catalog.setCatalogType( tempcatalogType );
+
+ //catalogService.addCatalog( catalog );
+
+
+ // -----------------------------------------------------------------------------
+ // Prepare catalog type Attributes
+ // -----------------------------------------------------------------------------
+
+ HttpServletRequest request = ServletActionContext.getRequest();
+
+ Collection<CatalogTypeAttribute> catalogTypeAttributes = tempcatalogType.getCatalogTypeAttributes();
+
+ List<CatalogDataValue> catalogDataValues = new ArrayList<CatalogDataValue>();
+
+ String value = null;
+
+ CatalogDataValue catalogDataValue = null;
+
+ if ( catalogTypeAttributes != null && catalogTypeAttributes.size() > 0 )
+ {
+ for ( CatalogTypeAttribute catalogTypeAttribute : catalogTypeAttributes )
+ {
+ value = request.getParameter( PREFIX_ATTRIBUTE + catalogTypeAttribute.getId() );
+ if ( StringUtils.isNotBlank( value ) )
+ {
+ catalogDataValue = new CatalogDataValue();
+ catalogDataValue.setCatalog( catalog );
+ catalogDataValue.setCatalogTypeAttribute( catalogTypeAttribute );
+
+ if ( CatalogTypeAttribute.TYPE_COMBO.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) )
+ {
+ CatalogTypeAttributeOption option = catalogTypeAttributeOptionService.getCatalogTypeAttributeOption( NumberUtils.toInt( value ) );
+
+ if ( option != null )
+ {
+ catalogDataValue.setCatalogTypeAttributeOption( option );
+ catalogDataValue.setValue( option.getName() );
+ }
+ else
+ {
+
+ }
+ }
+ else
+ {
+ catalogDataValue.setValue( value.trim() );
+ }
+
+ catalogDataValues.add( catalogDataValue );
+
+ //catalogDataValueService.addCatalogDataValue( catalogDataValue );
+ }
+ }
+ }
+ /*
+ System.out.println( "Size of catalog Data Values :" + catalogDataValues.size() );
+ for( CatalogDataValue tempcatalogDataValue : catalogDataValues )
+ {
+ System.out.println( "Name :" + tempcatalogDataValue.getCatalog().getName() );
+ System.out.println( "Catalog Type Attribute Name :" + tempcatalogDataValue.getCatalogTypeAttribute().getName() );
+ System.out.println( "Value :" + tempcatalogDataValue.getValue() );
+ }
+ */
+ // -------------------------------------------------------------------------
+ // Save catalog
+ // -------------------------------------------------------------------------
+
+
+ Integer id = catalogService.createCatalog( catalog, catalogDataValues );
+
+ message = id + "";
+
+ return SUCCESS;
+ }
+
+}
+
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddCatalogFormAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddCatalogFormAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddCatalogFormAction.java 2012-04-30 11:24:11 +0000
@@ -0,0 +1,46 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.coldchain.catalog.CatalogType;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
+
+import com.opensymphony.xwork2.Action;
+
+public class AddCatalogFormAction implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private CatalogTypeService catalogTypeService;
+
+ public void setCatalogTypeService( CatalogTypeService catalogTypeService )
+ {
+ this.catalogTypeService = catalogTypeService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & Output Getters & Setters
+ // -------------------------------------------------------------------------
+
+ private List<CatalogType> catalogTypes;
+
+ public List<CatalogType> getCatalogTypes()
+ {
+ return catalogTypes;
+ }
+
+ // -------------------------------------------------------------------------
+ // Execute
+ // -------------------------------------------------------------------------
+
+ public String execute() throws Exception
+ {
+ catalogTypes = new ArrayList<CatalogType>( catalogTypeService.getAllCatalogTypes());
+
+ return SUCCESS;
+ }
+}
+
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogListAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogListAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogListAction.java 2012-04-30 11:24:11 +0000
@@ -0,0 +1,52 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.coldchain.catalog.Catalog;
+import org.hisp.dhis.coldchain.catalog.CatalogService;
+import org.hisp.dhis.coldchain.catalog.comparator.CatalogComparator;
+
+import com.opensymphony.xwork2.Action;
+
+public class CatalogListAction implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependency
+ // -------------------------------------------------------------------------
+
+ private CatalogService catalogService;
+
+ public void setCatalogService( CatalogService catalogService )
+ {
+ this.catalogService = catalogService;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private List<Catalog> catalogs = new ArrayList<Catalog>();
+
+ public List<Catalog> getCatalogs()
+ {
+ return catalogs;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute() throws Exception
+ {
+ catalogs = new ArrayList<Catalog>( catalogService.getAllCatalogs() );
+
+ Collections.sort( catalogs, new CatalogComparator() );
+
+
+ return SUCCESS;
+ }
+
+}
=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogTypeListAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogTypeListAction.java 2012-04-21 10:23:39 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogTypeListAction.java 2012-04-30 11:24:11 +0000
@@ -5,11 +5,10 @@
import org.hisp.dhis.coldchain.catalog.CatalogType;
import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
-import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.paging.ActionPagingSupport;
public class CatalogTypeListAction
-extends ActionPagingSupport<DataSet>
+extends ActionPagingSupport<CatalogType>
{
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogDetailsAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogDetailsAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogDetailsAction.java 2012-04-30 11:24:11 +0000
@@ -0,0 +1,119 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.coldchain.catalog.Catalog;
+import org.hisp.dhis.coldchain.catalog.CatalogDataValue;
+import org.hisp.dhis.coldchain.catalog.CatalogDataValueService;
+import org.hisp.dhis.coldchain.catalog.CatalogService;
+import org.hisp.dhis.coldchain.catalog.CatalogType;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetCatalogDetailsAction
+implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private CatalogService catalogService;
+
+ public void setCatalogService( CatalogService catalogService )
+ {
+ this.catalogService = catalogService;
+ }
+
+ private CatalogDataValueService catalogDataValueService;
+
+
+ public void setCatalogDataValueService( CatalogDataValueService catalogDataValueService )
+ {
+ this.catalogDataValueService = catalogDataValueService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input/Output
+ // -------------------------------------------------------------------------
+
+ private int id;
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+
+ private Catalog catalog;
+
+ public Catalog getCatalog()
+ {
+ return catalog;
+ }
+
+ private CatalogType catalogType;
+
+ public CatalogType getCatalogType()
+ {
+ return catalogType;
+ }
+
+ private Collection<CatalogTypeAttribute> catalogTypeAttributes;
+
+ public Collection<CatalogTypeAttribute> getCatalogTypeAttributes()
+ {
+ return catalogTypeAttributes;
+ }
+
+ private Map<Integer, String> catalogTypeAttributeValueMap = new HashMap<Integer, String>();
+
+ public Map<Integer, String> getCatalogTypeAttributeValueMap()
+ {
+ return catalogTypeAttributeValueMap;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+
+ catalog = catalogService.getCatalog( id );
+
+ catalogType = catalog.getCatalogType();
+
+ catalogTypeAttributes = catalogType.getCatalogTypeAttributes();
+
+
+ List<CatalogDataValue> catalogDataValues = new ArrayList<CatalogDataValue>( catalogDataValueService.getAllCatalogDataValuesByCatalog( catalogService.getCatalog( id )) );
+
+
+ for( CatalogDataValue catalogDataValue : catalogDataValues )
+ {
+ if ( CatalogTypeAttribute.TYPE_COMBO.equalsIgnoreCase( catalogDataValue.getCatalogTypeAttribute().getValueType() ) )
+ {
+ catalogTypeAttributeValueMap.put( catalogDataValue.getCatalogTypeAttribute().getId(), catalogDataValue.getCatalogTypeAttributeOption().getName() );
+ }
+
+ else
+ {
+ catalogTypeAttributeValueMap.put( catalogDataValue.getCatalogTypeAttribute().getId(), catalogDataValue.getValue() );
+ }
+ }
+
+
+ return SUCCESS;
+ }
+}
=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeAttributesAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeAttributesAction.java 2012-04-25 05:52:37 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeAttributesAction.java 2012-04-30 11:24:11 +0000
@@ -7,8 +7,6 @@
import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute;
import org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeService;
import org.hisp.dhis.coldchain.catalog.comparator.CatalogTypeAttributeComparator;
-import org.hisp.dhis.common.IdentifiableObjectUtils;
-import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import com.opensymphony.xwork2.Action;
@@ -37,8 +35,12 @@
{
this.key = key;
}
+
+ public String getKey()
+ {
+ return key;
+ }
-
private List<CatalogTypeAttribute> catalogTypeAttributes = new ArrayList<CatalogTypeAttribute>();
public List<CatalogTypeAttribute> getCatalogTypeAttributes()
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/RemoveCatalogAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/RemoveCatalogAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/RemoveCatalogAction.java 2012-04-30 11:24:11 +0000
@@ -0,0 +1,97 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import java.util.Collection;
+
+import org.hisp.dhis.coldchain.catalog.Catalog;
+import org.hisp.dhis.coldchain.catalog.CatalogDataValue;
+import org.hisp.dhis.coldchain.catalog.CatalogDataValueService;
+import org.hisp.dhis.coldchain.catalog.CatalogService;
+import org.hisp.dhis.common.DeleteNotAllowedException;
+import org.hisp.dhis.i18n.I18n;
+
+import com.opensymphony.xwork2.Action;
+
+public class RemoveCatalogAction
+implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependency
+ // -------------------------------------------------------------------------
+
+ private CatalogService catalogService;
+
+ public void setCatalogService( CatalogService catalogService )
+ {
+ this.catalogService = catalogService;
+ }
+
+ private CatalogDataValueService catalogDataValueService;
+
+
+ public void setCatalogDataValueService( CatalogDataValueService catalogDataValueService )
+ {
+ this.catalogDataValueService = catalogDataValueService;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Input/Output
+ // -------------------------------------------------------------------------
+
+ private int id;
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ try
+ {
+ System.out.println( "Catalog ID is === :" + id );
+
+ Catalog catalog = catalogService.getCatalog( id );
+
+ //catalogService.deleteCatalogData( catalog );
+
+ //catalogService.deleteCatalogData( catalogService.getCatalog( id ) );
+
+ //Collection<CatalogDataValue> valuesForDelete = catalogDataValueService.getAllCatalogDataValuesByCatalog( catalogService.getCatalog( id )) ;
+
+ catalogService.deleteCatalogAndDataValue( catalog );
+
+ catalogService.deleteCatalog( catalog );
+
+ }
+ 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;
+ }
+}
+
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ShowAddCatalogFormAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ShowAddCatalogFormAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ShowAddCatalogFormAction.java 2012-04-30 11:24:11 +0000
@@ -0,0 +1,67 @@
+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 ShowAddCatalogFormAction
+implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private CatalogTypeService catalogTypeService;
+
+ public void setCatalogTypeService( CatalogTypeService catalogTypeService )
+ {
+ this.catalogTypeService = catalogTypeService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input/Output
+ // -------------------------------------------------------------------------
+
+ private int catalogTypeId;
+
+ public void setCatalogTypeId( int catalogTypeId )
+ {
+ this.catalogTypeId = catalogTypeId;
+ }
+
+ private Collection<CatalogTypeAttribute> catalogTypeAttributes;
+
+ public Collection<CatalogTypeAttribute> getCatalogTypeAttributes()
+ {
+ return catalogTypeAttributes;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+
+ CatalogType catalogType = catalogTypeService.getCatalogType( catalogTypeId );
+
+ catalogTypeAttributes = catalogType.getCatalogTypeAttributes();
+ /*
+ System.out.println( "Name of CatalogType is ====== :" + catalogType.getName() );
+ System.out.println( "Size of catalogTypeAttributes :" + catalogTypeAttributes.size() );
+ for( CatalogTypeAttribute catalogTypeAttribute : catalogTypeAttributes )
+ {
+ System.out.println( "Name :" + catalogTypeAttribute.getName() );
+ System.out.println( "valueType :" + catalogTypeAttribute.getValueType() );
+ System.out.println( "Is mandatory :" + catalogTypeAttribute.isMandatory() );
+ }
+ */
+ return SUCCESS;
+ }
+
+
+}
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogAction.java 2012-04-30 11:24:11 +0000
@@ -0,0 +1,220 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.coldchain.catalog.Catalog;
+import org.hisp.dhis.coldchain.catalog.CatalogDataValue;
+import org.hisp.dhis.coldchain.catalog.CatalogDataValueService;
+import org.hisp.dhis.coldchain.catalog.CatalogService;
+import org.hisp.dhis.coldchain.catalog.CatalogType;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeOption;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeOptionService;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
+
+import com.opensymphony.xwork2.Action;
+
+public class UpdateCatalogAction
+implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private CatalogService catalogService;
+
+ public void setCatalogService( CatalogService catalogService )
+ {
+ this.catalogService = catalogService;
+ }
+
+ private CatalogTypeService catalogTypeService;
+
+ public void setCatalogTypeService( CatalogTypeService catalogTypeService )
+ {
+ this.catalogTypeService = catalogTypeService;
+ }
+
+ private CatalogTypeAttributeOptionService catalogTypeAttributeOptionService;
+
+ public void setCatalogTypeAttributeOptionService( CatalogTypeAttributeOptionService catalogTypeAttributeOptionService )
+ {
+ this.catalogTypeAttributeOptionService = catalogTypeAttributeOptionService;
+ }
+
+ private CatalogDataValueService catalogDataValueService;
+
+
+ public void setCatalogDataValueService( CatalogDataValueService catalogDataValueService )
+ {
+ this.catalogDataValueService = catalogDataValueService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input/output and Getter/Setter
+ // -------------------------------------------------------------------------
+
+ private int catalogID;
+
+ public void setCatalogID( int catalogID )
+ {
+ this.catalogID = catalogID;
+ }
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private String description;
+
+ public void setDescription( String description )
+ {
+ this.description = description;
+ }
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+ /*
+ private int catalogType;
+
+ public void setCatalogType( int catalogType )
+ {
+ this.catalogType = catalogType;
+ }
+ */
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Catalog catalog;
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute() throws Exception
+ {
+
+ //System.out.println( "catalog id is :" + catalogID );
+
+ catalog = catalogService.getCatalog( catalogID );
+
+ // ---------------------------------------------------------------------
+ // Set name, description, and catalogType
+ // ---------------------------------------------------------------------
+
+ catalog.setName( name );
+ catalog.setDescription( description );
+
+ CatalogType catalogType = catalogTypeService.getCatalogType( catalog.getCatalogType().getId() );
+
+ catalog.setCatalogType( catalogType );
+
+ //System.out.println( " catalog Name is :" + catalog.getName() + "---- catalogType id is " + catalogType.getId() + " --catalog Type name is " + catalogType.getName());
+
+ // --------------------------------------------------------------------------------------------------------
+ // Save catalog Attributes
+ // -----------------------------------------------------------------------------------------------------
+
+ HttpServletRequest request = ServletActionContext.getRequest();
+
+ String value = null;
+
+ CatalogDataValue catalogDataValue = null;
+
+ Collection<CatalogTypeAttribute> catalogTypeAttributes = catalogType.getCatalogTypeAttributes();
+
+ List<CatalogDataValue> valuesForSave = new ArrayList<CatalogDataValue>();
+ List<CatalogDataValue> valuesForUpdate = new ArrayList<CatalogDataValue>();
+ Collection<CatalogDataValue> valuesForDelete = null;
+
+
+ if ( catalogTypeAttributes != null && catalogTypeAttributes.size() > 0 )
+ {
+ //catalog.getCatalogType().getCatalogTypeAttributes().clear();
+ valuesForDelete = catalogDataValueService.getAllCatalogDataValuesByCatalog( catalogService.getCatalog( catalogID )) ;
+
+ for ( CatalogTypeAttribute catalogTypeAttribute : catalogTypeAttributes )
+ {
+ value = request.getParameter( AddCatalogAction.PREFIX_ATTRIBUTE + catalogTypeAttribute.getId() );
+
+ if ( StringUtils.isNotBlank( value ) )
+ {
+ catalogDataValue = catalogDataValueService.catalogDataValue( catalog ,catalogTypeAttribute );
+
+ if ( !catalog.getCatalogType().getCatalogTypeAttributes().contains( catalogTypeAttribute ) )
+ {
+ catalog.getCatalogType().getCatalogTypeAttributes().add( catalogTypeAttribute );
+ }
+
+ if ( catalogDataValue == null )
+ {
+ catalogDataValue = new CatalogDataValue();
+ catalogDataValue.setCatalog( catalog );
+ catalogDataValue.setCatalogTypeAttribute( catalogTypeAttribute );
+
+ if ( CatalogTypeAttribute.TYPE_COMBO.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) )
+ {
+ CatalogTypeAttributeOption option = catalogTypeAttributeOptionService.getCatalogTypeAttributeOption( NumberUtils.toInt( value ) );
+
+ if ( option != null )
+ {
+ catalogDataValue.setCatalogTypeAttributeOption( option );
+ catalogDataValue.setValue( option.getName() );
+ }
+ else
+ {
+
+ }
+ }
+ else
+ {
+ catalogDataValue.setValue( value.trim() );
+ }
+ valuesForSave.add( catalogDataValue );
+ }
+ else
+ {
+ if ( CatalogTypeAttribute.TYPE_COMBO.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) )
+ {
+ CatalogTypeAttributeOption option = catalogTypeAttributeOptionService.getCatalogTypeAttributeOption( NumberUtils.toInt( value ));
+ if ( option != null )
+ {
+ catalogDataValue.setCatalogTypeAttributeOption( option );
+ catalogDataValue.setValue( option.getName() );
+ }
+ else
+ {
+ }
+ }
+ else
+ {
+ catalogDataValue.setValue( value.trim() );
+ }
+ valuesForUpdate.add( catalogDataValue );
+ valuesForDelete.remove( catalogDataValue );
+ }
+ }
+ }
+ }
+ catalogService.updateCatalogAndDataValue( catalog, valuesForSave, valuesForUpdate , valuesForDelete);
+ return SUCCESS;
+ }
+
+
+}
\ No newline at end of file
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogFormAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogFormAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogFormAction.java 2012-04-30 11:24:11 +0000
@@ -0,0 +1,143 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.coldchain.catalog.Catalog;
+import org.hisp.dhis.coldchain.catalog.CatalogDataValue;
+import org.hisp.dhis.coldchain.catalog.CatalogDataValueService;
+import org.hisp.dhis.coldchain.catalog.CatalogService;
+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 UpdateCatalogFormAction
+implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private CatalogService catalogService;
+
+ public void setCatalogService( CatalogService catalogService )
+ {
+ this.catalogService = catalogService;
+ }
+
+ private CatalogTypeService catalogTypeService;
+
+ public void setCatalogTypeService( CatalogTypeService catalogTypeService )
+ {
+ this.catalogTypeService = catalogTypeService;
+ }
+
+ private CatalogDataValueService catalogDataValueService;
+
+
+ public void setCatalogDataValueService( CatalogDataValueService catalogDataValueService )
+ {
+ this.catalogDataValueService = catalogDataValueService;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Input/Output and Getter / Setter
+ // -------------------------------------------------------------------------
+
+ private int id;
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+
+ private Catalog catalog;
+
+
+ public Catalog getCatalog()
+ {
+ return catalog;
+ }
+
+ private Map<Integer, String> catalogTypeAttributeValueMap = new HashMap<Integer, String>();
+
+ public Map<Integer, String> getCatalogTypeAttributeValueMap()
+ {
+ return catalogTypeAttributeValueMap;
+ }
+
+ private List<CatalogType> catalogTypes;
+
+ public List<CatalogType> getCatalogTypes()
+ {
+ return catalogTypes;
+ }
+
+ private Collection<CatalogTypeAttribute> catalogTypeAttributes;
+
+ public Collection<CatalogTypeAttribute> getCatalogTypeAttributes()
+ {
+ return catalogTypeAttributes;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute() throws Exception
+ {
+
+ catalog = catalogService.getCatalog( id );
+
+ catalogTypes = new ArrayList<CatalogType>( catalogTypeService.getAllCatalogTypes());
+
+
+ // -------------------------------------------------------------------------
+ // Get catalog attribute values
+ // -------------------------------------------------------------------------
+
+ Catalog tempCatalog = catalogService.getCatalog( id );
+
+ CatalogType catalogType = catalogTypeService.getCatalogType( tempCatalog.getCatalogType().getId() );
+
+ catalogTypeAttributes = catalogType.getCatalogTypeAttributes();
+
+ List<CatalogDataValue> catalogDataValues = new ArrayList<CatalogDataValue>( catalogDataValueService.getAllCatalogDataValuesByCatalog( catalogService.getCatalog( id )) );
+
+
+ for( CatalogDataValue catalogDataValue : catalogDataValues )
+ {
+ if ( CatalogTypeAttribute.TYPE_COMBO.equalsIgnoreCase( catalogDataValue.getCatalogTypeAttribute().getValueType() ) )
+ {
+ catalogTypeAttributeValueMap.put( catalogDataValue.getCatalogTypeAttribute().getId(), catalogDataValue.getCatalogTypeAttributeOption().getName() );
+ }
+
+ else
+ {
+ catalogTypeAttributeValueMap.put( catalogDataValue.getCatalogTypeAttribute().getId(), catalogDataValue.getValue() );
+ }
+ }
+ /*
+ System.out.println( "Size of catalog Data Values Map :" + catalogTypeAttributeValueMap.size() );
+ for( CatalogDataValue tempcatalogDataValue : catalogDataValues )
+ {
+ System.out.println( "Map value is ------- :" + catalogTypeAttributeValueMap.get( tempcatalogDataValue.getCatalogTypeAttribute().getId() ));
+
+ }
+ */
+
+
+
+ return SUCCESS;
+
+ }
+
+}
+
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ValidateCatalogAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ValidateCatalogAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ValidateCatalogAction.java 2012-04-30 11:24:11 +0000
@@ -0,0 +1,82 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import org.hisp.dhis.coldchain.catalog.Catalog;
+import org.hisp.dhis.coldchain.catalog.CatalogService;
+import org.hisp.dhis.i18n.I18n;
+
+import com.opensymphony.xwork2.Action;
+
+public class ValidateCatalogAction
+implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependency
+ // -------------------------------------------------------------------------
+
+ private CatalogService catalogService;
+
+ public void setCatalogService( CatalogService catalogService )
+ {
+ this.catalogService = catalogService;
+ }
+
+ // -------------------------------------------------------------------------
+ // 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
+ {
+
+ Catalog match = catalogService.getCatalogByName( 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-30 08:30:00 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-04-30 11:24:11 +0000
@@ -161,7 +161,100 @@
<property name="catalogTypeService"
ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
</bean>
-
+
+<!-- catalog -->
+
+ <!-- Catalog List -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.CatalogListAction"
+ class="org.hisp.dhis.coldchain.catalog.action.CatalogListAction"
+ scope="prototype">
+ <property name="catalogService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogService" />
+ </bean>
+
+ <!-- Add Catalog Form -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.AddCatalogFormAction"
+ class="org.hisp.dhis.coldchain.catalog.action.AddCatalogFormAction"
+ scope="prototype">
+ <property name="catalogTypeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ </bean>
+
+ <!-- Show Add Catalog Form -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.ShowAddCatalogFormAction"
+ class="org.hisp.dhis.coldchain.catalog.action.ShowAddCatalogFormAction"
+ scope="prototype">
+ <property name="catalogTypeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ </bean>
+
+
+ <!-- Add -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.AddCatalogAction"
+ class="org.hisp.dhis.coldchain.catalog.action.AddCatalogAction"
+ scope="prototype">
+ <property name="catalogService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogService" />
+ <property name="CatalogTypeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ <property name="catalogTypeAttributeOptionService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeOptionService" />
+ <!--<property name="catalogDataValueService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogDataValueService" />-->
+ </bean>
+
+ <!-- Update Form -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.UpdateCatalogFormAction"
+ class="org.hisp.dhis.coldchain.catalog.action.UpdateCatalogFormAction"
+ scope="prototype">
+ <property name="catalogService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogService" />
+ <property name="catalogTypeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ <property name="catalogDataValueService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogDataValueService" />
+ </bean>
+
+ <!-- Update -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.UpdateCatalogAction"
+ class="org.hisp.dhis.coldchain.catalog.action.UpdateCatalogAction"
+ scope="prototype">
+ <property name="catalogService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogService" />
+ <property name="catalogTypeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ <property name="catalogTypeAttributeOptionService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeOptionService" />
+ <property name="catalogDataValueService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogDataValueService" />
+ </bean>
+
+ <!-- Validation -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.ValidateCatalogAction"
+ class="org.hisp.dhis.coldchain.catalog.action.ValidateCatalogAction"
+ scope="prototype">
+ <property name="catalogService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogService" />
+ </bean>
+
+ <!-- show details -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.GetCatalogDetailsAction"
+ class="org.hisp.dhis.coldchain.catalog.action.GetCatalogDetailsAction"
+ scope="prototype">
+ <property name="catalogService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogService" />
+ <property name="catalogDataValueService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogDataValueService" />
+ </bean>
+
+ <!-- Remove/Delete -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.RemoveCatalogAction"
+ class="org.hisp.dhis.coldchain.catalog.action.RemoveCatalogAction"
+ scope="prototype">
+ <property name="catalogService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogService" />
+ </bean>
+
<!-- InventoryTypeAttribute -->
<bean id="org.hisp.dhis.coldchain.inventory.action.GetInventoryTypeAttributeListAction"
class="org.hisp.dhis.coldchain.inventory.action.GetInventoryTypeAttributeListAction"
@@ -273,7 +366,6 @@
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
<property name="equipmentInstanceService" ref="org.hisp.dhis.coldchain.inventory.EquipmentInstanceService" />
<property name="inventoryTypeService" ref="org.hisp.dhis.coldchain.inventory.InventoryTypeService" />
- <property name="inventoryTypeAttributeService" ref="org.hisp.dhis.coldchain.inventory.InventoryTypeAttributeService" />
</bean>
<bean id="org.hisp.dhis.coldchain.equipment.action.ShowAddEquipmentFormAction"
class="org.hisp.dhis.coldchain.equipment.action.ShowAddEquipmentFormAction"
@@ -281,38 +373,5 @@
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
<property name="inventoryTypeService" ref="org.hisp.dhis.coldchain.inventory.InventoryTypeService" />
</bean>
- <bean id="org.hisp.dhis.coldchain.equipment.action.AddEquipmentAction"
- class="org.hisp.dhis.coldchain.equipment.action.AddEquipmentAction"
- scope="prototype">
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="inventoryTypeService" ref="org.hisp.dhis.coldchain.inventory.InventoryTypeService" />
- <property name="inventoryTypeAttributeOptionService" ref="org.hisp.dhis.coldchain.inventory.InventoryTypeAttributeOptionService" />
- <property name="equipmentInstanceService" ref="org.hisp.dhis.coldchain.inventory.EquipmentInstanceService" />
- </bean>
- <bean id="org.hisp.dhis.coldchain.equipment.action.GetEquipmentInstanceDataAction"
- class="org.hisp.dhis.coldchain.equipment.action.GetEquipmentInstanceDataAction"
- scope="prototype">
- <property name="equipmentDetailsService" ref="org.hisp.dhis.coldchain.inventory.EquipmentDetailsService" />
- <property name="equipmentInstanceService" ref="org.hisp.dhis.coldchain.inventory.EquipmentInstanceService" />
- </bean>
- <bean id="org.hisp.dhis.coldchain.equipment.action.UpdateEquipmentAction"
- class="org.hisp.dhis.coldchain.equipment.action.UpdateEquipmentAction"
- scope="prototype">
- <property name="equipmentDetailsService" ref="org.hisp.dhis.coldchain.inventory.EquipmentDetailsService" />
- <property name="equipmentInstanceService" ref="org.hisp.dhis.coldchain.inventory.EquipmentInstanceService" />
- <property name="inventoryTypeAttributeOptionService" ref="org.hisp.dhis.coldchain.inventory.InventoryTypeAttributeOptionService" />
- </bean>
- <bean id="org.hisp.dhis.coldchain.equipment.action.ShowEquipmentStatusFormAction"
- class="org.hisp.dhis.coldchain.equipment.action.ShowEquipmentStatusFormAction"
- scope="prototype">
- </bean>
- <bean id="org.hisp.dhis.coldchain.equipment.action.UpdateEquipmentStatusAction"
- class="org.hisp.dhis.coldchain.equipment.action.UpdateEquipmentStatusAction"
- scope="prototype">
- <property name="equipmentStatusService" ref="org.hisp.dhis.coldchain.inventory.EquipmentStatusService" />
- <property name="equipmentInstanceService" ref="org.hisp.dhis.coldchain.inventory.EquipmentInstanceService" />
- <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
- </bean>
-
</beans>
\ No newline at end of file
=== modified file 'local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties'
--- local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties 2012-04-25 09:03:17 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties 2012-04-30 11:24:11 +0000
@@ -1,44 +1,54 @@
coldchain = Cold Chain
-coldchain_management = Cold Chain Management
-coldchain_catalog_type_attribute_management = Cold Chain catalog type attribute management
+coldchain_management = Cold chain management
+coldchain_catalog_type_attribute_management = Cold chain catalog type attribute management
filter_by_name = Filter by name
-catalogType_attribute = Catalog Type Attribute
-create_new_catalog_type_attribute = Create new catalog Type attribute
-catalog_type_attribute_details = Catalog Type attribute details
+catalogType_attribute = Catalog type attribute
+create_new_catalog_type_attribute = Create new catalog type attribute
+catalog_type_attribute_details = Catalog type attribute details
mandatory = Mandatory
no_of_char = Number of characters
attribute_combo_type = Predefined value
field_is_required = This field is required
attribute_options = Attribute options
-add_more_option = Add Option
+add_more_option = Add option
at_least_2_option = Please add at least two attribute options
-remove_option = Remove Option
+remove_option = Remove option
confirm_delete_catalogType_attribute = Are you sure you want to delete catalog type attribute?
-warning_delete_catalogType_attribute_option = This option has relationship with CatalogTypeAttributeValue. You must not delete it.
+warning_delete_catalogType_attribute_option = This option has relationship with catalog type attribute value. You must not delete it.
success_delete_ctalogType_attribute_option = Delete catalog type attribute option successfully.
error_delete_ctalogType_attribute_option = Can not find catalog type attribute option to delete.
edit_catalogType_attribute = Edit catalog type attribute
-catalogType_attribute_details = Catalog Type attribute details
-error_delete_catalogType_attribute_option = Can not find Catalog Type attribute option to delete.
+catalogType_attribute_details = Catalog type attribute details
+error_delete_catalogType_attribute_option = Can not find catalog type attribute option to delete.
name_in_use = Name in use
-everything_is_ok = Everything is OK
-catalogType = Catalog Type
+everything_is_ok = Everything is ok
+catalogType = Catalog type
confirm_delete = Are you sure you want to delete this catalog type?
-catalogType_management = Catalog Type management
-available_catalogType_attribute = Available Catalog Type Attributes
-selected_catalogType_attribute = Selected Data Catalog Type Attributes
+catalogType_management = Catalog type management
+available_catalogType_attribute = Available Catalog type attributes
+selected_catalogType_attribute = Selected data catalog type attributes
create_new_catalogType = Create new catalog type
catalogType_attributes = Catalog type attributes
edit_catalogType = Edit catalog type
-catalog_type_details = Details of Catalog Type
+catalog_type_details = Details of catalog type
object_not_deleted_associated_by_objects = Object not deleted because it is associated by objects of type
confirm_delete_catalog_type = Are you sure you want to delete this catalog type?
duplicate_names = Name is already in use
-no_of_catalogTypeAttributes = Number of Catalog Type Attributes to be collected
-
-
-inventorytype_attribute_management = Inventorytype Attribute Management
-inventorytype_attribute = Inventorytype Attribute
+no_of_catalogTypeAttributes = Number of catalog type attributes to be collected
+catalog = Catalog
+catalog_management = Catalog management
+add_new_catalog = Add new catalog
+please_select_catalog_type = Please select catalog type
+please_select = Please select
+confirm_delete_catalog = Are you sure you want to delete catalog?
+edit_catalog = Edit catalog
+catalog__details = Details of catalog
+attributes = Attributes
+
+
+
+inventorytype_attribute_management = Inventorytype attribute aanagement
+inventorytype_attribute = Inventorytype attribute
create_new_inventorytype_attribute = Create new inventorytype attribute
-inventorytype_attribute_details = Inventorytype attribute details
\ No newline at end of file
+inventorytype_attribute_details = Inventorytype attribute details
=== modified file 'local/in/dhis-web-coldchain/src/main/resources/struts.xml'
--- local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-04-30 08:30:00 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-04-30 11:24:11 +0000
@@ -31,11 +31,13 @@
<param name="page">/dhis-web-coldchain/addColdChainCatalogTypeAttributeForm.vm</param>
<param name="javascripts">javascript/catalogTypeAttribute.js</param>
<param name="stylesheets">css/style.css</param>
+ <param name="requiredAuthorities">F_CATALOGTYPEATTRIBUTE_ADD</param>
</action>
<!-- Add -->
<action name="addCatalogTypeAttribute" class="org.hisp.dhis.coldchain.catalog.action.AddCatalogTypeAttributeAction">
<result name="success" type="redirect">coldChainCatalogTypeAttribute.action</result>
+ <param name="requiredAuthorities">F_CATALOGTYPEATTRIBUTE_ADD</param>
</action>
<!-- show details -->
@@ -48,14 +50,15 @@
<action name="removeCatalogTypeAttribute" class="org.hisp.dhis.coldchain.catalog.action.RemoveCatalogTypeAttributeAction">
<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
<result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
+ <param name="requiredAuthorities">F_CATALOGTYPEATTRIBUTE_DELETE</param>
</action>
<!-- Remove/Delete Attrobute Option -->
<action name="removeCatalogTypeAttributeOption" class="org.hisp.dhis.coldchain.catalog.action.RemoveCatalogTypeAttributeOptionAction">
<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
<result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
- <result name="input" type="velocity-json">
- /dhis-web-commons/ajax/jsonResponseInput.vm</result>
+ <result name="input" type="velocity-json">/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+ <param name="requiredAuthorities">F_CATALOGTYPEATTRIBUTE_DELETE</param>
</action>
<!-- Update Form -->
@@ -64,11 +67,13 @@
<param name="page">/dhis-web-coldchain/updateCatalogTypeAttibuteForm.vm</param>
<param name="javascripts">javascript/catalogTypeAttribute.js</param>
<param name="stylesheets">css/style.css</param>
+ <param name="requiredAuthorities">F_CATALOGTYPEATTRIBUTE_UPDATE</param>
</action>
<!-- Update -->
<action name="updateCatalogTypeAttribute" class="org.hisp.dhis.coldchain.catalog.action.UpdateCatalogTypeAttributeAction">
<result name="success" type="redirect">coldChainCatalogTypeAttribute.action</result>
+ <param name="requiredAuthorities">F_CATALOGTYPEATTRIBUTE_UPDATE</param>
</action>
<!-- Validation -->
@@ -95,6 +100,7 @@
<param name="menu">/dhis-web-coldchain/menu.vm</param>
<param name="javascripts">javascript/catalogType.js</param>
<param name="stylesheets">css/style.css</param>
+ <param name="requiredAuthorities">F_CATALOGTYPE_ADD</param>
</action>
@@ -108,6 +114,7 @@
<!-- Add -->
<action name="addCataligType" class="org.hisp.dhis.coldchain.catalog.action.AddCatalogTypeAction">
<result name="success" type="redirect">catalogType.action</result>
+ <param name="requiredAuthorities">F_CATALOGTYPE_ADD</param>
</action>
<!-- Update Form -->
@@ -116,11 +123,13 @@
<param name="page">/dhis-web-coldchain/updateCatalogTypeForm.vm</param>
<param name="javascripts">javascript/catalogType.js</param>
<param name="stylesheets">css/style.css</param>
+ <param name="requiredAuthorities">F_CATALOGTYPE_UPDATE</param>
</action>
<!-- Update -->
<action name="updateCatalogType" class="org.hisp.dhis.coldchain.catalog.action.UpdateCatalogTypeAction">
<result name="success" type="redirect">catalogType.action</result>
+ <param name="requiredAuthorities">F_CATALOGTYPE_UPDATE</param>
</action>
<!-- Remove/Delete -->
@@ -128,6 +137,7 @@
<result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
<result name="error" type="velocity-json">../dhis-web-commons/ajax/jsonResponseError.vm</result>
<param name="onExceptionReturn">plainTextError</param>
+ <param name="requiredAuthorities">F_CATALOGTYPE_DELETE</param>
</action>
@@ -144,7 +154,82 @@
<result name="success" type="velocity-json">/dhis-web-coldchain/jsonCatalogType.vm</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
-
+
+<!-- catalog -->
+
+ <!-- Catalog List -->
+ <action name="catalog" class="org.hisp.dhis.coldchain.catalog.action.CatalogListAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-coldchain/catalogList.vm</param>
+ <param name="menu">/dhis-web-coldchain/menu.vm</param>
+ <param name="javascripts">javascript/catalog.js</param>
+ </action>
+
+ <!-- Add Catalog Form -->
+ <action name="addCatalogForm" class="org.hisp.dhis.coldchain.catalog.action.AddCatalogFormAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-coldchain/addCatalogForm.vm</param>
+ <param name="menu">/dhis-web-coldchain/menu.vm</param>
+ <param name="javascripts">javascript/catalog.js</param>
+ <param name="stylesheets">css/style.css</param>
+ <param name="requiredAuthorities">F_CATALOG_ADD</param>
+ </action>
+
+ <!-- Show Add Catalog Form -->
+ <action name="showAddCataLogForm" class="org.hisp.dhis.coldchain.catalog.action.ShowAddCatalogFormAction">
+ <result name="success" type="velocity">/content.vm</result>
+ <param name="page">/dhis-web-coldchain/showAddCatalogForm.vm</param>
+ <param name="requiredAuthorities">F_CATALOG_ADD</param>
+ </action>
+
+ <!-- Add -->
+ <action name="addCatalog" class="org.hisp.dhis.coldchain.catalog.action.AddCatalogAction">
+ <result name="success" type="redirect">catalog.action</result>
+ <param name="requiredAuthorities">F_CATALOG_ADD</param>
+ </action>
+
+ <!-- Update Form -->
+ <action name="showUpdateCatalogForm" class="org.hisp.dhis.coldchain.catalog.action.UpdateCatalogFormAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-coldchain/updateCatalogForm.vm</param>
+ <param name="stylesheets">css/style.css</param>
+ <param name="requiredAuthorities">F_CATALOG_UPDATE</param>
+ </action>
+
+ <!-- Update -->
+ <action name="updateCatalog" class="org.hisp.dhis.coldchain.catalog.action.UpdateCatalogAction">
+ <result name="success" type="redirect">catalog.action</result>
+ <param name="requiredAuthorities">F_CATALOG_UPDATE</param>
+ </action>
+
+ <!-- Validation -->
+ <action name="validateCatalog" class="org.hisp.dhis.coldchain.catalog.action.ValidateCatalogAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="error" type="velocity-json">../dhis-web-commons/ajax/jsonResponseError.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <!-- show details -->
+<!--
+ <action name="getCatalogDetails" class="org.hisp.dhis.coldchain.catalog.action.GetCatalogDetailsAction">
+ <result name="success" type="velocity-json">/dhis-web-coldchain/jsonCatalog.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+-->
+ <action name="getCatalogDetails" class="org.hisp.dhis.coldchain.catalog.action.GetCatalogDetailsAction">
+ <result name="success" type="velocity">/content.vm</result>
+ <param name="page">/dhis-web-coldchain/catalogDetails.vm</param>
+ </action>
+
+
+ <!-- Remove/Delete -->
+ <action name="removeCatalog" class="org.hisp.dhis.coldchain.catalog.action.RemoveCatalogAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="error" type="velocity-json">../dhis-web-commons/ajax/jsonResponseError.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ <param name="requiredAuthorities">F_CATALOG_DELETE</param>
+ </action>
+
<!-- InventoryTypeAttribute -->
<action name="inventoryTypeAttributeList" class="org.hisp.dhis.coldchain.inventory.action.GetInventoryTypeAttributeListAction">
<result name="success" type="velocity">/main.vm</result>
@@ -290,35 +375,11 @@
<param name="requiredAuthorities">F_EQUIPMENT_ADD</param>
</action>
<action name="addEquipment"
- class="org.hisp.dhis.coldchain.equipment.action.AddEquipmentAction">
+ class="">
<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
<param name="requiredAuthorities">F_EQUIPMENT_ADD</param>
</action>
- <action name="showUpdateEquipmentForm"
- class="org.hisp.dhis.coldchain.equipment.action.GetEquipmentInstanceDataAction">
- <result name="success" type="velocity">/content.vm</result>
- <param name="page">/dhis-web-coldchain/updateEquipmentForm.vm</param>
- <param name="requiredAuthorities">F_EQUIPMENT_UPDATE</param>
- </action>
- <action name="updateEquipment"
- class="org.hisp.dhis.coldchain.equipment.action.UpdateEquipmentAction">
- <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
- <param name="requiredAuthorities">F_EQUIPMENT_UPDATE</param>
- </action>
-
- <action name="showEquipmentStatusForm"
- class="org.hisp.dhis.coldchain.equipment.action.ShowEquipmentStatusFormAction">
- <result name="success" type="velocity">/content.vm</result>
- <param name="page">/dhis-web-coldchain/equipmentStatusForm.vm</param>
- <param name="requiredAuthorities">F_EQUIPMENTSTATUS_UPDATE</param>
- </action>
-
- <action name="updateEquipmentStatus"
- class="org.hisp.dhis.coldchain.equipment.action.UpdateEquipmentStatusAction">
- <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
- <param name="requiredAuthorities">F_EQUIPMENTSTATUS_UPDATE</param>
- </action>
-
+
</package>
</struts>
\ No newline at end of file
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm 2012-04-30 11:24:11 +0000
@@ -0,0 +1,46 @@
+<script>
+</script>
+
+<h3>$i18n.getString( "add_new_catalog" )</h3>
+
+<form id="catalogForm" name="catalogForm" action="addCatalog.action" method="post" >
+
+<table>
+ <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, unicodechars:true, rangelength:[4,160]}}"/></td>
+ </tr>
+
+ <tr>
+ <td><label>$i18n.getString( "description" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="description" name="description" class="{validate:{required:true,unicodechars:true, minlength:4}}"/></td>
+ </tr>
+ <tr>
+
+ <td><label>$i18n.getString( "catalogType" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td>
+ <select id="catalogType" name="catalogType" onChange="catalogTypeChange();" class="{validate:{required:true}}">
+ <option value="">[$i18n.getString( "please_select_catalog_type" )]</option>
+ #foreach( $catalogType in $catalogTypes )
+ <option value="$catalogType.id">$encoder.htmlEncode( $catalogType.name )</option>
+ #end
+ </select>
+ </td>
+ </tr>
+ <tr><td> </td><td> </td></tr>
+</table>
+
+<div id='addCatalogFormDiv'></div> <!-- Add Catalog Form -->
+
+
+<p>
+ <input type="submit" class="button" value="$i18n.getString( 'add' )"/>
+ <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='catalog.action'" />
+</p>
+
+</form>
+#parse( "/dhis-web-commons/loader/loader.vm" )
+<script>
+ var i18n_error_connect_to_server = '$encoder.jsEscape( $i18n.getString( "error_connect_to_server" ) , "'" )';
+ var i18n_add_person_successfully = '$encoder.jsEscape( $i18n.getString( "add_person_successfully" ) , "'" )';
+</script>
\ No newline at end of file
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogDetails.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogDetails.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogDetails.vm 2012-04-30 11:24:11 +0000
@@ -0,0 +1,47 @@
+<table>
+ <tr>
+ <td>
+ <label class="bold">$i18n.getString('name') : </label>
+ </td>
+ <td>
+ $catalog.name
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <label class="bold">$i18n.getString('description') : </label>
+ </td>
+ <td>
+ $catalog.description
+ </td>
+ </tr>
+ <tr>
+ <td><label class="bold">$i18n.getString('catalogType') : </label>
+ </td>
+ <td>
+ $catalogType.name
+ </td>
+ </tr>
+
+ <tr><td colspan='2'> </td></tr>
+ <tr>
+ <td colspan='2'><label class="bold">$i18n.getString( "attributes" )</label></td>
+ </tr>
+ #foreach( $catalogTypeAttribute in $catalogTypeAttributes )
+ #if( $catalogTypeAttributeValueMap.get( $catalogTypeAttribute.id ) != " " )
+ <tr>
+ <td><label class="bold">$catalogTypeAttribute.name : </label>
+ </td>
+ <td>
+ #if($catalogTypeAttribute.valueType=="YES/NO")
+ $i18n.getString( $!catalogTypeAttributeValueMap.get( $catalogTypeAttribute.id ) )
+ #else
+ $!catalogTypeAttributeValueMap.get( $catalogTypeAttribute.id )
+ #end
+ </td>
+ </tr>
+ #end
+ #end
+
+ <tr><td> </td></tr>
+</table>
\ No newline at end of file
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogList.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogList.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogList.vm 2012-04-30 11:24:11 +0000
@@ -0,0 +1,76 @@
+
+<h3>$i18n.getString( "catalog_management" ) #openHelp( "catalog" )</h3>
+<table class="mainPageTable">
+ <tr>
+ <td style="vertical-align:top">
+ <table width="100%">
+ <tr>
+ <td>
+ $i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:250px"/>
+ </td>
+ <td colspan="3" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='addCatalogForm.action'" style="width:70px"></td>
+ </tr>
+ </table>
+
+ <table class="listTable">
+ <col>
+ <col width="20">
+ <col width="20">
+ <col width="20">
+ <thead>
+ <tr>
+ <th>$i18n.getString( "name" )</th>
+ <th colspan="3">$i18n.getString( "operations" )</th>
+ </tr>
+ </thead>
+ <tbody id="list">
+ #foreach( $catalog in $catalogs )
+ <tr id="tr${catalog.id}">
+
+ <!--<td>$encoder.htmlEncode( $catalog.name )</td>-->
+ <td onclick="showCatalogDetails( $catalog.id )">$encoder.htmlEncode( $catalog.name )</td>
+ <td style="text-align:center">
+ <!--<a href="javascript:showUpdateCatalogForm( '$catalog.id' )" title='$i18n.getString( "edit" )'><img src="../images/edit.png" alt='$i18n.getString( "edit_profile" )'></a>-->
+ <a href="showUpdateCatalogForm.action?id=$catalog.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
+ </td>
+
+ <td style="text-align:center">
+ <a href="javascript:removeCatalog( '$catalog.id', '$encoder.jsEncode( $catalog.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )" ></a>
+ </td>
+
+ <td style="text-align:center">
+ <a href="javascript:showCatalogDetails( $catalog.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
+ </td>
+
+ </tr>
+ #end
+
+ </tbody>
+
+ </table>
+ </td>
+
+ <td style="width:20em; padding-left:2em; vertical-align:top">
+
+ <div id="detailsArea" style="display:none">
+ <div style="float:right">
+ <a href="javascript:hideDetails()" title="$i18n.getString( 'hide_details' )"><img src="../images/close.png" alt="$i18n.getString( 'hide_details' )"></a>
+ </div>
+ <p><label class="bold">$i18n.getString( "name" ):</label><br><span id="nameField"></span></p>
+ <p><label class="bold">$i18n.getString( "description" ):</label><br><span id="descriptionField"></span></p>
+ <p><label class="bold">$i18n.getString( "catalogType" ):</label><br><span id="catalogTypeField"></span></p>
+ <!--<p><label class="bold">$i18n.getString( "mandatory" ):</label><br><span id="mandatoryField"></span></p>-->
+ </div>
+
+ </td>
+ </tr>
+</table>
+
+<div id="detailsCatalogInfo"></div>
+
+
+<script type="text/javascript">
+ var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_catalog" ) , "'" )';
+ var i18n_catalog_details = '$encoder.jsEscape( $i18n.getString( "catalog__details" ) , "'" )';
+</script>
+
=== 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 09:03:17 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm 2012-04-30 11:24:11 +0000
@@ -8,14 +8,15 @@
</script>
-<h3>$i18n.getString( "catalogType_management" ) ##openHelp( "dataSet" )</h3>
+<h3>$i18n.getString( "catalogType_management" ) #openHelp( "catalogType" )</h3>
<table class="mainPageTable">
<tr>
<td style="vertical-align:top">
<table width="100%">
<tr>
- <td>#filterDiv( "catalogType" )</td>
+ <!--<td>#filterDiv( "catalogType" )</td>-->
+ <td>$i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:250px"/></td>
<td colspan="9" style="text-align:right">
<input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='addCatalogTypeForm.action'" style="width:80px"/></a>
</td>
@@ -46,7 +47,7 @@
</table>
<p></p>
- #parse( "/dhis-web-commons/paging/paging.vm" )
+ ##parse( "/dhis-web-commons/paging/paging.vm" )
</td>
<td style="width:20em; padding-left:2em; vertical-align:top">
@@ -55,8 +56,8 @@
<div style="float:right">
<a href="javascript:hideDetails()" title="$i18n.getString( 'hide_details' )"><img src="../images/close.png" alt="$i18n.getString( 'hide_details' )"/></a>
</div>
- <p><label>$i18n.getString( "name" ):</label><br/><span id="nameField"></span></p>
- <p><label>$i18n.getString( "description" ):</label><br/><span id="descriptionField"></span></p>
+ <p><label class="bold">$i18n.getString( "name" ):</label><br/><span id="nameField"></span></p>
+ <p><label class="bold">$i18n.getString( "description" ):</label><br/><span id="descriptionField"></span></p>
<p><label class="bold">$i18n.getString( "no_of_catalogTypeAttributes" ):</label><br><span id="catalogTypeattributesCountField"></span></p>
</div>
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm 2012-04-21 10:23:39 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm 2012-04-30 11:24:11 +0000
@@ -1,5 +1,5 @@
-<h3>$i18n.getString( "coldchain_catalog_type_attribute_management" )</h3>
+<h3>$i18n.getString( "coldchain_catalog_type_attribute_management" ) #openHelp( "catalogTypeAttribute" )</h3>
<table class="mainPageTable">
<tr>
<td style="vertical-align:top">
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js 2012-04-30 11:24:11 +0000
@@ -0,0 +1,98 @@
+
+jQuery(document).ready( function(){
+ validation( 'catalogForm', function(form){
+ form.submit();
+ }, function(){
+ isSubmit = true;
+
+ });
+
+ checkValueIsExist( "name", "validateCatalog.action");
+ });
+
+
+//-----------------------------------------------------------------------------
+//View catalog type change
+//-----------------------------------------------------------------------------
+
+function catalogTypeChange()
+{
+ var catalogTypeList = document.getElementById("catalogType");
+ var catalogTypeId = catalogTypeList.options[ catalogTypeList.selectedIndex ].value;
+
+ hideById('addCatalogFormDiv');
+ jQuery('#loaderDiv').show();
+ contentDiv = 'addCatalogFormDiv';
+
+ jQuery('#addCatalogFormDiv').load('showAddCataLogForm.action',
+ {
+ catalogTypeId:catalogTypeId
+ }, function()
+ {
+ showById('addCatalogFormDiv');
+ jQuery('#loaderDiv').hide();
+ });
+ hideLoader();
+}
+
+//-----------------------------------------------------------------------------
+//View details
+//-----------------------------------------------------------------------------
+
+function showCatalogDetails( catalogId )
+{
+ /*
+ jQuery.getJSON( 'getCatalogDetails.action', { id: catalogId }, function ( json ) {
+ setInnerHTML( 'nameField', json.catalog.name );
+ setInnerHTML( 'descriptionField', json.catalog.description );
+ setInnerHTML( 'catalogTypeField', json.catalog.catalogType );
+
+ showDetails();
+ });
+ */
+
+
+ $('#detailsCatalogInfo').load("getCatalogDetails.action",
+ {
+ id:catalogId
+ }
+ , function( ){
+ }).dialog({
+ title: i18n_catalog_details,
+ maximize: true,
+ closable: true,
+ modal:true,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 500,
+ height: 500
+ });;
+}
+
+//-----------------------------------------------------------------------------
+//Remove catalog
+//-----------------------------------------------------------------------------
+function removeCatalog( catalogId, name )
+{
+ removeItem( catalogId, name, i18n_confirm_delete, 'removeCatalog.action' );
+}
+
+//----------------------------------------------------------------
+// Update Catalog
+//----------------------------------------------------------------
+/*
+unction showUpdateCatalogForm( catalogId )
+{
+ setInnerHTML('addCatalogFormDiv', '');
+
+ jQuery('#loaderDiv').show();
+ jQuery('#addCatalogFormDiv').load('showUpdateCatalogForm.action',
+ {
+ catalogId:catalogId
+ }, function()
+ {
+ showById('addCatalogFormDiv');
+ });
+ hideLoader();
+}
+*/
+
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/updateCatalogForm.js'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/updateCatalogForm.js 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/updateCatalogForm.js 2012-04-30 11:24:11 +0000
@@ -0,0 +1,10 @@
+jQuery(document).ready( function(){
+ validation( 'updateCatalogForm', function(form){
+ form.submit();
+ }, function(){
+ isSubmit = true;
+
+ });
+
+ checkValueIsExist( "name", "validateCatalog.action", {id:getFieldValue('id')});
+});
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalog.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalog.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalog.vm 2012-04-30 11:24:11 +0000
@@ -0,0 +1,18 @@
+{ "catalog":
+ {
+ "id": "${catalog.id}",
+ "name": "$!encoder.jsonEncode( ${catalog.name} )",
+ "description": "$!encoder.jsonEncode( ${catalog.description} )",
+ "catalogType": "${catalogType.name}",
+
+ #set( $size = ${catalogTypeAttributes.size()} )
+ "catalogTypeAttribute": [
+ #foreach($typeAttribute in $catalogTypeAttributes)
+ {
+ "id": "${typeAttribute.catalogTypeAttribute.id}",
+ "name": "$!encoder.jsonEncode( ${typeAttribute.catalogTypeAttribute.name} )"
+ }#if( $velocityCount < $size ),#end
+ #end
+ ]
+ }
+}
\ No newline at end of file
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonInventoryTypeAttribute.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonInventoryTypeAttribute.vm 2012-04-21 12:57:24 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonInventoryTypeAttribute.vm 2012-04-30 11:24:11 +0000
@@ -4,6 +4,6 @@
"name": "$!encoder.jsonEncode( ${inventoryTypeAttribute.name} )",
"description": "$!encoder.jsonEncode( ${inventoryTypeAttribute.description} )",
"mandatory": "$!{inventoryTypeAttribute.mandatory}",
- "valueType": "$!encoder.jsonEncode( ${inventoryTypeAttribute.valueType} )",
+ "valueType": "$!encoder.jsonEncode( ${inventoryTypeAttribute.valueType} )"
}
}
\ No newline at end of file
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm 2012-04-26 10:00:48 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm 2012-04-30 11:24:11 +0000
@@ -3,6 +3,7 @@
<ul>
<li><a href="coldChainCatalogTypeAttribute.action">$i18n.getString( "catalogType_attribute" )</a></li>
<li><a href="catalogType.action">$i18n.getString( "catalogType" )</a></li>
+ <li><a href="catalog.action">$i18n.getString( "catalog" )</a></li>
</ul>
<h2>$i18n.getString( "inventory" )</h2>
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/showAddCatalogForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/showAddCatalogForm.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/showAddCatalogForm.vm 2012-04-30 11:24:11 +0000
@@ -0,0 +1,45 @@
+## Macro for generating the jQuery validation rules
+#macro( validate $type $require )
+ #if( $type == "NUMBER" )
+ {validate:{ number:true #if($require), required:true #end }}
+ #elseif( $require )
+ {validate:{required:true}}
+ #end
+#end
+
+<!-- ATTRIBUTES -->
+<table>
+<tr><td> </td></tr>
+#if ( $catalogTypeAttributes.size() > 0)
+ <tr><th colspan="2" class="heading-column">$i18n.getString( "catalogType_attribute" )</th></tr>
+ #foreach($attribute in $catalogTypeAttributes )
+ <tr>
+ <td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>
+ <td class="input-column">
+ #if( $attribute.valueType == "YES/NO" )
+ <select id="attr$attribute.id" name="attr$attribute.id" >
+ <option value="" >[$i18n.getString( "please_select" )]</option>
+ <option value="true">$i18n.getString( "yes" )</option>
+ <option value="false" >$i18n.getString( "no" )</option>
+ </select>
+ #elseif( $attribute.valueType == "DATE" )
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" class='#validate( "default" $attribute.mandatory )' />
+ <script type="text/javascript">
+ datePickerValid( 'attr$attribute.id' );
+ </script>
+ #elseif( $attribute.valueType == "COMBO" )
+ <select id="attr$attribute.id" name="attr$attribute.id" class='#validate( "default" $attribute.mandatory )'>
+ <option value="">[$i18n.getString( "please_select" )]</option>
+ #foreach ($option in $attribute.attributeOptions )
+ <option value="$option.id" >$option.name</option>
+ #end
+ </select>
+ #else
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" />
+ #end
+ </td>
+ </tr>
+
+ #end
+#end
+</table>
\ No newline at end of file
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogForm.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogForm.vm 2012-04-30 11:24:11 +0000
@@ -0,0 +1,86 @@
+#macro( validate $type $require )
+ #if( $type == "NUMBER" )
+ {validate:{ number:true #if($require), required:true #end }}
+ #elseif( $type == "string" )
+ {validate:{ alphanumeric:true #if($require), required:true #end }}
+ #elseif( $require )
+ {validate:{required:true}}
+ #end
+#end
+<script type="text/javascript" src="javascript/updateCatalogForm.js"></script>
+
+<h3>$i18n.getString( "edit_catalog" )</h3>
+<p>
+<form id="updateCatalogForm" name="updateCatalogForm" action="updateCatalog.action" method="post" >
+<div>
+ <input type="hidden" id="id" name="id" value="$catalog.id">
+ <input type="hidden" id="catalogID" name="catalogID" value="$catalog.id">
+ <input type="hidden" id="catalogTypeID" name="id" value="$catalog.catalogType.id">
+</div>
+<table>
+ <tr>
+ <th colspan="2" class="heading-column">$i18n.getString( "catalog__details" )</th>
+ </tr>
+ <tr>
+ <td class='text-column'><label for="name">$i18n.getString( "name" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td class="input-column" ><input type="text" id="name" name="name" value="$!catalog.name" class="{validate:{required:true, unicodechars:true, rangelength:[4,50]}}"></td>
+ </tr>
+ <tr>
+ <td class='text-column'><label for="description">$i18n.getString( "description" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td class="input-column" ><input type="text" id="description" name="description" value="$!catalog.description" class="{validate:{required:true, unicodechars:true, minlength:4}}"></td>
+ </tr>
+
+ <tr>
+ <td class='text-column'><label>$i18n.getString( "catalogType" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td class="input-column" >
+ <select id="catalogType" name="catalogType" onChange="catalogTypeChange();" disabled>
+ <option value="" selected="selected">[$i18n.getString( "please_select_catalog_type" )]</option>
+ #foreach( $catalogType in $catalogTypes )
+ <option value="$catalogType.id" #if( $catalogType.id == $catalog.catalogType.id ) selected="selected" #end>$encoder.htmlEncode( $catalogType.name )</option>
+ #end
+ </select>
+ </td>
+ </tr>
+ <!-- ATTRIBUTES -->
+<tr><td> </td><td> </td></tr>
+ #if ( $catalogTypeAttributes.size() > 0)
+ <tr><th colspan="2" class="heading-column">$i18n.getString( "catalogType_attribute" )</th></tr>
+ #foreach($attribute in $catalogTypeAttributes )
+ #set( $attributeValue = "" )
+ #set( $attributeValue = $!catalogTypeAttributeValueMap.get( $attribute.id ) )
+ <tr>
+ <td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
+ <td class="input-column" >
+ #if( $attribute.valueType == "YES/NO" )
+ <select id="attr$attribute.id" name="attr$attribute.id" >
+ <option value="">[$i18n.getString( "please_select" )]</option>
+ <option value="true" #if( $attributeValue ) selected="selected" #end>$i18n.getString( "yes" )</option>
+ <option value="false" #if( !$attributeValue ) selected="selected" #end>$i18n.getString( "no" )</option>
+ </select>
+ #elseif( $attribute.valueType == "DATE" )
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class=' #validate( "default" $attribute.mandatory )'>
+ <script type="text/javascript">
+ datePickerValid( 'attr$attribute.id' );
+ </script>
+ #elseif( $attribute.valueType == "COMBO" )
+ <select id="attr$attribute.id" name="attr$attribute.id" class=' #validate( "default" $attribute.mandatory )' >
+ <option value="">[$i18n.getString( "please_select" )]</option>
+ #foreach ($option in $attribute.attributeOptions )
+ <option value="$option.id" #if($attributeValue == $option.name) selected="selected" #end>$option.name</option>
+ #end
+ </select>
+ #else
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" >
+ #end
+ </td>
+ </tr>
+ #end
+ #end
+</table>
+
+<p>
+ <input type="submit" class='button' value="$i18n.getString( 'update' )" >
+ <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='catalog.action'" />
+</p>
+
+</form>
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogTypeForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogTypeForm.vm 2012-04-25 05:52:37 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogTypeForm.vm 2012-04-30 11:24:11 +0000
@@ -42,9 +42,9 @@
<select size="15" id="availableList" name='availableList' multiple="multiple" ondblclick="selectCatalogTypeAttributes()">
</select>
</td>
- <td valign="top" align="center">
+ <td>
<input type="button" value=">" onclick="selectCatalogTypeAttributes()" class='filterButton' /><br/>
- <input type="button" value="<" onclick="unselectCatalogTypeAttributes()" class='filterButton' /><br/><br/>
+ <input type="button" value="<" onclick="unselectCatalogTypeAttributes()" class='filterButton' /><br/><br/>
<td>
<div class="catalogTypeAttributeDiv">
<table>