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

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

> 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()):
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.
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.