Unable to fetch the list of allowed values for Defect attribute i.e priority, severity of type Enumeration .
Hi,
I have following configurations: Jazz Server with RTC 4.0.3 I am working with the REST API of RTC 4.0.3 and trying to fetch the list of allowed values of the attributes of type enumeration i.e severity, priority or any custom enum type through the Java Client. As per the REST API documentation i am able to fetch the Resource Shape details for the creation factory of the type defect. It shows the RDF/XML data like this: <oslc:property> <oslc:Property rdf:about="https://localhost:9443/ccm/oslc/context/_xE9Ycmk-EeOkI5-xWTQ7Fw/shapes/workitems/defect/property/internalSeverity"> <dcterms:title rdf:parseType="Literal">Severity</dcterms:title> <oslc:readOnly rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</oslc:readOnly> <oslc:representation rdf:resource="http://open-services.net/ns/core#Either"/> <oslc:valueType rdf:resource="http://open-services.net/ns/core#Resource"/> <oslc:allowedValues> <oslc:AllowedValues rdf:about="https://localhost:9443/ccm/oslc/context/_xE9Ycmk-EeOkI5-xWTQ7Fw/shapes/workitems/defect/property/internalSeverity/allowedValues"> <oslc:allowedValue rdf:resource="https://localhost:9443/ccm/oslc/enumerations/_xE9Ycmk-EeOkI5-xWTQ7Fw/severity/severity.literal.l2"/> </oslc:AllowedValues> </oslc:allowedValues> <oslc:name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">severity</oslc:name> Here i can see the tag : "oslc:allowedValue" which will list the allowed values for the attribute priority which is showing the single value only </oslc:AllowedValues> But when i am seeing the RTC Web UI i am able to see the all the 4 items in the drop down box. Question : 01 Why i am unable to fetch the all the enum values for the attribute of type enum(i.e severity) from the resource shape of the creation factory? Question :02 When i have set the external value from the enumeration settings as shown in the below snapshot , it starts showing the list in the allowed values field in the resource shape . Why is it like this? Any pointer regarding this issue will we highly appreciated. Thanks & Regards, Rahul |
7 answers
Hello Rahul,
I first fetched shapes (for defect):
ccm/oslc/context/_fzVScHhOEeOaco7oIGRnEg/shapes/workitems/defect
Checked the XML, and found:
<rdf:Description rdf:about="https://9.37.26.38:9443/ccm/oslc/context/_fzVScHhOEeOaco7oIGRnEg/shapes/workitems/defect/property/internalPriority">
<oslc:occurs rdf:resource="http://open-services.net/ns/core#Zero-or-one"/>
<oslc:valueType rdf:resource="http://open-services.net/ns/core#Resource"/>
<dcterms:title rdf:parseType="Literal">Priority</dcterms:title>
<oslc:allowedValues rdf:resource="https://9.37.26.38:9443/ccm/oslc/context/_fzVScHhOEeOaco7oIGRnEg/shapes/workitems/defect/property/internalPriority/allowedValues"/>
<oslc:propertyDefinition rdf:resource="http://open-services.net/ns/cm-x#priority"/>
<oslc:representation rdf:resource="http://open-services.net/ns/core#Either"/>
<oslc:name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">priority</oslc:name>
<rdf:type rdf:resource="http://open-services.net/ns/core#Property"/>
<oslc:defaultValue rdf:resource="https://9.37.26.38:9443/ccm/oslc/enumerations/_fzVScHhOEeOaco7oIGRnEg/priority/priority.literal.l01"/>
<oslc:readOnly rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</oslc:readOnly>
</rdf:Description>
So I used:
ccm/oslc/context/_fzVScHhOEeOaco7oIGRnEg/shapes/workitems/defect/property/internalPriority/allowedValues
and received:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:oslc="http://open-services.net/ns/core#" >
<rdf:Description rdf:about="https://9.37.26.38:9443/ccm/oslc/context/_fzVScHhOEeOaco7oIGRnEg/shapes/workitems/defect/property/internalPriority/allowedValues">
<rdf:type rdf:resource="http://open-services.net/ns/core#AllowedValues"/>
<oslc:allowedValue rdf:resource="https://9.37.26.38:9443/ccm/oslc/enumerations/_fzVScHhOEeOaco7oIGRnEg/priority/priority.literal.l11"/>
<oslc:allowedValue rdf:resource="https://9.37.26.38:9443/ccm/oslc/enumerations/_fzVScHhOEeOaco7oIGRnEg/priority/priority.literal.l07"/>
<oslc:allowedValue rdf:resource="https://9.37.26.38:9443/ccm/oslc/enumerations/_fzVScHhOEeOaco7oIGRnEg/priority/priority.literal.l02"/>
<oslc:allowedValue rdf:resource="https://9.37.26.38:9443/ccm/oslc/enumerations/_fzVScHhOEeOaco7oIGRnEg/priority/priority.literal.l01"/>
</rdf:Description>
</rdf:RDF>
|
So in your context:
https://localhost:9443/ccm/oslc/context/_xE9Ycmk-EeOkI5-xWTQ7Fw/shapes/workitems/defect/property/internalSeverity/allowedValues
should fetch all values.
Hope it helps,
Eric
|
Hi Eric,
Thanks for your answer! As per my question:02 If i don't set the External Value for the severity via settings -> Manage Project Area ->Workitem -> Enumerations -> choose the severity enum for edit -> Delete the External values if set Now i am not able to fetch the list of the allowed severity values via the URL https://localhost:9443/ccm/oslc/context/_xE9Ycmk-EeOkI5-xWTQ7Fw/shapes/workitems/defect/property/internalPriority/allowedValues It shows me only one default value Are you able to fetch the all allowed values after removing the External Value for any enum type attribute?
And why should i provide these external values? it's even not mandatory to add.
Thanks & Regards,
Rahul
|
Hi Rahul,
Please try using this code
//Look at the allowed values for Priority. This is generally a required field for defects.
Property PriorityProperty = shape.getProperty(new URI("http://open-services.net/ns/cm-x#priority"));
if (PriorityProperty != null) {
System.out.println("Inside not null property");
URI allowedValuesRef8 = PriorityProperty.getAllowedValuesRef();
ClientResponse allowedValuesResponse8 = client.getResource(allowedValuesRef8.toString(),OslcMediaType.APPLICATION_XML);
AllowedValues allowedValues8 = allowedValuesResponse8.getEntity(AllowedValues.class);
Object[] values8 = allowedValues8.getValues().toArray();
for(Object val:values8) {
System.out.println("The values of Priority literal are "+val);
}
//If this fails, you might need to check that the value is not "Unassigned", which is an allowed value in some RTC project areas.
//Try the second value instead of the first, most project area processes create more than one category
defect1.getExtendedProperties().put(new QName("http://open-services.net/ns/cm-x#", "priority"), (URI) values8[2]);
}
Thanks,
Sujith Babu
|
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.