It's all about the answers!

Ask a question

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


Vaibhav S (106247) | asked Sep 29 '21, 8:58 a.m.

 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

2 answers



permanent link
Ralph Schoon (63.1k33645) | answered Sep 30 '21, 2:54 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 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.


permanent link
Luca Martinucci (1.0k294112) | answered Sep 29 '21, 10:05 a.m.

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;
}
}
}


Comments
Vaibhav S commented Sep 30 '21, 8:49 a.m.

 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


Ralph Schoon commented Sep 30 '21, 9:00 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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