svn commit: r1819730 [2/6] - in /ofbiz/ofbiz-framework/trunk/applications: content/src/main/java/org/apache/ofbiz/content/ content/src/main/java/org/apache/ofbiz/content/compdoc/ content/src/main/java/org/apache/ofbiz/content/content/ content/src/main/...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1819730 [2/6] - in /ofbiz/ofbiz-framework/trunk/applications: content/src/main/java/org/apache/ofbiz/content/ content/src/main/java/org/apache/ofbiz/content/compdoc/ content/src/main/java/org/apache/ofbiz/content/content/ content/src/main/...

jleroux@apache.org
Modified: ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java?rev=1819730&r1=1819729&r2=1819730&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java Sun Dec 31 11:11:46 2017
@@ -28,6 +28,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.ofbiz.base.util.Debug;
+import org.apache.ofbiz.base.util.GeneralException;
 import org.apache.ofbiz.base.util.UtilDateTime;
 import org.apache.ofbiz.base.util.UtilGenerics;
 import org.apache.ofbiz.base.util.UtilMisc;
@@ -40,6 +41,7 @@ import org.apache.ofbiz.entity.util.Enti
 import org.apache.ofbiz.manufacturing.mrp.ProposedOrder;
 import org.apache.ofbiz.service.GenericServiceException;
 import org.apache.ofbiz.service.LocalDispatcher;
+import org.apache.ofbiz.service.ServiceUtil;
 
 /** An ItemCoinfigurationNode represents a component in a bill of materials.
  */
