Author: jonesde
Date: Fri Aug 10 02:10:27 2007 New Revision: 564523 URL: http://svn.apache.org/viewvc?view=rev&rev=564523 Log: Changed a few calls from the message router to by async persisted; a few fixes for the process shipment service to not send when there is no shipping address or when there are no physical items in the order Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java?view=diff&rev=564523&r1=564522&r2=564523 ============================================================================== --- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java (original) +++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java Fri Aug 10 02:10:27 2007 @@ -218,7 +218,7 @@ try { userLogin = delegator.findByPrimaryKey("UserLogin",UtilMisc.toMap("userLoginId", "system")); } catch (GenericEntityException e){ - String errMsg = "Error Getting UserLogin with userLoginId 'system':"+e.toString(); + String errMsg = "Error Getting UserLogin with userLoginId 'system':" + e.toString(); Debug.logError(e, errMsg, module); } @@ -292,7 +292,7 @@ } */ } catch (GenericServiceException e){ - String errMsg = "Error creating OagisMessageInfo for the Incoming Message: "+e.toString(); + String errMsg = "Error creating OagisMessageInfo for the Incoming Message: " + e.toString(); errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException")); Debug.logError(e, errMsg, module); } @@ -307,7 +307,7 @@ try { originalOagisMsgInfo = delegator.findByPrimaryKey("OagisMessageInfo", originalOagisMsgCtx); } catch (GenericEntityException e){ - String errMsg = "Error Getting Entity OagisMessageInfo: "+e.toString(); + String errMsg = "Error Getting Entity OagisMessageInfo: " + e.toString(); errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericEntityException")); Debug.logError(e, errMsg, module); } @@ -334,7 +334,7 @@ Debug.logError(errMsg, module); } } catch (GenericServiceException e){ - String errMsg = "Error creating OagisMessageErrorInfo: "+e.toString(); + String errMsg = "Error creating OagisMessageErrorInfo: " + e.toString(); errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException")); Debug.logError(e, errMsg, module); } @@ -433,7 +433,7 @@ try { oagisMessageInfo = delegator.findByPrimaryKey("OagisMessageInfo", UtilMisc.toMap("logicalId", logicalId, "component", component, "task", task, "referenceId", referenceId)); } catch (GenericEntityException e) { - String errMsg = "Error Getting Entity OagisMessageInfo: "+e.toString(); + String errMsg = "Error Getting Entity OagisMessageInfo: " + e.toString(); Debug.logError(e, errMsg, module); } @@ -441,27 +441,29 @@ if (UtilValidate.isEmpty(oagisMessageInfo)) { if (bsrVerb.equalsIgnoreCase("CONFIRM") && bsrNoun.equalsIgnoreCase("BOD")) { try { - subServiceResult = dispatcher.runSync("receiveConfirmBod", UtilMisc.toMap("document",doc)); + subServiceResult = dispatcher.runSync("receiveConfirmBod", UtilMisc.toMap("document", doc)); } catch (GenericServiceException e) { - String errMsg = "Error running service receiveConfirmBod: "+e.toString(); + String errMsg = "Error running service receiveConfirmBod: " + e.toString(); errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException")); Debug.logError(e, errMsg, module); } } else if (bsrVerb.equalsIgnoreCase("SHOW") && bsrNoun.equalsIgnoreCase("SHIPMENT")) { try { - //subServiceResult = dispatcher.runSync("showShipment", UtilMisc.toMap("document",doc)); - // DEJ20070808 changed to run asynchronously and persisted so that if it fails it will retry - dispatcher.runAsync("showShipment", UtilMisc.toMap("document",doc), true); + //subServiceResult = dispatcher.runSync("showShipment", UtilMisc.toMap("document", doc)); + // DEJ20070808 changed to run asynchronously and persisted so that if it fails it will retry; for transaction deadlock and other reasons + dispatcher.runAsync("showShipment", UtilMisc.toMap("document", doc), true); } catch (GenericServiceException e) { - String errMsg = "Error running service showShipment: "+e.toString(); + String errMsg = "Error running service showShipment: " + e.toString(); errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException")); Debug.logError(e, errMsg, module); } } else if (bsrVerb.equalsIgnoreCase("SYNC") && bsrNoun.equalsIgnoreCase("INVENTORY")) { try { - subServiceResult = dispatcher.runSync("syncInventory", UtilMisc.toMap("document",doc)); + //subServiceResult = dispatcher.runSync("syncInventory", UtilMisc.toMap("document", doc)); + // DEJ20070808 changed to run asynchronously and persisted so that if it fails it will retry; for transaction deadlock and other reasons + dispatcher.runAsync("syncInventory", UtilMisc.toMap("document", doc), true); } catch (GenericServiceException e) { - String errMsg = "Error running service syncInventory: "+e.toString(); + String errMsg = "Error running service syncInventory: " + e.toString(); errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException")); Debug.logError(e, errMsg, module); } @@ -473,17 +475,19 @@ String docType = UtilXml.childElementValue(docRefElement, "of:DOCTYPE"); if ("PO".equals(docType)){ try { - subServiceResult = dispatcher.runSync("receivePoAcknowledge", UtilMisc.toMap("document",doc)); + //subServiceResult = dispatcher.runSync("receivePoAcknowledge", UtilMisc.toMap("document", doc)); + dispatcher.runAsync("receivePoAcknowledge", UtilMisc.toMap("document", doc), true); } catch (GenericServiceException e) { - String errMsg = "Error running service receivePoAcknowledge: "+e.toString(); + String errMsg = "Error running service receivePoAcknowledge: " + e.toString(); errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException")); Debug.logError(e, errMsg, module); } } else if ("RMA".equals(docType)) { try { - subServiceResult = dispatcher.runSync("receiveRmaAcknowledge", UtilMisc.toMap("document",doc)); + //subServiceResult = dispatcher.runSync("receiveRmaAcknowledge", UtilMisc.toMap("document", doc)); + dispatcher.runAsync("receiveRmaAcknowledge", UtilMisc.toMap("document", doc), true); } catch (GenericServiceException e) { - String errMsg = "Error running service receiveRmaAcknowledge: "+e.toString(); + String errMsg = "Error running service receiveRmaAcknowledge: " + e.toString(); errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException")); Debug.logError(e, errMsg, module); } Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java?view=diff&rev=564523&r1=564522&r2=564523 ============================================================================== --- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java (original) +++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java Fri Aug 10 02:10:27 2007 @@ -470,6 +470,24 @@ if (orderHeader != null) { String orderStatusId = orderHeader.getString("statusId"); if (orderStatusId.equals("ORDER_APPROVED")) { + // first check some things... + OrderReadHelper orderReadHelper = new OrderReadHelper(orderHeader); + try { + // before doing or saving anything see if any OrderItems are Products with isPhysical=Y + if (!orderReadHelper.hasPhysicalProductItems()) { + // no need to process shipment, return success + return ServiceUtil.returnSuccess(); + } + } catch (GenericEntityException e) { + String errMsg = "Error checking order: " + e.toString(); + Debug.logError(e, errMsg, module); + return ServiceUtil.returnError(errMsg); + } + if (!orderReadHelper.hasShippingAddress()) { + return ServiceUtil.returnError("Cannot send Process Shipment for order [" + orderId + "], it has no shipping address."); + } + + String logicalId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.LOGICALID"); bodyParameters.put("logicalId", logicalId); Map comiCtx = UtilMisc.toMap("logicalId", logicalId); @@ -482,12 +500,11 @@ bodyParameters.put("referenceId", referenceId); comiCtx.put("referenceId", referenceId); - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'Z"); Timestamp timestamp = UtilDateTime.nowTimestamp(); - String sentDate = dateFormat.format(timestamp); + String sentDate = OagisServices.isoDateFormat.format(timestamp); bodyParameters.put("sentDate", sentDate); comiCtx.put("sentDate", timestamp); - + // prepare map to Create Oagis Message Info comiCtx.put("processingStatusId", "OAGMP_TRIGGERED"); comiCtx.put("component", "INVENTORY"); @@ -531,22 +548,22 @@ } bodyParameters.put("shipment", shipment); - OrderReadHelper orderReadHelper = new OrderReadHelper(orderHeader); - if(orderReadHelper.hasShippingAddress()) { - GenericValue address = EntityUtil.getFirst(orderReadHelper.getShippingLocations()); - bodyParameters.put("address", address); - } + List shipmentItems = delegator.findByAnd("ShipmentItem", UtilMisc.toMap("shipmentId", shipmentId)); + bodyParameters.put("shipmentItems", shipmentItems); + + GenericValue address = EntityUtil.getFirst(orderReadHelper.getShippingLocations()); + bodyParameters.put("address", address); String emailString = orderReadHelper.getOrderEmailString(); bodyParameters.put("emailString", emailString); String contactMechId = shipment.getString("destinationTelecomNumberId"); GenericValue telecomNumber = delegator.findByPrimaryKey("TelecomNumber", UtilMisc.toMap("contactMechId", contactMechId)); bodyParameters.put("telecomNumber", telecomNumber); - List shipmentItems = delegator.findByAnd("ShipmentItem", UtilMisc.toMap("shipmentId", shipmentId)); - bodyParameters.put("shipmentItems", shipmentItems); + orderItemShipGroup = EntityUtil.getFirst(delegator.findByAnd("OrderItemShipGroup", UtilMisc.toMap("orderId", orderId))); bodyParameters.put("orderItemShipGroup", orderItemShipGroup); Set correspondingPoIdSet = FastSet.newInstance(); - List orderItems = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId)); + + List orderItems = orderReadHelper.getOrderItems(); Iterator oiIter = orderItems.iterator(); while (oiIter.hasNext()) { GenericValue orderItem = (GenericValue) oiIter.next(); |
Free forum by Nabble | Edit this page |