Package nexj.core.meta.integration

Examples of nexj.core.meta.integration.CompositeMessagePart


      exporter.exportMessage(msg);

      // Check result
      assertEquals("validTime", msg.getName());

      CompositeMessagePart comp = msg.getRoot();

      assertTrue(comp.getDescription().startsWith("An interval of time specifying"));
      assertEquals(CompositeMessagePart.RANDOM, comp.getAggregation());
      assertEquals(4, comp.getPartCount());

      assertEquals("low", comp.getPart(0).getName());
      assertEquals(Primitive.ANY_ORDINAL, ((PrimitiveMessagePart)comp.getPart(0)).getType().getOrdinal());

      assertEquals("width", comp.getPart(1).getName());
      assertEquals(Primitive.ANY_ORDINAL, ((PrimitiveMessagePart)comp.getPart(1)).getType().getOrdinal());

      assertEquals("high", comp.getPart(2).getName());
      assertEquals(Primitive.ANY_ORDINAL, ((PrimitiveMessagePart)comp.getPart(2)).getType().getOrdinal());

      assertEquals("center", comp.getPart(3).getName());
      assertEquals(Primitive.ANY_ORDINAL, ((PrimitiveMessagePart)comp.getPart(3)).getType().getOrdinal());
   }
View Full Code Here


      exporter.exportMessage(msg);

      // Check result
      assertEquals("validTime", msg.getName());

      CompositeMessagePart comp = msg.getRoot();

      assertEquals(1, comp.getPartCount());
      comp = (CompositeMessagePart)comp.getPart(0);
      assertEquals("elemwithtypereferral", comp.getName());
      assertTrue(comp instanceof CompositeMessagePartRef);
      comp = ((CompositeMessagePartRef)comp).getRefPart();

      msg = (Message)msgRegistry.get("IVL_TS");
      assertNotNull(msg);
      assertSame(comp, msg.getRoot());
      assertEquals(1, comp.getPartCount());
      assertEquals("low", comp.getPart(0).getName());
      assertEquals(Primitive.ANY_ORDINAL, ((PrimitiveMessagePart)comp.getPart(0)).getType().getOrdinal());

      // Test export
      writer = new StringWriter();
      exporter = new XMLMetadataExporter(writer);
      exporter.exportMessage(msg);
View Full Code Here

      Element root = XMLUtil.parse(new StringReader(writer.toString())).getDocumentElement();
      assertEquals("Address", root.getAttribute("ref"));

      // Check result
      CompositeMessagePart comp = msg.getRoot();

      assertTrue(comp instanceof CompositeMessagePartRef);

      msg = (Message)msgRegistry.get("Address");
      assertNotNull(msg);

      comp = msg.getRoot();
      assertTrue(comp instanceof CompositeMessagePartInstance);
      assertEquals(1, comp.getPartCount());
      assertEquals("addr", comp.getPart(0).getName());
      assertTrue(comp.getPart(0) instanceof CompositeMessagePartRef);
      assertSame(comp, ((CompositeMessagePartRef)comp.getPart(0)).getRefPart());


      // Test export
      writer = new StringWriter();
      exporter = new XMLMetadataExporter(writer);
View Full Code Here

      Message msg = (Message)msgRegistry.get("account");
     
      assertEquals(msg.getRoot().getAggregation(), CompositeMessagePart.SINGLE);
      msg = (Message)msgRegistry.get("aaaParent");
     
      CompositeMessagePart cPart = (CompositeMessagePart)msg.getRoot().getPart("aaaChild");
     
      assertEquals(3, cPart.getPart("areaCode").getMinCount());
      assertTrue(msg.getRoot().getAggregation() != CompositeMessagePart.SINGLE);
      msg = (Message)msgRegistry.get("phoneNumberA");
      assertTrue(msg.getRoot().getAggregation() != CompositeMessagePart.SINGLE);

      MessagePart p = msg.getRoot().getPart("phoneNumber");
