3 Replies Latest reply on Jul 6, 2007 4:27 AM by galvino

    get the token in another task-node on a struts application

    galvino

      Hi everybody .
      I have a problem to go to next task-node with jbpm in a web application by using struts.

      i did a small process like this:

      start
      task1
      task2
      end


      On my first bean in strut, i deploy process and i go to the first task.
      But when i write this in order to go to the next task:


      TaskMgmtSession taskMgmtSession = jbpmContext.getTaskMgmtSession();

      TaskInstance taskInstance = taskMgmtSession.loadTaskInstance(1);
      taskInstance.setActorId(jbpmContext.getActorId());
      taskInstance.start();

      Token token = graphSession.loadToken(1);
      Transition transition=null;
      String transitionName=null;

      if (token.getNode().getLeavingTransitions().isEmpty() == false) {
      Iterator availableTransitionsIterator = token.getNode().getLeavingTransitions().iterator();
      while (availableTransitionsIterator.hasNext()) {
      transition = (Transition) availableTransitionsIterator.next();
      }
      transitionName=transition.getName();
      }

      token.signal(transitionName);
      ProcessInstance processInstance = token.getProcessInstance();

      jbpmContext.save(processInstance);


      there are an error :

      Integrity constraint violation - no parent FK_TASKINST_TASK table: JBPM_TASK in statement [insert into JBPM_TASKINSTANCE (NAME_, DESCRIPTION_, ACTORID_, CREATE_, START_, END_, DUEDATE_, PRIORITY_, ISCANCELLED_, ISSUSPENDED_, ISOPEN_, ISSIGNALLING_, ISBLOCKING_, TASK_, TOKEN_, SWIMLANINSTANCE_, TASKMGMTINSTANCE_, CLASS_, ID_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'T', null)]


      what's this error means ?
      i think it can't execute
      *.signal()
      why ?

      Please I need your help !!!

        • 1. Re: get the token in another task-node on a struts applicati
          cristian_e

          I don't really understand what are you trying to do. Usually you should just end() a taskInstance for the related token to continue to the next node in the graph, unless it's not signalling. Looking at your code, you are loading the taskinstance and a token independently. Then, you get the last available transition and signal the token to get through it, because the while just goes through the transition list obtained before.

          Maybe you can explain further the objective you are trying to accomplish to understand the problem better.

          Finally, if it helps anyway, I believe the error you are seeing is telling you that the taskInstance you are trying to save doesn't have a related task, or the task assigned as a property doesn't exist in the database.

          • 2. Re: get the token in another task-node on a struts applicati
            galvino

            thank you for your response.

            i want to do a simple workflow by using struts where each form correspond to the next task .

            For example,


            start ->start state
            task-node 1
            task-node 2
            end


            on my first form i do this:


            jbpmContext=this.getJbpmContext(request);

            graphSession=jbpmContext.getGraphSession();
            System.out.println("\n StartProcessInstance.jbpmContext: "+jbpmContext+"\n");

            ProcessDefinition processDefinition=ProcessDefinition.parseXmlResource("SimpleApp/processdefinition.xml");
            graphSession.deployProcessDefinition(processDefinition);

            System.out.println(" ...........Id: "+processDefinition.getId());
            System.out.println(" ...........Name: "+processDefinition.getName());
            System.out.println(" ...........Version: "+processDefinition.getVersion()+"\n");


            //create a new process instance to run
            ProcessInstance processInstance = new ProcessInstance(processDefinition);

            Token token=processInstance.getRootToken();
            token.signal();
            processDefinition.getNode("task-node1");
            jbpmContext.save(processInstance);


            After that, the token go to task-node 1, there is no problem.
            then, on my second form, i want to get where is my token and continue the process execution.

            this is my problem.............

            • 3. Re: get the token in another task-node on a struts applicati
              galvino

              so i do this code program on th esecond form :


              jbpmContext=this.getJbpmContext(request).getJbpmConfiguration().getCurrentJbpmContext();
              graphSession=jbpmContext.getGraphSession();
              /*System.out.println("\n StartProcessInstance.jbpmContext: "+jbpmContext+"\n");
              System.out.println("\n Actor: "+jbpmContext.getActorId()+"\n");

              ProcessDefinition processDefinition=graphSession.getProcessDefinition(1);*/

              /*ProcessInstance instance=jbpmContext.getProcessInstance(1);
              System.out.println("..............id: "+instance.getId());
              System.out.println("..............Version: "+instance.getVersion()+"\n");*/

              TaskMgmtSession taskMgmtSession = jbpmContext.getTaskMgmtSession();

              TaskInstance taskInstance = taskMgmtSession.loadTaskInstance(1);
              taskInstance.setActorId(jbpmContext.getActorId());
              taskInstance.start();

              System.out.println("......"+taskInstance.getName());

              Token token = taskInstance.getToken();
              Transition transition=null;
              String transitionName=null;

              if (token.getNode().getLeavingTransitions().isEmpty() == false) {
              Iterator availableTransitionsIterator = token.getNode().getLeavingTransitions().iterator();
              while (availableTransitionsIterator.hasNext()) {
              transition = (Transition) availableTransitionsIterator.next();
              }
              transitionName=transition.getName();
              }

              //token.signal(transitionName);
              ProcessInstance processInstance = token.getProcessInstance();

              Map<String, String> taskVariables = new HashMap<String, String>();
              taskVariables.put("nom", "maldini");
              taskVariables.put("prenom", "paolo");
              taskVariables.put("decision", "no");
              taskInstance.addVariables(taskVariables);

              taskInstance.end();

              jbpmContext.save(processInstance);