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 |
3 answers
Ralph Schoon (63.5k●3●36●46)
| answered Jan 02 '13, 10:18 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
As far as I can tell, this depends on how the attribute is actually set up.
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
Meera Varma
commented Jan 02 '13, 12:17 p.m.
Hi Ralph
Ralph Schoon
commented Jan 02 '13, 12:35 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
As Sam and I were saying:
Meera Varma
commented Jan 03 '13, 4:57 a.m.
Hi Ralph & Sam
I see the problem. The knowledge about the enumeration in use is in the presentation, so you have to put some knowledge in your extension to find it. Since Sam seems to have done that already, I leave it to him to answer.
|
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; }} Comments
Meera Varma
commented Jan 24 '13, 11:51 a.m.
Getting the enumeration objacte as below
Ralph Schoon
commented Jan 24 '13, 12:27 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
This shows what worked for me in 3.x-4.x so far: http://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/
sam detweiler
commented Jan 24 '13, 12:37 p.m.
I will have to update my sample to handle the string version of the enum
|
|
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.
Comments
as mentioned, this is not an enumeration in practice, but a string.. so you handle it like a string. (If you use my code, it attempts to get the enum, and the catch() processes non-enumerations..)..
then it is a string.. and a string is a string..
the multi-select presentation just stores the literals in the string separated by semi-colon (';') this was a hack solution, and IBM said so.. and replaced it with something in 4.x.. but it is also a different kind of hack. cause the values are in an external database, and harder to manage/manipulate/etc from extension code.
Hi Sam,
I don't understand
As far as I understand the new attribute type that is available is a list type for enumerations (as well as other basic data types). You can use it with enumerations that are backed by the database as well as with the ones stored in the template.
So where is the issue?
I can't change my post.. I updated my sample to handle the V4 multi-select..
it is a list.. (still of the literals) when it is stored in the process config