RTC Plain Java API: Build Definition ID from Build Definition Handle
Hi,
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:
Thanks in advance.
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
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;
logon
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
in one of my utilities I do
private static ITeamRepository Server = TeamPlatform.getTeamRepositoryService().getTeamRepository(Properties.get(ServerURL));
private static IAuditableClient auditableClient = null;
logon
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
Comments
Works like a charm. Thanks very much. Being a relative newbie to the RTC object model, is there a place inside or outside of jazz.net where all of these interrelationships are documented and explained from a high-level viewpoint?
I have never seen information like this.
OK. Thanks again for your help.
that is why I create samples.. and why Ralph has such a good blog
https://rsjazz.wordpress.com/