/** * 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()); }
/** * 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 }
/** * Convert the external form to the internal message form. * You must override this method. * @param root The root object of the marshallable object. * @param recordOwner The recordowner * @return The error code. */ public int convertMarshallableObjectToInternal(Object root, RecordOwner recordOwner) { if (root instanceof ConversionRateResponse) { // Always ConversionRateResponse msg = (ConversionRateResponse)root; double rate = msg.getConversionRateResult(); BaseMessage message = this.getMessage(); message.put(ManualMessage.MESSAGE_PARAM, rate); } return DBConstants.NORMAL_RETURN; }
/** * Convert this message map to the message map AutoRecordMessageListener * is expecting, so the correct fields will be updated. */ public void fixMessageMap(BaseMessage message) { ProductRateResponse productRateResponse = this.addMessageDesc(message); ProductRateResponseMessageData messageData = (ProductRateResponseMessageData)productRateResponse.getMessageDataDesc(BaseProductResponse.PRODUCT_RESPONSE_MESSAGE); message.put(DBParams.FIELD, MULTIPLE_FIELDS); String strProductCostParam = m_record.getField(Product.PRODUCT_COST).getFieldName(); Double dblProductCost = (Double)messageData.get(BookingDetailModel.TOTAL_COST); if (dblProductCost == null) dblProductCost = DoubleField.ZERO; message.put(strProductCostParam, dblProductCost.toString()); String strCostStatusParam = m_record.getField(Product.DISPLAY_COST_STATUS_ID).getFieldName(); Integer intProductStatus = (Integer)productRateResponse.get(BaseDataStatus.DATA_STATUS); if (intProductStatus == null) intProductStatus = BaseStatus.VALID; message.put(strCostStatusParam, intProductStatus.toString()); } /**
/** * 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 this message map to the message map AutoRecordMessageListener * is expecting, so the correct fields will be updated. */ public void fixMessageMap(BaseMessage message) { ProductRateResponse productRateResponse = this.addMessageDesc(message); ProductRateResponseMessageData messageData = (ProductRateResponseMessageData)productRateResponse.getMessageDataDesc(BaseProductResponse.PRODUCT_RESPONSE_MESSAGE); message.put(DBParams.FIELD, MULTIPLE_FIELDS); String strProductCostParam = m_record.getField(Product.PRODUCT_COST).getFieldName(); Double dblProductCost = (Double)messageData.get(BookingDetailModel.TOTAL_COST); if (dblProductCost == null) dblProductCost = DoubleField.ZERO; message.put(strProductCostParam, dblProductCost.toString()); String strCostStatusParam = m_record.getField(Product.DISPLAY_COST_STATUS_ID).getFieldName(); Integer intProductStatus = (Integer)productRateResponse.get(BaseDataStatus.DATA_STATUS); if (intProductStatus == null) intProductStatus = BaseStatus.VALID; message.put(strCostStatusParam, intProductStatus.toString()); } /**
/** * 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 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()); } /**
public void addMessageProperty(BaseMessage message, Record screenRecord, String iFieldSeq) { if (!screenRecord.getField(iFieldSeq).isNull()) message.put(screenRecord.getField(iFieldSeq).getFieldName(), screenRecord.getField(iFieldSeq).toString()); } });
messageIn.put(key, propMessage.get(key));
messageIn.put(key, propMessage.get(key));
/** 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. */ public int handleMessage(BaseMessage message) { Record record = this.getMainRecord(); // Record changed if ((record.getTable() instanceof GridTable) // Always except HTML && (message.getMessageHeader() != null) && (message.getMessageHeader() instanceof RecordMessageHeader)) { int iIndex = -1; synchronized (this.getTask()) { iIndex = ((GridTable)record.getTable()).updateGridToMessage(message, true, true); } if (iIndex != -1) { // This screen has changed, add this clue so a remote thin table will know where the change was. message.put(ModelMessageHandler.START_INDEX_PARAM, Integer.toString(iIndex)); } } return super.handleMessage(message); } /**
/** * If you are sending a thick message to a thin client, convert it first. * Since BaseMessage is already, so conversion is necessary... return this message. * @return this message. */ public BaseMessage convertToThinMessage() { int iChangeType = ((RecordMessageHeader)this.getMessageHeader()).getRecordMessageType(); // See if this record is currently displayed or buffered, if so, refresh and display. Object data = this.getData(); BaseMessage messageTableUpdate = null; // NOTE: The only way I will send this message to the client is if the ModelMessageHandler.START_INDEX_PARAM has been added to this message by the TableSession // if (properties.get(ModelMessageHandler.START_INDEX_PARAM) != null) { BaseMessageHeader messageHeader = new SessionMessageHeader(this.getMessageHeader().getQueueName(), this.getMessageHeader().getQueueType(), null, this); messageTableUpdate = new MapMessage(messageHeader, data); messageTableUpdate.put(MessageConstants.MESSAGE_TYPE_PARAM, Integer.toString(iChangeType)); } return messageTableUpdate; } }
/** * If you are sending a thick message to a thin client, convert it first. * Since BaseMessage is already, so conversion is necessary... return this message. * @return this message. */ public BaseMessage convertToThinMessage() { int iChangeType = ((RecordMessageHeader)this.getMessageHeader()).getRecordMessageType(); // See if this record is currently displayed or buffered, if so, refresh and display. Object data = this.getData(); BaseMessage messageTableUpdate = null; // NOTE: The only way I will send this message to the client is if the ModelMessageHandler.START_INDEX_PARAM has been added to this message by the TableSession // if (properties.get(ModelMessageHandler.START_INDEX_PARAM) != null) { BaseMessageHeader messageHeader = new SessionMessageHeader(this.getMessageHeader().getQueueName(), this.getMessageHeader().getQueueType(), null, this); messageTableUpdate = new MapMessage(messageHeader, data); messageTableUpdate.put(MessageConstants.MESSAGE_TYPE_PARAM, Integer.toString(iChangeType)); } return messageTableUpdate; } }
message.put(ManualMessage.MESSAGE_PARAM, strMessage); // The physical message if (trxMessageHeader.get(TrxMessageHeader.MESSAGE_PROCESSOR_CLASS) == null) trxMessageHeader.put(TrxMessageHeader.MESSAGE_PROCESSOR_CLASS, BaseMessageOutProcessor.class.getName()); // Default processor
messageReply.addMessageDataDesc(productResponse); if (strMessage != null) messageReply.put(MESSAGE_PARAM, strMessage); else
message.put(PingRequestMessageInProcessor.MESSAGE_PARAM, "Hello"); if (!MessageTransport.DIRECT.equalsIgnoreCase((String)trxMessageHeader.get(MessageTransport.SEND_MESSAGE_BY_PARAM))) message.put(PingRequestMessageInProcessor.MESSAGE_PARAM, "CHF"); if (!MessageTransport.DIRECT.equalsIgnoreCase((String)trxMessageHeader.get(MessageTransport.SEND_MESSAGE_BY_PARAM)))