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">
</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.
|
Accepted answer
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
Comments
silencehill wu
commented Dec 29 '13, 11:18 a.m.
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
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.