It's all about the answers!

Ask a question

IChangeEvent title language indipendent

Michele Pegoraro (1.8k12114101) | asked May 24 '11, 9:09 a.m.
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?


6 answers

permanent link
Nick Edgar (6.5k711) | answered Jun 09 '11, 4:06 p.m.
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.

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:

permanent link
Nick Edgar (6.5k711) | answered Jun 10 '11, 11:15 a.m.
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:, String[])

permanent link
Michele Pegoraro (1.8k12114101) | 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.


permanent link
Nick Edgar (6.5k711) | answered Jun 17 '11, 11:09 a.m.
> 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:

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.

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

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

Thanks in advance.

Nevermind, we found it:

permanent link
Michele Pegoraro (1.8k12114101) | 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,

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

Your answer

Register or to post your answer.