Author: apatel
Date: Mon Jun 25 23:28:08 2007 New Revision: 550708 URL: http://svn.apache.org/viewvc?view=rev&rev=550708 Log: First cut of sendConfirmBod service and template. Added: ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ConfirmBod.ftl Modified: ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java ofbiz/trunk/specialpurpose/oagis/widget/MessageInfoScreens.xml Modified: ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml?view=diff&rev=550708&r1=550707&r2=550708 ============================================================================== --- ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml (original) +++ ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml Mon Jun 25 23:28:08 2007 @@ -54,6 +54,21 @@ <description>Process incoming shipment message</description> <implements service="serviceStreamInterface"/> </service> + + <service name="sendConfirmBod" engine="java" transaction-timeout="300" + location="org.ofbiz.oagis.OagisServices" invoke="sendConfirmBod" auth="false"> + <description>Send ConfirmBod</description> + <attribute name="logicalId" type="String" mode="IN" optional="false"/> + <attribute name="component" type="String" mode="IN" optional="false"/> + <attribute name="task" type="String" mode="IN" optional="false"/> + <attribute name="referenceId" type="String" mode="IN" optional="false"/> + <attribute name="description" type="String" mode="IN" optional="true"/> + <attribute name="reasonCode" type="String" mode="IN" optional="true"/> + <attribute name="orderId" type="String" mode="IN" optional="true"/> + <attribute name="returnId" type="String" mode="IN" optional="true"/> + <attribute name="shipmentId" type="String" mode="IN" optional="true"/> + </service> + <service name="receiveConfirmBod" engine="java" transaction-timeout="300" location="org.ofbiz.oagis.OagisServices" invoke="receiveConfirmBod" auth="false"> <description>Process incoming ConfirmBod</description> 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=550708&r1=550707&r2=550708 ============================================================================== --- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java (original) +++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java Mon Jun 25 23:28:08 2007 @@ -22,15 +22,16 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.sql.Timestamp; import java.util.HashMap; import java.util.Map; import org.ofbiz.base.util.*; -import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ServiceUtil; import org.w3c.dom.Document; @@ -41,7 +42,95 @@ public static final String module = OagisServices.class.getName(); public static Map sendConfirmBod(DispatchContext ctx, Map context) { - return ServiceUtil.returnError("Service not Implemented"); + + GenericDelegator delegator = ctx.getDelegator(); + LocalDispatcher dispatcher = ctx.getDispatcher(); + OutputStream out = (OutputStream) context.get("outputStream"); + + Map bodyParameters = new HashMap(); + Map confirmBodContext = new HashMap(); + Map oagisMsgInfoContext = new HashMap(); + String bodyScreenUri = "component://oagis/widget/MessageInfoScreens.xml#ConfirmBod"; + Timestamp timestamp = null; + timestamp = UtilDateTime.nowTimestamp(); + GenericValue userLogin = null; + try + { + userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "admin")); + } catch (GenericEntityException e) { + Debug.logError(e, "Error getting userLogin", module); + } + + String logicalId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.LOGICALID"); + String authId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.AUTHID"); + String referenceId = delegator.getNextSeqId("OagisMessageInfo"); + + String errorLogicalId = (String) context.get("logicalId"); + String errorComponent = (String) context.get("component"); + String errorTask = (String) context.get("task"); + String errorReferenceId = (String) context.get("referenceId"); + String errorDescription = (String) context.get("description"); + String errorReasonCode = (String) context.get("reasonCode"); + + bodyParameters.put("logicalId", logicalId); + bodyParameters.put("referenceId", referenceId); + bodyParameters.put("authId", authId); + bodyParameters.put("sentDate", timestamp); + + bodyParameters.put("errorLogicalId", errorLogicalId); + bodyParameters.put("errorComponent", errorComponent); + bodyParameters.put("errorTask", errorTask); + bodyParameters.put("errorReferenceId", errorReferenceId); + bodyParameters.put("errorDescription", errorDescription); + bodyParameters.put("errorReasonCode", errorReasonCode); + + if (((String) context.get("orderId")) != null){ + String origRef = (String) context.get("orderId"); + bodyParameters.put("origRef", origRef); + } else + if (((String) context.get("returnId")) != null){ + String origRef = (String) context.get("returnId"); + bodyParameters.put("origRef", origRef); + }else + if (((String) context.get("shipmentId")) != null){ + String origRef = (String) context.get("shipmentId"); + bodyParameters.put("origRef", origRef); + } + + confirmBodContext.put("bodyParameters", bodyParameters); + confirmBodContext.put("bodyScreenUri", bodyScreenUri); + + try + { + Map exportMsgResult = dispatcher.runSync("exportMsgFromScreen", confirmBodContext); + if (ServiceUtil.isError(exportMsgResult)) return exportMsgResult; + String messageBody = (String)exportMsgResult.get("body"); + PrintWriter writer = new PrintWriter(new OutputStreamWriter(out)); + writer.print(messageBody); + } catch (GenericServiceException e){ + Debug.logError(e, "Error while generating message", module); + } + + oagisMsgInfoContext.put("logicalId", logicalId); + oagisMsgInfoContext.put("component", "EXCEPTION"); + oagisMsgInfoContext.put("task", "RECIEPT"); + oagisMsgInfoContext.put("referenceId", referenceId); + oagisMsgInfoContext.put("authId", authId); + oagisMsgInfoContext.put("sentDate", timestamp); + oagisMsgInfoContext.put("confirmation", "0"); + oagisMsgInfoContext.put("bsrVerb", "CONFIRM"); + oagisMsgInfoContext.put("bsrNoun", "BOD"); + oagisMsgInfoContext.put("bsrRevision", "004"); + oagisMsgInfoContext.put("userLogin", userLogin); + + try + { + Map oagisMsgInfoResult = dispatcher.runSync("createOagisMessageInfo", oagisMsgInfoContext); + if (ServiceUtil.isError(oagisMsgInfoResult)) return oagisMsgInfoResult; + } catch (GenericServiceException e) { + Debug.logError(e, "Saving message to database failed", module); + } + return ServiceUtil.returnSuccess("Service Completed Successfully"); } public static Map receiveConfirmBod(DispatchContext ctx, Map context) { @@ -53,6 +142,8 @@ Map oagisMsgInfoContext = new HashMap(); Map oagisMsgErrorContext = new HashMap(); GenericValue userLogin = null; + Timestamp timestamp = null; + timestamp = UtilDateTime.nowTimestamp(); String errMsg = null; try{ userLogin = delegator.findByPrimaryKey("UserLogin",UtilMisc.toMap("userLoginId","admin")); @@ -82,6 +173,7 @@ oagisMsgInfoContext.put("task", task); oagisMsgInfoContext.put("referenceId", referenceId); oagisMsgInfoContext.put("authId", authId); + oagisMsgInfoContext.put("recievedDate", timestamp); oagisMsgInfoContext.put("confirmation", confirmation); oagisMsgInfoContext.put("bsrVerb", bsrVerb); oagisMsgInfoContext.put("bsrNoun", bsrNoun); Added: ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ConfirmBod.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ConfirmBod.ftl?view=auto&rev=550708 ============================================================================== --- ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ConfirmBod.ftl (added) +++ ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ConfirmBod.ftl Mon Jun 25 23:28:08 2007 @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +<n:CONFIRM_BOD_004 xmlns:n="http://www.openapplications.org/002_confirm_bod_004" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openapplications.org/002_confirm_bod_004 file:///C:/Documents%20and%20Settings/022523/My%20Documents/Vudu/XML%20Specs/OAG%20721/002_confirm_bod_004.xsd" xmlns:N1="http://www.openapplications.org/oagis_segments" xmlns:N2="http://www.openapplications.org/oagis_fields"> + <N1:CNTROLAREA> + <N1:BSR> + <N2:VERB>CONFIRM</N2:VERB> + <N2:NOUN>BOD</N2:NOUN> + <N2:REVISION>004</N2:REVISION> + </N1:BSR> + <N1:SENDER> + <N2:LOGICALID>${logicalId?if_exists}</N2:LOGICALID> + <N2:COMPONENT>EXCEPTION</N2:COMPONENT> + <N2:TASK>RECEIPT</N2:TASK> + <N2:REFERENCEID>${referenceId?if_exists}</N2:REFERENCEID> + <N2:CONFIRMATION>1</N2:CONFIRMATION> + <N2:LANGUAGE>ENG</N2:LANGUAGE> + <N2:CODEPAGE>NONE</N2:CODEPAGE> + <N2:AUTHID>${authId?if_exists}</N2:AUTHID> + </N1:SENDER> + <N1:DATETIMEANY>${sentDate?if_exists}</N1:DATETIMEANY> + </N1:CNTROLAREA> + <n:DATAAREA> + <n:CONFIRM_BOD> + <n:CONFIRM> + <N1:CNTROLAREA> + <N1:SENDER> + <N2:LOGICALID>${errorLogicalId?if_exists}</N2:LOGICALID> + <N2:COMPONENT>${errorComponent?if_exists}</N2:COMPONENT> + <N2:TASK>${errorTask?if_exists}</N2:TASK> + <N2:REFERENCEID>${errorReferenceId?if_exists}</N2:REFERENCEID> + </N1:SENDER> + <N1:DATETIMEANY></N1:DATETIMEANY> + </N1:CNTROLAREA> + <N2:ORIGREF>${origRef?if_exists}</N2:ORIGREF> + <n:CONFIRMMSG> + <N2:DESCRIPTN>${errorDescription?if_exists}</N2:DESCRIPTN> + <N2:REASONCODE>${errorReasonCode?if_exists}</N2:REASONCODE> + </n:CONFIRMMSG> + </n:CONFIRM> + </n:CONFIRM_BOD> + </n:DATAAREA> +</n:CONFIRM_BOD_004> Modified: ofbiz/trunk/specialpurpose/oagis/widget/MessageInfoScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/widget/MessageInfoScreens.xml?view=diff&rev=550708&r1=550707&r2=550708 ============================================================================== --- ofbiz/trunk/specialpurpose/oagis/widget/MessageInfoScreens.xml (original) +++ ofbiz/trunk/specialpurpose/oagis/widget/MessageInfoScreens.xml Mon Jun 25 23:28:08 2007 @@ -116,4 +116,14 @@ </section> </screen> + <screen name="ConfirmBod"> + <section> + <widgets> + <platform-specific> + <html><html-template location="component://oagis/webapp/oagis/message/ConfirmBod.ftl"/></html> + </platform-specific> + </widgets> + </section> + </screen> + </screens> |
Free forum by Nabble | Edit this page |