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

How to read Custom Attributes of an RTC Work item using java

 Hello all,


I need to read Custom Attributes of an RTC Work item using java.

For DNG we have a method as requirement.getExtendedPropoerties for this, for RTC Work Item i couldn't find the method. 

workItem.getCustomAttributes() method did not return the required results.

If anyone has done this, please let me know.

Thanks
Vaibhav

0 votes



2 answers

Permanent link

 It is unclear what API is meant at all. The comparison to DNG does not make sense, as there is no Java API for it.....


If the question refers to the Plain Java Client Libraries or the EWM/RTC SDK, https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ explains how to work with work item attributes. The post also links to others explaining how to setup your environment to support development. Although everyone seems to ignore the advice, it is best to perform the RTC Extensions Workshop at least LAB 1 completely to get a working development environment. Setting up the SDK is key, also for developing for the Plain Java Client Libraries.

1 vote


Permanent link

Using server side Java API, you can retrieve a custom attribute, provided that you know the attribute ID.

The getCustomAttributes() method returns the list of all custom attributes, then you loop over them and check the attribute ID.
This code snippet I developed used to work for me:

IAttribute attribute = null;
List<IAttributeHandle> attributesHandles = new ArrayList<IAttributeHandle>();
attributesHandles = workItemToCheck.getCustomAttributes();
Iterator<IAttributeHandle> attributesHandlesIterator = attributesHandles.iterator();
if (attributesHandlesIterator!=null) {
while (attributesHandlesIterator.hasNext()) {
IAttributeHandle currentAttributeHandle = attributesHandlesIterator.next();
IAttribute currentAttribute = (IAttribute) this.repositoryItemService.fetchItem(currentAttributeHandle, IRepositoryItemService.COMPLETE);
String currentAttributeID = currentAttribute.getIdentifier();
if (currentAttributeID.equalsIgnoreCase(attributeID)) {
attribute = currentAttribute;
break;
}
}
}

1 vote

Comments

 Hello Luca,


Thanks for the help here. really appreciate.

Can you please help me with one more thing: How did you initialize repositoryItemService variable? 

I tried declaring it as IRepositoryItemService repositoryItemService ; and using it as in your code, but it gives me null value.

please let me know how you initialized this variable.

Thanks again
vaibhav

Because your question is lacking details Luca provides example code for a server extension. I a server extension you extend AbstractService and then you have getService(Servide.class) to get it. 


There is no realistic chance for you to implement a server extension if you do not follow the RTC Extensions Workshop. 

Since you provide no context, I would assume that you likely do not want to create a server extension. Maybe some automation, who knows. You can read https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/ and understand what you could do and provide more context. Otherwise I am pretty sure, this is not leading anywhere. If you want to use any Java API you should perform the RTC Extensions Workshop, at least the full lab1 to get a dev environment.

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

Question asked: Sep 29 '21, 8:58 a.m.

Question was seen: 1,467 times

Last updated: Sep 30 '21, 9:00 a.m.

Confirmation Cancel Confirm