It's all about the answers!

Ask a question

How to get all the data values that are inside a custom attribute?


kishan adhi (44279) | asked Apr 09 '13, 1:35 p.m.
Hi,
I have a custom Attribute that has n number of data that can be selected from RTC front hand.
What I am trying to do is get all the data that are included in the attribute

    IAttribute custom = workItemClient.findAttribute(projectArea,"affected_environments", progressMonitor);
    System.out.println(    "Value "+workItem.getValue(custom));

This above code only gives me default value .
Is there any way i can get the list of all the data that are associated with that attribute?


Thanks

Accepted answer


permanent link
Ralph Schoon (62.0k33643) | answered Apr 09 '13, 3:26 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please have a look at http://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ and for enumerations here: http://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/
kishan adhi selected this answer as the correct answer

Comments
Ralph Schoon commented Apr 09 '13, 3:28 p.m. | edited Apr 09 '13, 3:32 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You need to get the client library workitemCommon. The code below shows it for the workitemClient, but the pattern is the same.

IWorkItemClient workItemClient = (IWorkItemClient) teamRepository().getClientLibrary(IWorkItemClient.class);

WorkitemCommon would look like:


IWorkItemCommon workItemCommon = (IWorkItemCommon) teamRepository().getClientLibrary(IWorkItemCommon.class);

2 other answers



permanent link
kishan adhi (44279) | answered Apr 10 '13, 12:45 p.m.
Thank you guys for your time and suggestion.
For other reader this link also might be helpful

https://jazz.net/forum/questions/52722/getset-the-displayed-name-of-an-enumeration-type-attribute


Thanks

permanent link
sam detweiler (12.5k6189201) | answered Apr 09 '13, 1:42 p.m.
edited Apr 09 '13, 1:45 p.m.
do you mean this is a variable that holds one selection of an enumeration, and you would like to get all the values of the enumeration?

<code>
List<ILiteral> enumerationLiterals = (List<ILiteral>) workItemCommon
                   .resolveEnumeration(ia, monitor).getEnumerationLiterals();
System.out.println("\t\t\t\thave an enumeration list (V4 and up)");
List<Identifier> ial = (List<Identifier>)ia.getValue(auditableClient, workItem, monitor);
System.out.println("\t\t\t\t there are " + ial.size() + " entries selected");
for(int r=0;r<ial.size();r++)
{                               
   for (ILiteral literal : enumerationLiterals)
   {
        if (literal.getIdentifier2().getStringIdentifier()
          .equalsIgnoreCase(ial.get(r).getStringIdentifier()))
        {
            System.out.println("\t\t\t\t entry "+  (r+1) + " -->
                   + " literal="
                   + literal.getIdentifier2().getStringIdentifier()
                   + " literal value="
                   + literal.getName());
            break;
         }
    }                                                               
}
</code>

Comments
kishan adhi commented Apr 09 '13, 2:48 p.m.

I dont know how to initialize variable
Object ia;
 IWorkItemCommon workItemCommon;


Can you explain little bit or provide the code
Thanks for your time

Your answer


Register or to post your answer.