-
1. Re: Variables Scoped only to the Task
rebody Sep 17, 2010 8:31 AM (in response to shannonsumner)Hi Shannon,
As I known, there is no scope for task. you could only create a scope for an Activity. Of course, we could set a variable into task. but this variable will also be set to the related execution. Even if the task completed, the variable won't be removed.
-
2. Re: Variables Scoped only to the Task
shannonsumner Sep 17, 2010 8:41 AM (in response to rebody)Thanks HuiSheng, I was hoping for a variable scoped only to a task. This might be something to be considered in future releases.
-
3. Re: Variables Scoped only to the Task
mwohlf Sep 17, 2010 9:02 AM (in response to shannonsumner)You might be able to do this programmatically if you try this:
EnvironmentImpl environment = processEngine.openEnvironment();
try {
task.createVariable("variableName", "variableContent", null, false);
Variable variable = task.getVariableObject("variableName");
variable.setExecution(null);
} finally {
environment.close();
}this should create a variable that is no longer linked to the execution but still to the task
-
4. Re: Variables Scoped only to the Task
rebody Sep 17, 2010 10:49 AM (in response to mwohlf)Hi Micheal,
You means that if we didn't link a task to execution, the related variable will be removed when task completed?
-
5. Re: Variables Scoped only to the Task
shannonsumner Sep 17, 2010 10:56 AM (in response to mwohlf)I don't mind doing this programmatically as long as I can some how store the variable in the jdpl within the task definition - Do you know how I would do this?
-
6. Re: Variables Scoped only to the Task
mwohlf Sep 17, 2010 11:37 AM (in response to shannonsumner)Shannon, sorry for being not clear about that by "programmatically" I meant that you have to do it in Java code and I see no way to do it in the jDPL definition, variables in jPDL are execution scoped like HuiSheng said.
HuiSheng, I hacked that in my project but I have other customizations too, so not sure if this works in a plain jBPM4.4, however the variable table in the database is linked to the task with a hibernate map definition that has cascade="all-delete-orphan" so the variable should be deleted when the task is removed from the task table... but I am still trying to figure out the details
-
7. Re: Variables Scoped only to the Task
shannonsumner Sep 17, 2010 12:58 PM (in response to mwohlf)I understood what you meant - I'm willing to create a java class create task variables - however - I'd like to define these values in the jdpl - is there any elements of a task or a transition I can stick the values in where I can grab them during the task initialization to create the variable. I hope I'm making sense.
-
8. Re: Variables Scoped only to the Task
rebody Sep 17, 2010 1:47 PM (in response to shannonsumner)Hi all,
Should we open an issue for this feature. Maybe it could be like that:
<task name="local task">
<variable name="local" scope="task"/>
</task>
or
<task name="local task">
<task-variable name="local"/>
</task>
-
9. Re: Variables Scoped only to the Task
mwohlf Sep 17, 2010 1:53 PM (in response to shannonsumner)1 of 1 people found this helpfulI use this in a custom node,
so I don't use plain jPDL
see: http://community.jboss.org/thread/156571
or: http://www.lunatech-research.com/archives/2010/03/09/jbpm4-and-seam-working-together
about how to create custom nodes -
10. Re: Variables Scoped only to the Task
shannonsumner Sep 17, 2010 2:39 PM (in response to mwohlf)I'll have to look into custom nodes - I'd love to add the "task-variable" element.
-
11. Re: Variables Scoped only to the Task
shannonsumner Sep 22, 2010 9:58 AM (in response to shannonsumner)From my review of the links above - I'd either have to create my own custom Task node containing my task-variable node (which scares me) or create a Task Variable node - which somehow would look up a corresponding Task upon creation - which seems sloppy. Which is the preferred method or should I just wait for a future release containing this feature?