Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get buildDefinition from AdvisableOperation via RTC API

Dear RTC API team,

I'd like to have question on getting buildDefinition from AdvisableOperation via RTC API.
I'm trying to write a RTC extension with the event has operation id com.ibm.team.build.server.saveBuildDefinition for my case of update a build definition, I can debug in my class SaveBuildDefinition implements IOperationParticipant and see val$buildDefinition variable, but I can't find any API to get BuildDefinitionImpl object.

My point is when I update a build definition and do save, RTC server will trigger my class SaveBuildDefinition and then I can get the build definition info which I'm working on.

Can you please help me out.

Thank You!

0 votes

Comments

Now I can find a way like:

Field field = operation.getClass().getDeclaredField("val$buildDefinition");
field.setAccessible(true);
BuildDefinitionImpl buildDefinition = (BuildDefinitionImpl)field.get(operation);

If someone has any better way, please help to provide.

Thanks.



One answer

Permanent link
I would suggest to look at one of the advisors here: https://rsjazz.wordpress.com/?s=advisor

All work with this pattern:
Object data = operation.getOperationData();
	if (data instanceof ISaveParameter) {
		IAuditable auditable = ((ISaveParameter) data).getNewState();
		if (auditable instanceof IWorkItem) {
			IWorkItem workItem = (IWorkItem) auditable;


You test if the object is what you expect it to be - depends on the operation ID - and cast it.
Note in your case the interface is likely IBuildDefinition or something. Without good reason you never cast to the implementation class. You always use the interface.




1 vote

Comments

Thanks Ralph for the quick response. In my case currently operation.getOperationData() returns null.

You don't provide any information about the operation etc. So what you see above is what works in general. See How should I ask a question in the Forum if I want to receive useful answers?

Ok. I will try to explain my issue. Thanks for your time.

Your answer

Register or log in 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.

Search context
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
Question details
× 10,941

Question asked: Jul 22 '16, 3:35 a.m.

Question was seen: 1,901 times

Last updated: Jul 22 '16, 6:36 a.m.

Confirmation Cancel Confirm