Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get enumeration value

I am writing program  to get enumeration values by http client using OSLC-CM 2.0.

I want to know how I can get all id and name of enumeration by OSLC-CM 2.0 in java api.

For example:

      <enumeration attributeTypeId="bugtype" name="bugproblemtype">
           <literal id="bugtype.literal.l1" name="CA-用例缺陷"/>
           <literal id="bugtype.literal.l2" name="DOC-文档错误"/>
           <literal id="bugtype.literal.l3" name="EC-编码错误"/>

    </enumeration>

1. I want to get a map <id, name> of enumeration.

  AttributeTypeId ="bugtype"  or  name ="bugproblemtype" as argument. I want to get the map as below:

  <bugtype.literal.l1, CA-用例缺陷>, <bugtype.literal.l2, DOC-文档错误>, <bugtype.literal.l3, EC-编码错误>

2. I want to get a id by name

Input CA-用例缺陷 as argument, the id  bugtype.literal.l1 will be return.

Please give me an advise.

0 votes


Accepted answer

Permanent link
If you already have the IAttribute instance you can get the IEnumeration this way:

IWorkItemClient svc = (IWorkItemClient)teamrepo.getClientLibrary(IWorkItemClient.class);
IEnumeration<ILiteral> enum = (IEnumeration<ILiteral>)svc.resolveEnumeration(attribute, null);
List<ILiteral> literals = enum.getEnumerationLiterals();

Now, you said both HTTP (meaning REST?) and Java API, this is just the Java API method.
silencehill wu selected this answer as the correct answer

0 votes

Comments

Thank for your answer. I am using java plain api, but not using RTC-SDK. The REST is the only way now I want to know. Do you have any idea? 

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Dec 26 '13, 12:00 p.m.

Question was seen: 4,785 times

Last updated: Dec 29 '13, 11:18 a.m.

Confirmation Cancel Confirm