Package nexj.core.rpc

Examples of nexj.core.rpc.TransferObject$Iterator


    * @param partsInOrder The message parts, in CSV field order.
    * @return A TransferObject graph representing the processed data row.
    */
   protected TransferObject convertRow(Object[] rawRow, MessagePart[] partsInOrder)
   {
      TransferObject result = new TransferObject(partsInOrder.length)//over-allocates
      boolean bGotData = false;

      for (int nDataIndex = 0; nDataIndex < partsInOrder.length; nDataIndex++)
      {
         PrimitiveMessagePart part = (PrimitiveMessagePart)partsInOrder[nDataIndex];

         //Check for missing required parts.
         if (nDataIndex >= rawRow.length || rawRow[nDataIndex] == Invalid.VALUE)
         {
            for (int nPartScanIndex = nDataIndex; nPartScanIndex < partsInOrder.length; nPartScanIndex++)
            {
               MessagePart scanPart = partsInOrder[nPartScanIndex];

               if (scanPart != null && scanPart.isRequired())
               {
                  throw new IntegrationException("err.integration.minPartCount",
                     new Object[]{scanPart.getFullPath()});
               }
            }

            continue;
         }

         //Skip data that are not mapped to a MessagePart
         if (part == null)
         {
            continue;
         }

         Object datum = rawRow[nDataIndex];

         //Traverse graph of TransferObjects to find the object to which this
         //datum should be attached, creating the graph as necessary.
         if ((datum != null && datum != Invalid.VALUE) || part.isRequired())
         {
            CSVMessagePartMapping mapping = (CSVMessagePartMapping)part.getMapping();

            if (mapping.getFormat() == null)
            {
               datum = part.convertValue(datum);
            }
            else
            {
               if (m_primitiveFormatter == null)
               {
                  m_primitiveFormatter = new PrimitiveFormatter(m_context);
               }

               datum = m_primitiveFormatter.parse((String)datum, part);
            }

            TransferObject nestedResult = result;
            TransferObject nextNestedResult = null;
            String[] dataKeyPath = mapping.getDataKeyPath();

            for (int nKeyPathIndex=0; nKeyPathIndex < dataKeyPath.length - 1; nKeyPathIndex++)
            {
               nextNestedResult = (TransferObject)nestedResult.findValue(dataKeyPath[nKeyPathIndex]);

               if (nextNestedResult == null)
               {
                  nextNestedResult = new TransferObject();
                  nestedResult.setValue(dataKeyPath[nKeyPathIndex], nextNestedResult);
               }

               nestedResult = nextNestedResult;
            }
View Full Code Here


    * Gets a default MSH value.
    */
   protected Object getDefaultMSHValue(MessagePart part)
   {
      Primitive primitive = null;
      TransferObject tobj;

      if (part instanceof PrimitiveMessagePart)
      {
         primitive = ((PrimitiveMessagePart)part).getType();
      }

      switch (((HL7MessagePartMapping)part.getMapping()).getSeq())
      {
         case 7: // Message time
            if (primitive != null)
            {
               return primitive.convert(new Timestamp(System.currentTimeMillis()));
            }

            break;

         case 9: // Message type
            String sType = ((HL7MessagePartMapping)m_message.getRoot().getMapping()).getName();
            String sEvent = null;

            int i = sType.indexOf('^');

            if (i >= 0)
            {
               sEvent = sType.substring(i + 1);
               sType = sType.substring(0, i);
            }

            if (primitive != null)
            {
               return sType;
            }

            tobj = new TransferObject(2);
            setValue(tobj, (CompositeMessagePart)part, 1, sType);
            setValue(tobj, (CompositeMessagePart)part, 2, sEvent);

            return tobj;

         case 10: // Control Id
            if (primitive != null)
            {
               return primitive.convert(getControlId());
            }

            break;

         case 11: // Processing Id
            if (primitive != null)
            {
               return DEFAULT_PROCESSING;
            }

            tobj = new TransferObject(1);
            setValue(tobj, (CompositeMessagePart)part, 1, DEFAULT_PROCESSING);

            return tobj;

         case 12: // Version
View Full Code Here

         {
            resetReader();
            nextToken();
         }

         TransferObject tobj = new TransferObject(message.getName());

         parse(message.getRoot(), null, null, tobj);

         return tobj;
      }
View Full Code Here

      {
         resetReader();
         nextToken();
      }

      TransferObject tobj = new TransferObject(message.getName());

      try
      {
         parse(message.getRoot(), null, null, tobj);
      }
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();

                  if (msgPart == m_msh && nNextSeq <= 2)
                  {
                     if (nNextSeq == 1)
                     {
                        m_sToken = new String(m_sepArray, SEP_FIELD, 1);
                     }
                     else
                     {
                        m_sToken = m_buf.toString();
                     }

                     nNextSeq = 2;
                  }

                  skipTokens(nLevel + 1, nNextSeq - nSeq);
                  nSeq = nNextSeq;
               }

               if (parse(part, composite, parentMsgPart, tobj))
               {
                  bMatch = true;

                  if (tobj == null)
                  {
                     value = tobj = m_tobj;
                  }
               }
               else
               {
                  if (part.isRequired())
                  {
                     if (bMatch ||
                        nLevel == HL7MessagePartMapping.LEVEL_SEGMENT ||
                        nLevel > HL7MessagePartMapping.LEVEL_SEGMENT && m_nSepLevel > nLevel)
                     {
                        throw new IntegrationException("err.integration.minPartCount", new Object[]{part.getFullPath()});
                     }
                     else
                     {
                        break loop;
                     }
                  }
               }
            }
         }

         if (bMatch)
         {
            ++nCount;

            if (parentMsgPart != null)
            {
               if (parent == null)
               {
                  parent = new TransferObject();
               }

               m_tobj = parent;
              
               if (nLevel == HL7MessagePartMapping.LEVEL_SEGMENT && value == null)
               {
                  value = new TransferObject(((CompositeMessagePart)msgPart).getPartCount());
               }

               if (msgPart.isCollection())
               {
                  if (list == null)
View Full Code Here

    */
   public void send(
      Metaclass metaclass, Object to, Object from, String sSubject, Object message, Pair properties,
      ActionContext actx)
   {
      TransferObject msg = (message instanceof TransferObject) // if already in Mail.message format
                         ? (TransferObject)((TransferObject)message).clone() : toMessage(message);

      msg.setValue(Mail.TO, toAddress(to));
      msg.setValue(Mail.FROM, toAddress(from));
      msg.setValue(Mail.SUBJECT, sSubject);

      // set all previously supported headers as key->value pairs in msg
      for (Pair props = properties; props != null; props = props.getNext())
      {
         if (!(props.getHead() instanceof Pair))
         {
            throw new RPCException("err.rpc.mailPropertyFormat");
         }

         Pair pair = (Pair)props.getHead();
         Object name = pair.getHead();

         if (!(name instanceof Symbol) && !(name instanceof String))
         {
            throw new RPCException("err.rpc.mailPropertyFormat");
         }

         String sName = name.toString();

         if (sName.equals("CC"))
         {
            msg.setValue(Mail.CC, toAddress(pair.getNext()));
         }
         else if (sName.equals("BCC"))
         {
            msg.setValue(Mail.BCC, toAddress(pair.getNext()));
         }
         else if (sName.equals("Reply-To"))
         {
            msg.setValue(Mail.REPLY, toAddress(pair.getNext()));
         }
         else
         {
            throw new RPCException("err.rpc.mailProperty", new Object[]{sName});
         }
View Full Code Here

      Pair pair = (Pair)addr;

      if (pair.getHead() instanceof String &&
          (pair.getTail() == null || pair.getTail() instanceof String))
      {
         TransferObject address = new TransferObject(2);

         address.setValue(Mail.ADDRESS, ((Pair)addr).getHead());
         address.setValue(Mail.PERSONAL, ((Pair)addr).getTail());

         return address;
      }

      ArrayList array = new ArrayList(2);
View Full Code Here

      if (list == null)
      {
         return null;
      }

      TransferObject tobj = new TransferObject();

      for (; list != null; list = list.getNext())
      {
         Pair header = (Pair)list.getHead();
         String sKey = (header.getHead() instanceof Symbol)
                     ? ((Symbol)header.getHead()).getName() : (String)header.getHead();
         String sValue = (String)header.getTail(); // string required by protocol

         tobj.setValue(sKey, sValue);
      }

      return tobj;
   }
View Full Code Here

    * @param content The content to transform.
    * @return The TransferObject message representation with the content.
    */
   protected static TransferObject toMessage(Object content)
   {
      TransferObject msg = new TransferObject(2);

      if (content instanceof Pair) // (msg (header1 . val1) ... (headerN . valN))
      {
         msg.setValue(Mail.BODY, toBody(((Pair)content).getHead()));
         msg.setValue(Mail.HEADERS, toHeaders(((Pair)content).getNext()));
      }
      else // A string, Multipart, null, or list
      {
         msg.setValue(Mail.BODY, content);
      }

      return msg;
   }
View Full Code Here

   }


   public static void submit(Function function, List arguments, InvocationContext context)
   {
      TransferObject properties = new TransferObject(1);
     
      if (context.getPrincipal() != InvocationContext.ANONYMOUS_PRINCIPAL)
      {
         properties.setValue(JMSSender.USER, context.getPrincipal().getName());
      }
     
      properties.setValue(JMS.MAX_ERROR_COUNT, new Integer(0)); // Do not retry

      context.getUnitOfWork().addMessage(UnitOfWork.SYSTEM_QUEUE, new FunctionExecutor(function, arguments), properties, 2, 0, false);
   }
View Full Code Here

TOP

Related Classes of nexj.core.rpc.TransferObject$Iterator

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.