Package nexj.core.scripting

Examples of nexj.core.scripting.Pair


   protected Pair getWhere(Object obj, CompositeMessagePart composite, TransferObject parent,
      CompositeMessagePart parentComposite, Pair assoc, boolean bRoot)
   {
      if (composite.isCollection())
      {
         Pair where = null;
         List list = getList(obj, composite);

         for (int i = 0, n = list.size(); i != n; ++i)
         {
            Pair expr = getWhere1((TransferObject)list.get(i), composite, parent, parentComposite, assoc, bRoot);

            if (expr != EMPTY && expr != null)
            {
               where = new Pair(expr, where);
            }
         }

         if (where != null)
         {
            if (where.getTail() == null)
            {
               return (Pair)where.getHead();
            }

            return new Pair(Symbol.OR, where);
         }

         return EMPTY;
      }
View Full Code Here


   {
      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()))
               {
                  return EMPTY;
               }

               Object obj = tobj.getValue(part.getName());
               Pair expr = null;

               if (part instanceof CompositeMessagePart)
               {
                  expr = getWhere(obj, (CompositeMessagePart)part, tobj, composite, assoc, false);

                  if (expr == EMPTY)
                  {
                     return EMPTY;
                  }
               }
               else if (partMapping.getSystemAttribute() == ObjectMessagePartMapping.ATTR_OID)
               {
                  expr = getComparison(assoc, obj);
               }
               else if (partMapping.getAttribute() != null)
               {
                  expr = getComparison(new Pair(partMapping.getAttribute().getSymbol(), assoc),
                     partMapping.getAttribute().getType().convert(obj));
               }

               if (expr != null)
               {
                  where = new Pair(expr, where);
               }
            }
         }

         if (!bRoot && derivedMetaclass != mapping.getAttribute().getType())
         {
            where = new Pair(Pair.binary(Symbol.INSTANCE_P, getAssociation(assoc),
               derivedMetaclass.getSymbol()), where);
         }

         if (mapping.getWhere() != Boolean.TRUE)
         {
            where = new Pair(mapping.getWhere(), where);
         }
      }

      if (where != null)
      {
         if (where.getTail() == null)
         {
            return (Pair)where.getHead();
         }

         where = new Pair(Symbol.AND, where);
      }

      return where;
   }
View Full Code Here

    * Creates an association operator based on an association list.
    * @param assoc The reversed association symbol list.
    */
   protected static Pair getAssociation(Pair assoc)
   {
      Pair pair = null;

      while (assoc != null)
      {
         pair = new Pair(assoc.getHead(), pair);
         assoc = assoc.getNext();
      }

      return new Pair(Symbol.AT, pair);
   }
View Full Code Here

                        {
                           s_logger.debug(sMsg);
                        }
                     }

                     Pair cond = Pair.list(Symbol.ATAT, m_container.getMetaclass().getSymbol(),
                        m_attribute.getSymbol()).eq(m_container.getOID());

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

                     if (nCount > 0 && m_changeMap != null)
                     {
                        for (Iterator itr = m_changeMap.valueIterator(); itr.hasNext();)
View Full Code Here

    */
   public Pair list()
   {
      load();

      Pair pair = null;

      for (int i = m_nCount - 1; i >= 0; --i)
      {
         pair = new Pair(m_instanceArray[i], pair);
      }

      return pair;
   }
View Full Code Here

   /**
    * @return The items in the collection as a linked list.
    */
   public Pair list()
   {
      Pair pair = null;

      for (Iterator itr = iterator(); itr.hasNext();)
      {
         pair = new Pair(itr.next(), pair);
      }

      return Pair.nreverse(pair);
   }
View Full Code Here

      Context contextSaved = ThreadContextHolder.getContext();
     
      try
      {
         ThreadContextHolder.setContext(m_context);
         m_context.getMachine().invoke(m_function, new Pair(Integer.valueOf(nStatus), m_argumentPair));
      }
      finally
      {
         ThreadContextHolder.setContext(contextSaved);
      }
View Full Code Here

         }

         if (m_nState == NEW && value == Undefined.VALUE && attribute.getInitializer() != Undefined.VALUE)
         {
            return setCalcValue(attribute,
               m_context.getMachine().invoke(attribute.getInitializerFunction(), new Pair(this)));
         }

         if (attribute.getValueFunction() != null)
         {
            return setCalcValue(attribute,
               m_context.getMachine().invoke(attribute.getValueFunction(), new Pair(this)));
         }

         if (attribute.isCollection() && attribute.isPersistent() &&
            (m_nState == CLEAN || m_nState == DIRTY))
         {
View Full Code Here

            {
               list = new InstanceArrayList((Collection)value);
            }
            else if (value instanceof Pair)
            {
               Pair pair = (Pair)value;

               list = new InstanceArrayList(Pair.length(pair));

               do
               {
                  list.add(type.convert(pair.getHead()));
                  pair = pair.getNext();
               }
               while (pair != null);

               return list;
            }
View Full Code Here

                  value != null && e == null)
               {
                  if (((InstanceList)attribute.getEnumeration().invoke("read",
                     new Object[]{null, (type.isPrimitive()) ?
                        Pair.attribute(Metaclass.ENUMERATION_VALUE).eq(value) :
                        new Pair(Symbol.AT).eq(value), null, Primitive.createInteger(-1),
                        Primitive.ZERO_INTEGER, Boolean.FALSE})).isEmpty())
                  {
                     e = createValidationException(e);

                     ValidationException x = new ValidationException("err.validation.enumerationValue",
                        new Object[]{new StringId(attribute.getEnumeration().getCaption()),
                           new StringId(attribute.getCaption()), new StringId(m_metaclass.getCaption())});

                     x.setClassName(m_metaclass.getName());
                     x.setOIDHolder(this);
                     e.addException(attribute.getName(), x);
                  }
               }

               if (attribute.getValidationFunction() != null && e == null)
               {
                  Object result = m_context.getMachine().invoke(attribute.getValidationFunction(), this, value, null);

                  if (result != null)
                  {
                     ValidationException x = null;

                     if (result instanceof Boolean)
                     {
                        if (!((Boolean)result).booleanValue())
                        {
                           x = new ValidationException("err.validation.valueRange",
                              new Object[]{new StringId(attribute.getCaption()), new StringId(m_metaclass.getCaption())});
                        }
                     }
                     else if (result instanceof String)
                     {
                        x = new ValidationException((String)result);
                     }
                     else if (result instanceof Pair)
                     {
                        x = new ValidationException((String)((Pair)result).getHead(),
                              Pair.toArray(((Pair)result).getNext()));
                     }

                     if (x != null)
                     {
                        x.setClassName(m_metaclass.getName());
                        x.setOIDHolder(this);
                        e = createValidationException(e);
                        e.addException(attribute.getName(), x);
                     }
                  }
               }
            }

            if (type.isPrimitive() && attribute.isPersistent() && adapter != null)
            {
               try
               {
                  adapter.validate(persistenceMapping.getAttributeMapping(attribute), value);
               }
               catch (ValidationException x)
               {
                  x.setClassName(m_metaclass.getName());
                  x.setOIDHolder(this);
                  e = createValidationException(e);
                  e.addException(attribute.getName(), x);
               }
            }
         }

         if (bFull && m_metaclass.getValidationFunction() != null && e == null)
         {
            Object result = m_context.getMachine().invoke(m_metaclass.getValidationFunction(), new Pair(this));

            if (result != null)
            {
               if (result instanceof Boolean)
               {
View Full Code Here

TOP

Related Classes of nexj.core.scripting.Pair

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.