@@ -287,6 +289,11 @@ public class BOMNode {
                                 GenericValue variantProduct = null;
                                 try {
                                     storeResult = dispatcher.runSync("getProductVariant", context);
+                                    if (ServiceUtil.isError(storeResult)) {
+                                        String errorMessage = ServiceUtil.getErrorMessage(storeResult);
+                                        Debug.logError(errorMessage, module);
+                                        throw new GenericEntityException(errorMessage);
+                                    }
                                     List<GenericValue> variantProducts = UtilGenerics.checkList(storeResult.get("products"));
                                     if (variantProducts.size() == 1) {
                                         variantProduct = variantProducts.get(0);
@@ -428,6 +435,10 @@ public class BOMNode {
             Map<String, Object> inputContext = UtilMisc.<String, Object>toMap("arguments", arguments, "userLogin", userLogin);
             try {
                 resultContext = dispatcher.runSync(serviceName, inputContext);
+                if (ServiceUtil.isError(resultContext)) {
+                    String errorMessage = ServiceUtil.getErrorMessage(resultContext);
+                    Debug.logError(errorMessage, module);
+                }
                 BigDecimal calcQuantity = (BigDecimal)resultContext.get("quantity");
                 if (calcQuantity != null) {
                     this.quantity = calcQuantity;
@@ -555,11 +566,15 @@ public class BOMNode {
                 serviceContext.put("startDate", startDate);
             }
             serviceContext.put("userLogin", userLogin);
-            Map<String, Object> resultService = null;
+            Map<String, Object> serviceResult = null;
             try {
-                resultService = dispatcher.runSync("createProductionRun", serviceContext);
-                productionRunId = (String)resultService.get("productionRunId");
-                endDate = (Timestamp)resultService.get("estimatedCompletionDate");
+                serviceResult = dispatcher.runSync("createProductionRun", serviceContext);
+                if (ServiceUtil.isError(serviceResult)) {
+                    String errorMessage = ServiceUtil.getErrorMessage(serviceResult);
+                    Debug.logError(errorMessage, module);
+                }
+                productionRunId = (String)serviceResult.get("productionRunId");
+                endDate = (Timestamp)serviceResult.get("estimatedCompletionDate");
             } catch (GenericServiceException e) {
                 Debug.logError("Problem calling the createProductionRun service", module);
             }

Modified: ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java?rev=1819730&r1=1819729&r2=1819730&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java Sun Dec 31 11:11:46 2017
@@ -139,6 +139,9 @@ public class BOMServices {
             GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
             Map<String, Object> depthResult = dispatcher.runSync("getMaxDepth",
                     UtilMisc.toMap("productId", productId, "bomType", "MANUF_COMPONENT"));
+            if (ServiceUtil.isError(depthResult)) {
+                return ServiceUtil.returnError(ServiceUtil.getErrorMessage(depthResult));
+            }
             llc = (Long)depthResult.get("depth");
             // If the product is a variant of a virtual, then the billOfMaterialLevel cannot be
             // lower than the billOfMaterialLevel of the virtual product.
@@ -166,6 +169,9 @@ public class BOMServices {
             product.store();
             if (alsoComponents.booleanValue()) {
                 Map<String, Object> treeResult = dispatcher.runSync("getBOMTree", UtilMisc.toMap("productId", productId, "bomType", "MANUF_COMPONENT"));
+                if (ServiceUtil.isError(treeResult)) {
+                    return ServiceUtil.returnError(ServiceUtil.getErrorMessage(treeResult));
+                }
                 BOMTree tree = (BOMTree)treeResult.get("tree");
                 List<BOMNode> products = new LinkedList<BOMNode>();
                 tree.print(products, llc.intValue());
@@ -228,6 +234,9 @@ public class BOMServices {
             for (GenericValue product : products) {
                 try {
                     Map<String, Object> depthResult = dispatcher.runSync("updateLowLevelCode", UtilMisc.<String, Object>toMap("productIdTo", product.getString("productId"), "alsoComponents", Boolean.valueOf(false), "alsoVariants", Boolean.valueOf(false)));
+                    if (ServiceUtil.isError(depthResult)) {
+                        return ServiceUtil.returnError(ServiceUtil.getErrorMessage(depthResult));
+                    }
                     Debug.logInfo("Product [" + product.getString("productId") + "] Low Level Code [" + depthResult.get("lowLevelCode") + "]", module);
                 } catch (Exception exc) {
                     Debug.logWarning(exc.getMessage(), module);
@@ -388,11 +397,17 @@ public class BOMServices {
         try {
             Map<String, Object> routingInMap = UtilMisc.toMap("productId", productId, "ignoreDefaultRouting", "Y", "userLogin", userLogin);
             Map<String, Object> routingOutMap = dispatcher.runSync("getProductRouting", routingInMap);
+            if (ServiceUtil.isError(routingOutMap)) {
+                return ServiceUtil.returnError(ServiceUtil.getErrorMessage(routingOutMap));
+            }
             GenericValue routing = (GenericValue)routingOutMap.get("routing");
             if (routing == null) {
                 // try to find a routing linked to the virtual product
                 routingInMap = UtilMisc.toMap("productId", tree.getRoot().getProduct().getString("productId"), "userLogin", userLogin);
                 routingOutMap = dispatcher.runSync("getProductRouting", routingInMap);
+                if (ServiceUtil.isError(routingOutMap)) {
+                    return ServiceUtil.returnError(ServiceUtil.getErrorMessage(routingOutMap));
+                }
                 routing = (GenericValue)routingOutMap.get("routing");
             }
             if (routing != null) {
@@ -536,13 +551,16 @@ public class BOMServices {
                 Map<String, Object> serviceContext = new HashMap<String, Object>();
                 serviceContext.put("productId", orderItem.getString("productId"));
                 serviceContext.put("quantity", orderShipment.getBigDecimal("quantity"));
-                Map<String, Object> resultService = null;
+                Map<String, Object> serviceResult = null;
                 try {
-                    resultService = dispatcher.runSync("getProductsInPackages", serviceContext);
+                    serviceResult = dispatcher.runSync("getProductsInPackages", serviceContext);
+                    if (ServiceUtil.isError(serviceResult)) {
+                        return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingPackageConfiguratorError", locale));
+                    }
                 } catch (GenericServiceException e) {
                     return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingPackageConfiguratorError", locale));
                 }
-                List<BOMNode> productsInPackages = UtilGenerics.checkList(resultService.get("productsInPackages"));
+                List<BOMNode> productsInPackages = UtilGenerics.checkList(serviceResult.get("productsInPackages"));
                 if (productsInPackages.size() == 1) {
                     BOMNode root = productsInPackages.get(0);
                     String rootProductId = (root.getSubstitutedNode() != null? root.getSubstitutedNode().getProduct().getString("productId"): root.getProduct().getString("productId"));
@@ -692,8 +710,11 @@ public class BOMServices {
                         // If needed, create the package
                         if (shipmentPackageSeqId == null) {
                             try {
-                                Map<String, Object> resultService = dispatcher.runSync("createShipmentPackage", UtilMisc.<String, Object>toMap("shipmentId", orderShipment.getString("shipmentId"), "shipmentBoxTypeId", boxTypeId, "userLogin", userLogin));
-                                shipmentPackageSeqId = (String)resultService.get("shipmentPackageSeqId");
+                                Map<String, Object> serviceResult = dispatcher.runSync("createShipmentPackage", UtilMisc.<String, Object>toMap("shipmentId", orderShipment.getString("shipmentId"), "shipmentBoxTypeId", boxTypeId, "userLogin", userLogin));
+                                if (ServiceUtil.isError(serviceResult)) {
+                                    return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
+                                }
+                                shipmentPackageSeqId = (String)serviceResult.get("shipmentPackageSeqId");
                             } catch (GenericServiceException e) {
                                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingPackageConfiguratorError", locale));
                             }
@@ -715,7 +736,10 @@ public class BOMServices {
                                 "userLogin", userLogin,
                                 "quantity", qty);
                             }
-                            dispatcher.runSync("createShipmentPackageContent", inputMap);
+                            Map<String, Object> serviceResult = dispatcher.runSync("createShipmentPackageContent", inputMap);
+                            if (ServiceUtil.isError(serviceResult)) {
+                                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingPackageConfiguratorError", locale));
+                            }
                         } catch (GenericServiceException e) {
                             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingPackageConfiguratorError", locale));
                         }

Modified: ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java?rev=1819730&r1=1819729&r2=1819730&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java Sun Dec 31 11:11:46 2017
@@ -38,7 +38,7 @@ import org.apache.ofbiz.entity.util.Enti
 import org.apache.ofbiz.manufacturing.techdata.TechDataServices;
 import org.apache.ofbiz.service.GenericServiceException;
 import org.apache.ofbiz.service.LocalDispatcher;
-
+import org.apache.ofbiz.service.ServiceUtil;
 
 /**
  * ProductionRun Object used by the Jobshop management OFBiz components,
@@ -425,8 +425,12 @@ public class ProductionRun {
                     // and put the value in totalTaskTime
                     Map<String, Object> estimateCalcServiceMap = UtilMisc.<String, Object>toMap("workEffort", task, "quantity", quantity, "productId", productId, "routingId", routingId);
                     Map<String, Object> serviceContext = UtilMisc.<String, Object>toMap("arguments", estimateCalcServiceMap);
-                    Map<String, Object> resultService = dispatcher.runSync(serviceName, serviceContext);
-                    totalTaskTime = ((BigDecimal)resultService.get("totalTime")).doubleValue();
+                    Map<String, Object> serviceResult = dispatcher.runSync(serviceName, serviceContext);
+                    if (ServiceUtil.isError(serviceResult)) {
+                        String errorMessage = ServiceUtil.getErrorMessage(serviceResult);
+                        Debug.logError(errorMessage, module);
+                    }
+                    totalTaskTime = ((BigDecimal)serviceResult.get("totalTime")).doubleValue();
                 }
             } catch (GenericServiceException exc) {
                 Debug.logError(exc, "Problem calling the customMethod service " + serviceName);

Modified: ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java?rev=1819730&r1=1819729&r2=1819730&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java Sun Dec 31 11:11:46 2017
@@ -92,7 +92,9 @@ public class ProductionRunEvents {
             inputMap.put("userLogin", userLogin);
             Map<String, Object> result = dispatcher.runSync("productionRunDeclareAndProduce", inputMap);
             if (ServiceUtil.isError(result)) {
-                request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(result));
+                String errorMessage = ServiceUtil.getErrorMessage(result);
+                request.setAttribute("_ERROR_MESSAGE_", errorMessage);
+                Debug.logError(errorMessage, module);
                 return "error";
             }
         } catch (GenericServiceException e) {