It's all about the answers!

Ask a question

How to invoke a IChangeEventHandler by server side programmatically


SEC Servizi (97123860) | asked Mar 21 '16, 10:46 a.m.
edited Mar 21 '16, 12:20 p.m.
We would try to invoke an our IChangeEventHandler implementation by server side.
How could we create that IChangeEventHandler instance to be adviced by the change event manager (e.g., internal API)?
IChangeEvent event = IChangeEvent.FACTORY.newInstance(null);
// event.set???(???);
IServerProcess serverProcess = processService.getServerProcess(prjArea);
serverProcess.handleChangeEvent(event, prjArea);
Thanks in advance.

4 answers



permanent link
Ralph Schoon (63.5k33646) | answered Mar 22 '16, 3:02 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
As far as I  can tell, you don't do that. You extend the event handler extension point and then your event handler is called, once you configure it for the project.



Comments
1
sam detweiler commented Mar 22 '16, 8:29 a.m.

I think his question was, what causes the event to fire, that would invoke his handler.
and can he manually cause whatever it was to start the event handler chain


permanent link
Ralph Schoon (63.5k33646) | answered Mar 23 '16, 11:02 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Mar 23 '16, 11:02 a.m.
You can configure event handler here:

 
There is a built in (hard to find) event for all of these.

I don't know if you can cause events yourself.

permanent link
SEC Servizi (97123860) | answered Mar 24 '16, 4:18 a.m.
edited Mar 24 '16, 4:21 a.m.

We already extended the event handler extension point "com.ibm.team.workitem.event.stateChanged" with our implementation and it works like a charm.

Also, we created a REST command to be able to simulate the invocation of that implementation and it works like a charm, too.

We are looking for the right way to generate the IChangeEvent instance to be used for that invocation:

IChangeEvent event = IChangeEvent.FACTORY.newInstance(null);

event.setCategory(StateChangeNotifier.ID_STATE_CHANGED_EVENT_CATEGORY);
event.setOwnerNamespace(IWorkItem.ITEM_TYPE.getName());
event.setContextId(???);
event.setProcessArea(prjArea);
event.setAuthor(getAuthenticatedContributor());
event.setTime(timeService.getCurrentTimestamp());
changeService.save(event);

For instance, we do not know how to set a correct contextId...

Thanks in advance.

Cheers.


permanent link
Massimo Caprinali (1636) | answered Jun 09 '16, 1:21 p.m.
edited Jun 09 '16, 1:29 p.m.
I suppose you have extended com.ibm.team.process.service.eventHandlers and configured it with eventCategory="com.ibm.team.workitem.event.stateChanged" to intercept a workitem state transition.

In my opinion the contextId is the context UUID of the Workitem
	IWorkItem workitem ....
        
event.setContextId(workitem.getContextId()); event.setItem(workitem)

or if you do not need it you can use for example:
	event.setContextId(IContext.PUBLIC) 


Comments
SEC Servizi commented Jun 10 '16, 4:04 a.m.

We would be able to invoke our event handler implementation even without a real work-item state transition. So, in this case, we will not be able to retrieve the context UUID from the item...

We will now try to set the context UUID as 'IContext.PUBLIC'.
Thanks for the advice.
Cheers.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.