Package model

Examples of model.Message


          public void run() {
            try {
              // get message ID
              String ID = MessageIDGenerator.getInstance()
                  .getNewID();
              Message out = parser.parse(outText);
              Terser tOut = new Terser(out);
              tOut.set("/MSH-10", ID);

              // send, get response
              Message in = initiator.sendAndReceive(out);
              // get ACK ID
              Terser tIn = new Terser(in);
              String ackID = tIn.get("/MSA-2");
              if (ID.equals(ackID)) {
                System.out.println("OK - ack ID matches");
View Full Code Here


   */
  protected Message doParse(String message, String version) throws HL7Exception {

    // try to instantiate a message object of the right class
    MessageStructure structure = getStructure(message);
    Message m = instantiateMessage(structure.messageStructure, version, structure.explicitlyDefined);
    // Note: this will change in future to reuse the Parser's/HapiContext's
    // ValidationContext.
    m.setValidationContext(getValidationContext());
   
    m.setParser(this);
   
    parse(m, message);

    return m;
  }
View Full Code Here

   */
  protected Message doParseForSpecificPackage(String message, String version, String packageName) throws HL7Exception {

    // try to instantiate a message object of the right class
    MessageStructure structure = getStructure(message);
    Message m = instantiateMessageInASpecificPackage(structure.messageStructure, version, structure.explicitlyDefined, packageName);

    parse(m, message);

    return m;
  }
View Full Code Here

   
    if (clazz.isAnnotationPresent(DoNotCacheStructure.class)) {
      Holder<StructureDefinition> previousLeaf = new Holder<StructureDefinition>();
      retVal = createStructureDefinition(theMessage, previousLeaf, theMessage.getName());
    } else {
      Message message = ReflectionUtil.instantiateMessage(clazz, getFactory());
      Holder<StructureDefinition> previousLeaf = new Holder<StructureDefinition>();
      retVal = createStructureDefinition(message, previousLeaf, theMessage.getName());

      if (!myStructureDefinitions.containsKey(clazz)) {
        myStructureDefinitions.put(clazz, new HashMap<String, StructureDefinition>());
View Full Code Here

public class HL7DataFormat implements DataFormat {

    private boolean validate = true;

    public void marshal(Exchange exchange, Object body, OutputStream outputStream) throws Exception {
        Message message = ExchangeHelper.convertToMandatoryType(exchange, Message.class, body);
        String encoded = HL7Converter.encode(message, validate);
        String charsetName = IOHelper.getCharsetName(exchange);
        outputStream.write(encoded.getBytes(charsetName));
    }
View Full Code Here

        outputStream.write(encoded.getBytes(charsetName));
    }

    public Object unmarshal(Exchange exchange, InputStream inputStream) throws Exception {
        String body = ExchangeHelper.convertToMandatoryType(exchange, String.class, inputStream);
        Message message = HL7Converter.parse(body, validate);

        // add MSH fields as message out headers
        Terser terser = new Terser(message);
        exchange.getOut().setHeader(HL7Constants.HL7_SENDING_APPLICATION, terser.get("MSH-3"));
        exchange.getOut().setHeader(HL7Constants.HL7_SENDING_FACILITY, terser.get("MSH-4"));
View Full Code Here

        mock.expectedMessageCount(1);
        mock.message(0).body().isInstanceOf(byte[].class);
        mock.message(0).body(String.class).contains("MSA|AA|123");
        mock.message(0).body(String.class).contains("QRD|20080805120000");

        Message message = createHL7AsMessage();
        template.sendBody("direct:marshal", message);

        assertMockEndpointsSatisfied();
    }
View Full Code Here

        mock.expectedMessageCount(1);
        mock.message(0).body().isInstanceOf(byte[].class);
        mock.message(0).body(String.class).contains("MSA|AA|123");
        mock.message(0).body(String.class).contains("QRD|20080805120000");
        mock.message(0).body(String.class).not().contains(NONE_ISO_8859_1);
        Message message = createHL7AsMessage();
        template.sendBodyAndProperty("direct:marshal", message, Exchange.CHARSET_NAME, "ISO-8859-1");
        assertMockEndpointsSatisfied();
    }
View Full Code Here

        mock.expectedMessageCount(1);
        mock.message(0).body().isInstanceOf(byte[].class);
        mock.message(0).body(String.class).contains("MSA|AA|123");
        mock.message(0).body(String.class).contains("QRD|20080805120000");
        mock.message(0).body(String.class).contains(NONE_ISO_8859_1);
        Message message = createHL7AsMessage();
        template.sendBodyAndProperty("direct:marshal", message, Exchange.CHARSET_NAME, "UTF-8");
        assertMockEndpointsSatisfied();
    }
View Full Code Here

        String body = createHL7AsString();
        template.sendBody("direct:unmarshal", body);

        assertMockEndpointsSatisfied();

        Message msg = mock.getExchanges().get(0).getIn().getBody(Message.class);
        assertEquals("2.4", msg.getVersion());
        QRD qrd = (QRD) msg.get("QRD");
        assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());
    }
View Full Code Here

TOP

Related Classes of model.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.