dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17146
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6733: CCEM_Catalog work in progress
------------------------------------------------------------
revno: 6733
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-25 14:33:17 +0530
message:
CCEM_Catalog work in progress
added:
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/RemoveCatalogTypeAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ValidateCatalogTypeAction.java
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalogType.vm
modified:
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/UpdateCatalogTypeAction.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/javascript/addCatalogTypeForm.js
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogType.js
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/updateCatalogTypeForm.js
--
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/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<CatalogTypeAttribute> catalogTypeAttributes;
+
+ public Collection<CatalogTypeAttribute> 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 @@
<property name="catalogTypeAttributeService"
ref="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeService" />
</bean>
-
+
+ <!-- Remove/Delete -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.RemoveCatalogTypeAction"
+ class="org.hisp.dhis.coldchain.catalog.action.RemoveCatalogTypeAction"
+ scope="prototype">
+ <property name="catalogTypeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ </bean>
+
+ <!-- Validation -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.ValidateCatalogTypeAction"
+ class="org.hisp.dhis.coldchain.catalog.action.ValidateCatalogTypeAction"
+ scope="prototype">
+ <property name="catalogTypeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ </bean>
+
+ <!-- show details -->
+ <bean id="org.hisp.dhis.coldchain.catalog.action.GetCatalogTypeDetailsAction"
+ class="org.hisp.dhis.coldchain.catalog.action.GetCatalogTypeDetailsAction"
+ scope="prototype">
+ <property name="catalogTypeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ </bean>
+
<!-- Inventory -->
<bean id="org.hisp.dhis.coldchain.inventory.action.GetInventoryTypeAttributeListAction"
class="org.hisp.dhis.coldchain.inventory.action.GetInventoryTypeAttributeListAction"
=== 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 05:52:37 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties 2012-04-25 09:03:17 +0000
@@ -32,8 +32,10 @@
catalogType_attributes = Catalog type attributes
edit_catalogType = Edit 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
=== modified file 'local/in/dhis-web-coldchain/src/main/resources/struts.xml'
--- local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-04-25 05:52:37 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-04-25 09:03:17 +0000
@@ -122,7 +122,29 @@
<action name="updateCatalogType" class="org.hisp.dhis.coldchain.catalog.action.UpdateCatalogTypeAction">
<result name="success" type="redirect">catalogType.action</result>
</action>
-
+
+ <!-- Remove/Delete -->
+ <action name="removeCatalogType" class="org.hisp.dhis.coldchain.catalog.action.RemoveCatalogTypeAction">
+ <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>
+
+
+ <!-- Validation -->
+ <action name="validateCatalogType" class="org.hisp.dhis.coldchain.catalog.action.ValidateCatalogTypeAction">
+ <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="getCatalogTypeDetails" class="org.hisp.dhis.coldchain.catalog.action.GetCatalogTypeDetailsAction">
+ <result name="success" type="velocity-json">/dhis-web-coldchain/jsonCatalogType.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
<!-- Inventory -->
<action name="inventoryTypeAttributeList" class="org.hisp.dhis.coldchain.inventory.action.GetInventoryTypeAttributeListAction">
<result name="success" type="velocity">/main.vm</result>
=== 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 @@
<td onclick="showCalatogTypeDetails( $catalogType.id )">$encoder.htmlEncode( $catalogType.name )</td>
<td style="text-align:right">
<a href="editCatalogTypeForm.action?id=$catalogType.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>
- <a href="javascript:removeCatalogType( '$catalogType.id', '$encoder.jsEncode( $catalogType.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a>
+ <a href="javascript:removeItem( '$catalogType.id', '$encoder.jsEncode( $catalogType.name )', i18n_confirm_delete , 'removeCatalogType.action' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>
<a href="javascript:showCalatogTypeDetails( $catalogType.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a>
</td>
</tr>
@@ -57,6 +57,7 @@
</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( "no_of_catalogTypeAttributes" ):</label><br><span id="catalogTypeattributesCountField"></span></p>
</div>
<div id="warningArea" style="position:fixed;right:10px;top:200px;display:none">
@@ -69,3 +70,8 @@
</td>
</tr>
</table>
+<script type="text/javascript">
+ var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_catalog_type" ) , "'" )';
+ var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ), "'")';
+
+</script>
\ No newline at end of file
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/addCatalogTypeForm.js'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/addCatalogTypeForm.js 2012-04-25 05:52:37 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/addCatalogTypeForm.js 2012-04-25 09:03:17 +0000
@@ -25,6 +25,6 @@
}
});
- //checkValueIsExist( "name", "validateProgramStage.action");
+ checkValueIsExist( "name", "validateCatalogType.action");
});
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogType.js'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogType.js 2012-04-25 05:52:37 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogType.js 2012-04-25 09:03:17 +0000
@@ -1,4 +1,20 @@
// -----------------------------------------------------------------------------
+// View details
+// -----------------------------------------------------------------------------
+
+function showCalatogTypeDetails( catalogTypeId )
+{
+ jQuery.getJSON( 'getCatalogTypeDetails.action', { id: catalogTypeId }, function ( json ) {
+ setInnerHTML( 'nameField', json.catalogType.name );
+ setInnerHTML( 'descriptionField', json.catalogType.description );
+ setInnerHTML( 'catalogTypeattributesCountField', json.catalogType.catalogTypeAttributeCount );
+
+ showDetails();
+ });
+}
+
+
+// -----------------------------------------------------------------------------
// select/ Catalog Type Attributes
// -----------------------------------------------------------------------------
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/updateCatalogTypeForm.js'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/updateCatalogTypeForm.js 2012-04-25 05:52:37 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/updateCatalogTypeForm.js 2012-04-25 09:03:17 +0000
@@ -11,7 +11,7 @@
});
});
- //checkValueIsExist( "name", "validateProgramStage.action", {id:getFieldValue('id')});
+ checkValueIsExist( "name", "validateCatalogType.action", {id:getFieldValue('id')});
jQuery("#availableList").dhisAjaxSelect({
source: "getCatalogTypeAttributes.action",
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalogType.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalogType.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalogType.vm 2012-04-25 09:03:17 +0000
@@ -0,0 +1,18 @@
+{ "catalogType":
+ {
+ "id": "${catalogType.id}",
+ "name": "$!encoder.jsonEncode( ${catalogType.name} )",
+ "description": "$!encoder.jsonEncode( ${catalogType.description} )",
+ "catalogTypeAttributeCount": "${catalogTypeAttributes.size()}",
+
+ #set( $size = ${catalogTypeAttributes.size()} )
+ "catalogTypeAttribute": [
+ #foreach($typeAttribute in $catalogTypeAttributes)
+ {
+ "id": "${typeAttribute.catalogTypeAttribute.id}",
+ "name": "$!encoder.jsonEncode( ${typeAttribute.catalogTypeAttribute.name} )"
+ }#if( $velocityCount < $size ),#end
+ #end
+ ]
+ }
+}