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
|
2 answers
![]() 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 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. |
![]()
Ralph Schoon (63.3k●3●36●46)
| 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.
|
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.