Package nexj.core.meta.integration

Examples of nexj.core.meta.integration.CompositeMessagePart


    * @param message The message to analyze.
    * @return The message part, or null if not found.
    */
   public static CompositeMessagePart findMSH(Message message)
   {
      CompositeMessagePart root = message.getRoot();

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

      MessagePart hdr = root.getPart(0);
      HL7MessagePartMapping mapping = (HL7MessagePartMapping)hdr.getMapping();

      return (mapping.getLevel() == HL7MessagePartMapping.LEVEL_SEGMENT &&
         mapping.getName().equals("MSH")) ? (CompositeMessagePart)hdr : null;
   }
View Full Code Here


   public void init(MessagePart part)
   {
      verifyNotReadOnly();
      m_part = part;

      CompositeMessagePart parentPart = part.getParent();
      XMLMessagePartMapping parentMapping = (parentPart == null) ? null : (XMLMessagePartMapping)parentPart.getMapping();
      PrimitiveMessagePart primitivePart = null;
      CompositeMessagePart compositePart = null;

      if (part instanceof PrimitiveMessagePart)
      {
         primitivePart = (PrimitiveMessagePart)part;
      }
View Full Code Here

      }

      if (part instanceof CompositeMessagePart)
      {
         boolean bInstance = part instanceof CompositeMessagePartInstance;
         CompositeMessagePart composite = (CompositeMessagePart)part;

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

            if (mapping != null)
            {
               if (bInstance)
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

      {
         addPreInheritanceMessageFixup(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               CompositeMessagePart root = m_metadata.getMessage(sRef).getRoot();

               partRef.setRefPart(root);

               MessagePartMapping rootMapping = root.getMapping();

               if (rootMapping != null)
               {
                  if (partRef.getMapping() == null)
                  {
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

      MetadataCompoundValidationException comp = null;

      while (iterator.hasNext())
      {
         Message message = (Message)iterator.next();
         CompositeMessagePart root = message.getRoot();
         MessagePartMapping mapping = root.getMapping();

         if (mapping != null)
         {
            try
            {
View Full Code Here

      if (instance != null || srcTobj != null)
      {
         if (msg instanceof CompositeMessagePartRef)
         {
            CompositeMessagePartRef ref = (CompositeMessagePartRef)msg;
            CompositeMessagePart referencedPart = ref.getRefPart();

            message = ((ObjectMessagePartMapping)referencedPart.getMapping()).getMessage();
         }
         else if (msg.getParent() == null)
         {
            message = ((ObjectMessagePartMapping)msg.getRoot().getMapping()).getMessage();
         }
      }

      // Process inheritance
      if (message != null)
      {
         metaclass = (instance != null) ? instance.getMetaclass() :
            m_context.getMetadata().getMetaclass(srcTobj.getClassName());

         Message derivedMessage = findDerivedMessage(message, metaclass);

         if (derivedMessage == null)
         {
            throw new IntegrationException("err.integration.object.missingMapping",
               new Object[]{metaclass.getName(), message.getName(), msg.getFullPath()});
         }

         Message.validatePolymorphism(message, derivedMessage, msg);
         msg = derivedMessage.getRoot();
         message = derivedMessage;
         sMessageName = message.getName();
      }

      ObjectMessagePartMapping mapping = (ObjectMessagePartMapping)msg.getMapping();

      if (m_context.isSecure())
      {
         if (mapping.getAttribute() != null)
         {
            mapping.getAttribute().checkReadAccess(m_context.getPrivilegeSet());
         }
         else
         {
            mapping.getMetaclass().checkReadAccess(m_context.getPrivilegeSet());
         }
      }

      if (obj == null)
      {
         if (msg.isRequired())
         {
            throw new IntegrationException("err.integration.minPartCount", new Object[]{msg.getFullPath()});
         }
        
         return null;
      }
     
      if (msg instanceof PrimitiveMessagePart)
      {
         return ((PrimitiveMessagePart)msg).convertValue(obj);
      }

      CompositeMessagePart composite = (CompositeMessagePart)msg;
      int nCount = composite.getPartCount();
     
      if (obj instanceof TransferObject)
      {
         if (isFetchInstance())
         {
            instance = (Instance)RPCUtil.instantiateClean(srcTobj, new HashTab(), m_context);
         }
         else
         {
            TransferObject tobj = new TransferObject(sMessageName, composite.getPartCount());

            tobj.setEventName(srcTobj.getEventName());
            tobj.setOID(srcTobj.getOID());
  
            for (int i = 0; i < nCount; ++i)
            {
               MessagePart part = composite.getPart(i);
               ObjectMessagePartMapping objectMessagePartMapping = (ObjectMessagePartMapping)part.getMapping();
               Attribute attribute = objectMessagePartMapping.getAttribute();
               Object value = null;

               if (attribute != null)
               {
                  value = transfer(srcTobj.findValue(attribute.getName()), part);
               }
               else
               {
                  switch (objectMessagePartMapping.getSystemAttribute())
                  {
                     case ObjectMessagePartMapping.ATTR_OID:
                        value = srcTobj.getOID().toBinary();
                        break;

                     case ObjectMessagePartMapping.ATTR_CLASS:
                        value = srcTobj.getClassName();
                        break;

                     case ObjectMessagePartMapping.ATTR_EVENT:
                        value = srcTobj.getEventName();
                        break;
                  }
               }

               tobj.setValue(part.getName(), value);
            }
  
            return tobj;
         }
      }

      if (m_context.isSecure() && !instance.isReadable())
      {
         return null;
      }

      metaclass = instance.getMetaclass();

      TransferObject tobj = new TransferObject(sMessageName, composite.getPartCount());
     
      if (!mapping.getMetaclass().isUpcast(metaclass))
      {
         throw new IntegrationException("err.integration.object.partClass",
            new Object[]{mapping.getMetaclass().getName(), composite.getFullPath()});
      }

      String sEvent = null;
      boolean bProcessed = m_processedSet.put(instance, processedPart, Boolean.TRUE) != null;
     
      m_instanceMap.put(instance, tobj);
      tobj.setOID(instance.getOID());

      if (srcTobj != null)
      {
         sEvent = srcTobj.getEventName();
      }
      else
      {
         switch (instance.getState())
         {
            case Instance.NEW:
               sEvent = "create";
               break;

            case Instance.DIRTY:
               sEvent = "update";
               break;

            case Instance.DELETED:
               sEvent = "delete";
               break;
         }
      }

      tobj.setEventName(sEvent);

      for (int i = 0; i < nCount; ++i)
      {
         MessagePart part = composite.getPart(i);
         ObjectMessagePartMapping objectMessagePartMapping = (ObjectMessagePartMapping)part.getMapping();
         Attribute attribute = objectMessagePartMapping.getAttribute();
         Object value = null;

         if (attribute != null)
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 rootPart = message.getRoot();
      CSVMessagePartMapping rootMapping = (CSVMessagePartMapping)rootPart.getMapping();
     
      CompositeMessagePart rowPart = (CompositeMessagePart)rootPart.getPart(0);
     
      //Get the MessageParts in the order specified by their ordinal tags.
      PrimitiveMessagePart[] partsInOrder = rootMapping.getPartsInOrder();
     
      try
      {
         m_writer = out.getWriter();
        
         //First line should be the column headers.
         if (rootMapping.isHeader())
         {
            formatHeader(rootMapping);
         }
        
         //The one and only sub-datum will be a List of TransferObjects if there
         //are many rows or a single TransferObject if there is just one row.
         Object toFormat = tobj.findValue(rowPart.getName());

         if (toFormat instanceof List)
         {
            formatRows((List)toFormat, partsInOrder, rowPart);
         }
View Full Code Here

   /**
    * @see nexj.core.integration.MessageParser#parse(nexj.core.integration.Input, nexj.core.meta.integration.Message)
    */
   public TransferObject parse(Input in, Message msg) throws IntegrationException
   {
      CompositeMessagePart rootPart = msg.getRoot();
      CSVMessagePartMapping rootMapping = (CSVMessagePartMapping)rootPart.getMapping();

      initializeParse(in, rootMapping);

      return parseMessage(msg, null);
   }
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.