/** * Get the cost or inventory information from the product now. * @return The message status. */ public int getDirectProductInfo(Product recProduct, BaseMessage message) { BaseProductResponse response = (BaseProductResponse)((BaseMessage)recProduct.processAvailabilityRequestInMessage(message, null, null)).getMessageDataDesc(null); if (response != null) return response.getMessageDataStatus(); return BaseStatus.NOT_VALID; } /**
/** * Get the cost or inventory information from the product now. * @return The message status. */ public int getDirectProductInfo(Product recProduct, BaseMessage message) { BaseProductResponse response = (BaseProductResponse)((BaseMessage)recProduct.processAvailabilityRequestInMessage(message, null, null)).getMessageDataDesc(null); if (response != null) return response.getMessageDataStatus(); return BaseStatus.NOT_VALID; } /**
/** * 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)); } } } } /**
/** * Process this product information request (override this). */ public Message processInfoRequestInMessage(Message messageIn, Message messageReply) { MessageRecordDesc productRequest = (ProductRequest)((BaseMessage)messageIn).getMessageDataDesc(null); MessageRecordDesc messageData = (ProductMessageData)productRequest.getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE); BaseProductResponse responseMessage = null; if (messageReply == null) messageReply = (BaseMessage)this.getMessageProcessInfo().createReplyMessage((BaseMessage)messageData.getMessage()); responseMessage = (BaseProductResponse)((BaseMessage)messageReply).getMessageDataDesc(null); responseMessage.moveRequestInfoToReply(messageIn); int iProductStatus = InventoryStatus.VALID; //?String strErrorMessage = null; //?this.getField(Product.DISPLAY_INFO_STATUS_ID).setValue(iProductStatus); responseMessage.setMessageDataStatus(iProductStatus); //?if (strErrorMessage != null) //? responseMessage.setMessageDataError(strErrorMessage); return messageReply; } /**
/** * Process this product information request (override this). */ public Message processInfoRequestInMessage(Message messageIn, Message messageReply) { MessageRecordDesc productRequest = (ProductRequest)((BaseMessage)messageIn).getMessageDataDesc(null); MessageRecordDesc messageData = (ProductMessageData)productRequest.getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE); BaseProductResponse responseMessage = null; if (messageReply == null) messageReply = (BaseMessage)this.getMessageProcessInfo().createReplyMessage((BaseMessage)messageData.getMessage()); responseMessage = (BaseProductResponse)((BaseMessage)messageReply).getMessageDataDesc(null); responseMessage.moveRequestInfoToReply(messageIn); int iProductStatus = InventoryStatus.VALID; //?String strErrorMessage = null; //?this.getField(Product.DISPLAY_INFO_STATUS_ID).setValue(iProductStatus); responseMessage.setMessageDataStatus(iProductStatus); //?if (strErrorMessage != null) //? responseMessage.setMessageDataError(strErrorMessage); return messageReply; } /**
/** * 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 } /**
/** * Convert this message map to the message map AutoRecordMessageListener * is expecting, so the correct fields will be updated. */ public void fixMessageMap(BaseMessage message) { super.fixMessageMap(message); HotelRateResponse productRateResponse = (HotelRateResponse)message.getMessageDataDesc(null); HotelRateResponseMessageData messageData = (HotelRateResponseMessageData)productRateResponse.getMessageDataDesc(BaseProductResponse.PRODUCT_RESPONSE_MESSAGE); String strDoubleCostParam = m_record.getField(Hotel.DOUBLE_COST).getFieldName(); Double dblProductCost = (Double)messageData.get(BookingDetailModel.TOTAL_COST); if (dblProductCost == null) dblProductCost = DoubleField.ZERO; message.put(strDoubleCostParam, dblProductCost.toString()); } /**
/** * Process this internal message. * @param internalMessage The message to process. * @return (optional) The return message if applicable. */ public BaseMessage processMessage(BaseMessage internalMessage) { ProductRequest msgProductAvailRequestIn = (ProductRequest)internalMessage.getMessageDataDesc(null); Product recProduct = (Product)this.getMainRecord(); if (recProduct == null) recProduct = this.getProductRecord(); if (!((ProductMessageData)msgProductAvailRequestIn.getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE)).getProduct(recProduct)) { // Error, hotel not found // pend(don) } BaseProductResponse productAvailResponseOut = (BaseProductResponse)((BaseMessage)recProduct.processAvailabilityRequestInMessage((BaseMessage)msgProductAvailRequestIn.getMessage(), null, null)).getMessageDataDesc(null); // ProductAvailabilityResponse BaseProductResponse productRateResponseOut = (BaseProductResponse)((BaseMessage)recProduct.processCostRequestInMessage((BaseMessage)msgProductAvailRequestIn.getMessage(), null)).getMessageDataDesc(null); TrxMessageHeader messageHeader = (TrxMessageHeader)productAvailResponseOut.getMessage().getMessageHeader(); //?Map<String,Object> mapMessage = productAvailResponseOut.getMap(); //?Map<String,Object> mapMessage2 = productRateResponseOut.getMap(); //?mapMessage.putAll(mapMessage2); BaseMessage response = null;//?new BaseMessage(messageHeader, new HotelRateAvailResponse(null, mapMessage)); return response; }
/** * Move to entered fields to the return message. */ public void moveScreenParamsToMessage(BaseMessage message) { super.moveScreenParamsToMessage(message); ProductResponseMessageData messageData = (ProductResponseMessageData)message.getMessageDataDesc(BaseProductResponse.PRODUCT_RESPONSE_MESSAGE); Double dblHotelCost = (Double)this.getScreenRecord().getField(HotelInfoScreenRecord.TOTAL_COST).getData(); messageData.put(BookingDetail.TOTAL_COST, dblHotelCost); }
/** * Convert this message map to the message map AutoRecordMessageListener * is expecting, so the correct fields will be updated. */ public void fixMessageMap(BaseMessage message) { super.fixMessageMap(message); HotelRateResponse productRateResponse = (HotelRateResponse)message.getMessageDataDesc(null); HotelRateResponseMessageData messageData = (HotelRateResponseMessageData)productRateResponse.getMessageDataDesc(BaseProductResponse.PRODUCT_RESPONSE_MESSAGE); String strDoubleCostParam = m_record.getField(Hotel.DOUBLE_COST).getFieldName(); Double dblProductCost = (Double)messageData.get(BookingDetailModel.TOTAL_COST); if (dblProductCost == null) dblProductCost = DoubleField.ZERO; message.put(strDoubleCostParam, dblProductCost.toString()); } /**
/** * 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 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 to entered fields to the return message. */ public void moveScreenParamsToMessage(BaseMessage message) { super.moveScreenParamsToMessage(message); ProductResponseMessageData messageData = (ProductResponseMessageData)message.getMessageDataDesc(BaseProductResponse.PRODUCT_RESPONSE_MESSAGE); Double dblCost = (Double)this.getScreenRecord().getField(ProductInfoScreenRecord.TOTAL_COST).getData(); messageData.put(BookingDetail.TOTAL_COST, dblCost); Integer intAvailability = (Integer)this.getScreenRecord().getField(ProductInfoScreenRecord.AVAILABILITY).getData(); messageData.put(Product.AVAILABILITY_PARAM, intAvailability); String strConfirmationNo = this.getScreenRecord().getField(ProductInfoScreenRecord.CONFIRMATION_NO).getString(); messageData.put(Product.CONFIRMATION_NO_PARAM, strConfirmationNo); String strConfirmedBy = this.getScreenRecord().getField(ProductInfoScreenRecord.CONFIRMED_BY).getString(); messageData.put(Product.CONFIRMED_BY_PARAM, strConfirmedBy); BaseProductResponse productResponseData = (BaseProductResponse)message.getMessageDataDesc(null); productResponseData.setMessageDataStatus(MessageDataDesc.VALID); // Change this in the overriding class if not valid }
/** * Move to entered fields to the return message. */ public void moveScreenParamsToMessage(BaseMessage message) { super.moveScreenParamsToMessage(message); ProductResponseMessageData messageData = (ProductResponseMessageData)message.getMessageDataDesc(BaseProductResponse.PRODUCT_RESPONSE_MESSAGE); Double dblCost = (Double)this.getScreenRecord().getField(ProductInfoScreenRecord.TOTAL_COST).getData(); messageData.put(BookingDetail.TOTAL_COST, dblCost); Integer intAvailability = (Integer)this.getScreenRecord().getField(ProductInfoScreenRecord.AVAILABILITY).getData(); messageData.put(Product.AVAILABILITY_PARAM, intAvailability); String strConfirmationNo = this.getScreenRecord().getField(ProductInfoScreenRecord.CONFIRMATION_NO).getString(); messageData.put(Product.CONFIRMATION_NO_PARAM, strConfirmationNo); String strConfirmedBy = this.getScreenRecord().getField(ProductInfoScreenRecord.CONFIRMED_BY).getString(); messageData.put(Product.CONFIRMED_BY_PARAM, strConfirmedBy); BaseProductResponse productResponseData = (BaseProductResponse)message.getMessageDataDesc(null); productResponseData.setMessageDataStatus(MessageDataDesc.VALID); // Change this in the overriding class if not valid }
/** * Set up the properties for a price lookup. */ public void setPriceProperties(BaseMessage message, Record recProduct) { ProductRequest productRequest = (ProductRequest)message.getMessageDataDesc(null); ProductMessageData productMessageData = (ProductMessageData)productRequest.getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE); PassengerMessageData passengerMessageData = (PassengerMessageData)productRequest.getMessageDataDesc(ProductRequest.PASSENGER_MESSAGE); this.addMapProperty(productMessageData, BookingDetailModel.DETAIL_DATE, this, ProductScreenRecord.DETAIL_DATE); this.addMapProperty(productMessageData, BookingDetailModel.PRODUCT_ID, recProduct, Product.ID); this.addMapProperty(passengerMessageData, Product.PAX_PARAM, this, ProductScreenRecord.PAX); if (this.getField(ProductScreenRecord.PAX).getValue() == 2) // Default passengerMessageData.put(Product.ROOM_TYPE_PARAM + Integer.toString(PaxCategory.DOUBLE_ID), new Short((short)2)); // Two pax in a double room try { productRequest.put(DBConstants.STRING_OBJECT_ID_HANDLE, recProduct.getHandle(DBConstants.OBJECT_ID_HANDLE)); } catch (DBException ex) { ex.printStackTrace(); } // Land only productMessageData.put(Land.SIC_PMC_PARAM, LandClass.PRIVATE_VEHICLE_CODE); // Others productRequest.put(DBParams.RECORD, recProduct.getTableNames(false)); productRequest.put(DBParams.TIMESTAMP, Double.toString(this.getField(ProductScreenRecord.LAST_CHANGED).getValue())); this.addMapProperty(productMessageData, BookingDetailModel.RATE_ID, this, ProductScreenRecord.RATE_ID); this.addMapProperty(productMessageData, BookingDetailModel.CLASS_ID, this, ProductScreenRecord.CLASS_ID); } /**
/** * Process this internal message. * @param internalMessage The message to process. * @return (optional) The return message if applicable. */ public BaseMessage processMessage(BaseMessage internalMessage) { ProductRequest productRequestInMessage = (ProductRequest)internalMessage.getMessageDataDesc(null); Product recProduct = (Product)this.getMainRecord(); if (recProduct == null) recProduct = this.getProductRecord(); ProductMessageData productMessageDesc = (ProductMessageData)productRequestInMessage.getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE); BaseMessage messageReply = null; if (productMessageDesc != null) { for (int index = 1; ;index++) { productMessageDesc.setNodeIndex(index, null); if ((productMessageDesc.get(BookingDetail.PRODUCT_ID) == null) && (productMessageDesc.get(Product.CODE) == null)) break; // End of product descriptions if (!(productMessageDesc.getProduct(recProduct))) { // Error, product not found // pend(don) } messageReply = (BaseMessage)recProduct.processCostRequestInMessage(internalMessage, messageReply); } } return messageReply; }
/** * Process this internal message. * @param internalMessage The message to process. * @return (optional) The return message if applicable. */ public BaseMessage processMessage(BaseMessage internalMessage) { ProductRequest productRequestInMessage = (ProductRequest)internalMessage.getMessageDataDesc(null); Product recProduct = (Product)this.getMainRecord(); if (recProduct == null) recProduct = this.getProductRecord(); ProductMessageData productMessageDesc = (ProductMessageData)productRequestInMessage.getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE); BaseMessage messageReply = null; if (productMessageDesc != null) { for (int index = 1; ;index++) { productMessageDesc.setNodeIndex(index, null); if ((productMessageDesc.get(BookingDetail.PRODUCT_ID) == null) && (productMessageDesc.get(Product.CODE) == null)) break; // End of product descriptions if (!(productMessageDesc.getProduct(recProduct))) { // Error, product not found // pend(don) } messageReply = (BaseMessage)recProduct.processInfoRequestInMessage(internalMessage, messageReply); } } return messageReply; }
/** * Process this internal message. * @param internalMessage The message to process. * @return (optional) The return message if applicable. */ public BaseMessage processMessage(BaseMessage internalMessage) { ProductRequest productRequestInMessage = (ProductRequest)internalMessage.getMessageDataDesc(null); Product recProduct = (Product)this.getMainRecord(); if (recProduct == null) recProduct = this.getProductRecord(); ProductMessageData productMessageDesc = (ProductMessageData)productRequestInMessage.getMessageDataDesc(ProductRequest.PRODUCT_MESSAGE); BaseMessage messageReply = null; if (productMessageDesc != null) { for (int index = 1; ;index++) { productMessageDesc.setNodeIndex(index, null); if ((productMessageDesc.get(BookingDetail.PRODUCT_ID) == null) && (productMessageDesc.get(Product.CODE) == null)) break; // End of product descriptions if (!(productMessageDesc.getProduct(recProduct))) { // Error, product not found // pend(don) } messageReply = (BaseMessage)recProduct.processAvailabilityRequestInMessage(internalMessage, messageReply, null); } } return messageReply; }