It's all about the answers!

Ask a question

How to retrieve allowed values for custom enumeration attribute using RTC REST APIs?

Myles F (145) | asked Feb 13 '15, 6:46 p.m.

I can retrieve a resource shape, which will display all my attributes for the task type, with something like the following:

I have a custom single select (enumeration) attribute that looks like this in the resource shape:

    <rdf:Description rdf:about="">
        <rdf:type rdf:resource=""/>
        <oslc:valueType rdf:resource=""/>
        <oslc:representation rdf:resource=""/>
        <oslc:readOnly rdf:datatype="">false</oslc:readOnly>
        <oslc:propertyDefinition rdf:resource=""/>
        <oslc:occurs rdf:resource=""/>
        <oslc:name rdf:datatype="">customSingleSelect</oslc:name>
        <dcterms:title rdf:parseType="Literal">Custom Single Select</dcterms:title>

That attribute uses a custom enumeration with ID 'customEnumeration'. I know I can see the enumeration values with:

but I don't know how I would know to look that up given that I only know the ID of the attribute (customSingleSelect).  Other built in enumeration attributes like priority and severity show the allowedValues in the resource shape, but they don'y seem to appear for custom enumeration attributes.  Is there any way to look up the enumeration used for a custom enumeration attribute with the REST APIs?

Note: this is using RTC 5.0.1


2 answers

permanent link
Tuan Nguyen Minh (691421) | answered Feb 14 '15, 2:05 a.m.

To get all allowed values, just simply get the enumeration resource by do a GET with the enumeration URI, you can obtain this URI via the attribute value. Ex: I have a custom attribute MyCustomAttr1, and below is what I got when I get the Work Item OSLC resource:
<rtc_ext:test.task.attr.mycustomattr1 rdf:resource=""/>
And below is what I got when perform a GET to ""
    xmlns:oslc="" > 
  <rdf:Description rdf:about="">
    <rdf:type rdf:resource=""/>
    <dcterms:title rdf:datatype="">VAL3</dcterms:title>
    <dcterms:identifier rdf:datatype="">test.enum.myenum1.literal.l3</dcterms:identifier>
  <rdf:Description rdf:about="">
    <rdf:type rdf:resource=""/>
    <dcterms:title rdf:datatype="">VAL2</dcterms:title>
    <dcterms:identifier rdf:datatype="">test.enum.myenum1.literal.l2</dcterms:identifier>
  <rdf:Description rdf:about="">
    <rdf:type rdf:resource=""/>
    <dcterms:title rdf:datatype="">VAL1</dcterms:title>
    <dcterms:identifier rdf:datatype="">test.enum.myenum1.literal.l1</dcterms:identifier>
  <rdf:Description rdf:about="">
    <rdfs:member rdf:resource=""/>
    <rdfs:member rdf:resource=""/>
    <rdfs:member rdf:resource=""/>
    <rdf:type rdf:resource=""/>

Hope this help :)

Myles F commented Feb 18 '15, 4:55 p.m.

Thanks for your response.

I realized that my problem was due to using an enumeration that contained invalid characters in the ID.
When I set up a new one that just used characters from the Latin alphabet, the allowed values URI did appear in the resource shape.

So it seems that the answer is to not use non-latin scripts or special symbols when creating IDs for new enumerations or attributes.

permanent link
Myles F (145) | answered Feb 18 '15, 4:58 p.m.
It looks if the custom enumeration or attribute ID contains non-Latin characters or certain symbols, then it won't show up in the resource shape.  I recreated the enumeration and attribute using only Latin characters, then the 'allowedValues' element appeared in the resourhce shape where I expected.

Your answer

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