Override Code

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Senior Member II

Override Code

I want to override setAssignee method of activiti/alfersco workflow.How Can I do that?

I found that TaskEntity.java class is called during set assignee.

Is this proper way to change existing  setAssignee below method of TaskEntity.java?

 public void setAssignee(String assignee, boolean dispatchAssignmentEvent, boolean dispatchUpdateEvent) {}

Thanks & Regard,
Sanjay
7 Replies
Highlighted
Master

Re: Override Code

Why do you want to change / override that method in the first place? Generally speaking it is not recommend / actually discouraged to make changes to the core classes / sources just to addess a business requirement. If you need some different behaviour from task assignment, you should implement a proper API facade / action wrapper around the things you need to adapt.

Highlighted
Senior Member II

Re: Override Code

How Can I  Implement  API facade / action wrapper for setAssignee()?

Can you provide some help on that?

Thanks & Regard,
Sanjay
Highlighted
Master

Re: Override Code

I don't want to sound rude, but the facade pattern is a common software design pattern. Any help I would provide would basically just be a TL;DR summary of that pattern at this point...

Highlighted
Senior Member II

Re: Override Code

can you provide some more detail?

Thanks & Regard,
Sanjay
Highlighted
Senior Member

Re: Override Code

why not use taskListener instead? write your business logic on "assign" event then send the variable to the setAssignee

Regards,
Abbas
Highlighted
Senior Member II

Re: Override Code

This is not for particular workflow.it is for all workflow.

can you describe how can i achieve?

Thanks & Regard,
Sanjay
Highlighted
Senior Member

Re: Override Code

you can a listener before every task assignment. This thread might help you - Does engine have a hook to install an event listener?

update: use AbstractBpmnParseHandler instead of AbstractBpmnParseListener (with 5.22 engine)

example:

public class AssingmentExample extends AbstractBpmnParseHandler<UserTask>  {

    @Override
    protected void executeParse(BpmnParse arg0, UserTask userTask) {

        // add your custom logic here
        userTask.setAssignee("// your assignee here");
    }

    @Override
    protected Class<? extends BaseElement> getHandledType() {
        // TODO Auto-generated method stub
        return null;
    }

}

Register this with your process engine configuration.

Regards,
Abbas