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.
Hello,

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

https://my.rtc.com:9443/ccm/oslc/context/_02g42kavb_VvoZ4IKA/shapes/workitems/task

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

    <rdf:Description rdf:about="https://my.rtc.com:9443/ccm/oslc/context/_02g42kavb_VvoZ4IKA/shapes/workitems/task/property/customSingleSelect">
        <rdf:type rdf:resource="http://open-services.net/ns/core#Property"/>
        <oslc:valueType rdf:resource="http://open-services.net/ns/core#Resource"/>
        <oslc:representation rdf:resource="http://open-services.net/ns/core#Either"/>
        <oslc:readOnly rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</oslc:readOnly>
        <oslc:propertyDefinition rdf:resource="http://jazz.net/xmlns/prod/jazz/rtc/ext/1.0/customSingleSelect"/>
        <oslc:occurs rdf:resource="http://open-services.net/ns/core#Zero-or-many"/>
        <oslc:name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">customSingleSelect</oslc:name>
        <oslc:defaultValue>[]</oslc:defaultValue>
        <dcterms:title rdf:parseType="Literal">Custom Single Select</dcterms:title>
    </rdf:Description>

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

https://my.rtc.com:9443/ccm/oslc/context/_02g42kavb_VvoZ4IKA/shapes/workitems/task/property/customEnumeration

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

Thanks.

2 answers



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

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="https://jazz.net/sandbox03-ccm/oslc/enumerations/_WTf9ErQSEeSlxYyKijnAgg/test.enum.myenum1/test.enum.myenum1.literal.l1"/>
And below is what I got when perform a GET to "https://jazz.net/sandbox03-ccm/oslc/enumerations/_WTf9ErQSEeSlxYyKijnAgg/test.enum.myenum1"
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:rtc_cm="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/"
    xmlns:oslc="http://open-services.net/ns/core#" > 
  <rdf:Description rdf:about="https://jazz.net/sandbox03-ccm/oslc/enumerations/_WTf9ErQSEeSlxYyKijnAgg/test.enum.myenum1/test.enum.myenum1.literal.l3">
    <rdf:type rdf:resource="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/Literal"/>
    <dcterms:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">VAL3</dcterms:title>
    <dcterms:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#string">test.enum.myenum1.literal.l3</dcterms:identifier>
  </rdf:Description>
  <rdf:Description rdf:about="https://jazz.net/sandbox03-ccm/oslc/enumerations/_WTf9ErQSEeSlxYyKijnAgg/test.enum.myenum1/test.enum.myenum1.literal.l2">
    <rdf:type rdf:resource="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/Literal"/>
    <dcterms:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">VAL2</dcterms:title>
    <dcterms:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#string">test.enum.myenum1.literal.l2</dcterms:identifier>
  </rdf:Description>
  <rdf:Description rdf:about="https://jazz.net/sandbox03-ccm/oslc/enumerations/_WTf9ErQSEeSlxYyKijnAgg/test.enum.myenum1/test.enum.myenum1.literal.l1">
    <rdf:type rdf:resource="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/Literal"/>
    <dcterms:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">VAL1</dcterms:title>
    <dcterms:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#string">test.enum.myenum1.literal.l1</dcterms:identifier>
  </rdf:Description>
  <rdf:Description rdf:about="https://jazz.net/sandbox03-ccm/oslc/enumerations/_WTf9ErQSEeSlxYyKijnAgg/test.enum.myenum1">
    <rdfs:member rdf:resource="https://jazz.net/sandbox03-ccm/oslc/enumerations/_WTf9ErQSEeSlxYyKijnAgg/test.enum.myenum1/test.enum.myenum1.literal.l3"/>
    <rdfs:member rdf:resource="https://jazz.net/sandbox03-ccm/oslc/enumerations/_WTf9ErQSEeSlxYyKijnAgg/test.enum.myenum1/test.enum.myenum1.literal.l2"/>
    <rdfs:member rdf:resource="https://jazz.net/sandbox03-ccm/oslc/enumerations/_WTf9ErQSEeSlxYyKijnAgg/test.enum.myenum1/test.enum.myenum1.literal.l1"/>
    <dcterms:title>test.enum.myenum1</dcterms:title>
    <oslc:totalCount>3</oslc:totalCount>
    <rdf:type rdf:resource="http://open-services.net/ns/core#ResponseInfo"/>
  </rdf:Description>
</rdf:RDF>

Hope this help :)

Comments
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.