-
1. Re: get the token in another task-node on a struts applicati
cristian_e Jul 5, 2007 12:50 PM (in response to galvino)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 Jul 6, 2007 4:11 AM (in response to 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 Jul 6, 2007 4:27 AM (in response to 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);