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

Accessing Custom Fields set in RTC for a Project using Rest Services/API

 I would like to retrieve the custom fields set for a Project in RTC(version 3.0.1.3) and I am currently trying to use API to do this :

public void getCustomAttributes() {
IProgressMonitor myProgressMonitor = new CustomProgressMonitor(); // Create a progress monitor
final String userId = ""; 
final String password = "";
String repoUri = "";
TeamPlatform.startup();


ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(repoUri);
repo.registerLoginHandler(new ILoginHandler2() {
@Override
public ILoginInfo2 challenge(ITeamRepository repo) {
return new UsernameAndPasswordLoginInfo(userId, password);
}
});
try {
repo.login(myProgressMonitor);
} catch (TeamRepositoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
TeamPlatform.shutdown();
}


IWorkItemClient workItemClient = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
try {
IWorkItem workItem = workItemClient.findWorkItemById(18588, IWorkItem.FULL_PROFILE, myProgressMonitor);
List custAttributeHandles = workItem.getCustomAttributes();
for (Iterator iterator = custAttributeHandles.iterator(); iterator.hasNext();) {
   IAttributeHandle iAttributeHandle = (IAttributeHandle) iterator.next();
   IAttribute iAttribute = (IAttribute) repo
       .itemManager().fetchCompleteItem(
       iAttributeHandle, IItemManager.DEFAULT ,myProgressMonitor);
   LOGGER.info(iAttribute.getDisplayName());
}
} catch (TeamRepositoryException e) {
e.printStackTrace();
}
repo.logout();
 
}

The work item with ID 18588(it has been hard-coded int he above snippet) has a value set for a custom field(say, 'Re-open count' ). I have set the correct userId, password and repoUrl for access.

Issue : 
    The code won't run because there is a NoSuchMethod exception thrown for a class(org/eclipse/core/internal/registry/ExtensionRegistry) whose containing jar is in my Project's build path. I don't see any issue there but I keep getting this exception. Also, hitting the Simple query URL for the Project, exposed by OSLC, retrieves ONLY the built-in fields for the work items such as 'foundIn','description','title',...

Question :
    Is the above code snippet the right way to retrieve custom fields? Or is it possible to do the same using rest services.
 
Any guidance would be of great help. Thanks in advance.

0 votes

Comments

my sample code here, post 3.


prints out custom as well as builtin  fields. 

I do not know the OSLC/Rest  answer personally, but I think one has to get the workitem 'Shapes' (which gives u the ids of the other attributes) 



One answer

Permanent link
Hi Sam.

Thanks very much for your prompt response. I was able to obtain all custom attributes without any hassles. You are a star!

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
× 10,934
× 7,494
× 1,700
× 383

Question asked: Mar 24 '14, 8:47 a.m.

Question was seen: 6,585 times

Last updated: Mar 25 '14, 3:14 a.m.

Confirmation Cancel Confirm