-
1. Re: JBPM-2772 retrieve business key from sub-process
swiderski.maciej Jul 24, 2010 11:59 AM (in response to rebody)I was wondering if that is what we shall provide in this case - to me somehow it looks like incorrect information. Subprocess business key is not set so it shall return null, returning it parent business key can be sometimes misleading, can be misinterpreted as parent and can cause some unexpected behavior.
Perhaps better approach would be to enable possibility to set business key for a sub process when starting it from parent?!
-
2. Re: JBPM-2772 retrieve business key from sub-process
rebody Aug 10, 2010 11:35 AM (in response to swiderski.maciej)Hi Maciej,
One small problem.
If the parent of an execution is null, as it is a process instance, and the key of this execution is not null. The result of generated id is 'processDefinitionId' + '.' + 'key'. This will cause the super and sub process instance has same id. It will cause database exception, because the id column has unique constraint.
So if we want to set key from super process instance to sub process instance, we should change the strategy of the DbidGenerator.
-
3. Re: JBPM-2772 retrieve business key from sub-process
mwohlf Aug 10, 2010 4:13 PM (in response to rebody)Hi HuiSheng,
I don't understand, I think the patch is about the user provided "business key" for the process instance, it doesn't look like this key is used as any kind of database key anywhere or in the DbidGenerator. The DatabaseIdComposer uses the key from the process definition which is something different too... maybe i missed something?
-
4. Re: JBPM-2772 retrieve business key from sub-process
rebody Aug 11, 2010 3:09 AM (in response to mwohlf)Hi Michael,
Please refer these codes:(DatabaseIdComposer)
String executionPart = null;
if ( (parent==null)
&& (execution.getKey()!=null)
) {
executionPart = execution.getKey();
} else if (execution.getName()!=null) {
executionPart = execution.getName() + '.' + Long.toString(execution.getDbid());
} else {
executionPart = Long.toString(execution.getDbid());
}String executionId = base+"."+executionPart;
-
5. Re: JBPM-2772 retrieve business key from sub-process
swiderski.maciej Aug 11, 2010 4:10 AM (in response to rebody)But this should never happen for sub process since first condition will be not met - perent will be not null.
it's all about having possibility to assign business key by user as part of jpdl, of course it must support expression.
-
6. Re: JBPM-2772 retrieve business key from sub-process
mwohlf Aug 11, 2010 4:32 AM (in response to rebody)Hi HuiSheng,
you are right, it is used in DatabaseIdComposer, I didn't scroll that far ;-)
-
7. Re: JBPM-2772 retrieve business key from sub-process
rebody Aug 11, 2010 5:29 AM (in response to swiderski.maciej)Hi Maciej,
When we create a sub process, the parent field of sub process instance is null. It just set super process instance, not the parent.
public ClientProcessInstance createSubProcessInstance(ClientProcessDefinition processDefinition, String key) { if (subProcessInstance!=null) { throw new JbpmException(toString()+" already has a sub process instance: "+subProcessInstance); } subProcessInstance = (ExecutionImpl) processDefinition.createProcessInstance(key); subProcessInstance.setSuperProcessExecution(this); return subProcessInstance; }
-
8. Re: JBPM-2772 retrieve business key from sub-process
swiderski.maciej Aug 11, 2010 5:57 AM (in response to rebody)If you go a bit deeper you will find that there is a bidirectional reletionship created between super and subprocess.
subProcessInstance = (ExecutionImpl) processDefinition.createProcessInstance(key);
next go into that method:
if (superProcessExecution!=null) { // establish the bidirectional relation between super process activity instance // and sub process instance ExecutionImpl superProcessExecutionImpl = (ExecutionImpl) superProcessExecution; processInstance.setSuperProcessExecution(superProcessExecutionImpl); superProcessExecutionImpl.setSubProcessInstance(processInstance); }
-
9. Re: JBPM-2772 retrieve business key from sub-process
rebody Aug 11, 2010 9:25 AM (in response to swiderski.maciej)Hi Maciej,
As I said, the sub process instance will used its key as part of id, because it has no parent.
The snippets which you showed set the
setSuperProcessExecution
, but no parent. Am I right for this situation? Or the super process execution is just as same as parent?Regards.
-
10. Re: JBPM-2772 retrieve business key from sub-process
swiderski.maciej Aug 12, 2010 2:37 AM (in response to rebody)Correct, I mixed parent and super/subprocess usage in jBPM. Parent is used for executions that are derived from origin such as when using fork and super/sub are used to reflect relationship between processes. My mistake.
Back to the issue, I was suggesting to allow users to provide their business key for subprocess that will be used when executing it. Please consider very simple definition that consists of subprocess:
<process name="SubProcessDocument" xmlns="http://jbpm.org/4.4/jpdl"> <start g="20,20,48,48"> <transition to="review" /> </start> <sub-process name="review" key="#{mySubProcessBusinessKey}" sub-process-key="SubProcessReview" g="96,16,127,52"> <parameter-in var="document" subvar="document" /> <parameter-out var="reviewResult" subvar="result" /> <transition to="wait" /> </sub-process> <state name="wait" g="255,16,88,52"/> </process>
Then when subprocess is created it will assign value of mySubProcessBusinessKey to key of the execution. Of course it can in some situations cause uniqueness problems but since it is designed to be externally provided (within scope of the process definition) I would say that it is a known risk.
Does it make sense to you or am I completely lost?