Package nexj.core.meta.workflow

Examples of nexj.core.meta.workflow.Branch


         public void handleElement(Element eventElement, String sEventName)
         {
            Node child = eventElement.getFirstChild();
            String sElement = eventElement.getNodeName();
            Concurrent activity = new Concurrent();
            Branch branch = null;

            activity.setFork(fork);

            if (sElement.equals("TimerEvent"))
            {
               if (m_bTimer)
               {
                  throw new MetadataException("err.meta.workflow.multipleQueueTimers",
                     new Object[]{assignment.getName()});
               }

               Timeout timeout = new Timeout();

               timeout.setActivity(activity);
               timeout.setValue(m_helper.parse(XMLUtil.getReqStringAttr(eventElement, "value"),
                  false, activity.getFlow().getPosMap(), null, m_metadata.getGlobalEnvironment()));
               activity.addStep(timeout);

               Wait wait = new Wait(timeout);

               timeout.setNext(wait);
               activity.addStep(wait);

               m_bTimer = true;
            }
            else if (sElement.equals("ClassEvent"))
            {
               AutoCompletion completion = new AutoCompletion(assignment);

               loadWorkflowHandler(eventElement, completion, activity.getFlow());
               activity.addStep(completion);
            }
            else if (sElement.equals("ManualEvent"))
            {
               Object condition = m_helper.parse(XMLUtil.getStringAttr(eventElement, "condition"),
                  false, assignment.getActivity().getFlow().getPosMap(),
                  Boolean.TRUE, m_metadata.getGlobalEnvironment());
               boolean bTarget = loadTarget(eventElement, assignment, condition, sEventName, false);
               Element first = XMLUtil.findFirstElement(child);

               if (first != null && first.getNodeName().equals("UIAction"))
               {
                  loadTarget(first, assignment, condition, sEventName, bTarget);
                  child = first.getNextSibling();
               }

               if (assignment.getManualCompletion() == null)
               {
                  ManualCompletion completion = new ManualCompletion(assignment);

                  activity.addStep(completion);
               }
               else
               {
                  activity = null;
               }
            }
            else if (sElement.equals("ProcessEvent"))
            {
               branch = new Branch();
               decision.addBranch(branch);

               assignment.setSemaphore(true);

               Semaphore semaphore = new Semaphore(assignment.getName() + ":Semaphore", assignment);

               semaphore.setActivity(activity);
               activity.addStep(semaphore);

               Block block = new Block();

               block.setActivity(branch);
               branch.addStep(block);
               loadActivity(child, block.getContainedActivity());
               block.setCleanupCode(semaphore.getExitCode());
            }
            else
            {
               throw new MetadataException("err.meta.workflow.invalidQueueElement",
                  new Object[]{sElement, assignment.getName()});
            }

            if (eventMap.put(sEventName, Boolean.TRUE) != null)
            {
               throw new MetadataException("err.meta.workflow.queueEventDup",
                  new Object[]{sEventName, assignment.getName()});
            }

            Variable var = assignment.getActivity().getFlow().findVariable(assignment.getName());

            if (var == null)
            {
               var = new Variable(assignment.getName());
               assignment.getActivity().getFlow().addVariable(var);
            }

            if (activity != null)
            {
               Object code;

               if (activity.getStep(0) instanceof ManualCompletion)
               {
                  // ((:state'bind ('<assignment>'targetFunction)) '() (:flow'getToken <step>))
                  code =
                     Pair.list(
                        Pair.list(Symbol._STATE, Pair.quote(Symbol.BIND),
                           Pair.list(Pair.quote(assignment), Pair.quote(Symbol.TARGETFUNCTION))),
                        null,
                        Pair.list(Symbol._FLOW, Pair.quote(Symbol.GETTOKEN), Pair.quote(activity.getStep(0))));
               }
               else
               {
                  code = sEventName;
               }

               Script script = new Script();

               script.setBody(Pair.list(Pair.list(Symbol.SET, var.getSymbol(), code)));
               activity.addStep(script);
               fork.addConcurrent(activity);
            }

            if (branch == null)
            {
               branch = new Branch();
               decision.addBranch(branch);
               loadActivity(child, branch);
            }

            branch.setCondition(Pair.list(Symbol.EQUAL_P, var.getSymbol(), sEventName));
         }
      });

      if (fork.getConcurrentCount() == 0)
      {
View Full Code Here


   {
      XMLUtil.forEachChildElement(element, loader.getElementName(), new ElementHandler()
      {
         public void handleElement(Element branchElement)
         {
            Branch branch = loader.createBranch();

            branch.setDecision(decision);
            branch.setCondition(helper.parse(XMLUtil.getStringAttr(branchElement, "condition"),
               false, decision.getActivity().getFlow().getPosMap(), Boolean.TRUE,
               metadata.getGlobalEnvironment()));
            branch.setCaption(XMLUtil.getStringAttr(branchElement, "caption"));

            if (branch.getCaption() == null)
            {
               branch.setCaption(XMLUtil.getStringAttr(branchElement, "name"));
            }

            loader.loadActivity(branchElement, branch);
            decision.addBranch(branch);
         }
View Full Code Here

                     return "Branch";
                  }

                  public Branch createBranch()
                  {
                     return new Branch();
                  }

                  public void loadActivity(Element element, Activity activity)
                  {
                     XMLMetadataLoader.this.loadActivity(element.getFirstChild(), activity);
View Full Code Here

      activity.addStep(initializer);

      // Loop test step
      Decision decision = new Decision(sLoopName + ":branch");
      Branch loopBody = new Branch();

      decision.setActivity(activity);
      loopBody.setDecision(decision);
      loopBody.setCondition(Pair.list(Symbol.COND,
         Pair.list(Pair.list(Symbol.PAIR_P, collectionSym),
            Pair.list(Symbol.NOT, Pair.list(Symbol.NULL_P, indexSym))),
         Pair.list(Pair.list(Symbol.VECTOR_P, collectionSym),
            Pair.list(Symbol.LT, indexSym, Pair.list(Symbol.VECTOR_LENGTH, collectionSym))),
         Pair.list(Symbol.ELSE,
            Pair.list(collectionSym, Pair.quote(XMLMetadataLoader.HAS_NEXT)))
      ));

      // Get current item and advance to next step
      Script getItem = new Script(sLoopName + ":next");

      getItem.setActivity(loopBody);
      getItem.setBody(new Pair(
         Pair.list(Symbol.COND,
            Pair.list(Pair.list(Symbol.PAIR_P, collectionSym),
               Pair.list(Symbol.SET, itemSym, Pair.list(Symbol.CAR, indexSym)),
               Pair.list(Symbol.SET, indexSym, Pair.list(Symbol.CDR, indexSym))
            ),
            Pair.list(Pair.list(Symbol.VECTOR_P, collectionSym),
               Pair.list(Symbol.SET, itemSym, Pair.list(collectionSym, indexSym)),
               Pair.list(Symbol.SET, indexSym, Pair.list(Symbol.PLUS, indexSym, Primitive.ONE_INTEGER))
            ),
            Pair.list(Symbol.ELSE,
               Pair.list(Symbol.SET, itemSym, Pair.list(collectionSym, Pair.quote(XMLMetadataLoader.NEXT)))
            )
         ),
         activity.getFlow().getDefaultReturnCode()
      ));
      loopBody.addStep(getItem);

      // Load loop body
      loader.loadActivity(element, loopBody);

      loopBody.getStep(loopBody.getStepCount() - 1).setNext(decision);
      decision.addBranch(loopBody);

      // Branch to follow when done
      Branch doneBranch = new Branch();

      doneBranch.setDecision(decision);
      doneBranch.setCondition(Boolean.TRUE);
      decision.addBranch(doneBranch);

      // Finish the loop expansion
      activity.addStep(decision);
   }
View Full Code Here

    */
   public void exportDecision(Decision decision, BranchExporter exporter) throws IOException
   {
      for (Iterator itr = decision.getBranchIterator(); itr.hasNext();)
      {
         Branch branch = (Branch)itr.next();

         m_writer.openElement(exporter.getElementName());

         exportSExpression(branch.getCondition(), false, false, Boolean.TRUE, "condition");

         if (branch.getCaption() != null)
         {
            m_writer.writeAttribute("caption", branch.getCaption());
         }

         if (branch.getLayout() != null)
         {
           m_writer.writeAttribute("layout", branch.getLayout());
         }

         exporter.exportActivity(branch);

         m_writer.endElement(exporter.getElementName());
View Full Code Here

      List defaultList = new ArrayList(4);

      // Group the branches by message
      for (int i = 0, n = getBranchCount(); i != n; ++i)
      {
         Branch branch = getBranch(i);
         Message message = (branch instanceof Case) ? ((Case)branch).getMessage() : null;

         if (message != null)
         {
            List list = (List)messageMap.get(message.getName());
View Full Code Here

TOP

Related Classes of nexj.core.meta.workflow.Branch

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.