/** * Move this standard payload properties from the message to the xml. * @param message * @param msg * @param strKey */ public void setPayloadProperty(BaseMessage message, Object msg, String strKey, Class<?> classKey) { Object data = message.get(strKey); if (data == null) return; this.setPayloadProperty(data, msg, strKey, classKey); } /**
/** * Get the message queue registry ID from this message. * @param internalMessage The message to get the registry ID from. * @return Integer The registry ID. */ public Integer getRegistryID(BaseMessage internalMessageReply) { Integer intRegistryID = null; Object objRegistryID = null; if (internalMessageReply.getMessageHeader() instanceof TrxMessageHeader) // Always objRegistryID = ((TrxMessageHeader)internalMessageReply.getMessageHeader()).getMessageHeaderMap().get(TrxMessageHeader.REGISTRY_ID); if (objRegistryID == null) objRegistryID = internalMessageReply.get(TrxMessageHeader.REGISTRY_ID); if (objRegistryID instanceof Integer) intRegistryID = (Integer)objRegistryID; else if (objRegistryID instanceof String) { try { intRegistryID = new Integer(Integer.parseInt((String)objRegistryID)); } catch (NumberFormatException ex) { intRegistryID = null; } } return intRegistryID; } /**
/** * 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 } /**
internalMessage.addMessageDataDesc(new BaseProductMessageDesc(null, null)); BaseMessageHeader inMessageHeader = internalMessage.getMessageHeader(); String strMessage = (String)internalMessage.get(MESSAGE_PARAM); BaseMessageHeader messageReplyHeader = null; messageReplyHeader = new TrxMessageHeader(inMessageHeader.getQueueName(), inMessageHeader.getQueueType(), null);
/** * A record with this datasource handle changed, notify any behaviors that are checking. * NOTE: Be very careful as this code is running in an independent thread * (synchronize to the task before calling record calls). * NOTE: For now, you are only notified of the main record changes. * @param message The message to handle. * @return The error code. */ public int handleMessage(BaseMessage message) { System.out.println("---------------------------------------------------------- HotelSession/86"); if (message instanceof BaseMessage) { Double dblRate = (Double)message.get(BookingDetail.TOTAL_COST); if (message.get(HotelRateResponse.PRODUCT_RESPONSE_MESSAGE) instanceof HotelRateResponseMessageData) { dblRate = new Double(((HotelRateResponseMessageData)message.get(HotelRateResponse.PRODUCT_RESPONSE_MESSAGE)).getRoomCost(PaxCategory.DOUBLE_ID)); } MessageManager messageManager = ((Application)this.getTask().getApplication()).getMessageManager(); BaseMessageHeader messageFilter = message.getMessageHeader(); BaseMessageHeader messageHeader = new SessionMessageHeader(null, this); Map<String,Object> properties = new Hashtable<String,Object>(); properties.put("hotelCost", dblRate); BaseMessage messageTableUpdate = new MapMessage(messageHeader, properties); messageManager.sendMessage(messageTableUpdate); } return super.handleMessage(message); }
if (message.getMessageHeader().getRegistryIDMatch() != null) // My private message if (message.get(PingRequestMessageInProcessor.MESSAGE_PARAM) == null) String strMessage = (String)message.get(PingRequestMessageInProcessor.MESSAGE_PARAM); System.out.println("Message: " + strMessage); if ("Hello".equalsIgnoreCase(strMessage))
/** * SetDetailProperty Method. */ public void setDetailProperty(BaseMessage message, Record record, String iFieldSeq) { String strParamName = record.getField(iFieldSeq).getFieldName(); if (message.get(strParamName) != null) { if (message.get(strParamName) instanceof String) record.getField(iFieldSeq).setString((String)message.get(strParamName)); else record.getField(iFieldSeq).setData(message.get(strParamName)); } }
String strRecord = (String)message.get(RecordMessageConstants.TABLE_NAME); Record recordToSync = ((ReferenceField)this.getMainRecord().getField(TourHeaderDetail.MODIFY_ID)).getReferenceRecord(); if ((strRecord != null) && (strRecord.equals(recordToSync.getTableNames(false)))) String bookmark = (String)message.get(DBConstants.STRING_OBJECT_ID_HANDLE); int iRecordMessageType = DBConstants.SELECT_TYPE;
/** * Is this the correct message for this screen. * (Double-check to make sure the user still wants this price information) * @return True if the properties are correct. */ public boolean checkPriceProperties(BaseMessage map, Record recProduct) { Object objData = map.get(DBParams.TIMESTAMP); Object objLast = Double.toString(this.getField(ProductScreenRecord.LAST_CHANGED).getValue()); if (objData != null) if (objData.equals(objLast)) return true; // Same return false; } /**
String strRecord = (String)message.get(RecordMessageConstants.TABLE_NAME); Record recordToSync = ((ReferenceField)this.getMainRecord().getField(TourHeaderDetail.MODIFY_ID)).getReferenceRecord(); if ((strRecord != null) && (strRecord.equals(recordToSync.getTableNames(false)))) String bookmark = (String)message.get(DBConstants.STRING_OBJECT_ID_HANDLE); int iRecordMessageType = DBConstants.SELECT_TYPE;
/** * Is this the correct message for this screen. * (Double-check to make sure the user still wants this price information) * @return True if the properties are correct. */ public boolean checkPriceProperties(BaseMessage map, Record recProduct) { Object objData = map.get(DBParams.TIMESTAMP); Object objLast = Double.toString(this.getField(ProductScreenRecord.LAST_CHANGED).getValue()); if (objData != null) if (objData.equals(objLast)) return true; // Same return false; } /**
/** * Handle the message. */ public int handleMessage(BaseMessage message) { System.out.println("message: " + message); Double dblRate = (Double)message.get("hotelCost"); if (dblRate != null) // Display the rate this.getFieldList().getField("RoomPrice").setValue(dblRate.doubleValue()); return Constants.NORMAL_RETURN; } /**
/** * Process this internal message. * @param internalMessage The message to process. * @return (optional) The return message if applicable. */ public BaseMessage processMessage(BaseMessage internalMessage) { String strRoomType = (String)internalMessage.get("rateType"); String strRoomClass = (String)internalMessage.get("roomClass"); // Add code to lookup hotel rate here try { java.lang.Thread.currentThread().sleep(5000); // Simulate time for message turnaround } catch (InterruptedException ex) { } BaseMessage replyMessage = new MapMessage(); replyMessage.put(DBParams.FIELD, "multipleFields"); replyMessage.put("CityOrTown", "Los Angeles"); replyMessage.put("Contact", "Fred"); //? this.sendMessage(new BaseMessage(null, replyMessage)); return null; // No reply expected }
/** * Process this internal message. * @param internalMessage The message to process. * @return (optional) The return message if applicable. */ public BaseMessage processMessage(BaseMessage internalMessage) { String strRoomType = (String)internalMessage.get("rateType"); String strRoomClass = (String)internalMessage.get("roomClass"); // Add code to lookup hotel rate here try { java.lang.Thread.currentThread().sleep(5000); // Simulate time for message turnaround } catch (InterruptedException ex) { } BaseMessage replyMessage = new MapMessage(); replyMessage.put(DBParams.FIELD, "multipleFields"); replyMessage.put("CityOrTown", "Los Angeles"); replyMessage.put("Contact", "Fred"); //? this.sendMessage(new BaseMessage(null, replyMessage)); return null; // No reply expected }
/** * Handle this message. * Basically, if I get a message that the current record changed, I re-read the record. * @param The message to handle. * @return An error code. */ public int handleMessage(BaseMessage message) { try { int iMessageType = Integer.parseInt((String)message.get(MessageConstants.MESSAGE_TYPE_PARAM)); if ((iMessageType == Constants.AFTER_UPDATE_TYPE) || (iMessageType == Constants.CACHE_UPDATE_TYPE)) { // Record updated - be very careful, you are running in an independent thread. refreshItinerary(); } } catch (NumberFormatException ex) { // Ignore } return super.handleMessage(message); } };
/** * Convert this message map to the message map AutoRecordMessageListener * is expecting, so the correct fields will be updated. */ public void fixMessageMap(BaseMessage message) { message.put(DBParams.FIELD, MULTIPLE_FIELDS); String strAvailStatusParam = m_record.getField(Product.DISPLAY_INVENTORY_STATUS_ID).getFieldName(); Integer intMessageStatus = (Integer)message.get(BaseDataStatus.DATA_STATUS); int iMessageStatus = BaseStatus.VALID; if (intMessageStatus != null) iMessageStatus = intMessageStatus.intValue(); message.put(strAvailStatusParam, intMessageStatus.toString()); }
/** * Convert this message map to the message map AutoRecordMessageListener * is expecting, so the correct fields will be updated. */ public void fixMessageMap(BaseMessage message) { message.put(DBParams.FIELD, MULTIPLE_FIELDS); String strAvailStatusParam = m_record.getField(Product.DISPLAY_INVENTORY_STATUS_ID).getFieldName(); Integer intMessageStatus = (Integer)message.get(BaseDataStatus.DATA_STATUS); int iMessageStatus = BaseStatus.VALID; if (intMessageStatus != null) iMessageStatus = intMessageStatus.intValue(); message.put(strAvailStatusParam, intMessageStatus.toString()); }
/** * Get the external message container for this Internal message. * Typically, the overriding class supplies a default format for the transport type. * <br/>NOTE: The message header from the internal message is copies, but not the message itself. * @param The internalTrxMessage that I will convert to this external format. * @return The (empty) External message. */ public ExternalMessage createExternalMessage(BaseMessage message, Object rawData) { ExternalMessage externalTrxMessageOut = super.createExternalMessage(message, rawData); if (externalTrxMessageOut == null) { if (MessageType.MESSAGE_IN.equalsIgnoreCase((String)message.get(TrxMessageHeader.MESSAGE_PROCESS_TYPE))) externalTrxMessageOut = new XmlTrxMessageIn(message, rawData); else externalTrxMessageOut = new XmlTrxMessageOut(message, rawData); } return externalTrxMessageOut; } /**
/** * Get the external message container for this Internal message. * Typically, the overriding class supplies a default format for the transport type. * <br/>NOTE: The message header from the internal message is copies, but not the message itself. * @param The internalTrxMessage that I will convert to this external format. * @return The (empty) External message. */ public ExternalMessage createExternalMessage(BaseMessage message, Object rawData) { ExternalMessage externalTrxMessageOut = super.createExternalMessage(message, rawData); if (externalTrxMessageOut == null) { if (MessageType.MESSAGE_IN.equalsIgnoreCase((String)message.get(TrxMessageHeader.MESSAGE_PROCESS_TYPE))) externalTrxMessageOut = new SoapTrxMessageIn(message, rawData); else externalTrxMessageOut = new SoapTrxMessageOut(message, rawData); } return externalTrxMessageOut; } /**
/** * Get the external message container for this Internal message. * Typically, the overriding class supplies a default format for the transport type. * <br/>NOTE: The message header from the internal message is copies, but not the message itself. * @param The internalTrxMessage that I will convert to this external format. * @return The (empty) External message. */ public ExternalMessage createExternalMessage(BaseMessage message, Object rawData) { ExternalMessage externalTrxMessageOut = super.createExternalMessage(message, rawData); if (externalTrxMessageOut == null) { if (MessageTypeModel.MESSAGE_IN.equalsIgnoreCase((String)message.get(TrxMessageHeader.MESSAGE_PROCESS_TYPE))) externalTrxMessageOut = new XmlTrxMessageIn(message, rawData); else externalTrxMessageOut = new XmlTrxMessageOut(message, rawData); } return externalTrxMessageOut; } /**