How to retrieve enumeration values from a multi-select field
Hi
I have been trying to find out a way of getting the actual values for a multi select attribute in RTC version 3.0.1
The attribute has been set up as Large String type with enumeration as Key in the presentation and the attribute kind is multi select list in the presentation.
I have been trying the following code
IAttribute ia = workItemServer.findAttribute(workItem.getProjectArea(),attributeId,null);
EnumerationManager enumerationManager = new EnumerationManager(workItemServer.getAuditableCommon());
enumerationManager.internalResolve(workItem.getProjectArea(), ia.getAttributeType(), monitor);
This gives exception AssertionFailed as the attribute is not of type Enumeration. Appreciate if you can please provide an example of sample code that can be used to get this sorted.
Thanks in advance
however this fails to get the enumeration handle as
I have been trying to find out a way of getting the actual values for a multi select attribute in RTC version 3.0.1
The attribute has been set up as Large String type with enumeration as Key in the presentation and the attribute kind is multi select list in the presentation.
I have been trying the following code
IAttribute ia = workItemServer.findAttribute(workItem.getProjectArea(),attributeId,null);
EnumerationManager enumerationManager = new EnumerationManager(workItemServer.getAuditableCommon());
enumerationManager.internalResolve(workItem.getProjectArea(), ia.getAttributeType(), monitor);
This gives exception AssertionFailed as the attribute is not of type Enumeration. Appreciate if you can please provide an example of sample code that can be used to get this sorted.
Thanks in advance
however this fails to get the enumeration handle as
3 answers
As far as I can tell, this depends on how the attribute is actually set up.
- In the past, you had to use a string type attribute and the multi selection was actually done by the presentation.The values stored where the enumeration literals, separated by a , or ;. You can tell from looking at a query if you display the attribute.
- Since 4.x there seems to be a new attribute type (Enumeration List). I have only remotely played with that one, but I assume the data is stored in the database and you would get a list of objects that are enumeration literals.
So for option 1, I assume you have to cast to a string and then you need to split() the string using the separator. You can use means like in this post to get the enumeration literals from the string.
For the other option I would try to cast to List and then look into the list you retrieve.
I would always use if(object instanceof SomeClassOrInterface) to test before I cast. During debugging it should also be possible to determine the type.
Comments
once u have the literal, there is one more step, matching it with a value..
from my prior code post
List<iliteral> enumerationLiterals = enumeration
.getEnumerationLiterals();
for (ILiteral literal : enumerationLiterals)
{
if (literal.getIdentifier2()
.getStringIdentifier()
.equalsIgnoreCase(iaval[1]))
{
System.out
.println("\t\t\t\t --> attribute name="
+ ia.getIdentifier()
+ ", type"
+ "="
+ ia.getAttributeType()
+ " literal="
+ literal
.getIdentifier2()
.getStringIdentifier()
+ " literal name="
+ literal.getName());
break;
}}
from my prior code post
List<iliteral> enumerationLiterals = enumeration
.getEnumerationLiterals();
for (ILiteral literal : enumerationLiterals)
{
if (literal.getIdentifier2()
.getStringIdentifier()
.equalsIgnoreCase(iaval[1]))
{
System.out
.println("\t\t\t\t --> attribute name="
+ ia.getIdentifier()
+ ", type"
+ "="
+ ia.getAttributeType()
+ " literal="
+ literal
.getIdentifier2()
.getStringIdentifier()
+ " literal name="
+ literal.getName());
break;
}}
Comments
sam detweiler
Jan 02 '13, 10:23 a.m.Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Jan 02 '13, 10:39 a.m.sam detweiler
Jan 02 '13, 2:48 p.m.