Examples of MessagePart


Examples of nexj.core.meta.integration.MessagePart

      Message msg = (Message)msgLookup.get("PRPA_IN101103CA");
     
      assertNull(msg.getRoot().getDescription());

      Message msgBase = (Message)msgLookup.get("PRPA_IN101103CA_MCCI_MT002100CA_Message");
      MessagePart part = msgBase.getRoot().getPart("id");

      String sDescription = part.getDescription();
     
      assertTrue(sDescription.startsWith("A unique identifier for the message."));
      assertTrue(sDescription.endsWith("A root component is required or else the II value is NULL."));
     
      msg = (Message)msgLookup.get("II");
View Full Code Here

Examples of nexj.core.meta.integration.MessagePart

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

            // append the namespace and the schema
            if (parentPart == null)
            {
View Full Code Here

Examples of nexj.core.meta.integration.MessagePart

      boolean bRequired = false;
      boolean bSingle = part.getAggregation() == CompositeMessagePart.SINGLE;

      for (int i = 0, nPartCount = part.getPartCount(); i < nPartCount; ++i)
      {
         MessagePart childPart = part.getPart(i);
         XMLMessagePartMapping childMapping = (XMLMessagePartMapping)childPart.getMapping();
         byte nNodeType = childMapping.getNodeType();

         // Skip the header
         if (childPart == headersPart)
         {
            continue;
         }

         if (nNodeType == XMLMessagePartMapping.ELEMENT)
         {
            if (bSingle)
            {
               bRequired |= childPart.isRequired();
            }

            if (childMapping.isNillable() || tobj.hasValue(childPart.getName()))
            {
               if (bSingle)
               {
                  if (bMatch)
                  {
                     throw new IntegrationException("err.integration.multipleParts",
                           new Object[]{part.getFullPath()});
                  }

                  bMatch = true;
               }

               if (bEmpty)
               {
                  m_writer.closeElement();
               }

               bEmpty = false;
               append(tobj.findValue(childPart.getName()), childPart, part);
            }
            else if (!bSingle && childPart.isRequired())
            {
               throw new IntegrationException("err.integration.minPartCount", new Object[]{childPart.getFullPath()});
            }
         }
         else if (nNodeType == XMLMessagePartMapping.VALUE)
         {
            PrimitiveMessagePart contentPart = (PrimitiveMessagePart)childPart;
View Full Code Here

Examples of nexj.core.meta.integration.MessagePart

    */
   protected void appendAttributes(TransferObject tobj, CompositeMessagePart part) throws IOException
   {
      for (int i = 0, nPartCount = part.getPartCount(); i < nPartCount; ++i)
      {
         MessagePart childPart = part.getPart(i);
         XMLMessagePartMapping childMapping = (XMLMessagePartMapping)childPart.getMapping();
         int nChildNodeType = childMapping.getNodeType();

         if (nChildNodeType == XMLMessagePartMapping.ATTRIBUTE)
         {
            if (tobj.hasValue(childPart.getName()))
            {
               m_writer.setNamespace((childMapping.getNamespace() == null) ? null : childMapping.getNamespace().getName());
               m_writer.writeAttribute(childMapping.getNodeName(), toString((PrimitiveMessagePart)childPart, tobj.getValue(childPart.getName())));
            }
            else
            {
               if (childPart.isRequired())
               {
                  throw new IntegrationException("err.integration.minPartCount", new Object[]{childPart.getFullPath()});
               }
            }
         }
      }

      XMLMessagePartMapping mapping = (XMLMessagePartMapping)part.getMapping();
      MessagePart valuePart = mapping.getValuePart();

      if (valuePart != null && mapping.isNillable() && tobj.findValue(valuePart.getName()) == null)
      {
         m_writer.setNamespace(XMLNamespace.XSI_NAME);
         m_writer.writeAttribute("nil", "1");
      }
   }
View Full Code Here

Examples of nexj.core.meta.integration.MessagePart

      m_writer.setNamespace(sEnvelopeNamespace);
      m_writer.openElement("Envelope");
      appendNamespaces(rootMapping, true, false);
      m_writer.closeElement();

      MessagePart headersPart = rootMapping.getHeaderPart();

      if (headersPart != null)
      {
         Object value = tobj.findValue(headersPart.getName());

         if (value != null || headersPart.isRequired())
         {
            append(value, headersPart, (CompositeMessagePart)rootMapping.getMessagePart());
         }
      }
View Full Code Here

Examples of nexj.core.meta.integration.MessagePart

      if (mapping.getType() == VCardMessagePartMapping.TYPE_GROUP)
      {
         for (int i = 0, nChildCount = part.getPartCount(); i < nChildCount; i++)
         {
            MessagePart childPart = part.getPart(i);
            Object childObj = tobj.findValue(childPart.getName());

            if (childPart instanceof CompositeMessagePart)
            {
               if (childPart.isCollection())
               {
                  // composite sub-part of group, and it is a collection (multiplicity * group or field w/ parameters)
                  List list = (List)childObj;
                  int nCount = (list != null) ? list.size() : 0;

                  checkMultiplicity(nCount, childPart);

                  for (int k = 0; k < nCount; k++)
                  {
                     format((TransferObject)list.get(k), (CompositeMessagePart)childPart);
                  }
               }
               else
               {
                  // composite sub-part of group (could be another group, a field with parameters, etc.)
                  format((TransferObject)childObj, (CompositeMessagePart)childPart);
               }
            }
            else
            {
               // primitive parts in the group
               writeField(childObj, childPart, (VCardMessagePartMapping)childPart.getMapping());
            }
         }
      }
      else
      {
View Full Code Here

Examples of nexj.core.meta.integration.MessagePart

    */
   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());

            if (parameterObj != null || childMapping.getDefault() != null)
            {
               m_writer.write(';');
               m_writer.write(childMapping.getName());
               m_writer.write('=');
               writeValue((PrimitiveMessagePart)childPart, childMapping, parameterObj);
            }
            else
            {
               if (childPart.isRequired())
               {
                  throw new IntegrationException("err.integration.minPartCount", new Object[]{childPart.getFullPath()});
               }
            }
         }
      }

View Full Code Here

Examples of nexj.core.meta.integration.MessagePart

    */
   protected void setValue(TransferObject tobj, CompositeMessagePart composite, int nSeq, Object value)
   {
      for (int i = 0, n = composite.getPartCount(); i < n; ++i)
      {
         MessagePart part = composite.getPart(i);

         if (((HL7MessagePartMapping)part.getMapping()).getSeq() == nSeq)
         {
            tobj.setValue(part.getName(), value);

            break;
         }
      }
   }
View Full Code Here

Examples of nexj.core.meta.integration.MessagePart

      {
         throw new IntegrationException("err.integration.xml.unexpectedElement",
               new Object[] {sURI, sLocalName});
      }

      MessagePart parentPart = m_stack.getTopMessagePart();

      if (m_bNilElement)
      {
         throw new IntegrationException("err.integration.xml.nilElementNotEmpty",
            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)
View Full Code Here

Examples of nexj.core.meta.integration.MessagePart

    * return false.
    * @return True if the document root is accepted; false if it is not accepted.
    */
   public boolean acceptRootElement(String sURI, String sLocalName, Attributes attributes, boolean bError)
   {
      MessagePart part = m_stack.getTopMessagePart();
      RootXMLMessagePartMapping rootMapping;

      if (part == null)
      {
         // Identify the XML message being parsed
         Message msg = (Message)m_messageMap.get(sURI, sLocalName);

         if (msg != null)
         {
            part = msg.getRoot();
         }

         if (part == null)
         {
            if (bError)
            {
               throw new IntegrationException("err.integration.xml.unsupportedMessage",
                  new Object[]{sURI, sLocalName});
            }

            return false;
         }

         rootMapping = (RootXMLMessagePartMapping)part.getMapping();
         assert m_stack.getSize() == 1;
         m_stack.setTopMessagePart(part);
         m_stack.setTopBaseMessagePart(part);

         if (s_logger.isDebugEnabled())
         {
            s_logger.debug("Identified the XML message as \"" + part.getName() + "\"");
         }

         ((TransferObject)m_stack.getTopObject()).setClassName(part.getName());
         m_headerPart = rootMapping.getHeaderPart();
         m_bRestart = (rootMapping.getSchemaResourceMap() != null) || (m_headerPart != null);
         m_baseRootPart = part;
      }
      else
      {
         // Verify root element of message being parsed
         rootMapping = (RootXMLMessagePartMapping)part.getMapping();

         if (!matches(m_baseRootPart, sURI, sLocalName))
         {
            if (bError)
            {
               throw new IntegrationException("err.integration.xml.invalidDocRoot",
                  new Object[]{sURI, sLocalName});
            }

            return false;
         }

         if (m_headerPart != rootMapping.getHeaderPart())
         {
            m_headerPart = rootMapping.getHeaderPart();
            m_bRestart = true;
         }
      }

      TransferObject tobj = (TransferObject)m_stack.getTopObject();

      if (!m_bRestart)
      {
         parseAttributes(tobj, (CompositeMessagePart)part, attributes);
      }

      Message derivedMessage = getDerivedMessage(attributes, rootMapping, part.getFullPath());
      Message primaryMessage = rootMapping.getRootMessage();

      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);
         tobj.setClassName(derivedMessage.getName());

         MessagePart headerPart = derivedMessageRootMapping.getHeaderPart();

         if (m_headerPart != headerPart)
         {
            m_headerPart = headerPart;
            m_bRestart = true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.