1
1

I would like to know if there is a possibility to dynamically listen to all ivy standard processes starts and ivy task creations and starts. The idea would be to get a reference to any standard processes-cases that are started or tasks that are created.

Thanks a lot in advance

Emmanuel

asked 03.03.2015 at 17:07

Emmanuel's gravatar image

Emmanuel
(suspended)
accept rate: 66%


There is yet no public API for that available. But there is an internal workflow event API that could handle this job - and the classes are accessible. So you can use it, but there is no guarantee that this API will not be changed or broken in the future.

The following sample code shows how you can track newly created cases. Many other events are also available: see the class ch.ivyteam.ivy.workflow.WorkflowEventKind

public class CaseCreatedListener implements ch.ivyteam.ivy.workflow.IWorkflowListener{
    public static void register(){
        IWorkflowManager workflowManager = ServerFactory.getServer().getManager(IWorkflowManager.class);
        workflowManager.addWorkflowListener(new CaseCreatedListener(workflowManager));
    }

    private IWorkflowManager wfManager;

    private CaseCreatedListener(IWorkflowManager wfManager){
        this.wfManager = wfManager;
    }

    @Override
    public void workflowChanged(WorkflowChangeEvent event) {
        if (event.getEventKind() != WorkflowChangeEventKind.CREATED){
            return;
        }

        IWorkflowEvent createEvent = wfManager.findWorkflowEvent(event.getId());
        if (createEvent.getEventKind() != WorkflowEventKind.EVENT_CREATE_CASE){
            return;
        }

        ICase newCase = createEvent.getCase();
        Ivy.log().info("new case created: "+newCase);
    }

}

I've created a little demo project: wfEventListener_51.iar

link

answered 04.03.2015 at 14:31

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k31958
accept rate: 70%

edited 07.03.2018 at 10:34

Alex%20Suter's gravatar image

Alex Suter ♦♦
3.1k122247

This seems to work for you example where a case is triggered. But it doesn't fire an event if a normal process start is picked up.

(06.03.2015 at 09:35) SupportIvyTeam ♦♦ SupportIvyTeam's gravatar image

The proces start event is not fired as this workflowEvent framework does only handle case/task changes on persistency level. But a picked up case lifes only in the memory until a taskSwitch is reached. So no event is fired. You could may work around the problem by forcing a persistent state by a placing a dummy taskswitch after the start

alt text

(06.03.2015 at 09:37) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

Hello Alex, Hello Reguel, is it possible to listen also EVENT_FAIL_TASK ? It seems it is not passing workflowChanged method.

link

answered 11.06.2019 at 08:50

tauser's gravatar image

tauser
(suspended)
accept rate: 33%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×37
×13

Asked: 03.03.2015 at 17:07

Seen: 3,857 times

Last updated: 11.06.2019 at 08:50