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

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

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.

1

0 votes



2 answers

Permanent link
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 :)

0 votes

Comments

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

0 votes

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,934
× 515
× 478

Question asked: Feb 13 '15, 6:46 p.m.

Question was seen: 6,761 times

Last updated: Feb 18 '15, 4:58 p.m.

Confirmation Cancel Confirm