Author: jonesde
Date: Tue Aug 14 03:07:35 2007 New Revision: 565689 URL: http://svn.apache.org/viewvc?view=rev&rev=565689 Log: Big refactoring of oagisReceiveDelivery service and template to structure properly, save interim status information, prepare proper name data, other cleanups; still need to write code to get serial numbers for returned items, as much as possible anyway Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ReceiveDelivery.ftl 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=565689&r1=565688&r2=565689 ============================================================================== --- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java (original) +++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java Tue Aug 14 03:07:35 2007 @@ -710,12 +710,12 @@ } if (Debug.infoOn()) Debug.logInfo("Finished rendering oagisProcessShipment message for orderId [" + orderId + "]", module); - comiCtx.put("processingStatusId", "OAGMP_OGEN_SUCCESS"); - comiCtx.put("shipmentId", shipmentId); - if (OagisServices.debugSaveXmlOut) { - comiCtx.put("fullMessageXml", outText); - } try { + comiCtx.put("processingStatusId", "OAGMP_OGEN_SUCCESS"); + comiCtx.put("shipmentId", shipmentId); + if (OagisServices.debugSaveXmlOut) { + comiCtx.put("fullMessageXml", outText); + } dispatcher.runSync("updateOagisMessageInfo", comiCtx, 60, true); } catch (GenericServiceException e){ String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); @@ -723,18 +723,19 @@ } Map sendMessageReturn = OagisServices.sendMessageText(outText, out, sendToUrl, saveToDirectory, saveToFilename); - if (sendMessageReturn != null) { - return sendMessageReturn; - } - if (Debug.infoOn()) Debug.logInfo("Message send done for oagisProcessShipment for orderId [" + orderId + "], sendToUrl=[" + sendToUrl + "], saveToDirectory=[" + saveToDirectory + "], saveToFilename=[" + saveToFilename + "]", module); - comiCtx.put("processingStatusId", "OAGMP_SENT"); + if (Debug.infoOn()) Debug.logInfo("Message send done for oagisProcessShipment for orderId [" + orderId + "], sendToUrl=[" + sendToUrl + "], saveToDirectory=[" + saveToDirectory + "], saveToFilename=[" + saveToFilename + "]", module); try { + comiCtx.put("processingStatusId", "OAGMP_SENT"); dispatcher.runSync("updateOagisMessageInfo", comiCtx, 60, true); } catch (GenericServiceException e){ String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } + + if (sendMessageReturn != null) { + return sendMessageReturn; + } } } return result; @@ -775,15 +776,51 @@ MapStack bodyParameters = MapStack.create(); GenericValue returnHeader = null; - String statusId = null; try { returnHeader = delegator.findByPrimaryKey("ReturnHeader", UtilMisc.toMap("returnId", returnId)); - statusId = returnHeader.getString("statusId"); } catch (GenericEntityException e) { Debug.logError(e, module); } if (returnHeader != null) { - if (statusId.equals("RETURN_ACCEPTED")) { + String statusId = returnHeader.getString("statusId"); + if ("RETURN_ACCEPTED".equals(statusId)) { + Map comiCtx = FastMap.newInstance(); + + String logicalId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.LOGICALID"); + bodyParameters.put("logicalId", logicalId); + comiCtx.put("logicalId", logicalId); + + String authId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.AUTHID"); + bodyParameters.put("authId", authId); + comiCtx.put("authId", authId); + + String referenceId = delegator.getNextSeqId("OagisMessageInfo"); + bodyParameters.put("referenceId", referenceId); + comiCtx.put("referenceId", referenceId); + + Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); + String sentDate = OagisServices.isoDateFormat.format(nowTimestamp); + bodyParameters.put("sentDate", sentDate); + + // prepare map to Create Oagis Message Info + comiCtx.put("component", "INVENTORY"); + comiCtx.put("task", "RMA"); + comiCtx.put("outgoingMessage", "Y"); + comiCtx.put("confirmation", "1"); + comiCtx.put("bsrVerb", "RECEIVE"); + comiCtx.put("bsrNoun", "DELIVERY"); + comiCtx.put("bsrRevision", "001"); + comiCtx.put("returnId", returnId); + comiCtx.put("sentDate", nowTimestamp); + comiCtx.put("userLogin", userLogin); + comiCtx.put("processingStatusId", "OAGMP_TRIGGERED"); + try { + dispatcher.runSync("createOagisMessageInfo", comiCtx, 60, true); + } catch (GenericServiceException e) { + String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + Debug.logError(e, errMsg, module); + } + List returnItems = null; try { returnItems = delegator.findByAnd("ReturnItem", UtilMisc.toMap("returnId", returnId)); @@ -804,56 +841,39 @@ Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } - Map comiCtx = UtilMisc.toMap("orderId", orderId); + + String partyId = returnHeader.getString("fromPartyId"); + try { GenericValue postalAddress = delegator.findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", returnHeader.getString("originContactMechId"))); bodyParameters.put("postalAddress", postalAddress); + bodyParameters.put("partyNameView", delegator.findByPrimaryKey("PartyNameView", UtilMisc.toMap("partyId", partyId))); } catch (GenericEntityException e) { Debug.logError(e, module); } // calculate total qty of return items in a shipping unit received, order associated with return - double itemQty = 0.0; double totalQty = 0.0; Iterator riIter = returnItems.iterator(); while (riIter.hasNext()) { GenericValue returnItem = (GenericValue) riIter.next(); - itemQty = returnItem.getDouble("returnQuantity").doubleValue(); - totalQty = totalQty + itemQty; + double itemQty = returnItem.getDouble("returnQuantity").doubleValue(); + totalQty += itemQty; } bodyParameters.put("totalQty", new Double(totalQty)); - String partyId = returnHeader.getString("fromPartyId"); String emailString = PartyWorker.findPartyLatestContactMech(partyId, "EMAIL_ADDRESS", delegator).getString("infoString"); bodyParameters.put("emailString", emailString); GenericValue telecomNumber = PartyWorker.findPartyLatestTelecomNumber(partyId, delegator); bodyParameters.put("telecomNumber", telecomNumber); - - String logicalId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.LOGICALID"); - bodyParameters.put("logicalId", logicalId); - comiCtx.put("logicalId", logicalId); - - String authId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.AUTHID"); - bodyParameters.put("authId", authId); - comiCtx.put("authId", authId); - - String referenceId = delegator.getNextSeqId("OagisMessageInfo"); - 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); - bodyParameters.put("sentDate", sentDate); - comiCtx.put("sentDate", timestamp); - - String entryDate = dateFormat.format(returnHeader.getTimestamp("entryDate")); + + String entryDate = OagisServices.isoDateFormat.format(returnHeader.getTimestamp("entryDate")); bodyParameters.put("entryDate", entryDate); bodyParameters.put("returnId", returnId); + String bodyScreenUri = UtilProperties.getPropertyValue("oagis.properties", "Oagis.Template.ReceiveDelivery"); - String outText = null; try { Writer writer = new StringWriter(); @@ -867,29 +887,28 @@ return ServiceUtil.returnError(errMsg); } - // prepare map to Create Oagis Message Info - comiCtx.put("component", "INVENTORY"); - comiCtx.put("task", "RMA"); - comiCtx.put("outgoingMessage", "Y"); - comiCtx.put("confirmation", "1"); - comiCtx.put("bsrVerb", "RECEIVE"); - comiCtx.put("bsrNoun", "DELIVERY"); - comiCtx.put("bsrRevision", "001"); - comiCtx.put("processingStatusId", statusId); - comiCtx.put("returnId", returnId); - comiCtx.put("userLogin", userLogin); - if (OagisServices.debugSaveXmlOut) { - comiCtx.put("fullMessageXml", outText); + try { + comiCtx.put("orderId", orderId); + comiCtx.put("processingStatusId", "OAGMP_OGEN_SUCCESS"); + if (OagisServices.debugSaveXmlOut) { + comiCtx.put("fullMessageXml", outText); + } + dispatcher.runSync("updateOagisMessageInfo", comiCtx, 60, true); + } catch (GenericServiceException e) { + String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); + Debug.logError(e, errMsg, module); } + Map sendMessageReturn = OagisServices.sendMessageText(outText, out, sendToUrl, saveToDirectory, saveToFilename); + try { - dispatcher.runSync("createOagisMessageInfo", comiCtx, 60, true); + comiCtx.put("processingStatusId", "OAGMP_SENT"); + dispatcher.runSync("updateOagisMessageInfo", comiCtx, 60, true); } catch (GenericServiceException e) { String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale")); Debug.logError(e, errMsg, module); } - Map sendMessageReturn = OagisServices.sendMessageText(outText, out, sendToUrl, saveToDirectory, saveToFilename); if (sendMessageReturn != null) { return sendMessageReturn; } Modified: ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ReceiveDelivery.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ReceiveDelivery.ftl?view=diff&rev=565689&r1=565688&r2=565689 ============================================================================== --- ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ReceiveDelivery.ftl (original) +++ ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ReceiveDelivery.ftl Tue Aug 14 03:07:35 2007 @@ -50,29 +50,32 @@ <of:NOTES></of:NOTES> <of:RECEIPTYPE>RMA</of:RECEIPTYPE> <os:PARTNER> - <of:NAME>${postalAddress.toName?if_exists}</of:NAME> + <#if postalAddress?has_content> + <#if (partyNameView.firstName)?has_content><#assign partyName = partyNameView.firstName/></#if> + <#if (partyNameView.middleName)?has_content><#assign partyName = partyName + " " + partyNameView.middleName/></#if> + <#if (partyNameView.lastName)?has_content><#assign partyName = partyName + " " + partyNameView.lastName/></#if> + <of:NAME>${postalAddress.toName?default(partyName)?if_exists}</of:NAME> <of:PARTNRTYPE>SHIPFROM</of:PARTNRTYPE> <of:CURRENCY>USD</of:CURRENCY> - <#if postalAddress?has_content> - <os:ADDRESS> - <of:ADDRLINE>${postalAddress.address1?if_exists}</of:ADDRLINE> - <#if postalAddress.address2?exists> - <of:ADDRLINE>${postalAddress.address2?if_exists}</of:ADDRLINE> - </#if> - <of:CITY>${postalAddress.city?if_exists}</of:CITY> - <of:COUNTRY>${postalAddress.countryGeoId?if_exists}</of:COUNTRY> - <of:FAX></of:FAX> - <of:POSTALCODE>${postalAddress.postalCode?if_exists}</of:POSTALCODE> - <of:STATEPROVN>${postalAddress.stateProvinceGeoId?if_exists}</of:STATEPROVN> - <of:TELEPHONE>${telecomNumber.countryCode?if_exists}${telecomNumber.areaCode?if_exists}-${telecomNumber.contactNumber?if_exists}</of:TELEPHONE> - </os:ADDRESS> - <os:CONTACT> - <of:NAME>${postalAddress.toName?if_exists}</of:NAME> - <of:EMAIL>${emailString?if_exists}</of:EMAIL> - <of:FAX></of:FAX> - <of:TELEPHONE>${telecomNumber.countryCode?if_exists}${telecomNumber.areaCode?if_exists}-${telecomNumber.contactNumber?if_exists}</of:TELEPHONE> - </os:CONTACT> - </#if> + <os:ADDRESS> + <of:ADDRLINE>${postalAddress.address1?if_exists}</of:ADDRLINE> + <#if postalAddress.address2?has_content> + <of:ADDRLINE>${postalAddress.address2?if_exists}</of:ADDRLINE> + </#if> + <of:CITY>${postalAddress.city?if_exists}</of:CITY> + <of:COUNTRY>${postalAddress.countryGeoId?if_exists}</of:COUNTRY> + <#-- <of:FAX></of:FAX> --> + <of:POSTALCODE>${postalAddress.postalCode?if_exists}</of:POSTALCODE> + <of:STATEPROVN>${postalAddress.stateProvinceGeoId?if_exists}</of:STATEPROVN> + <of:TELEPHONE><#if telecomNumber.countryCode?has_content>${telecomNumber.countryCode}-</#if>${telecomNumber.areaCode?if_exists}-${telecomNumber.contactNumber?if_exists}</of:TELEPHONE> + </os:ADDRESS> + <os:CONTACT> + <of:NAME>${postalAddress.attnName?default(partyName)?if_exists}</of:NAME> + <of:EMAIL>${emailString?if_exists}</of:EMAIL> + <#-- <of:FAX></of:FAX> --> + <of:TELEPHONE><#if telecomNumber.countryCode?has_content>${telecomNumber.countryCode}-</#if>${telecomNumber.areaCode?if_exists}-${telecomNumber.contactNumber?if_exists}</of:TELEPHONE> + </os:CONTACT> + </#if> </os:PARTNER> </n:RECEIPTHDR> <n:RECEIPTUNT> @@ -82,9 +85,9 @@ <of:SIGN>+</of:SIGN> <of:UOM>EACH</of:UOM> </os:QUANTITY> - <n:RECEIPTITM> <#list returnItems as returnItem> <#assign returnReason = returnItem.getRelatedOne("ReturnReason")> + <n:RECEIPTITM> <os:QUANTITY> <of:VALUE>${returnItem.returnQuantity?if_exists}</of:VALUE> <of:NUMOFDEC>0</of:NUMOFDEC> @@ -98,11 +101,12 @@ <of:DOCUMENTID>${returnId?if_exists}</of:DOCUMENTID> <of:LINENUM>${returnItem.returnItemSeqId}</of:LINENUM> </os:DOCUMNTREF> - </#list> + <#-- TODO: fill this in if available --> <n:INVDETAIL> <of:SERIALNUM></of:SERIALNUM> </n:INVDETAIL> </n:RECEIPTITM> + </#list> </n:RECEIPTUNT> </n:RECEIVE_DELIVERY> </n:DATAAREA> |
Free forum by Nabble | Edit this page |