Package nexj.core.scripting

Examples of nexj.core.scripting.Pair$PairIterator


      assert m_next != null;
      assert m_next.getOrdinal() >= 0;

      verifyNotReadOnly();
     
      Pair code = addArg(null, Symbol.WORKFLOW, Symbol._FLOW);
      Object caption = (m_caption != Undefined.VALUE) ? m_caption : getName();

      code = addArg(code, Symbol.CAPTION, (caption == null) ? " " : caption);

      if (m_priority != Undefined.VALUE)
      {
         code = addArg(code, Symbol.PRIORITY, m_priority);
      }
     
      if (m_assignee != Undefined.VALUE)
      {
         code = addArg(code, Symbol.ASSIGNEE, m_assignee);
      }

      if (m_owner != Undefined.VALUE)
      {
         code = addArg(code, Symbol.OWNER, m_owner);
      }

      if (m_queue != null)
      {
         code = addArg(code, Symbol.QUEUE,
            Pair.list(Symbol.SYSWORKFLOWQUEUE, Pair.quote(Symbol.GETQUEUE), m_queue)
            );
      }

      code = addArg(code, Symbol.ORDINAL, Primitive.createInteger(m_nOrdinal));
      code = addArg(code, SEMAPHORE, Boolean.valueOf(m_bSemaphore));

      // (lambda (...) (begin-privileged (<m_factory> (cons 'workflow :flow) (cons ...))))
      // m_factory defaults to produce the expression (SysWorkflowAssignment 'new (cons 'workflow :flow) (cons ...))
      m_function = compile(ARGUMENTS,
         new Pair(
            Pair.list(Symbol.BEGIN_PRIVILEGED,
               Pair.append(m_factory, code)
            ),
            m_activity.getFlow().getDefaultReturnCode()
         ), machine);

      // (lambda (...)
      //    (cond
      //       (cond1
      //          (:assignment'target "target1")
      //          (:assignment'form "form1")
      //          (:assignment'uimode nMode)
      //          "branch1"
      //       )
      //       ...
      //    )
      // )
      if (m_targetList != null)
      {
         Pair pair = null;

         for (int i = m_targetList.size() - 5; i >= 0; i -= 5)
         {
            Pair body = Pair.list(
               Pair.list(Symbol._ASSIGNMENT, Pair.quote(Symbol.TARGET), m_targetList.get(i + 1)),
               Pair.list(Symbol._ASSIGNMENT, Pair.quote(Symbol.FORM), m_targetList.get(i + 2)),
               Pair.list(Symbol._ASSIGNMENT, Pair.quote(Symbol.UIMODE), m_targetList.get(i + 3)),
               m_targetList.get(i + 4)
               );

            if (!m_activity.getFlow().isPrivileged())
            {
               body = Pair.list(new Pair(Symbol.BEGIN_PRIVILEGED, body));
            }

            pair = new Pair(new Pair(m_targetList.get(i), body), pair);
         }

         pair = new Pair(Symbol.COND, pair);

         if (m_activity.getFlow().isPrivileged())
         {
            pair = Pair.list(Symbol.BEGIN_PRIVILEGED, pair);
         }
View Full Code Here


       *
       * @see nexj.core.meta.xml.XMLSOAMetadataLoader.CodeProvider#getCode()
       */
      public Object getCode()
      {
         Pair methods = null;

         for (Iterator itr = m_methodSet.iterator(); itr.hasNext(); )
         {
            MethodImplementation method = (MethodImplementation)itr.next();

            methods = new Pair(method.getCode(), methods);
         }

         return new Pair(DEFINE_CLASS,
            new Pair(Symbol.define(getGlobalName()),
               new Pair(Pair.list(
                     Symbol.define(m_interface.getGlobalName())
                  ),
                  new Pair("", methods)
               )
            )
         );
      }
View Full Code Here

       *
       * @see nexj.core.meta.xml.XMLSOAMetadataLoader.SOAObject#getCode()
       */
      public Object getCode()
      {
         return new Pair(CLASS_METHOD,
            new Pair(Symbol.define(m_sName),
               new Pair(m_args,
                  new Pair("", m_script)
               )
            )
         );
      }
View Full Code Here

            bDefault = true;
            break;
         }
      }

      Pair code = (bDefault) ? null : DEFAULT_CATCH;

      for (int i = getBranchCount() - 1; i >= 0; --i)
      {
         code = new Pair(getBranch(i).generate(), code);
      }

      code = new Pair(Symbol.COND, code);

      if (m_activity.getFlow().isPrivileged())
      {
         code = Pair.list(Symbol.BEGIN_PRIVILEGED, code);
      }
     
      code = Pair.list(code);
     
      if (m_exceptionVariable != null)
      {
         code = new Pair(Pair.list(Symbol.SET, m_exceptionVariable.getSymbol(), Symbol._EXCEPTION), code);
      }

      m_function = compile(CATCH_ARGUMENTS, code, machine);
   }
View Full Code Here

      /*
       * (lambda (this properties)
       *    <script>
       * )
      */
      Pair code = new Pair(
         Symbol.LAMBDA,
         new Pair(
            Pair.list(Symbol.THIS, VirtualMapping.PROPERTIES),
            (m_script == null) ? new Pair(null) : m_script
         )
      );

      textPosMap.put(code, new TextPosition(0, 0, sURL));

View Full Code Here

         {
            attrDirectionList.add(head);
         }
         else
         {
            attrDirectionList.add(new Pair(head, Boolean.TRUE));
         }
      }

      int nCount = attrDirectionList.size();