View Full Code Here

      StringWriter writer = new StringWriter();
      XMLMetadataExporter exporter = new XMLMetadataExporter(writer);
      exporter.exportMessage(tableMessage);
     
      assertEquals(tableMessage.getRoot().getPartCount(), 2);
      CompositeMessagePart rowPart = (CompositeMessagePart)tableMessage.getRoot().getPart("Row");
      PrimitiveMessagePart namePart = (PrimitiveMessagePart)rowPart.getPart("name");
      assertEquals(namePart.getType(), Primitive.STRING);
      PrimitiveMessagePart timePart = (PrimitiveMessagePart)rowPart.getPart("time");
      assertEquals(timePart.getType(), Primitive.LONG);
      PrimitiveMessagePart booleanPart = (PrimitiveMessagePart)rowPart.getPart("required");
      assertEquals(booleanPart.getType(), Primitive.BOOLEAN);
      PrimitiveMessagePart enumPart = (PrimitiveMessagePart)rowPart.getPart("type");
      assertEquals(enumPart.getType(), Primitive.STRING);
      assertEquals( enumPart.getEnumerationCount(), 10);

      //System.err.println(XMLUtil.formatXML(writer.toString()));
     
View Full Code Here

    */
   public TransferObject parse(Input in, Message msg) throws IntegrationException
   {
      InputStream istream = in.getInputStream();

      CompositeMessagePart rootPart = msg.getRoot();
      CompositeMessagePart entriesPart = (CompositeMessagePart)rootPart.getPart(0);

      TransferObject root = new TransferObject(msg.getName());
      List entryList = new ArrayList();

      ZipInputStream zipStream = new ZipInputStream(istream);
      ZipEntry zipEntry;

      root.setValue(entriesPart.getName(), entryList);

      try
      {
         while ((zipEntry = zipStream.getNextEntry()) != null)
         {
            String sKeySize = null;
            long lValueSize = 0;
            String sKeyContents = null;
            Primitive sizeType = null;
            TransferObject entry = new TransferObject();

            entryList.add(entry);

            // Iterate the parts, assigning data from the Zip entry
            for (int i = 0; i < entriesPart.getPartCount(); i++)
            {
               PrimitiveMessagePart part = (PrimitiveMessagePart)entriesPart.getPart(i);
               ZipMessagePartMapping mapping = (ZipMessagePartMapping)part.getMapping();
               Object datum = null;
               Primitive partType = part.getType();

               switch (mapping.getValue())
View Full Code Here

            {
               baseMessage = ((RootXMLMessagePartMapping)part.getRoot().getMapping()).getRootMessage();
            }
            else if (part instanceof CompositeMessagePartRef)
            {
               CompositeMessagePart referencedPart = ((CompositeMessagePartRef)part).getRefPart();

               baseMessage = ((RootXMLMessagePartMapping)referencedPart.getMapping()).getRootMessage();
            }

            if (baseMessage != null)
            {
               Message.validatePolymorphism(baseMessage, derivedMessage, part);

               if (baseMessage != derivedMessage)
               {
                  part = derivedMessage.getRoot();
                  bAppendType = true;
                  derivedMapping = (XMLMessagePartMapping)part.getMapping();
               }
            }
         }
      }

      if (((RootXMLMessagePartMapping)part.getRoot().getMapping()).getRootMessage().getDerivation() == Message.DERIVATION_ABSTRACT)
      {
         throw new IntegrationException("err.integration.abstractMessage",
            new Object[]{((RootXMLMessagePartMapping)part.getRoot().getMapping()).getRootMessage().getName(), part.getFullPath()});
      }

      if (part instanceof CompositeMessagePart)
      {
         if (obj != null)
         {
            CompositeMessagePart composite = (CompositeMessagePart)part;
            TransferObject tobj = (TransferObject)obj;
            RootXMLMessagePartMapping rootMapping = null;
            MessagePart headersPart = null;
            boolean bEnvelopeStarted = false;
View Full Code Here

    */
   public void format(TransferObject tobj, Message message, Output out) throws IntegrationException
   {
      OutputStream ostream = out.getOutputStream();
      ZipOutputStream zipStream = null;
      CompositeMessagePart rootPart = message.getRoot();
      ZipMessagePartMapping rootMapping = (ZipMessagePartMapping)rootPart.getMapping();
      CompositeMessagePart entriesPart = (CompositeMessagePart)rootPart.getPart(0);

      // Pre-compute the transfer object keys for the various Zip entry attributes
      String sKeyComment = null;
      String sKeyContents = null;
      String sKeyExtra = null;
      String sKeyName = null;
      String sKeySize = null;
      String sKeyTime = null;

      for (int i = 0; i < entriesPart.getPartCount(); i++)
      {
         PrimitiveMessagePart part = (PrimitiveMessagePart)entriesPart.getPart(i);
         ZipMessagePartMapping mapping = (ZipMessagePartMapping)part.getMapping();

         switch (mapping.getValue())
         {
            case ZipMessagePartMapping.VALUE_COMMENT:
               sKeyComment = part.getName();
               break;

            case ZipMessagePartMapping.VALUE_CONTENTS:
               sKeyContents = part.getName();
               break;

            case ZipMessagePartMapping.VALUE_EXTRA:
               sKeyExtra = part.getName();
               break;

            case ZipMessagePartMapping.VALUE_NAME:
               sKeyName = part.getName();
               break;

            case ZipMessagePartMapping.VALUE_SIZE:
               sKeySize = part.getName();
               break;

            case ZipMessagePartMapping.VALUE_TIME:
               sKeyTime = part.getName();
               break;

            default:
               // Ignore values that are not for output
               break;
         }
      }

      // Format the transfer object into a Zip stream
      try
      {
         zipStream = new ZipOutputStream(ostream);

         if (rootMapping != null)
         {
            zipStream.setComment(rootMapping.getComment());
            zipStream.setLevel((int)rootMapping.getCompression());
         }

         List entryList = (List)tobj.getValue(entriesPart.getName());

         for (int i = 0; i < entryList.size(); i++)
         {
            TransferObject entry = (TransferObject)entryList.get(i);

View Full Code Here

   /**
    * @see nexj.core.integration.MessageFormatter#format(nexj.core.rpc.TransferObject, nexj.core.meta.integration.Message, nexj.core.integration.Output)
    */
   public void format(TransferObject tobj, Message message, Output out) throws IntegrationException
   {
      CompositeMessagePart msgRoot = message.getRoot();

      m_writer = new WrappingWriter(out.getWriter());

      try
      {
         switch (((VCardMessagePartMapping)msgRoot.getMapping()).getWrapping())
         {
            case VCardMessagePartMapping.WRAPPING_WHITESPACE:
               m_nDefaultWrappingMode = WrappingWriter.WRAP_REPLACE_WHITESPACE;
               m_writer.setMaxLineLength(72);
               break;
View Full Code Here

    * @throws IOException If an I/O error occurs.
    */
   protected void writeField(Object obj, MessagePart part, VCardMessagePartMapping mapping) throws IOException
   {
      boolean bParameters = (part instanceof CompositeMessagePart);
      CompositeMessagePart parentPart = null;
      MessagePart valuePart;
      Object valueObj;

      if (bParameters)
      {
         valuePart = mapping.getValuePart();
         valueObj = ((TransferObject)obj).findValue(valuePart.getName());
         parentPart = (CompositeMessagePart)part;
      }
      else
      {
         valuePart = part;
         valueObj = obj;
      }

      VCardMessagePartMapping valuePartMapping = (VCardMessagePartMapping)valuePart.getMapping();

      if (valueObj == null && valuePartMapping.getDefault() == null)
      {
         if (valuePart.isRequired())
         {
            throw new IntegrationException("err.integration.minPartCount", new Object[]{valuePart.getFullPath()});
         }

         return;
      }

      m_writer.write((bParameters) ? mapping.getFullName() : valuePartMapping.getFullName());

      int nChildCount = (bParameters) ? parentPart.getPartCount() : 0;

      for (int i = 0; i < nChildCount; i++)
      {
         MessagePart childPart = (MessagePart)parentPart.getPart(i);
         VCardMessagePartMapping childMapping = (VCardMessagePartMapping)childPart.getMapping();

         if (childMapping.getType() == VCardMessagePartMapping.TYPE_PARAMETER)
         {
            Object parameterObj = ((TransferObject)obj).findValue(childPart.getName());
View Full Code Here

TOP

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

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.