It's all about the answers!

Ask a question

IChangeEvent title language indipendent


Michele Pegoraro (1.8k14118103) | asked May 24 '11, 9:09 a.m.
Hi,
I'm looking for some object property in order to select change-event.
For example, while I'm looking for build result I get several different event title, but I want to do something only when the title is "Successful" or "Failed". So I use a string comparison to do it. But this it's OK only with an english locale server.

Is there a property (something like ChangeEvent.SUCCESSFUL_TITLE) which I can use to compare title for every locale?

Thanks,
Michele.

6 answers



permanent link
Nick Edgar (6.5k711) | answered Jun 09 '11, 4:06 p.m.
JAZZ DEVELOPER
Hi Michele, what kind of events are you dealing with? There's no generic success/failure status field on events, but events can carry arbitrary other data via string extensions.
See com.ibm.team.repository.common.IChangeEvent.getStringExtension(String)

For example, Build events carry the build state and status (at the time of the event) as string extensions.

You may also be able to retrieve the item the event is about and get status from there:
com.ibm.team.repository.common.IChangeEvent.getItem()

permanent link
Nick Edgar (6.5k711) | answered Jun 10 '11, 11:15 a.m.
JAZZ DEVELOPER
If you do fetch the item, note that you probably want to fetch the state at the time the event was created, not necessarily the latest state (if the item is an Auditable). You can use:
com.ibm.team.repository.service.IRepositoryItemService.fetchState(IAuditableHandle, String[])

permanent link
Michele Pegoraro (1.8k14118103) | answered Jun 17 '11, 4:16 a.m.
Hi Nick,
thanks for your answer. I'm dealing with build result events and getting the event title to find when a build is successful. Do I have to use something different? I see that getStatus returns an UUID but I don't know how to map it with a successful build.

Michele.

permanent link
Nick Edgar (6.5k711) | answered Jun 17 '11, 11:09 a.m.
JAZZ DEVELOPER
> I see that getStatus returns an UUID

It sounds like you might be using getState() on the item or item handle, not getStatus() on the IBuildResult item. getState() gives the state identifier for the item (for all items, not just builds).

Try something like the following (taken from our internal helper: com.ibm.team.build.internal.common.events.BuildResultEvent.getBuildStatus()):

public BuildStatus getBuildStatus() {
Object value = getChangeEvent().getStringExtension(KEY_BUILD_STATUS);
if (value instanceof String) {
return BuildStatus.valueOf((String) value);
} else {
return null;
}
}

where KEY_BUILD_STATUS is "build.IBuildResult.status". This will give you the build status at the time the event was generated, and doesn't require an extra fetch for the item (the string extensions are carried on the event itself). You can do similarly for the build state.

Comments
SEC Servizi commented Dec 12 '12, 5:44 a.m. | edited Dec 12 '12, 5:58 a.m.

There is a class "com.ibm.team.*" containing all keys valid for the IChangeEvent.getStringExtension(String key) method?

Thanks in advance.

Nevermind, we found it: com.ibm.team.build.internal.common.events.BuildResultEvent


permanent link
Michele Pegoraro (1.8k14118103) | answered Oct 10 '11, 9:15 a.m.
Thanks, it works properly using both .getStringExtension(PROPERTY_BUILD_STATUS) and .getStringExtension(PROPERTY_BUILD_STATE) and comparing them to BuildStatus and BuildState static variables.

Best Regards,
Michele

permanent link
Nick Edgar (6.5k711) | answered Oct 11 '11, 9:54 a.m.
JAZZ DEVELOPER
Good to hear. Thanks for confirming.

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.