0 Replies Latest reply on Jan 14, 2011 4:08 AM by leod leod

    How to define multiple users for a process

    leod leod Newbie

      Hello all,

       

      I try to develop an exemple of multiple users for ending a process

      I want to start a process

      doing step1 by toto

      doing step2 by titi

      ending process with tata

       

      Here its my current code :

       

      processDefinition.xml

       

      <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="simple">  
      
          <start-state name="start">  
              <transition name="toStep1" to="step1" />  
          </start-state>
      
          <task-node name="step1">  
              <task name="step1">  
                  <assignment actor-id="toto" />
              </task>  
              <transition name="toStep2" to="step2" />
              <transition name="cancel" to="error" />  
          </task-node>
      
          <task-node name="step2">  
              <task name="step2">  
                  <assignment actor-id="titi" />  
              </task>  
              <transition name="toStep3" to="step3" />  
              <transition name="cancel" to="error" />  
          </task-node>
      
          <task-node name="step3">  
              <task name="step3">  
                  <assignment actor-id="tata" />  
              </task>  
              <transition name="toEnd" to="end" />  
              <transition name="cancel" to="error" />  
          </task-node>
      
          <end-state name="error"/>  
          <end-state name="end" />
      
      </process-definition>
      

       

      My page is the fallowing WorkFlow.xhtml

       

      <ui:composition 
          xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://jboss.com/products/seam/taglib"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:a4j="http://richfaces.org/a4j" 
          template="include/template.xhtml">
      
          <ui:define name="body">
              <ui:include src="/include/menu.xhtml" />
      
              <h1><h:outputText value="#{MenuBean.currentFormularDescr}"/></h1>
      
              <h:form>  
                     <div>  
                        <h:outputText value="There are no process started for the moment" rendered="#{empty taskInstancePriorityList}"/>
                        <a4j:repeat value="#{taskInstancePriorityList}" var="task" rendered="#{not empty taskInstancePriorityList}">
                            <h:outputText value="Process created by #{actor.id} at #{task.taskMgmtInstance.processInstance.start}"/>
                            <br/><h:outputText styleClass="ml30" value="STATUS : #{task.name} Progress : #{orderStock.getPercent(task.name)}"/>
                            <br/><s:button styleClass="ml30" action="#{orderStock.doStep1}" taskInstance="#{task}" value="DoStep1"/>
                                 <s:button styleClass="ml30" action="#{orderStock.doStep2}" taskInstance="#{task}" value="DoStep2"/>
                                 <s:button styleClass="ml30" action="#{orderStock.doEnd}" taskInstance="#{task}" value="DoEnd"/>
                                 <s:button styleClass="ml30" action="#{orderStock.cancel}" taskInstance="#{task}" value="Cancel"/>
                            <br/><br/>
                        </a4j:repeat>
                     </div>
                     <br/><br/>
                     <h:commandButton value="Start Process" action="#{orderStock.startProcess}"/>  
              </h:form>
      
          </ui:define>
      </ui:composition>
      

       

      And OrderStock.java looks like this :

       

      package com.ste.crw.jbpm;
      
      import java.io.Serializable;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.bpm.BeginTask;
      import org.jboss.seam.annotations.bpm.CreateProcess;  
      import org.jboss.seam.annotations.bpm.EndTask;  
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      
      @Name("orderStock")
      @Scope(ScopeType.BUSINESS_PROCESS)
      public class OrderStock implements Serializable{
      
          private static final long serialVersionUID = -6823728442889976233L;
      
          public String getPercent(String name){
              if(name.equals("step1")){
                  return "0%";
              }else if(name.equals("step2")){
                  return "33%";
              }else if(name.equals("step3")){
                  return "66%";
              }else{
                  return "100%";
              }
          }
      
          @CreateProcess(definition="simple")  
          public  void startProcess(){
          }  
      
          @BeginTask
          @EndTask(transition="toStep2")  
          public void doStep1(){}  
      
          @BeginTask 
          @EndTask(transition="toStep3")  
          public void doStep2(){}
      
          @BeginTask  
          @EndTask(transition="toEnd")  
          public void doEnd(){}  
      
          @BeginTask  
          @EndTask(transition="cancel")  
          public void cancel(){}  
      
      }
      

       

      The beginning works fine

      I Create the process , and when i'm log on website with login "toto", I see the process

       

      but when i push on "DoStep1" button i have the following error :

       

      javax.el.ELException: java.lang.IllegalStateException: begin method invoked from a long-running conversation, try using @Begin(joi
      n=true) on method: doStep1
      

       

      Where is the problem ?

      I'm a begginner with JBPM and Seam , and documentation is not easy to understand

      I use : JBPM 3.2.7 and Seam 2.1.2

       

      Thanks in advance for your help

       

      Leod