Timer based on variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2011 03:21 PM
I have attached my WF in CallSubscriber.png. Basically I need to have a boundary event/timer on a user task based on a variable. Currently I do not see way to do this. So I had to duplicate the user task and then put an exclusive gateway in front of it so that I take the path with user task with timer or user task without timer, depending on the variable useTimer. This gets very complex and the whole diagram gets complicated as I will start to have duplicated paths. If I can have just a single path where the boundary event/timer is always present but the timer will only start based on a certain variable value.
Is there some way to accomplish this instead of the way I am doing with duplicated tasks/paths?
thanks,
Rue
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2011 08:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2011 01:01 PM
However if there was a way just to turn on/off (or use/not use) a timer on a node/task that would be much easier and elegant?
thanks,
Rue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2011 04:36 AM
you can put a serviceTask with a "behavior" just before your two "Call subscriber with timer node"s and define two different transitions. The script task can handle the transition:
<serviceTask id="javaService"
name="Java service invocation"
activiti:class="com.bigfirm.decisions.UseTimerCallSubscriber">
</serviceTask>
The class could be look like this:
public class UseTimerCallSubscriber implements ActivityBehavior {
public void execute(ActivityExecution execution) throws Exception {
boolean useTimer = (Boolean) execution.getVariable("useTimer");
PvmTransition transition = null;
if(useTimer){
transition = execution.getActivity().findOutgoingTransition("useTimerTransition");
} else {
transition = execution.getActivity().findOutgoingTransition("dontUseTimerTransition");
}
execution.take(transition);
}
}
Best regards,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2011 11:37 AM
thanks,
Rue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2011 03:35 AM
Thanks for the reply but I don't understand. That just seems to get rid of the Exclusive gateway. You would still have two nodes CallSubWithTimer and CallSubWithoutTimer. The issue here is not the Exclusive Gateway, but to minimize duplicate tasks/nodes and paths.Hi Rue,
thanks,
Rue
yes, you would still have two nodes. But you dont have two different paths any more. You can just make a join gateway after the two nodes and all returning transitions direct to the service node before the callsub nodes.
If you want, post your xml definition and I change it accordingly.
regards,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2011 10:27 AM
I have uploaded my latest diagram after some changes. Now it is much simplified to avoid confusion. What I would like to have is one node with timer and someway to turn on/of that timer based on 'useCallSubTimer' variable. Your ServiceTask does pretty much the same thing as the Exclusive Gateway (So I would prefer to have an Exlc Gateway rather than a Service Task that does the samething)
thanks,
Rue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2011 11:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2011 04:00 AM
your process is now almost what I suggested. You are right, with gateways its more like modeling not programming. So now you do not have duplicated paths.
I do not think that it is possible to turn the timer on/off based on a variable without extending activity.
A first thought (of a newbie) is to extend the class "TimerDeclarationImpl" and overwrite the method "prepareTimerEntity".
I would change the lines:
TimerEntity timer = new TimerEntity(this);
timer.setDuedate(duedate);
to
if(executionEntity.getParentVariableScope().getVariable("useCallSubTimer")){
timer.setDuedate(duedate);
} else {
timer.setDuedate(new Date()); // do not use timer value
}
But this approach would hard-code the variable name. Just a thought. Other ideas?
regards,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2011 10:32 AM
thanks,
Rue
