Author: arunpatidar
Date: Sat Jul 22 13:43:23 2017 New Revision: 1802694 URL: http://svn.apache.org/viewvc?rev=1802694&view=rev Log: Improvements in Lot entity definition and services. (OFBIZ-8273) Thanks Rishi Solanki and Devanshu Vyas for your contribution. Modified: ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java ofbiz/ofbiz-framework/trunk/applications/product/servicedef/services_inventory.xml Modified: ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?rev=1802694&r1=1802693&r2=1802694&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Sat Jul 22 13:43:23 2017 @@ -1643,26 +1643,33 @@ public class ProductionRunServices { } if (lotId == null && autoCreateLot.booleanValue()) { - lotId = delegator.getNextSeqId("Lot"); createLotIfNeeded = Boolean.TRUE; } - if (UtilValidate.isNotEmpty(lotId)) { try { // Find the lot GenericValue lot = EntityQuery.use(delegator).from("Lot").where("lotId", lotId).queryOne(); if (lot == null) { if (createLotIfNeeded.booleanValue()) { - lot = delegator.makeValue("Lot", UtilMisc.toMap("lotId", lotId, "creationDate", UtilDateTime.nowTimestamp())); - lot.create(); - } else { + Map<String, Object> createLotCtx = new HashMap<>(); + createLotCtx.put("creationDate", UtilDateTime.nowTimestamp()); + createLotCtx.put("userLogin", userLogin); + Map<String, Object> serviceResults = dispatcher.runSync("createLot", createLotCtx); + if (!ServiceUtil.isSuccess(serviceResults)) { + Debug.logError(ServiceUtil.getErrorMessage(serviceResults), module); + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResults)); + } + lotId = (String) serviceResults.get("lotId"); + } else if (UtilValidate.isNotEmpty(lotId)) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingLotNotExists", locale)); } } } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); return ServiceUtil.returnError(e.getMessage()); + } catch (GenericServiceException e) { + Debug.logWarning(e.getMessage(), module); + return ServiceUtil.returnError(e.getMessage()); } - } GenericValue orderItem = null; try { Modified: ofbiz/ofbiz-framework/trunk/applications/product/servicedef/services_inventory.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/servicedef/services_inventory.xml?rev=1802694&r1=1802693&r2=1802694&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/servicedef/services_inventory.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/servicedef/services_inventory.xml Sat Jul 22 13:43:23 2017 @@ -69,4 +69,19 @@ under the License. <auto-attributes include="pk" mode="IN" optional="false"/> </service> + <service name="createLot" default-entity-name="Lot" engine="entity-auto" invoke="create" auth="true"> + <description>Create a Lot</description> + <auto-attributes include="pk" mode="IN" optional="true"/> + <auto-attributes include="nonpk" mode="IN" optional="true"/> + </service> + <service name="updateLot" default-entity-name="Lot" engine="entity-auto" invoke="update" auth="true"> + <description>Update a Lot</description> + <auto-attributes include="pk" mode="IN" optional="false"/> + <auto-attributes include="nonpk" mode="IN" optional="true"/> + </service> + <service name="deleteLot" default-entity-name="Lot" engine="entity-auto" invoke="delete" auth="true"> + <description>Delete a Lot</description> + <auto-attributes include="pk" mode="IN" optional="false"/> + </service> + </services> \ No newline at end of file |
Free forum by Nabble | Edit this page |