Package model

Examples of model.Message


   *      boolean, String)
   */
  protected Message instantiateMessageInASpecificPackage(String theName,
      String theVersion, boolean isExplicit, String packageName)
      throws HL7Exception {
    Message result = null;

    try {
      Class<? extends Message> messageClass = myFactory
          .getMessageClassInASpecificPackage(theName, theVersion,
              isExplicit, packageName);
      if (messageClass == null) {
        throw new ClassNotFoundException(
            "Can't find message class in current package list: "
                + theName);
      }

      log.debug("Instantiating msg of class {}", messageClass.getName());
      Constructor<? extends Message> constructor = messageClass
          .getConstructor(new Class[] { ModelClassFactory.class });
      result = (Message) constructor
          .newInstance(new Object[] { myFactory });
    } catch (Exception e) {
      throw new HL7Exception("Couldn't create Message object of type "
          + theName, HL7Exception.UNSUPPORTED_MESSAGE_TYPE, e);
    }

    result.setValidationContext(myContext);

    return result;
  }
View Full Code Here


  public static Segment makeControlMSH(String version,
      ModelClassFactory factory) throws HL7Exception {
    Segment msh = null;

    try {
      Message dummy = GenericMessage.getGenericMessageClass(version)
          .getConstructor(new Class[] { ModelClassFactory.class })
          .newInstance(new Object[] { factory });

      Class<?>[] constructorParamTypes = { Group.class,
          ModelClassFactory.class };
View Full Code Here

   *             be found or the Message class throws an exception on
   *             instantiation (e.g. if args are not as expected)
   */
  protected Message instantiateMessage(String theName, String theVersion,
      boolean isExplicit) throws HL7Exception {
    Message result = null;

    try {
      Class<? extends Message> messageClass = myFactory.getMessageClass(
          theName, theVersion, isExplicit);
      if (messageClass == null)
        throw new ClassNotFoundException(
            "Can't find message class in current package list: "
                + theName);
      log.debug("Instantiating msg of class {}", messageClass.getName());
      Constructor<? extends Message> constructor = messageClass
          .getConstructor(new Class[] { ModelClassFactory.class });
      result = constructor.newInstance(new Object[] { myFactory });
    } catch (Exception e) {
      throw new HL7Exception("Couldn't create Message object of type "
          + theName, HL7Exception.UNSUPPORTED_MESSAGE_TYPE, e);
    }

    result.setValidationContext(myContext);

    return result;
  }
View Full Code Here

     * object.  This method checks that the given message string is XML encoded, creates an
     * XML Document object (using Xerces) from the given String, and calls the abstract
     * method <code>parse(Document XMLMessage)</code></p>
     */
    protected Message doParse(String message, String version) throws HL7Exception, EncodingNotSupportedException {
        Message m = null;

        //parse message string into a DOM document
        Document doc = null;
        doc = parseStringIntoDocument(message);
        m = parseDocument(doc, version);
View Full Code Here

     * @throws EncodingNotSupportedException if the message encoded
     *     is not supported by this parser.
     */
    public Message parseDocument(org.w3c.dom.Document XMLMessage, String version) throws HL7Exception {
        String messageName = XMLMessage.getDocumentElement().getTagName();
        Message message = instantiateMessage(messageName, version, true);
        parse(message, XMLMessage.getDocumentElement());
        return message;
    }
View Full Code Here

            else if (xp.getEncoding(messString) != null) {
                inParser = xp;
                outParser = pp;
            }

            Message mess = inParser.parse(messString);
            System.out.println("Got message of type " + mess.getClass().getName());

            String otherEncoding = outParser.encode(mess);
            System.out.println(otherEncoding);
        }
        catch (Exception e) {
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

        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

        if (log.isDebugEnabled()) {
            log.debug("creating message with text: " + text);
        }

        final Message message = new Message(text);
        this.messageRepository.create(message);
    }
View Full Code Here

    @Test
    public void smokeTest() {
        assertNotNull(this.messageRepository);

        // create
        final Message message = new Message("Test message");

        this.messageRepository.create(message);

        // read
        Collection<Message> messages = this.messageRepository.getAll();

        assertNotNull(messages);
        assertEquals(1, messages.size());
        final Message storedMessage = messages.iterator().next();

        assertNotNull(storedMessage.getId());
        assertEquals(message.getText(), storedMessage.getText());

        // delete
        this.messageRepository.deleteById(storedMessage.getId());

        messages = this.messageRepository.getAll();
        assertEquals(0, messages.size());
    }
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.