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

IChangeEvent title language indipendent

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.

0 votes



6 answers

Permanent link
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()

0 votes


Permanent link
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[])

0 votes


Permanent link
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.

0 votes


Permanent link
> 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.

0 votes

Comments

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
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

0 votes


Permanent link
Good to hear. Thanks for confirming.

0 votes

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
× 11,007

Question asked: May 24 '11, 9:09 a.m.

Question was seen: 7,221 times

Last updated: Dec 12 '12, 5:58 a.m.

Confirmation Cancel Confirm