Package nexj.core.meta.integration

Examples of nexj.core.meta.integration.CompositeMessagePart


      Object[] rawRow = null;
      Message detectedMessage = null;

      Message longestMessage = parserTable.getMessageWithMostFields();
      CSVMessagePartMapping rootMapping = (CSVMessagePartMapping)longestMessage.getRoot().getMapping();
      CompositeMessagePart rowPart = (CompositeMessagePart)longestMessage.getRoot().getPart(0);
      CSVMessagePartMapping rowMapping = (CSVMessagePartMapping)rowPart.getMapping();

      initializeParse(in, rootMapping);

      //Count the number of fields in the first row of input, and use this number
      //to guess the message.
View Full Code Here


    * @return A list of TransferObjects containing the data for each row of
    *         the CSV file.
    */
   protected TransferObject parseMessage(Message msg, Object[] firstRow)
   {
      CompositeMessagePart rootPart = msg.getRoot();
      CSVMessagePartMapping rootMapping = (CSVMessagePartMapping)rootPart.getMapping();
      CompositeMessagePart rowPart = (CompositeMessagePart)rootPart.getPart(0);
      CSVMessagePartMapping rowMapping = (CSVMessagePartMapping)rowPart.getMapping();
      MessagePart[] partsInOrder = rootMapping.getPartsInOrder();

      TransferObject result = null;
      List listResult;

      try
      {
         if (rootMapping.isHeader())
         {
            if (firstRow == null)
            {
               firstRow = rawReadRow(null, rowMapping);
            }

            consumeComments(rootMapping);
            partsInOrder = makePartsInHeaderOrder(firstRow, rootMapping);
            firstRow = null;
         }

         listResult = parseBody(partsInOrder, rowMapping, firstRow);
      }
      catch (Exception innerEx)
      {
         throw new IntegrationException("err.integration.parse",
            new Object[]{msg.getName()}, innerEx);
      }

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

      return result;
   }
