Package nexj.core.meta.integration

Examples of nexj.core.meta.integration.CompositeMessagePart


      {
         s_logger.debug("Formatting Fixed Length message \"" + message.getName() + "\"");
         s_logger.dump(tobj);
      }

      CompositeMessagePart rootPart = message.getRoot();
      CompositeMessagePart recordPart = (CompositeMessagePart)rootPart.getPart(0);

      m_writer = out.getWriter();

      FixedMessagePartMapping rootMapping = (FixedMessagePartMapping)rootPart.getMapping();

      try
      {
         m_writer.write(rootMapping.getPrefix());

         Object toFormat = tobj.findValue(recordPart.getName());

         if (toFormat instanceof List)
         {
            formatRecords((List)toFormat, recordPart);
         }
View Full Code Here


            new Object[] {parentPart.getFullPath()});
      }

      if (parentPart instanceof CompositeMessagePart)
      {
         CompositeMessagePart parentComposite = (CompositeMessagePart)parentPart;

         for (int nIndex = (parentComposite.getAggregation() == CompositeMessagePart.SEQUENTIAL) ? m_stack.getTopIndex() : 0;
            nIndex < parentComposite.getPartCount(); ++nIndex)
         {
            MessagePart part = parentComposite.getPart(nIndex);
            XMLMessagePartMapping mapping = (XMLMessagePartMapping)part.getMapping();

            if (mapping.getNodeType() == XMLMessagePartMapping.ELEMENT)
            {
               if (matches(part, sURI, sLocalName))
               {
                  TransferObject tobj;
                  MessagePart basePart = part;

                  m_bNilElement = mapping.isNillable() &&
                      (Primitive.toBoolean(attributes.getValue(XMLNamespace.XSI, "nil")) == Boolean.TRUE);

                  if (part instanceof PrimitiveMessagePart)
                  {
                     tobj = null;

                     if (((PrimitiveMessagePart)part).getType() == Primitive.ANY)
                     {
                        if (mapping.getInterface() == null)
                        {
                           startParsingAnyType((mapping.getSubtype() == XMLMessagePartMapping.SUBTYPE_XSI) ?
                              attributes.getValue(XMLNamespace.XSI, "type") : null);
                        }
                     }
                  }
                  else
                  {
                     CompositeMessagePart composite2 = (CompositeMessagePart)part;
                     PrimitiveMessagePart valuePart = mapping.getValuePart();

                     tobj = new TransferObject(composite2.getPartCount());
                     parseAttributes(tobj, composite2, attributes);

                     // Process message inheritance
                     if (composite2 instanceof CompositeMessagePartRef)
                     {
                        CompositeMessagePartRef ref = (CompositeMessagePartRef)composite2;
                        CompositeMessagePart referencedPart = ref.getRefPart();

                        tobj.setClassName(referencedPart.getName());

                        RootXMLMessagePartMapping refRootMapping = (RootXMLMessagePartMapping)referencedPart.getMapping();
                        Message derivedMessage = getDerivedMessage(attributes, refRootMapping, part.getFullPath());

                        if (derivedMessage != null)
                        {
                           Message referencedMessage = refRootMapping.getRootMessage();
View Full Code Here

      tobj.setClassName(primaryMessage.getName());

      if (derivedMessage != null)
      {
         CompositeMessagePart derivedMessageRoot = derivedMessage.getRoot();
         RootXMLMessagePartMapping derivedMessageRootMapping = (RootXMLMessagePartMapping)derivedMessageRoot.getMapping();

         Message.validatePolymorphism(primaryMessage, derivedMessage, derivedMessageRoot);
         m_stack.setTopBaseMessagePart(part);
         part = derivedMessageRoot;
         m_stack.setTopMessagePart(part);
View Full Code Here

            {
               s_logger.debug("Identified the XML anyType message as \"" + msg.getName() + "\"");
            }
         }

         CompositeMessagePart composite = (CompositeMessagePart)part;
         TransferObject tobj = new TransferObject(msg.getName(), composite.getPartCount());

         parseAttributes(tobj, composite, attributes);
         m_stack.setTopIndex(nIndex);
         m_stack.push(part, basePart, tobj, 0, null);
View Full Code Here

      {
         obj = Undefined.VALUE;
      }
      else
      {
         CompositeMessagePart composite = (CompositeMessagePart)part;
         TransferObject tobj = (TransferObject)m_stack.getTopObject();
         int nPartCount = composite.getPartCount();
         boolean bMatch = false;
         boolean bRequired = false;

         if (tobj != null)
         {
            for (int nIndex = 0; nIndex < nPartCount; ++nIndex)
            {
               MessagePart child = composite.getPart(nIndex);
               int nNodeType = ((XMLMessagePartMapping)child.getMapping()).getNodeType();

               if (!m_bNilElement && nNodeType == XMLMessagePartMapping.ELEMENT// ignore counts for nil elements
               {
                  if (composite.getAggregation() == CompositeMessagePart.SINGLE)
                  {
                     if (tobj.hasValue(child.getName()))
                     {
                        if (bMatch)
                        {
                           throw new IntegrationException("err.integration.multipleParts",
                              new Object[]{composite.getFullPath()});
                        }

                        validatePartCount(child);
                        bMatch = true;
                     }

                     bRequired |= child.isRequired();
                  }
                  else
                  {
                     validatePartCount(child);
                  }
               }
               else if (nNodeType == XMLMessagePartMapping.VALUE)
               {
                  Object value = null;

                  if ((value = getAnyTypeValue()) != null)
                  {
                     // Value-mapped part for literal XML will have just one element when collection
                     if (child.isCollection())
                     {
                        ArrayList list = new ArrayList(1);

                        list.add(value);
                        value = list;
                     }
                  }
                  else
                  {
                     value = m_stack.getTopValue();

                     if (value instanceof StringBuilder)
                     {
                        value = value.toString();
                     }

                     if (value instanceof String)
                     {
                        value = convert((PrimitiveMessagePart)child, (String)value);
                     }
                  }

                  tobj.setValue(child.getName(), value);
                  validatePartCount(child);
               }
            }

            if (bRequired && !bMatch)
            {
               throw new IntegrationException("err.integration.missingPart",
                  new Object[]{composite.getFullPath()});
            }
         }

         if (!m_bNilElement || tobj.getValueCount() > 0)
         {
View Full Code Here

      {
         s_logger.debug("Parsing Fixed message \"" + msg.getName() + "\"");
         s_logger.dump(msg);
      }

      CompositeMessagePart rootPart = msg.getRoot();

      // initialize reader
      m_reader = in.getReader();
      m_bEOF = false;

      // parse message
      CompositeMessagePart recordPart = (CompositeMessagePart)rootPart.getPart(0);
      FixedMessagePartMapping recordMapping = (FixedMessagePartMapping)recordPart.getMapping();

      if (m_chRecord == null)
      {
         m_chRecord = new char[recordMapping.getWidth()];
      }

      TransferObject result = null;
      List listResult;

      try
      {
         FixedMessagePartMapping rootMapping = (FixedMessagePartMapping)rootPart.getMapping();

         if (rootMapping != null)
         {
            m_reader.skip(rootMapping.getPrefix().length());
         }

         listResult = parseRecords(recordMapping);
      }
      catch (IOException innerEx)
      {
         throw new IntegrationException("err.integration.parseRecord",
            new Object[]{msg.getName(), Primitive.createInteger(m_nCurrentRecord)}, innerEx);
      }

      result = new TransferObject(msg.getName(), 1);
      result.setValue(recordPart.getName(), listResult);

      if (s_logger.isDumpEnabled())
      {
         s_logger.dump("Parsed result: ");
         s_logger.dump(result);
View Full Code Here

    * @return A record of data with a (possibly empty) value for every defined field in the message.
    * @throws IOException If an I/O error occurs.
    */
   protected String[] rawReadRecord(FixedMessagePartMapping recordMapping) throws IOException, IntegrationException
   {
      CompositeMessagePart recordPart = (CompositeMessagePart)recordMapping.getMessagePart();
      String[] sResultArray = new String[recordPart.getPartCount()];

      m_nCurrentRecord += 1;

      if (recordMapping.getPrefix() != null)
      {
         m_reader.skip(recordMapping.getPrefix().length());
      }

      for (int i = 0; i < recordPart.getPartCount(); i++)
      {
         PrimitiveMessagePart fieldPart = (PrimitiveMessagePart)recordPart.getPart(i);

         if ((sResultArray[i] = readField(fieldPart)) == null && m_bEOF)
         {
            return null;
         }
View Full Code Here

    * @param sRawRecordArray A single row of data, one element per fixed length field.
    * @return A TransferObject graph representing the processed data row.
    */
   protected TransferObject convertRecord(FixedMessagePartMapping recordMapping, String[] sRawRecordArray)
   {
      CompositeMessagePart recordPart = (CompositeMessagePart)recordMapping.getMessagePart();

      if (recordPart.getPartCount() == 0)
      {
         return null;
      }

      TransferObject result = new TransferObject(recordPart.getPartCount());

      for (int i = 0; i < recordPart.getPartCount(); i++)
      {
         PrimitiveMessagePart fieldPart = (PrimitiveMessagePart)recordPart.getPart(i);
         Object datum = sRawRecordArray[i];
         FixedMessagePartMapping mapping = (FixedMessagePartMapping)fieldPart.getMapping();

         if (mapping.getFormat() == null)
         {
View Full Code Here

         {
            if (((Integer)XSDMessageImporter.this.getMessageRegistry().m_msgRefCountMap.get(MessageRegistry.toKey(m_typeDef))).intValue() == 1)
            {
               if (m_partRef.getParent() != null && !m_partRef.isRefPartAncestor())  //when parent is null, we have several elements deriving off the same complex type
               {
                  CompositeMessagePart part = m_partRef.getRefPart();
                  part.copyAttributesFrom(m_partRef);
                  XSDMessageImporter.this.setMapping(part, null, m_sNodeName, m_sNamespace, m_bNillable, m_typeDef);
                  m_partRef.getParent().replacePart(m_partRef, part);
                  XSDMessageImporter.this.m_msgList.remove(msg);
               }
            }
View Full Code Here

    * @param currPathSet The current path.
    * @return The list of attributes or an attribute symbol.
    */
   private Object getAttributes(MessagePart part, Set currPathSet, Message message)
   {
      CompositeMessagePart refPart = null;
      ObjectMessagePartMapping partMapping = (ObjectMessagePartMapping)part.getMapping();

      if (part instanceof PrimitiveMessagePart)
      {
         if (message != null && part.getDeclarator() == message && partMapping.getMessage() != message)
         {
            return null;
         }

         return (m_attribute == null) ? null : m_attribute.getSymbol();
      }
      else if (part instanceof CompositeMessagePartRef)
      {
         refPart = ((CompositeMessagePartRef)part).getRefPart();
         message = refPart.getDeclarator();

         if (!currPathSet.add(refPart))
         {
            return (m_attribute == null) ? null : new Pair(m_attribute.getSymbol());
         }
      }

      CompositeMessagePart composite = (CompositeMessagePart)part;
      Pair attributes = null;

      for (int i = composite.getPartCount() - 1; i >= 0; --i)
      {
         MessagePart childPart = composite.getPart(i);
         ObjectMessagePartMapping childMapping = (ObjectMessagePartMapping)childPart.getMapping();
         Object childAttributes = childMapping.getAttributes(childPart, currPathSet, message);

         if (childAttributes != null)
         {
            attributes = new Pair(childAttributes, attributes);
         }
      }

      // Add attributes from derived messages
      if (refPart != null)
      {
         ObjectMessagePartMapping refMapping = (ObjectMessagePartMapping)refPart.getMapping();
         Message refMessage = refMapping.getMessage();

         for (int i = 0, nCount = refMessage.getDerivedMessageCount(); i < nCount; i++)
         {
            Message derivedMessage = refMessage.getDerivedMessage(i);
            CompositeMessagePart derivedRoot = derivedMessage.getRoot();
            ObjectMessagePartMapping derivedMapping = (ObjectMessagePartMapping)derivedRoot.getMapping();
            Object derivedAttributes = derivedMapping.getAttributes(derivedRoot, currPathSet, refMessage);

            if (derivedAttributes != null)
            {
               if (derivedAttributes instanceof Symbol)
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.