Package nexj.core.meta.integration

Examples of nexj.core.meta.integration.CompositeMessagePartInstance


      XSElementDeclaration elemDecl, final XSComplexTypeDefinition complexDef, String sNodeName, String sNamespace,
      boolean bNillable, Message msgArray[])
   {
      assert isComposite(complexDef, parent == null);

      CompositeMessagePartInstance newInstance;
      Message newMsg = null;
      String sMsgName = sNodeName;
      XSComplexTypeDefinition base = findBase(complexDef);

      if (parent == null)
      {
         sMsgName = generateMessageName(sMsgName);

         registerMessageName(sMsgName);
        
         newMsg = new Message(sMsgName);
        
         m_msgList.add(newMsg);
        
         if (msgArray != null)
         {
            msgArray[0] = newMsg;
         }
        
         if (m_metadata != null)
         {
            newMsg.setMetadata(m_metadata);
            newMsg.setFormat(m_metadata.getFormat("XML"));
         }

         if (isRegistered(complexDef))
         {
            String sName = generateDefaultMessageName(sNodeName, null);
            CompositeMessagePartRef ref = new CompositeMessagePartRef(sName);

            ref.setDescription(sElemDesc);
            newMsg.setRoot(ref);
            setMapping(ref, newMsg, sNodeName, sNamespace, bNillable, complexDef);

            addFixup(new MessageRefFixup(ref, sNodeName, sNamespace, bNillable, complexDef));

            return ref;
         }
        
         registerMessage(complexDef, newMsg);

         newInstance = new CompositeMessagePartInstance(sMsgName);
         newMsg.setRoot(newInstance);
        
         if (base != null)
         {
            addFixup(new MessageBaseFixup(base, newMsg));
         }
      }
      else
      {
         sMsgName = generateDefaultMessageName(sNodeName,
            new INameConflictChecker()
            {
               public boolean conflicts(String name)
               {
                  return parent.hasPart(name);
               }
            });

         assert base == null || elemDecl != null;
        
         if (base != null && elemDecl != null)
         {
            StringBuilder builder = new StringBuilder(sMsgName);
           
            for (CompositeMessagePartInstance ancestor = parent; ancestor != null; ancestor = ancestor.getParent())
            {
               builder.insert(0, ancestor.getName() + "_");
            }
           
            create(complexDef, builder.toString());
            return createRef(parent, elemDecl, sMsgName);
         }
        
         base = null;
         newInstance = new CompositeMessagePartInstance(sMsgName);
         newInstance.setParent(parent);
      }

      XSObjectList annotationList = complexDef.getAnnotations();
     
      if (annotationList != null && annotationList.getLength() > 0)
      {
         StringBuilder buffer = new StringBuilder();
        
         if (sElemDesc != null)
         {
            buffer.append(sElemDesc);
         }

         for (int i = 0; i < annotationList.getLength(); ++i)
         {
            XSAnnotation annotation = (XSAnnotation)annotationList.item(i);
        
            String sDescription = parseDescription(annotation);
           
            if (sDescription != null)
            {
               if (buffer.length() > 0)
               {
                  buffer.append("\r");
               }
              
               buffer.append(sDescription);
            }
         }

         if (buffer.length() > 0)
         {
            newInstance.setDescription(buffer.toString());
         }
      }
      else
      {
         newInstance.setDescription(sElemDesc);
      }

      setMapping(newInstance, newMsg, sNodeName, sNamespace, bNillable, complexDef);
      addAttributeParts(newInstance, complexDef, base);
      addChildParts(newInstance, EMPTY_PARTICLE_ARRAY, complexDef, base, null);
View Full Code Here


    */
   public void finish(MessagePart part)
   {
      if (part instanceof CompositeMessagePartInstance)
      {
         CompositeMessagePartInstance composite = (CompositeMessagePartInstance)part;

         // Sorts the message parts
         if (m_nLevel >= LEVEL_SEGMENT)
         {
            composite.sort(new Comparator()
            {
               public int compare(Object o1, Object o2)
               {
                  int n = ((HL7MessagePartMapping)((MessagePart)o1).getMapping()).getSeq() -
                     ((HL7MessagePartMapping)((MessagePart)o2).getMapping()).getSeq();

                  if (n == 0)
                  {
                     throw new MetadataException("err.meta.integration.hl7.dupSeq",
                        new Object[]{((MessagePart)o2).getFullPath()});
                  }

                  return n;
               }
            });
         }

         for (int i = 0, nCount = composite.getPartCount(); i < nCount; i++)
         {
            MessagePart child = composite.getPart(i);
            MessagePartMapping mapping = child.getMapping();

            if (mapping != null)
            {
               mapping.finish(child);
View Full Code Here

      final String sBaseMessage = XMLUtil.getStringAttr(messageElement, "base");

      if (!loadMessageRef(null, message, messageElement, sName))
      {
         CompositeMessagePart compMsgPart = new CompositeMessagePartInstance(sName);

         message.setRoot(compMsgPart);
         loadCompositeMessagePart(messageElement, compMsgPart, message);
      }
View Full Code Here

   protected void initCompositeMessagePart(Element partElement, final CompositeMessagePart composite, final Message message)
   {
      // Aggregation does not apply to referenced message parts
      if (composite instanceof CompositeMessagePartInstance)
      {
         CompositeMessagePartInstance part = (CompositeMessagePartInstance)composite;
         String sAggregation = XMLUtil.getStringAttr(partElement, "aggregation", "sequential");

         if (sAggregation != null)
         {
            if (sAggregation.equals("sequential"))
            {
               part.setAggregation(CompositeMessagePart.SEQUENTIAL);
            }
            else if (sAggregation.equals("random"))
            {
               part.setAggregation(CompositeMessagePart.RANDOM);
            }
            else if (sAggregation.equals("single"))
            {
               part.setAggregation(CompositeMessagePart.SINGLE);
            }
            else
            {
               throw new MetadataException("err.meta.integration.aggregation",
                  new Object[]{sAggregation});
            }
         }

         part.setLax(XMLUtil.getBooleanAttr(partElement, "lax", part.isLax()));
      }

      loadMessagePart(partElement, composite, message);
   }
View Full Code Here

               {
                  if (element.getNodeName().equals("Message"))
                  {
                     if (!loadMessageRef(composite, message, element, sName))
                     {
                        CompositeMessagePart part = new CompositeMessagePartInstance(sName);

                        composite.addPart(part);
                        loadCompositeMessagePart(element, part, message);
                     }
                  }
                  else if (element.getNodeName().equals("Value"))
                  {
                     final PrimitiveMessagePart part = new PrimitiveMessagePart(sName);

                     composite.addPart(part);
                     part.setType(Primitive.parse(XMLUtil.getReqStringAttr(element, "type")));
                     loadMessagePart(element, part, message);

                     XMLUtil.withFirstChildElement(element, "Enumerations", false, new ElementHandler()
                     {
                        public void handleElement(Element enumerationsElement)
                        {
                           XMLUtil.forEachChildElement(enumerationsElement, "Enumeration", new ElementHandler()
                           {
                              public void handleElement(Element enumerationElement)
                              {
                                 part.addEnumeration(XMLUtil.getReqStringAttr(enumerationElement, "value"));
                              }
                           });
                        }
                     });
                  }
View Full Code Here

      Metaclass specialClass = getMetadata().getMetaclass("Special");
      Message contactMsg = new Message("ContactMessage");
      Message doctorMsg = new Message("DoctorMessage");
      Message surgeonMsg1 = new Message("SurgeonMessage1");
      Message surgeonMsg2 = new Message("SurgeonMessage2");
      CompositeMessagePartInstance contactPart = new CompositeMessagePartInstance(contactMsg.getName());
      CompositeMessagePartInstance doctorPart = new CompositeMessagePartInstance(doctorMsg.getName());
      CompositeMessagePartInstance surgeonPart1 = new CompositeMessagePartInstance(surgeonMsg1.getName());
      CompositeMessagePartInstance surgeonPart2 = new CompositeMessagePartInstance(surgeonMsg2.getName());
      ObjectMessagePartMapping contactMapping = new ObjectMessagePartMapping();
      ObjectMessagePartMapping doctorMapping = new ObjectMessagePartMapping();
      ObjectMessagePartMapping surgeonMapping1 = new ObjectMessagePartMapping();
      ObjectMessagePartMapping surgeonMapping2 = new ObjectMessagePartMapping();

      contactMsg.setRoot(contactPart);
      doctorMsg.setRoot(doctorPart);
      surgeonMsg1.setRoot(surgeonPart1);
      surgeonMsg2.setRoot(surgeonPart2);

      contactPart.setDeclarator(contactMsg);
      doctorPart.setDeclarator(doctorMsg);
      surgeonPart1.setDeclarator(surgeonMsg1);
      surgeonPart2.setDeclarator(surgeonMsg2);

      doctorMsg.setBaseMessage(contactMsg);
      contactMsg.addDerivedMessage(doctorMsg);
      surgeonMsg1.setBaseMessage(doctorMsg);
      doctorMsg.addDerivedMessage(surgeonMsg1);
      surgeonMsg2.setBaseMessage(doctorMsg);
      doctorMsg.addDerivedMessage(surgeonMsg2);

      contactPart.setMapping(contactMapping);
      doctorPart.setMapping(doctorMapping);
      surgeonPart1.setMapping(surgeonMapping1);
      surgeonPart2.setMapping(surgeonMapping2);

      contactMapping.setMetaclass(contactClass);
      doctorMapping.setMetaclass(doctorClass);
      surgeonMapping1.setMetaclass(surgeonClass);
      surgeonMapping2.setMetaclass(surgeonClass);
View Full Code Here

TOP

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

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.