0 Replies Latest reply on Oct 14, 2005 3:32 AM by Abhikal Jaiswal

    create a task without task node

    Abhikal Jaiswal Newbie

      hi
      i am trying to understand the work flow of websale demo.
      Please help me to know that how to create task in the state when no task node tag is given.

      <process-definition name="pay raise process">
       <swimlane name="requester" />
       <swimlane name="boss">
       <delegation class="ActorAssignmentHandler">cg</delegation>
       </swimlane>
      
       <swimlane name="erp operator">
       <delegation class="ActorAssignmentHandler">pf</delegation>
       </swimlane>
      
      
       <start-state name="request a payraise">
       <transition to="evaluating">
       </transition>
       </start-state>
      
       <state name="evaluating">
       <assignment swimlane="boss" />
       <transition name="approve" to="fork"></transition>
       <transition name="disapprove" to="done"></transition>
       </state>
      
      
       <fork name="fork">
       <transition to="updating erp asynchronously"></transition>
       <transition to="treating collegues on cake and pie"></transition>
       </fork>
      
      
       <state name="updating erp asynchronously">
       <assignment swimlane="erp operator" />
       <transition to="join"></transition>
       </state>
      
       <state name="treating collegues on cake and pie">
       <assignment swimlane="requester" />
       <transition to="join"></transition>
       </state>
      
      
       <join name="join">
       <transition to="done"></transition>
       </join>
      
      
       <end-state name="done"></end-state>
      
      </process-definition>
      


      
      CODE IS
      
      public class WebSale
      {
      
       static JbpmSessionFactory jsf =
       JbpmSessionFactory.buildJbpmSessionFactory();
      
       static
       {
       jsf.getJbpmSchema().createSchema();
       }
      
      
       public WebSale()
       {
      
       ProcessDefinition pd =ProcessDefinition.parseXmlResource("sale2.par/processdefinition.xml" );
       JbpmSession js = jsf.openJbpmSession();
       js.beginTransaction();
       js.getGraphSession().saveProcessDefinition(pd);
       js.commitTransaction();
       js.close();
      
       }
      
       public void func1()
       {
      
       JbpmSession js = jsf.openJbpmSession();
       js.beginTransaction();
       ProcessDefinition pd =js.getGraphSession()
       .findLatestProcessDefinition("pay raise process");
      
       ProcessInstance pi = new ProcessInstance(pd);
      
       ContextInstance ci =pi.getContextInstance();
       ci.setVariable("amount", new Integer(500));
       ci.setVariable("reason", "i met my deadline");
      
      
       System.out.println("-----"+pi.getRootToken().getNode().getName());
       pi.signal();
      
       Collection tasks = pi.getTaskMgmtInstance().getTaskInstances();
       if(tasks!=null)
       {
       for (Iterator taskIterator =
       tasks.iterator (); taskIterator.hasNext();)
       {
       TaskInstance task = (TaskInstance)
       tasks.iterator().next ();
       System.out.println("+++++========"+ equals(task.getName()));
       }
       }
      
      
      
       System.out.println("-----"+pi.getRootToken().getNode().getName());
      
       js.getGraphSession().saveProcessInstance(pi);
       js.commitTransaction();
       js.close();
      
       }
      
       public void func2()
       {
      
       JbpmSession js = jsf.openJbpmSession();
       js.beginTransaction();
       ProcessDefinition pd =js.getGraphSession()
       .findLatestProcessDefinition("pay raise process");
      
       GraphSession graphSession = js.getGraphSession();
      
       List all_pi=graphSession.findProcessInstances(pd.getId());
       System.out.println("+++++"+ all_pi);
       ProcessInstance pi =(ProcessInstance) all_pi.get(0);
      
      
       ContextInstance ci =pi.getContextInstance();
       System.out.println(" AMOUNT ###="+ci.getVariable("amount"));
       System.out.println(" REASON ###="+ci.getVariable("reason"));
      
      
       System.out.println("-----"+pi.getRootToken().getNode().getName());
       pi.signal();
      
       System.out.println("-----"+pi.getRootToken().getNode().getName());
      
      
       pi.signal();
       System.out.println("-----"+pi.getRootToken().getNode().getName());
      
       pi.signal();
       System.out.println("-----"+pi.getRootToken().getNode().getName());
      
       pi.signal();
       System.out.println("-----"+pi.getRootToken().getNode().getName());
      
      
       js.getGraphSession().saveProcessInstance(pi);
       js.commitTransaction();
       js.close();
       }
       public static void main(String a[])
       {
       WebSale sale=new WebSale();
       System.out.println("Going to start the process");
       sale.func1();
       sale.func2();
       }
      }