View Full Code Here

                           final String sReadPrefix = sURLPrefix + ".read." + m_nOrdinal;
                           Object whereExpr = m_helper.parse(
                              XMLUtil.getStringAttr(element, "where"),
                              false, sReadPrefix + "$where", mapping.getTextPositionMap(), Symbol.ELSE, metadata.getGlobalEnvironment()
                           );
                           Pair variables = (Pair)m_helper.parse(
                              XMLUtil.getStringAttr(element, "variables"),
                              true, mapping.getTextPositionMap(), null, metadata.getGlobalEnvironment()
                           );
                           final ReadMappingCase readMappingCase = new ReadMappingCase();

                           readMappingCase.setWhere(whereExpr);
                           readMappingCase.setVariables(variables);

                           XMLUtil.withFirstChildElement(element, "Read", true, new XMLUtil.ElementHandler()
                           {
                              public void handleElement(Element element)
                              {
                                 readMappingCase.setReadScript(loadScript(element, sReadPrefix + "$read", mapping.getTextPositionMap()));
                              }
                           });

                           XMLUtil.withFirstChildElement(element, "Close", false, new XMLUtil.ElementHandler()
                           {
                              public void handleElement(Element element)
                              {
                                 readMappingCase.setCloseScript(loadScript(element, sReadPrefix + "$close", mapping.getTextPositionMap()));
                              }
                           });

                           readMapping.addCase(readMappingCase);
                           m_nOrdinal += 1;
                        }
                     });
                  }
               });

               XMLUtil.withFirstChildElement(element, "CreateMapping", false,
                  new XMLUtil.ElementHandler()
               {
                  public void handleElement(Element element)
                  {
                     final WorkMapping operation = new WorkMapping(metaclass);

                     operation.setBatch(XMLUtil.getBooleanAttr(element, "batch", operation.isBatch()));
                     operation.setScript(loadScript(element, sURLPrefix + ".create", mapping.getTextPositionMap()));
                     mapping.setCreateMapping(operation);
                  }
               });

               XMLUtil.withFirstChildElement(element, "UpdateMapping", false,
                  new XMLUtil.ElementHandler()
               {
                  public void handleElement(Element element)
                  {
                     final UpdateMapping updateMapping = new UpdateMapping(mapping);

                     XMLUtil.forEachChildElement(element, "Case", new XMLUtil.ElementHandler()
                     {
                        private int m_nOrdinal = 0;

                        public void handleElement(Element element)
                        {
                           final UpdateMappingCase update = new UpdateMappingCase(metaclass);

                           update.setBatch(XMLUtil.getBooleanAttr(element, "batch", update.isBatch()));
                           update.setDirty(XMLUtil.getBooleanAttr(element, "dirty", update.isDirty()));
                           update.setFull(XMLUtil.getBooleanAttr(element, "full", update.isFull()));

                           Pair attributes = (Pair)m_helper.parse(
                              XMLUtil.getStringAttr(element, "attributes"),
                              true, mapping.getTextPositionMap(), null, metadata.getGlobalEnvironment()
                           );

                           update.setScript(loadScript(element, sURLPrefix + ".update." + m_nOrdinal, mapping.getTextPositionMap()));
View Full Code Here

    * at the end.
    * @return The code for use in an expr-case block.
    */
   private Pair getReadMappings()
   {
      Pair elseMapping = new Pair(Pair.list(Symbol.ELSE, Pair.list(Symbol.ERROR, "fail.persistence.virtual.unmappedWhere", WHERE, CLASS)));
      Pair mappings = null;

      for (Iterator itr = m_readMappingSet.iterator(); itr.hasNext(); )
      {
         ReadMappingCase read = (ReadMappingCase)itr.next();
         Object whereExpr = read.getWhere();

         if (whereExpr == Symbol.ELSE)
         {
            elseMapping.setHead(Pair.list(Symbol.ELSE, read.getScript()));
         }
         else
         {
            mappings = new Pair(Pair.list(whereExpr, read.getScript()), mappings);
         }
      }

      elseMapping.setTail(mappings);

View Full Code Here

       *          etc.
       *       )
       *    )
       * )
       */
      Pair code = Pair.list(
         Symbol.LAMBDA,
         Pair.list(CLASS, ATTRIBUTES, WHERE, ORDER_BY, COUNT, OFFSET, XLOCK, ASSOCIATIONS, VirtualMapping.PROPERTIES),
         new Pair(
            EXPR_CASE,
            new Pair(
               WHERE,
               getReadMappings()
            )
         )
      );
View Full Code Here

    * @param query The query.
    * @return A list of the attributes being read homogeneously.
    */
   public static Pair getCompositeAttributeList(Query query)
   {
      Pair compAttrs = null;

      assert query.isRoot();

      for (int nQuery = 1; nQuery < query.getOutputQueryCount(); nQuery++)
      {
         Query subQuery = query.getOutputQuery(nQuery);

         if (!subQuery.isRoot())
         {
            Object attr = subQuery.getAttribute().getSymbol();

            if ((subQuery = subQuery.getParent()) != query)
            {
               attr = new Pair(attr);

               do
               {
                  attr = new Pair(subQuery.getAttribute().getSymbol(), attr);
                  subQuery = subQuery.getParent();
               }
               while (subQuery != query);
            }

            compAttrs = new Pair(attr, compAttrs);
         }
      }

      return compAttrs;
   }
View Full Code Here

TOP

Related Classes of nexj.core.scripting.Pair$PairIterator

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.