Package nexj.core.meta.integration

Examples of nexj.core.meta.integration.Format


    * Sets up a parser and message instance for use by test cases.
    * @see junit.framework.TestCase#setUp()
    */
   protected void setUp() throws Exception
   {
      Format format = Repository.getMetadata().getFormat("Zip");
      m_parser = (MessageParser)format.getParser().getInstance(null);
      m_message = Repository.getMetadata().getMessage("Zip_AllMapped");
   }
View Full Code Here


      }
   }
  
   public void testHL7Adapter()
   {
      Format format = m_metadata.getFormat("HL7");
      Message msg = m_metadata.getMessage("HL7_25_ADT_A04");
      TransferObject to = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new StringInput("MSH|^~\\&|||||20050326012305.528+0100||ADT^A04|1|P|2.5||||||\rEVN|A04||||||\rPID|||1234567890^^^&OHIP||Test^Joe||19800102|M||U|123 45th St^^Toronto^ON^A1B2C3^Canada^H^||(416) 123-4567|(416) 456-7890|||||||||||||||||||||||||\r"), msg);
      TransferObject patientID = (TransferObject)to.getValue("patientIdentification");

      Timestamp birthDate = (Timestamp)((TransferObject)patientID.getValue("dateTimeOfBirth")).getValue("time");
      Calendar calendar = Calendar.getInstance();
View Full Code Here

      id.setValue("type", "OHIP");
      id.setValue("id", "111222333");
      ids.add(id);
      pl.setValue("ids", ids);
      pat.setValue("player", pl);
      Format format = m_metadata.getFormat("Object");
      Message msg = m_metadata.getMessage("Object_PatientDemographics");
      ObjectOutput out = new ObjectOutput();
     
      ((MessageFormatter)format.getFormatter().getInstance(m_context)).format(pat, msg, out);
     
      TransferObject patCompare = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new ObjectInput(out.getObject()), msg);
      TransferObject plCompare = (TransferObject)patCompare.getValue("player");
      List idsCompare = (List)plCompare.getValue("ids");
      TransferObject idCompare = (TransferObject)idsCompare.get(0);
      assertEquals("OHIP", idCompare.getValue("type"));
View Full Code Here

      id.setValue("type", "OHIP");
      id.setValue("id", "111222333");
      ids.add(id);
      pl.setValue("id", ids);
      pat.setValue("player", pl);
      Format format = m_metadata.getFormat("XML");
      Message msg = m_metadata.getMessage("XML_PatientDemographics");
      Writer writer = new StringWriter();

      ((MessageFormatter)format.getFormatter().getInstance(m_context)).format(pat, msg, new WriterOutput(writer));
     
      TransferObject patCompare = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new StringInput(writer.toString()), msg);
      TransferObject plCompare = (TransferObject)patCompare.getValue("player");
      List idsCompare = (List)plCompare.getValue("id");
      TransferObject idCompare = (TransferObject)idsCompare.get(0);
      assertEquals(idCompare.getValue("id"), "111222333");
View Full Code Here

      assertEquals(plCompare.getValue("lastName"), "Test");
   }

   public void testXMLAdapter2()
   {
      Format format = m_metadata.getFormat("XML");
      Message msg = m_metadata.getMessage("XML_PatientDemographics");
      TransferObject to = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new StringInput("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a:Patient xmlns:a=\"http://nexj.com/nexj\" xmlns:b=\"http://nexj.com/nexj/b\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://nexj.com/nexj/integration.xsd\"><player><firstName>My1</firstName><lastName>Test</lastName><id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>"), msg);
      TransferObject player = (TransferObject)to.getValue("player");
      List ids = (List)player.getValue("id");
      TransferObject id = (TransferObject)ids.get(0);
      assertEquals(id.getValue("id"), "111222333");
