12 Replies Latest reply on Aug 29, 2006 5:49 AM by antitrust1982

    How use Swimlane in a portlet??

    antitrust1982

      Hi,

      I created a process in a portlet. first without any swimlane in order to understand how it work. Now, I want to assign my tasks to somebody. So I use swimlane, but when I create my swimlane I can understand how execute my token, task.... and when I execute my process the swimlane change doesn't have any consequence on my execution :s.

      I would like know if somebody have created a JBPM portlet in JSP and if he can help me to understand how I can do working my process well?

      thank you very much

      antitrust1982

        • 1. Re: How use Swimlane in a portlet??
          kukeltje

          Antitrust,

          You posted the same question in different forms onver and over again. If no-one answers, that might have two reasons:
          - They've never done this and don't know how
          - They do no understand what the question is.

          For me, I get so many mixed, bulrry statements that I have no idea what your problem is:

          So I use swimlane, but when I create my swimlane I can understand how execute my token, task.... and when I execute my process the swimlane change doesn't have any consequence on my execution :s.


          What do you mean by this

          • 2. Re: How use Swimlane in a portlet??
            antitrust1982

            I try to create a swimlane and when I execute my process. I assign to a person. and when I arrived on an other swimlane, i mustn't excute the task of the new swimlane if I don't change of user. Now I try to follow the exemple that I can find in the posts, but when I execute I log me for the first swimlane but when the process change of swimlane the process continu and it mustn't can I haven't change of user. My problem is to have an example of how create well a swimlane and assign well to a task and how I must log me in order to use correctly the swimlane because I create swimlane the swimlane exist but I don't know why I can use correctly.

            I just want to know is somebody know how create weel a swimlane and can help me to understand how log me in and execute well my task in there.

            thank you

            antitrust1982

            • 3. Re: How use Swimlane in a portlet??
              kukeltje

              Antitrust,

              It is hard for me to understand what you mean.

              What is your native language? If it is French, Spanish, or German, or even Dutch, please write in that language. If it is not, try to use babelfish or freetranslation to do some translation.

              • 4. Re: How use Swimlane in a portlet??
                antitrust1982

                bonjour,

                Je suis francais.

                Ce que je cherche. C'est à créer un processus avec des tache allouées à des personnes données. Pour cela j'ai trouvée le swimlane. j'ai essayé de créer et faire fonctionner mon porcessus avec les swimlane. Mais mon problem c'est que lorsque j'execute mon processus le changement de swimlane (donc de d'assignation) n'ai pas pris en compte. Je penses que j'utilise mal le swimlane. C'est pour ca que je demande si quelqu'un a déja créer un portlet avec un swimlane en JSP pour m'aider et voir pourquoi ca fonctionne pas. voila


                merci


                antitrust1982

                • 5. Re: How use Swimlane in a portlet??
                  kukeltje

                  ah.. ok, now I think I understand your question(lucky me I had french classes for 4 years)

                  I suspect your problem is not related to a portlet. You mention that you change the swimlane. What do you change? The actors in it? Have the task use a new swimlane? The latter is indeed a wrong usage of swimlanes. See them as roles, the role does not change, only the people that are in that role.

                  Try making a unit test for this and see what the behaviour is. If that is what you expect and in the portlet it is not, please post the unit test so we can see in detail what you want to achieve.

                  • 6. Re: How use Swimlane in a portlet??
                    kukeltje

                    btw, this is what freetranslation.com makes from your text. Everything in bold is what I added as a manual translation of the word in front

                    This that I look for. This is to create a process with allocated spot (tasks) to given persons. For that I found the swimlane. I tried to create and do to work my porcessus with the swimlane. But my problem this that when I j'execute my process the change of swimlane (therefore of summons (assignment)) did not take into account. I think that I use poorly the swimlane. This is for ca that I ask if someone has déja (already) to create a portlet with a swimlane in JSP to help me and see why ca works not. voila

                    So maybe in more complex cases, use freetranslation as well and post that.

                    • 7. Re: How use Swimlane in a portlet??
                      antitrust1982

                      in my process I have two swimlane, with some tasks assign on them. When I execute my first swimlane it works, sountil the end of my swimlane all is good (perhaps i don't know perhaps my assignment is not good). When I pass to the next token, an other swimlane, the porcess continu to be executed instead of i don't change the assignment of actor. So, I would like to know what is the good way to use my swimlane and assign correctly to my actor this swimlane.


                      thank you for your help

                      antitrust

                      • 8. Re: How use Swimlane in a portlet??
                        kukeltje

                        You do not 'execute' swimlanes, you execute a process, which in turn can have tasks which are in swimlanes. You also not 'pass' to the next token. The token travels through the process.

                        Please post a processdefinition and a unit test to demonstrate what you want (or tried up to now)

                        The 'correct' usage of swimlanes is in understanding the docs and looking at the testcases. Read those first, try the examples see what is different between those and yours.

                        • 9. Re: How use Swimlane in a portlet??
                          antitrust1982

                          hi,

                          I post my java file, where I create my process and try to use the swimlane.

                          package com.opensymphony.webwork.portlet.tutorial;
                          
                          import java.util.*;
                          import java.util.ArrayList;
                          
                          
                          import org.jbpm.graph.def.ProcessDefinition;
                          import org.jbpm.graph.exe.ProcessInstance;
                          import org.jbpm.db.*;
                          import org.jbpm.graph.exe.Token;
                          import org.jbpm.taskmgmt.exe.*;
                          import org.jbpm.taskmgmt.log.TaskCreateLog;
                          import org.jbpm.graph.exe.*;
                          
                          import com.opensymphony.xwork.ActionContext;
                          import com.opensymphony.xwork.ActionSupport;
                          import org.jbpm.*;
                          
                          import org.jbpm.taskmgmt.def.*;
                          
                          public class CreateProcessInstanceAction extends ActionSupport{
                          
                           private String nameProcess;
                           private String currentNode;
                          
                           static JbpmConfiguration jbpmConfiguration = null;
                           static ProcessDefinition processDefinition= null;
                           ProcessInstance pi= null;
                           JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
                           Map session = (Map) ActionContext.getContext().get("session");
                           SwimlaneInstance si =null;
                           ExecutionContext ec=null;
                          
                           public void setNameProcess(String nameProcess) {
                           System.out.println("set NameProcess");
                           this.nameProcess = nameProcess;
                           }
                          
                           public String getNameProcess() {
                           System.out.println("get NameProcess");
                           return nameProcess;
                           }
                          
                           public void setCurrentNode(String currentNode) {
                           System.out.println("set currentNode");
                           this.currentNode = currentNode;
                           }
                          
                           public String getCurrentNode() {
                           System.out.println("get currentNode");
                           return currentNode;
                           }
                          
                           public Long instantiate(ProcessDefinition pd, String userId) {
                           Long instanceId = null;
                           System.out.println("JBPM session factory");
                           JbpmSessionFactory jbpmSessionFactory = JbpmSessionFactory.getInstance();
                           System.out.println("JBPM session");
                           JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
                           System.out.println("Graph session");
                           GraphSession graphSession = jbpmSession.getGraphSession();
                           System.out.println("Task management");
                           TaskMgmtSession taskMgmtSession = jbpmSession.getTaskMgmtSession();
                           System.out.println("instance des session ok");
                          
                           System.out.println("process definition instance");
                           System.out.println("PROCESS NAME:"+ pd.getName());
                           jbpmSession.beginTransaction();
                           pi = new ProcessInstance(pd);
                           System.out.println("PROCESS INSTANCE ID:"+ pi.getId());
                           //This ensures that all swimlanes are initialized and available for reporting and reassignment immediately.
                           //If we don't initialize them up front, they won't be created until a task calls for them.
                          
                           Map swimlanes = pd.getTaskMgmtDefinition().getSwimlanes();
                           Iterator itr = swimlanes.keySet().iterator();
                           while(itr.hasNext()) {
                           Swimlane swimlane = (Swimlane)swimlanes.get(itr.next());
                           System.out.println("SWIMLANE CREE:"+ swimlane.getName());
                          
                           swimlane.setPooledActorsExpression("ernie");
                           swimlane.setPooledActorsExpression("bert");
                          
                          
                           System.out.println("ID porcess "+pi.toString());
                           System.out.println(pi.getRootToken().toString());
                           System.out.println(pi.getRootToken().getName());
                           ec= new ExecutionContext(pi.getRootToken());
                           System.out.println("execution context reussi");
                           System.out.println("token lancer:"+ec.getToken().getName());
                          
                          
                           SwimlaneInstance swi = pi.getTaskMgmtInstance().getInitializedSwimlaneInstance(ec, swimlane);
                          
                          
                           System.out.println("swimlane instance good : "+swi.getName());
                           //We have to do this cause it doesn't automatically happen when we
                           // call swimlaneInstance.setPooledActors()
                           System.out.println("pooled actors");
                           Set pooledActors = swi.getPooledActors();
                           if(pooledActors != null) {
                           Iterator paItr = pooledActors.iterator();
                           while(paItr.hasNext()) {
                           ( (PooledActor)paItr.next() ).setSwimlaneInstance(swi);
                           }
                           }
                           }
                          
                           //If this process definition defines a startTask in the StartState, we'll have to
                           // explicitly create it--it won't be created otherwise...
                           if (pd.getTaskMgmtDefinition().getStartTask() != null) {
                          
                           //When we create the startTaskInstance, the start task will be assigned
                           // to the currently authenticated user (as understood by Jbpm), and that
                           // data WILL overwrite any default swimlane assignments, as well as update
                           // the actual swimlaneInstance itself. The swimlaneInstance's pooledActors will be NULL
                          
                           // To preserve any original assignments to the swimlaneInstance, we'll have
                           // to record that data now and re-set it in the swimlaneInstance after the
                           // startTaskInstance has been created.
                           org.jbpm.taskmgmt.def.Task task = pd.getTaskMgmtDefinition().getStartTask();
                           String swimlaneName = task.getSwimlane().getName();
                           SwimlaneInstance swi = pi.getTaskMgmtInstance().getSwimlaneInstance(swimlaneName);
                           String originalActorId = swi.getActorId();
                           Set originalPooledActors = swi.getPooledActors();
                           System.out.println("taskinstance");
                           TaskInstance startTask = pi.getTaskMgmtInstance().createStartTaskInstance();
                           System.out.println("task instance name: "+startTask.getName());
                           //Unless our application's authentication scheme has been tied into Jbpm's, we
                           // should manually assign the startTask to a user as well as manually set the swimlane actors
                           // referenced by this task, otherwise both will be null.
                           System.out.println("set actor ID a task instance");
                           startTask.setActorId(userId);
                          
                           if(startTask.getSwimlaneInstance() != null) {
                           System.out.println("startTask.getSwimlaneInstance() != null");
                           System.out.println("Swimlane assigned actor: " + startTask.getSwimlaneInstance().getActorId());
                           si = startTask.getSwimlaneInstance();
                           System.out.println(si.getName());
                          
                           System.out.println("test pour voir");
                           startTask.getSwimlaneInstance().setActorId(userId);
                          
                          
                           //Currently, no pooledActors are being set
                          
                           //swi.setPooledActors(originalPooledActors);
                           //startTask.getSwimlaneInstance().setPooledActors(originalPooledActors);
                           if (startTask.getSwimlaneInstance().getPooledActors() != null) {
                           System.out.println("startTask.getSwimlaneInstance().getPooledActors() != null");
                           System.out.println("Swimlane assigned pooled actor: " + ( (PooledActor)(startTask.getSwimlaneInstance().getPooledActors().iterator().next()) ).getActorId() );
                           }
                           System.out.println("NOM DE LA TACHE////::"+startTask.getName());
                          
                           //////////////////////////////
                           // jbpmSession.getSession().save(swi);
                           //////////////////////////////
                           }
                          
                           }else {
                           //If our new process doesn't have a startTask defined, we may want to get the new process rolling...
                           // Although, some executions may want to set process variables, etc. before
                           // continuing, in which case they should do such and signal for themselves.
                           //pi.signal();
                           System.out.println("################################else#########################################");
                           }
                          
                           System.out.println("graphsession enregistre le porcess instance");
                           //graphSession.saveProcessInstance(pi);
                           System.out.println("OK");
                           jbpmSession.commitTransaction();
                          
                           instanceId = Long.valueOf(pi.getId());
                           jbpmSession.close();
                          
                           return instanceId;
                           }
                           @Override
                           public String execute() throws Exception {
                          
                           System.out.println("#### execute");
                           System.out.println("Create process instance" );
                           // This method shows a process definition and one execution
                           // of the process definition. The process definition has
                           // 3 nodes: an unnamed start-state, a state 's' and an
                           // end-state named 'end'.
                           // The next line parses a piece of xml text into a
                           // ProcessDefinition. A ProcessDefinition is the formal
                           // description of a process represented as a java object.
                          
                           processDefinition = ProcessDefinition.parseXmlString(
                          
                          
                           "<process-definition name='DeclarationSinistre'>"+
                           "<swimlane name='F*' >"+
                           "<assignment expression='user(ernie)'/>"+
                           "</swimlane>"+
                          
                           "<swimlane name='A*' >"+
                           "<assignment expression='user(bert)'/>"+
                           "</swimlane>"+
                          
                          
                           "<start-state name='start'>"+
                           "<task swimlane='F*'>"+
                           "</task>"+
                           "<transition name='' to='DeclarationSinistre'>"+"</transition>"+
                           "</start-state>"+
                          
                           "<end-state name='end'>"+"</end-state>"+
                          
                           "<task-node name='DeclarationSinistre'>"+
                           "<task swimlane='F*'>"+
                           "</task>"+
                           "<transition name='' to='EnregistrementSinistre'>"+"</transition>"+
                           "</task-node>"+
                          
                           "<task-node name='EnregistrementSinistre'>"+
                           "<task swimlane='A*'>"+
                           "</task>"+
                           "<transition name='' to='ControlePrime'>"+"</transition>"+
                           "</task-node>"+
                          
                           "<task-node name='ControlePrime'>"+
                           "<task swimlane='F*'>"+
                           "</task>"+
                           "<transition name='OK' to='fork1'>"+"</transition>"+
                           "<transition name='SinistreHorsClause' to='HorsClause'>"+"</transition>"+
                           "<transition name='PrimeNonPayee' to='RelancePaiement'>"+"</transition>"+
                           "</task-node>"+
                          
                           "<task-node name='RelancePaiement'>"+
                           "<task swimlane='A*'>"+
                           "</task>"+
                           "<transition name='' to='ControlePrime'>"+"</transition>"+
                           "</task-node>"+
                          
                           "<task-node name='HorsClause'>"+
                           "<task swimlane='F*'>"+
                           "</task>"+
                           "<transition name='' to='end'>"+"</transition>"+
                           "</task-node>"+
                          
                           "<task-node name='TraitementSinistre'>"+
                           "<task swimlane='A*'>"+
                           "</task>"+
                           "<transition name='' to='join1'>"+"</transition>"+
                           "</task-node>"+
                          
                           "<task-node name='ExtractionDonnées'>"+
                           "<task swimlane='F*'>"+
                           "</task>"+
                           "<transition name='' to='transfertDonnées'>"+"</transition>"+
                           "</task-node>"+
                          
                           "<task-node name='transfertDonnées'>"+
                           "<task swimlane='A*'>"+
                           "</task>"+
                           "<transition name='' to='join1'>"+"</transition>"+
                           "</task-node>"+
                          
                           "<fork name='fork1'>"+
                           "<transition name='' to='TraitementSinistre'>"+"</transition>"+
                           "<transition name='tr2' to='ExtractionDonnées'>"+"</transition>"+
                           "</fork>"+
                          
                           "<join name='join1'>"+
                           "<transition name='' to='end'>"+"</transition>"+
                           "</join>"+
                          
                           "</process-definition>"
                           );
                           System.out.println("################## debut jbpm configuration #############");
                          
                           jbpmConfiguration = JbpmConfiguration.parseXmlString(
                           "<jbpm-configuration>" +
                          
                           // A jbpm-context mechanism separates the jbpm core
                           // engine from the services that jbpm uses from
                           // the environment.
                          
                           " <jbpm-context>" +
                           " <service name='persistence' " +
                           " factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
                           " </jbpm-context>" +
                          
                           // Also all the resource files that are used by jbpm are
                           // referenced from the jbpm.cfg.xml
                          
                           " <string name='resource.hibernate.cfg.xml' " +
                           " value='hibernate.cfg.xml' />" +
                           " <string name='resource.business.calendar' " +
                           " value='org/jbpm/calendar/jbpm.business.calendar.properties' />" +
                           " <string name='resource.default.modules' " +
                           " value='org/jbpm/graph/def/jbpm.default.modules.properties' />" +
                           " <string name='resource.converter' " +
                           " value='org/jbpm/db/hibernate/jbpm.converter.properties' />" +
                           " <string name='resource.action.types' " +
                           " value='org/jbpm/graph/action/action.types.xml' />" +
                           " <string name='resource.node.types' " +
                           " value='org/jbpm/graph/node/node.types.xml' />" +
                           " <string name='resource.varmapping' " +
                           " value='org/jbpm/context/exe/jbpm.varmapping.xml' />" +
                           "</jbpm-configuration>"
                           );
                          
                          
                          
                           Long longVariable = instantiate(processDefinition, "ernie");
                           try{
                           Token token = pi.getRootToken();
                           nameProcess=pi.getProcessDefinition().getName();
                           // System.out.println("avant affectation user");
                           // jbpmContext.setActorId("ernie");
                           // System.out.println("affectation user effectuer ok");
                           // System.out.println("nom de l'utilisateur est:"+ jbpmContext.getActorId());
                           this.setNameProcess(nameProcess);
                           token.signal();
                          
                           currentNode=token.getNode().getName();
                           this.setCurrentNode(currentNode);
                           System.out.println("noeud courant:"+currentNode);
                           jbpmContext.save(token);
                           System.out.println("############## save token good#######");
                           jbpmContext.save(pi);
                           System.out.println("############## save process good#######");
                           Map session = (Map) ActionContext.getContext().get("session");
                           session.put("process",pi);
                           session.put("jbpmContext",jbpmContext);
                           System.out.println("cuicuiactorid: "+jbpmContext.getActorId());
                           session.put("processName",nameProcess);
                           session.put("processDefiniton",processDefinition);
                           session.put("ec",ec);
                           session.put("si",si);
                           }
                           finally {
                           System.out.println("dans finally");
                           //jbpmContext.close();
                           System.out.println("fermeture du context");
                           }
                          
                          
                           return SUCCESS;
                           }
                          }


                          I hope you will see where my error or my missing.

                          thank you very much for you help. I will try to see you way of problem of execution of the swimlane.

                          antitrust1982

                          • 10. Re: How use Swimlane in a portlet??
                            antitrust1982

                            little question:

                            When I use swimlane I must use the token to change of task node or I must use an other solution? because when I use the token I passed in a swimlane F* task I do a signal and I arrived in a swimlane A* task but I have any error instead of I don't change of actor :s

                            • 11. Re: How use Swimlane in a portlet??
                              antitrust1982

                              I have seen in the javadoc a class who named swimlanelog(). How I can use it? I can use it to log in my swimlane? and when I arrive in antoher swimlane the porcess is stop??

                              can you help me to understand please


                              antitrust1982

                              • 12. Re: How use Swimlane in a portlet??
                                antitrust1982

                                Hi all,

                                I try to use swimlaneCreateLog and swimlaneAssignLog classes.

                                I wrote this line in order to put in the log ernie:

                                swimalneAssignLog slog=swimlaneAssignLog(swimlane, null, "ernie");


                                when I want to verify that the actorID is the good one. I do this:

                                System.out.println(slog.getSwimlaneInstance() +"...........a pour actor ID..........."+slog.getActorId());


                                And I have null like actor ID. somebody know why? how can I resolve this problem?

                                thanks in avance

                                antitrust1982