It's all about the answers!

Ask a question

RTC Plain Java API: Build Definition ID from Build Definition Handle

E Muehl (325) | asked Aug 24 '14, 9:19 p.m.

How do I get to the Build Definition ID (or object) from the Build Definition Handle?  I'm using the Plain Java API (4.0.2) to generate a list of build definitions from queries based on labels and tags.  After the query, I have the following code:
String[] properties = new String[] { IBuildResult.PROPERTY_LABEL, IBuildResult.PROPERTY_TAGS, IBuildResult.PROPERTY_BUILD_DEFINITION};
List buildResults = teamRepository.itemManager().fetchPartialItems(queryPage.getItemHandles(), IItemManager.DEFAULT, Arrays.asList(properties), monitor);
buildResults.getTags() and buildResults.getLabel() both return strings, but when I use buildResults.getBuildDefinition(), I get the handle and can't find a way to access the Build Definition ID (or the object, for that matter) from that handle.

Thanks in advance.

Accepted answer

permanent link
sam detweiler (12.5k6184201) | answered Aug 24 '14, 11:29 p.m.
edited Aug 25 '14, 7:50 a.m.
when u have  handle to an object, you need to use some repository service to compose the full object

in one of my utilities I do
private static ITeamRepository Server = TeamPlatform.getTeamRepositoryService().getTeamRepository(Properties.get(ServerURL));
private static IAuditableClient auditableClient = null;


auditableClient = (IAuditableClient) Server.getClientLibrary(IAuditableClient.class);
IBuildDefinitionHandle bdh;

IBuildDefinition bd = (IBuildDefinition)auditableClient.fetchCurrentAuditable(bdh, ItemProfile.createFullProfile(IBuildDefinition.ITEM_TYPE), null);

you can pass a set of properties to be loaded instead of just FULL. with ItemProfile.createProfile()
when u only need 1 or two properties
E Muehl selected this answer as the correct answer

E Muehl commented Aug 25 '14, 12:56 a.m.

Works like a charm.  Thanks very much.  Being a relative newbie to the RTC object model, is there a place inside or outside of where all of these interrelationships are documented and explained from a high-level viewpoint?

sam detweiler commented Aug 25 '14, 7:53 a.m.

I have never seen information like this.

E Muehl commented Aug 25 '14, 11:42 a.m.

OK.  Thanks again for your help.

sam detweiler commented Aug 25 '14, 12:05 p.m.

that is why I create samples.. and why Ralph has such a good blog

Your answer

Register or to post your answer.