View Full Code Here

      rows.add(row);
      table.setValue("Row", rows);
      row.setValue("name", "row1");
      row.setValue("value", "abcdef");

      Format format = m_metadata.getFormat("XML");
      Writer writer = new StringWriter();
      ((MessageFormatter)format.getFormatter().getInstance(m_context)).format(table, tableMessage, new WriterOutput(writer));

      table = ((MessageParser)format.getParser().getInstance(m_context)).parse(new StringInput(writer.toString()), tableMessage);
      rows = (List)table.getValue("Row");
      row = (TransferObject)rows.get(0);
      assertEquals(row.getValue("value"), "abcdef");
     
      Message recursiveMessage = (Message)messageRegistry.get("recursiveElement");
     
      TransferObject recursiveElement = new TransferObject();
      TransferObject recursiveElement2 = new TransferObject();
      recursiveElement.setValue("recursiveElement2", recursiveElement2);
      recursiveElement2.setValue("recursiveElement", new TransferObject());

      ((MessageFormatter)format.getFormatter().getInstance(m_context))
         .format(recursiveElement, recursiveMessage, new WriterOutput(new StringWriter()));
   }
View Full Code Here

      TransferObject table = new TransferObject();
      TransferObject row = new TransferObject();
      table.setValue("a_b", row);
      row.setValue("isConfirmedBySourceOwner", Boolean.FALSE);

      Format format = m_metadata.getFormat("XML");
     
      writer = new StringWriter();
      ((MessageFormatter)format.getFormatter().getInstance(m_context)).format(table, tableMessage, new WriterOutput(writer));
     
      table = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new StringInput(writer.toString()), tableMessage);
      row = (TransferObject)table.getValue("a_b");
      assertEquals(row.getValue("isConfirmedBySourceOwner"), Boolean.FALSE);
   }
View Full Code Here

       * in the XML schema.
       */
      StringWriter writer;
      WriterOutput out;
      TransferObject root, ref;
      Format format = m_context.getMetadata().getFormat("XML");
      MessageFormatter formatter = (MessageFormatter)format.getFormatter().getInstance(m_context);

      root = new TransferObject("XML_Inherit_Schema_Reference", 1);
      ref = new TransferObject("XML_Inherit_Schema1", 2);
      root.setValue("s1", ref);
      ref.setValue("a", "aValue");
View Full Code Here

    */
   protected void loadFormat(Element formatElement, final String sName)
   {
      XMLMetadataHelper.verifyRootElement(formatElement, "Format");

      final Format format = new Format(sName);

      format.setMetadata(m_metadata);
      format.setLoader(m_helper.getClassObject(XMLUtil.getReqStringAttr(formatElement, "loader")));

      String sExporter = XMLUtil.getStringAttr(formatElement, "exporter");

      if (sExporter != null)
      {
         format.setExporter(m_helper.getClassObject(sExporter));
      }

      XMLUtil.withFirstChildElement(formatElement, "Parser", true, new ElementHandler()
      {
         public void handleElement(Element componentElement)
         {
            Component parser = new Component("<MessageParser:" + sName + ">");

            loadComponent(componentElement, parser);
            format.setParser(parser);
         }
      });

      XMLUtil.withFirstChildElement(formatElement, "Formatter", true, new ElementHandler()
      {
         public void handleElement(Element componentElement)
         {
            Component formatter = new Component("<MessageFormatter:" + sName + ">");

            loadComponent(componentElement, formatter);
            format.setFormatter(formatter);
         }
      });

      m_metadata.addFormat(format);
   }
View Full Code Here

            SchemaExporter exporter = null;
            MessageTable msgTable = channel.getMessageTable();

            if (msgTable != null)
            {
               Format format = msgTable.getFormat();

               if (format != null)
               {
                  Class exporterClass = format.getExporter();

                  if (exporterClass != null)
                  {
                     Object obj = m_context.getClassInstance(exporterClass);
View Full Code Here

TOP

Related Classes of nexj.core.meta.integration.Format

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.