UserTask + ServiceTask
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2013 07:52 AM
I'm searching for a way to solve one of my problem.
I would love to create a task that would be a mix of a userTask and a serviceTask
In fact I want to find a solution to let my workflow ask some parameters to the user with an interface and, when the parameters are in and the user is ok, then launch a java class treatment.
I know this is possible with 2 tasks but is that possible too with one ?
Further, could it be possible to create a task like that in the palette.
I need it for my company as we want to let the clients create their own workflow with our own palette tasks. And all these tasks need to launch a java treatment with some informations the user has to enter first.
Can you help me ?
Vivien
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2013 03:59 AM
Yes, adding to the palette in the Eclipse designer is possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2013 09:55 AM
I mean, how to create some in my palette as every components have to implements AbstractCustomServiceTask ?
Could you give me an example ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2013 04:41 AM
The userguide does mention it:
<code>
[INTERNAL: non-public implementation classes] It is also possible to provide a class that implements the org.activiti.engine.impl.pvm.delegate.ActivityBehavior interface. Implementations have then access to the more powerful ActivityExecution that for example also allows to influence the control flow of the process. Note however that this is not a very good practice, and should be avoided as much as possible. So, it is advised to use the ActivityBehavior interface only for advanced use cases and if you know exactly what you're doing.
</code>
Activiti is open source. Open up for example the UserTaskActivityBehaviour to see how it can be done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2013 05:36 AM
I ll try it
But maybe i ll need your help as i m not an "advanced" activiti and java user ^^
So this advice is so important for me :
"Note however that this is not a very good practice, and should be avoided as much as possible. So, it is advised to use the ActivityBehavior interface only for advanced use cases and if you know exactly what you're doing."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2013 03:55 AM
In reality, it'll be ok. Simply let you inspire by all the ones that are shipped in the Activiti code. And if you're stuck somewhere, come back here with your questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2013 04:15 AM

I'll try it
i m downloading the last Activiti version to see the sources and have a look to UserTaskActivityBehaviour

Thanks for your support and if i have question, be sure i ll come back ^^
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2013 05:02 AM
As i want a mix between the two tasks usertask and servicetask i just copy the servicetask code to implement it after th usertask :
<code>
package com.effisoft.designer.tasks;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.JavaDelegate;
import org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.delegate.JavaDelegateInvocation;
import org.activiti.engine.impl.el.ExpressionManager;
import org.activiti.engine.impl.pvm.delegate.ActivityBehavior;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.task.TaskDefinition;
/**
* activity implementation for the user/service task.
*
* @author Vivien René
*/
public class EffiTaskActivityBehavior extends UserTaskActivityBehavior implements ActivityBehavior, ExecutionListener {
protected TaskDefinition taskDefinition;
protected JavaDelegate javaDelegate;
public EffiTaskActivityBehavior(ExpressionManager expressionManager, TaskDefinition taskDefinition) {
super(expressionManager, taskDefinition);
}
public EffiTaskActivityBehavior(ExpressionManager expressionManager, TaskDefinition taskDefinition, JavaDelegate javaDelegate) {
super(expressionManager, taskDefinition);
this.javaDelegate = javaDelegate;
}
public void execute(ActivityExecution execution) throws Exception {
execute(execution);
execute((DelegateExecution) execution);
leave(execution);
}
public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {
leave(execution);
}
public void notify(DelegateExecution execution) throws Exception {
execute((DelegateExecution) execution);
}
public void execute(DelegateExecution execution) throws Exception {
Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new JavaDelegateInvocation(javaDelegate, execution));
}
}
</code>
In addition a little question :
Is it Activiti or Activity ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2013 03:29 AM
Activity is used internally as it is a BPMN concept for a step in the process.
And yes, this is one way to do it. Probably the more 'clean' Java approach would be to use composition instead inheritance (ie have both the UserTaskActivityBehaviour and the ServiceTaskActivityBehaviour as members - but thats nitpicking).
But the most important thing: does it do what you expected it to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2013 04:41 AM
I really don't know if that does what i want because i don t know how to put this in the palette and test it.
Normally it would as i want a component which is both a human and service task.
Before my classes inherited AbstractCustomServiceTask and i had all to create a new element in the palette as
- getName
- contributeToPaletteDrawer
- getSmallIconPath
- etc…
.
Maybe i have to implement the interface CustomServiceTask with the same methods like in AbstractCustomServiceTask
.
But with this system, i realy don t know how to do to it in the designer
.
.
2) About the best implementation method
In addition, about what you told, how can you have both the UserTaskActivityBehaviour and the ServiceTaskActivityBehaviour as members ?
Because if my remembers are good, java has no multiple inheritance, hasn t it ?
.
In all cases, thanks a lot for your time as it helps me a lot

