Package nexj.core.integration

Examples of nexj.core.integration.IntegrationException


         mark(MAX_MSH);
         parseMSH(msh);
      }
      catch (Exception e)
      {
         throw new IntegrationException("err.integration.hl7.unparseableMessage", e);
      }

      Lookup2D map = (Lookup2D)table.getParserTable();
      Message message = (Message)map.get(msh.type, msh.event);

      if (message == null)
      {
         String s = msh.structure;

         if (s.length() != 0)
         {
            int i = s.indexOf('_');

            message = (Message)((i < 0) ? map.get(s, "") : map.get(s.substring(0, i), s.substring(i + 1)));
         }

         if (message == null)
         {
            if (msh.event.length() != 0)
            {
               message = (Message)map.get(msh.type, "");
            }

            if (message == null)
            {
               throw new IntegrationException("err.integration.hl7.unsupportedMessage", new Object[]{msh.type, msh.event});
            }
         }
      }

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

      m_msh = HL7MessagePartMapping.findMSH(message);

      if (m_msh != null)
      {
         resetReader();
         nextToken();
      }

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

      try
      {
         parse(message.getRoot(), null, null, tobj);
      }
      catch (IntegrationException e)
      {
         throw e;
      }
      catch (Exception e)
      {
         throw new IntegrationException("err.integration.hl7.messageSyntax",
            new Object[]{message.getName()}, e);
      }

      return tobj;
   }
View Full Code Here


      {
         m_reader.mark(nCount);
      }
      catch (IOException e)
      {
         throw new IntegrationException("err.integration.io",
            new Object[]{ObjUtil.getMessage(e)}, e);
      }
   }
View Full Code Here

      {
         m_reader.reset();
      }
      catch (IOException e)
      {
         throw new IntegrationException("err.integration.io",
            new Object[]{ObjUtil.getMessage(e)}, e);
      }
   }
View Full Code Here

      {
         return m_reader.read();
      }
      catch (IOException e)
      {
         throw new IntegrationException("err.integration.io",
            new Object[]{ObjUtil.getMessage(e)}, e);
      }
   }
View Full Code Here

                     }

                     break;

                  default:
                     throw new IntegrationException("err.integration.hl7.escapeChar",
                        new Object[]{Primitive.createCharacter(ch)});
               }

               if (ch != m_sepArray[SEP_ESCAPE])
               {
                  throw new IntegrationException("err.integration.hl7.unterminatedEscape");
               }
            }
            else if (i == SEP_REPEAT)
            {
               m_nSepLevel = HL7MessagePartMapping.LEVEL_FIELD;
View Full Code Here

    */
   protected void parseMSH(MSH msh)
   {
      if (getNextChar() != 'M' || getNextChar() != 'S' || getNextChar() != 'H')
      {
         throw new IntegrationException("err.integration.hl7.msh");
      }

      m_sepArray = new char[6];
      m_sepArray[SEP_SEGMENT] = '\r';
      m_sepArray[SEP_FIELD] = (char)getNextChar();
      m_sepArray[SEP_COMPONENT] = (char)getNextChar();
      m_sepArray[SEP_REPEAT] = (char)getNextChar();

      int ch = getNextChar();

      if (ch != m_sepArray[SEP_FIELD])
      {
         m_sepArray[SEP_ESCAPE] = (char)ch;
         ch = getNextChar();
      }
      else
      {
         m_sepArray[SEP_ESCAPE] = '\\';
      }

      if (ch != m_sepArray[SEP_FIELD])
      {
         m_sepArray[SEP_SUBCOMPONENT] = (char)ch;
         ch = getNextChar();
      }
      else
      {
         m_sepArray[SEP_SUBCOMPONENT] = '&';
      }

      if (ch != m_sepArray[SEP_FIELD])
      {
         throw new IntegrationException("err.integration.hl7.sepField");
      }

      for (int i = m_sepArray.length - 1; i >= 0; --i)
      {
         ch = m_sepArray[i];

         for (int j = i - 1; j >= 0; --j)
         {
            if (m_sepArray[j] == ch)
            {
               throw new IntegrationException("err.integration.hl7.dupSep",
                  new Object[]{Primitive.createCharacter(ch)});
            }
         }
      }

      nextToken();
      skipTokens(HL7MessagePartMapping.LEVEL_FIELD, 4);

      String s = getCurToken();

      try
      {
         m_defTZ = HL7Util.parseTimeZone(s);

         if (m_defTZ == null)
         {
            m_defTZ = m_context.getTimeZone();
         }
      }
      catch (Exception e)
      {
         throw new IntegrationException("err.integration.hl7.timeZone", new Object[]{s}, e);
      }

      if (msh != null)
      {
         skipTokens(HL7MessagePartMapping.LEVEL_FIELD, 2);
View Full Code Here

                  {
                     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)
                  {
                     list = new ArrayList();
                     parent.setValue(msgPart.getName(), list);
                  }

                  list.add(value);
               }
               else
               {
                  parent.setValue(msgPart.getName(), value);
               }
            }
         }
         else
         {
            if (nLevel == HL7MessagePartMapping.LEVEL_MESSAGE)
            {
               throw new IntegrationException("err.integration.hl7.segment",
                  new Object[]{m_sToken, msgPart.getFullPath()});
            }

            if (nLevel == HL7MessagePartMapping.LEVEL_GROUP)
            {
               break;
            }
         }

         if (nLevel > HL7MessagePartMapping.LEVEL_SEGMENT)
         {
            if (!m_bRepeat || m_nSepLevel != nLevel)
            {
               break;
            }

            skipTokens(nLevel, 1);
         }
         else if (nLevel == HL7MessagePartMapping.LEVEL_SEGMENT)
         {
            if (nCount >= msgPart.getMaxCount())
            {
               skipTokens(nLevel, 1);

               break;
            }

            skipTokens(nLevel, 1);
         }
         else
         {
            if (nCount >= msgPart.getMaxCount())
            {
               break;
            }
         }
      }

      if (nCount < msgPart.getMinCount())
      {
         if (nCount == 0 && nLevel != HL7MessagePartMapping.LEVEL_FIELD &&
            parentMsgPart != null && grandParentMsgPart != null)
         {
            return false;
         }

         throw new IntegrationException("err.integration.minPartCount", new Object[]{msgPart.getFullPath()});
      }

      if (nCount > msgPart.getMaxCount())
      {
         throw new IntegrationException("err.integration.maxPartCount", new Object[]{msgPart.getFullPath()});
      }

      return (nCount != 0);
   }
View Full Code Here

                  break;
            }
         }
         catch (Exception e)
         {
            throw new IntegrationException("err.integration.hl7.dtm", new Object[]{sValue}, e);
         }
      }
      else
      {
         value = part.getType().getConverter(Primitive.STRING).invoke(sValue);
View Full Code Here

      }
      catch (Exception e)
      {
         s_logger.debug("Object formatting error", e);

         throw new IntegrationException("err.integration.format",
            new Object[]{composite.getName()}, e);
      }
      finally
      {
         m_context.setAudited(bAuditedSaved);
View Full Code Here

               {
                  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");
View Full Code Here

TOP

Related Classes of nexj.core.integration.IntegrationException

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.