-
1. Re: How to start this process instance?
estaub Feb 5, 2007 5:42 PM (in response to clandestino_bgd)Why do you want to do this?
Start-nodes in workflow systems often have behavior different than other nodes - they're mostly just a marker for where to start. This is carried forward from general state machines. In general, trying to pin a lot of other behavior (e.g., a task) into the start node is probably asking for trouble. Even if it works in a particular scenario in a particular release, it's unlikely to be tested very well, and hence is likely to get inadvertently broken.
But maybe you really need it - I don't know.
-Ed Staub
(newbie) -
2. Re: How to start this process instance?
estaub Feb 5, 2007 6:09 PM (in response to clandestino_bgd)Oops - please ignore my earlier message - I didn't read carefully.
Are you supposed to get an enter event on the start state?
I would only have expected a leave event.
Start state are usually special.
The documentation hints that there isn't an enter event on the start node, but doesn't say it explicitly:When a process instance is created, a token is created for the main path of execution. This token is called the root token of the process instance and it is positioned in the start state of the process definition.
I'm guessing a lot, but I wonder if you are trying to createStartTaskInstance() before signalling to enter the node where the swimlane is started. I suspect that you have to wait till then, based on the examples.
-Ed Staub -
3. Re: How to start this process instance?
clandestino_bgd Feb 6, 2007 2:15 PM (in response to clandestino_bgd)Oops - please ignore my earlier message - I didn't read carefully.
I mean the manual of course, so I will answer here to my questions maybe somebody will find it useful, but I do not believe so :)
1. In the JBPM manual stands:Start state: supported event types: {node-leave}
So, there is no miracle, why I could not invoke my action on "node-enter" event :)
2. The second question related how to start process instance in generic way and to cover the situations, when your start-state is either Task-node or some wait state, can be solved with additional method in JBPMTemplate (I am using springmodules-0.7)/** * Create and start process instance * * @author agaton * @param definitionId. * The definitionId to be started. * @return ProcessInstance that is created */ public ProcessInstance createStartProcessInstance(final long definitionId) { return (ProcessInstance)execute(new JbpmCallback() { public Object doInJbpm(JbpmContext context) { ProcessInstance processInstance = null; ProcessDefinition processDef = context.getGraphSession() .getProcessDefinition(definitionId); if(processDef != null) { processInstance = (ProcessInstance)processDef.createInstance(); if(processInstance != null) { if(processInstance.getTaskMgmtInstance() .getTaskMgmtDefinition().getStartTask()!=null){ processInstance.getTaskMgmtInstance() .createStartTaskInstance(); } else{ processInstance.getRootToken().signal(); } context.save(processInstance); } } return processInstance; } }); }
So, if start-state has task (startTask!=null) createStartTaskInstance() is invoked. If opposite, rootToken is signaled.
Thank you for ignoring my questions, apart for Mr Staub, whom I am thankful as a polite and nice person, since it helped me to realize how stupid my question was.
Cheers
Milan