/** * Process this internal message. * @param internalMessage The message to process. * @return (optional) The return message if applicable. */ public BaseMessage processMessage(BaseMessage internalMessage) { BaseMessage messageOrig = this.getOriginalMessage(internalMessage); BaseProductMessageDesc message = (BaseProductMessageDesc)internalMessage.getMessageDataDesc(null); if (messageOrig != null) { // Open the process message if (messageOrig.getMessageDataDesc(null) != null) if (messageOrig.getMessageDataDesc(null).getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE) instanceof ProductMessageData) { // Always ProductMessageData productRequest = (ProductMessageData)messageOrig.getMessageDataDesc(null).getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE); String strProductType = (String)productRequest.get(BookingDetail.PRODUCT_TYPE); this.openProductFile(strProductType); } } return super.processMessage(internalMessage); } /**
/** * Utility to add the standard payload properties to the message * @param msg * @param message */ public void addPayloadProperties(Object msg, BaseMessage message) { MessageDataDesc messageDataDesc = message.getMessageDataDesc(null); // Top level only if (messageDataDesc != null) { Map<String,Class<?>> mapPropertyNames = messageDataDesc.getPayloadPropertyNames(null); if (mapPropertyNames != null) { Map<String,Object> properties = this.getPayloadProperties(msg, mapPropertyNames); for (String key : properties.keySet()) { message.put(key, properties.get(key)); } } } } /**
/** * Convert the external form to the internal message form. * You must override this method. * @param externalMessage The received message to be converted to internal form. * @return The internal message. */ public int convertExternalToInternal(Object recordOwner) { String strMessage = (String)this.getRawData(); strMessage = this.stripHtmlTags((String)strMessage); Map<String,Object> map = this.getEMailParams(strMessage); this.moveHeaderParams(map, ((TrxMessageHeader)this.getMessage().getMessageHeader()).getMessageHeaderMap()); String rootTag = BaseMessage.ROOT_TAG; if (this.getMessage() != null) if (this.getMessage().getMessageDataDesc(null) != null) if (this.getMessage().getMessageDataDesc(null).getKey() != null) rootTag = this.getMessage().getMessageDataDesc(null).getKey(); StringBuffer sb = new StringBuffer(); Util.addStartTag(sb, rootTag); Util.addXMLMap(sb, map); Util.addEndTag(sb, rootTag); String strXML = sb.toString(); if (this.getXSLTDocument() != null) strXML = this.transformMessage(strXML, null); // Now use the XSLT document to convert this XSL document. boolean bSuccess = this.getMessage().setXML(strXML); return bSuccess ? DBConstants.NORMAL_RETURN : DBConstants.ERROR_RETURN; } /**
/** * Move the original(sent) message params to this screen. */ public void moveMessageParamsToScreen(BaseMessage message) { Record screenRecord = this.getScreenRecord(); ProductMessageData messageData = (ProductMessageData)message.getMessageDataDesc(null).getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE); messageData.getRawFieldData(screenRecord.getField(ProductInfoScreenRecord.PRODUCT_ID)); messageData.getRawFieldData(screenRecord.getField(ProductInfoScreenRecord.RATE_ID)); messageData.getRawFieldData(screenRecord.getField(ProductInfoScreenRecord.CLASS_ID)); messageData.getRawFieldData(screenRecord.getField(ProductInfoScreenRecord.DETAIL_DATE)); } /**
/** * Move the standard payload properties from the message to the xml. * @param message * @param msg */ public void setPayloadProperties(BaseMessage message, Object msg) { MessageDataDesc messageDataDesc = message.getMessageDataDesc(null); // Top level only if (messageDataDesc != null) { Map<String,Class<?>> mapPropertyNames = messageDataDesc.getPayloadPropertyNames(null); if (mapPropertyNames != null) { for (String strKey : mapPropertyNames.keySet()) { Class<?> classKey = mapPropertyNames.get(strKey); this.setPayloadProperty(message, msg, strKey, classKey); } } } if (message.get("Version") == null) this.setPayloadProperty(DEFAULT_VERSION, msg, "Version", Float.class); this.setPayloadProperty(this.getTimeStamp(), msg, "TimeStamp", org.joda.time.DateTime.class); // Current timestamp } /**
/** * Move the original(sent) message params to this screen. */ public void moveMessageParamsToScreen(BaseMessage message) { Record screenRecord = this.getScreenRecord(); ProductMessageData messageData = (ProductMessageData)message.getMessageDataDesc(null).getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE); messageData.getRawFieldData(screenRecord.getField(ProductInfoScreenRecord.PRODUCT_ID)); messageData.getRawFieldData(screenRecord.getField(ProductInfoScreenRecord.RATE_ID)); messageData.getRawFieldData(screenRecord.getField(ProductInfoScreenRecord.CLASS_ID)); messageData.getRawFieldData(screenRecord.getField(ProductInfoScreenRecord.DETAIL_DATE)); } /**
if (messageOrig.getMessageDataDesc(null).getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE) instanceof ProductMessageData) ProductMessageData productRequest = (ProductMessageData)messageOrig.getMessageDataDesc(null).getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE); productRequest.setDataIndex(index, null); if ((productRequest.get(BookingDetail.PRODUCT_ID) == null) && (productRequest.get(Product.CODE) == null)) break; // End of product descriptions ProductResponseMessageData productResponse = (ProductResponseMessageData)message.getMessageDataDesc(null).getMessageDataDesc(BaseProductResponse.PRODUCT_RESPONSE_MESSAGE);