View Full Code Here

               skipTokens(nLevel + 1, 1);
               bMatch = true;
            }

            final CompositeMessagePart composite = (CompositeMessagePart)msgPart;
            TransferObject tobj = (parentMsgPart == null) ? parent : null;
            int nSeq = 1;

            if (msgPart == m_msh)
            {
               m_buf.append(m_sepArray[SEP_COMPONENT]);

               for (;;)
               {
                  int ch = getNextChar();

                  if (ch == m_sepArray[SEP_FIELD])
                  {
                     break;
                  }

                  m_buf.append((char)ch);
               }

               m_nSepLevel = HL7MessagePartMapping.LEVEL_FIELD;
               nSeq = 2;
            }

            for (int nPart = 0, nPartCount = composite.getPartCount(); nPart != nPartCount; ++nPart)
            {
               MessagePart part = composite.getPart(nPart);

               if (nLevel > HL7MessagePartMapping.LEVEL_GROUP)
               {
                  int nNextSeq = ((HL7MessagePartMapping)part.getMapping()).getSeq();
View Full Code Here

      {
         return null;
      }

      ObjectMessagePartMapping mapping = (ObjectMessagePartMapping)composite.getMapping();
      CompositeMessagePart derivedComposite = getPolymorphic(composite, tobj);
      ObjectMessagePartMapping derivedMapping = (ObjectMessagePartMapping)derivedComposite.getMapping();
      Metaclass derivedClass = (derivedMapping == null) ? null : derivedMapping.getMetaclass();

      // If any message part is mapped to special attributes ATTR_EVENT and ATTR_OID,
      // it overrides the event or oid set on message.
      String sEventName = (String)getSystemAttributeValue(derivedComposite, tobj, ObjectMessagePartMapping.ATTR_EVENT);
      OID oid = (OID)getSystemAttributeValue(derivedComposite, tobj, ObjectMessagePartMapping.ATTR_OID);

      if (sEventName != null)
      {
         setEventName(tobj, sEventName);
      }

      if (oid != null)
      {
         tobj.setOID(oid);
      }

      boolean bDelete = "delete".equals(tobj.getEventName());

      adjustEventName(tobj, derivedClass);

      Instance instance = (Instance)m_instanceByTobjMap.get(tobj);

      if (instance == null)
      {
         deleteInstanceState(tobj, derivedClass);

         if ("create".equals(tobj.getEventName())
            && (!derivedMapping.hasAlternativeSyncKey() || !isRootSynchronized(tobj)))
         {
            // The internal instance corresponding to the transfer object will be created during instantiation.
            m_instanceByTobjMap.put(tobj, null);
         }
         else
         {
            if (derivedClass != null)
            {
               if (derivedClass.getPersistenceMapping() == null)
               {
                  if (tobj.getEventName() == null)
                  {
                     if (parentTobj == null)
                     {
                        throw new IntegrationException("err.integration.object.missingEvent",
                           new Object[]{derivedComposite.getFullPath()});
                     }

                     setEventName(tobj, "create");
                  }

                  m_instanceByTobjMap.put(tobj, null);
               }
               else if (!mapping.isLocal() || m_instanceByTobjMap.contains(parentTobj))
               {
                  Pair where = getWhere1(tobj, composite, parentTobj, parentComposite, null, true);
                  InstanceList list = null;

                  if (where != EMPTY && !(mapping.isLocal() && m_instanceByTobjMap.get(parentTobj) == null))
                  {
                     if (mapping.isLocal())
                     {
                        Pair eq = Pair.list(Symbol.ATAT, ((ObjectMessagePartMapping)
                           parentComposite.getMapping()).getMetaclass().getSymbol(),
                           mapping.getAttribute().getSymbol()).eq(m_instanceByTobjMap.get(parentTobj));

                        if (where != null)
                        {
                           where = where.and(eq);
                        }
                        else
                        {
                           where = eq;
                        }
                     }

                     if (where != null)
                     {
                        list = (InstanceList)m_queryMap.get(derivedComposite, where);

                        if (list == null)
                        {
                           list = Query.createRead(derivedClass, getAttributes(derivedComposite), where, null,
                              2, 0, false, Query.SEC_NONE, m_context).read();

                           m_queryMap.put(derivedComposite, where, list);
                        }
                     }
                     else
                     {
                        where = EMPTY;
                     }
                  }

                  if (where != EMPTY && list != null && list.size() != 0)
                  {
                     if (list.size() > 1)
                     {
                        throw new IntegrationException("err.integration.object.ambiguousMatch",
                           new Object[]{derivedComposite.getFullPath()});
                     }

                     instance = list.getInstance(0);
                     m_instanceByTobjMap.put(tobj, instance);
                  }
                  else if (!bDelete)
                  {
                     if (tobj.getEventName() != null && (!mapping.isLocal() || m_instanceByTobjMap.get(parentTobj) == null) ||
                        !mapping.isCreate() && !mapping.isKey())
                     {
                        throw new IntegrationException("err.integration.object.noMatch",
                           new Object[]{derivedComposite.getFullPath()});
                     }

                     setEventName(tobj, (!mapping.isCreate() ||
                        where == EMPTY && !isKeyAvailable(tobj, derivedComposite)) ? "delete" : "create");

                     m_instanceByTobjMap.put(tobj, null);
                  }
               }
            }
         }
      }

      for (int i = 0, n = derivedComposite.getPartCount(); i != n; ++i)
      {
         MessagePart part = derivedComposite.getPart(i);

         if (part instanceof CompositeMessagePart)
         {
            findInstance(tobj.findValue(part.getName()), (CompositeMessagePart)part, tobj, derivedComposite);
         }
View Full Code Here

    */
   protected Pair getWhere1(TransferObject tobj, CompositeMessagePart composite, TransferObject parent,
      CompositeMessagePart parentComposite, Pair assoc, boolean bRoot)
   {
      ObjectMessagePartMapping mapping = (ObjectMessagePartMapping)composite.getMapping();
      CompositeMessagePart derivedComposite = getPolymorphic(composite, tobj);
      ObjectMessagePartMapping derivedMapping = ((ObjectMessagePartMapping)derivedComposite.getMapping());
      Metaclass derivedMetaclass = derivedMapping.getMetaclass();
      Pair where = null;

      if (!bRoot)
      {
         assoc = new Pair(mapping.getAttribute().getSymbol(), assoc);

         if (!mapping.isLocal())
         {
            Instance instance = (Instance)m_instanceByTobjMap.get(tobj);

            if (instance == null)
            {
               if (!m_instanceByTobjMap.contains(tobj) && !mapping.isSubKeyParent())
               {
                  instance = findInstance1(tobj, composite, parent, parentComposite);
               }

               if (instance == null && !mapping.isSubKeyParent())
               {
                  return EMPTY;
               }
            }

            if (instance != null && !mapping.isSubKeyParent())
            {
               return getComparison(assoc, instance);
            }
         }
      }

      if (tobj == null || isInstanceRead(tobj, derivedMapping))
      {
         return EMPTY;
      }

      if (tobj.getOID() != null)
      {
         where = new Pair(getComparison(assoc, tobj.getOID()), where);
      }
      else
      {
         for (int i = 0, n = derivedComposite.getPartCount(); i != n; ++i)
         {
            MessagePart part = derivedComposite.getPart(i);
            ObjectMessagePartMapping partMapping = (ObjectMessagePartMapping)part.getMapping();

            if (bRoot && partMapping.isKey() || !bRoot && partMapping.isSubKey())
            {
               if (!tobj.hasValue(part.getName()))
View Full Code Here

      InvocationContext context)
   {
      if (composite instanceof CompositeMessagePartRef)
      {
         String sDerivedMessageName = tobj.getClassName();
         CompositeMessagePart referencedPart = ((CompositeMessagePartRef)composite).getRefPart();

         if (!StringUtil.isEmpty(sDerivedMessageName))
         {
            Metadata metadata = context.getMetadata();
            Message derivedMessage = metadata.getMessage(sDerivedMessageName);
            Message baseMessage = metadata.getMessage(referencedPart.getRoot().getName());

            Message.validatePolymorphism(baseMessage, derivedMessage, composite);

            return derivedMessage.getRoot();
         }
View Full Code Here

            return validatedValue;
         }
      }

      CompositeMessagePart composite = (CompositeMessagePart)derivedPart;
      TransferObject tobj = (TransferObject)obj;
      Instance instance = (Instance)m_instanceByTobjMap.get(tobj);

      if (instance == null && "delete".equals(tobj.getEventName())) // Obsolete delete
      {
View Full Code Here

            if (!bDifferent)
            {
               if (part instanceof CompositeMessagePart && !part.isCollection())
               {
                  CompositeMessagePart derivedMessagePart = getPolymorphic((CompositeMessagePart)part, newTobj,
                     context);

                  bDifferent = !isSameKey((TransferObject)oldTobj.getValue(sName),
                     (TransferObject)newTobj.getValue(sName), derivedMessagePart, context);
               }
View Full Code Here

    *                        which does not have ordinal set.
    * @return The ordinal that should be assigned to the next mapping found.
    */
   protected int computeOrdinalValues(MessagePart part, int nCurrentOrdinal)
   {
      CompositeMessagePart compositePart = (CompositeMessagePart)part;
      int nChildren = compositePart.getPartCount();
     
      for (int nChild = 0; nChild < nChildren; nChild++)
      {
         MessagePart childPart = compositePart.getPart(nChild);
         CSVMessagePartMapping childMapping = (CSVMessagePartMapping)childPart.getMapping();
        
         if (childPart instanceof PrimitiveMessagePart)
         {
            if (childMapping.m_nOrdinal <= 0)
View Full Code Here

         finalizeInitialization((CompositeMessagePart)m_messagePart);
      }

      if (m_messagePart instanceof CompositeMessagePartInstance)
      {
         CompositeMessagePart composite = (CompositeMessagePartInstance)m_messagePart;

         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

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.