POST/PUT Requirement with a Custom Attribute Using REST API / OSLC
Following the OSLC workshops, We have been able to create a new requirement in RRC using the REST API. The body used in the POST request is as below.
We have a custom attribute calledpriority (property id = _6m0UhJUTEeGjDYB2VGA7DA) in this requirement and we would like to fill in its value as well.
How do we do it? Is there something like the following we can use along with the above body?
We understand that the above format is not correct. What is the correct format we should use?
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:oslc_rm="http://open-services.net/ns/rm#"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:rm_property="https://research.jazz:9443/rm/types/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<oslc_rm:Requirement
rdf:about="">
<dc:title>MyDocument</dc:title>
<dc:description>This is a test document</dc:description>
<oslc:instanceShape rdf:resource="https://research.jazz:9443/rm/types/_6t0UYJUTEeGjDYB2VGA7DA"/>
<rm_property:_ycrkq5UTEeGjDYB2VGA7DA rdf:parseType="Literal"><div xmlns="http://www.w3.org/1999/xhtml" id="_Nf2cQJKNEd25PMUBGiN3Dw"><h1 id="_DwpWsMueEd28xKN9fhQheA">Test Document</h1></div></rm_property:_ycrkq5UTEeGjDYB2VGA7DA>
</oslc_rm:Requirement>
</rdf:RDF>
We have a custom attribute called
How do we do it? Is there something like the following we can use along with the above body?
<rm_property:_6m0UhJUTEeGjDYB2VGA7DA rdf:parseType="Literal">High</rm_property:_6m0UhJUTEeGjDYB2VGA7DA>
We understand that the above format is not correct. What is the correct format we should use?
8 answers
Hi,
For Data Types that have specific ( allowed ) values, users must specify the corresponding UUID for that value.
For instance in my environment a requirement expose following property :
<rm_property:_Djd1ANDhEeGe18MmgIPNSw rdf:resource="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#e28b500e-77af-4f34-86f4-2ef1f70ad3dc"/>
The Property Type ( Bold) and its value (Italics) is specified by the rdf:resource :
"https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#e28b500e-77af-4f34-86f4-2ef1f70ad3dc"
To get the allowed values for a specific type do a get to the Resource type ( Bold ):
"https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw"
It will return the allowed values and the complete URI to be used in a POST create ) or a PUT ( change ) that value in an artifact
PLS let me know if questions.
For Data Types that have specific ( allowed ) values, users must specify the corresponding UUID for that value.
For instance in my environment a requirement expose following property :
<rm_property:_Djd1ANDhEeGe18MmgIPNSw rdf:resource="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#e28b500e-77af-4f34-86f4-2ef1f70ad3dc"/>
The Property Type ( Bold) and its value (Italics) is specified by the rdf:resource :
"https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#e28b500e-77af-4f34-86f4-2ef1f70ad3dc"
To get the allowed values for a specific type do a get to the Resource type ( Bold ):
"https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw"
It will return the allowed values and the complete URI to be used in a POST create ) or a PUT ( change ) that value in an artifact
PLS let me know if questions.
Comments
1 vote
Here is the sample output of a Get to the type of an attribute: "https://gradev.ibm.com:9444/rdm/accessControl/_OcYF0sSMEeGA8-GkKWmlAA"
Output :
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:acp="http://jazz.net/ns/acp#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw">
<acp:accessControl rdf:resource="https://gradev.ibm.com:9444/rdm/accessControl/_OcYF0sSMEeGA8-GkKWmlAA"/>
<rdfs:comment></rdfs:comment>
<rdfs:label>GRADATATYPE</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#2f257129-a0ee-4d8c-8d47-a72797f034ef">
<rdfs:comment></rdfs:comment>
<rdfs:label>4</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#e28b500e-77af-4f34-86f4-2ef1f70ad3dc">
<rdfs:comment></rdfs:comment>
<rdfs:label>1</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#9f02a905-9f06-4c31-873b-49fe8c8e36bb">
<rdfs:comment></rdfs:comment>
<rdfs:label>5</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#716d95cb-f50c-484e-8d0e-527702c1bff0">
<rdfs:comment></rdfs:comment>
<rdfs:label>2</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#17d50781-6691-4862-8041-ff9fb7dd04d1">
<rdfs:comment></rdfs:comment>
<rdfs:label>3</rdfs:label>
</rdf:Property>
</rdf:RDF>
In case user wants to set label 3, then user must specify the rdf:value for it:
"https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#17d50781-6691-4862-8041-ff9fb7dd04d1"
Regarding Arun's last comment, a real value is being used and that is not allowed.
Output :
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:acp="http://jazz.net/ns/acp#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw">
<acp:accessControl rdf:resource="https://gradev.ibm.com:9444/rdm/accessControl/_OcYF0sSMEeGA8-GkKWmlAA"/>
<rdfs:comment></rdfs:comment>
<rdfs:label>GRADATATYPE</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#2f257129-a0ee-4d8c-8d47-a72797f034ef">
<rdfs:comment></rdfs:comment>
<rdfs:label>4</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#e28b500e-77af-4f34-86f4-2ef1f70ad3dc">
<rdfs:comment></rdfs:comment>
<rdfs:label>1</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#9f02a905-9f06-4c31-873b-49fe8c8e36bb">
<rdfs:comment></rdfs:comment>
<rdfs:label>5</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#716d95cb-f50c-484e-8d0e-527702c1bff0">
<rdfs:comment></rdfs:comment>
<rdfs:label>2</rdfs:label>
</rdf:Property>
<rdf:Property rdf:about="https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#17d50781-6691-4862-8041-ff9fb7dd04d1">
<rdfs:comment></rdfs:comment>
<rdfs:label>3</rdfs:label>
</rdf:Property>
</rdf:RDF>
In case user wants to set label 3, then user must specify the rdf:value for it:
"https://gradev.ibm.com:9444/rdm/types/_-lxL8tDgEeGe18MmgIPNSw#17d50781-6691-4862-8041-ff9fb7dd04d1"
Regarding Arun's last comment, a real value is being used and that is not allowed.
If the attribute you are trying to PUT is described by the rm_property as you are describing
<pre>
<rm_property:_6m0UhJUTEeGjDYB2VGA7DA rdf:parseType="Literal">High</rm_property:_6m0UhJUTEeGjDYB2VGA7DA>
</pre>
in that case, you can very well include it within the body when you POST or PUT.
<pre>
<rm_property:_6m0UhJUTEeGjDYB2VGA7DA rdf:parseType="Literal">High</rm_property:_6m0UhJUTEeGjDYB2VGA7DA>
</pre>
in that case, you can very well include it within the body when you POST or PUT.
Comments
The above query gives me the artifact shape. In this shape, the artifact is described as follows
Next i used GET on the propertyDefinition (https://research.jazz:9443/rm/types/_6m0UhJUTEeGjDYB2VGA7DA) and i received the following response
I request you to assist on how to create the correct format.
Thank You,
Arun
<oslc:Property>
</oslc:Property>
Next i used GET on the propertyDefinition (https://research.jazz:9443/rm/types/_6m0UhJUTEeGjDYB2VGA7DA) and i received the following response
<rdf:RDF>
</rdf:RDF>
I request you to assist on how to create the correct format.
Thank You,
Arun
So the allowed values are 0,1 and 2 and the data type is int. So, please try sending an int to that value within the range of 0.1.2. Something like this - 0
Comments
1 vote
Thank You Gabriel for the great hint...
I am able to create a requirement with a custom attribute value.
This is the line that worked for me.
The following is the property definition received from the Artifact Shape which I used for the formation of the above line. (for reference)
Cheers..!!
I am able to create a requirement with a custom attribute value.
This is the line that worked for me.
<rm_property:_6m0UhJUTEeGjDYB2VGA7DA rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA#85f26fb6-2f9c-40db-83ff-aefe1ab69618"></rm_property:_6m0UhJUTEeGjDYB2VGA7DA>
The following is the property definition received from the Artifact Shape which I used for the formation of the above line. (for reference)
<oslc:property> <oslc:Property> <oslc:valueType rdf:resource="http://open-services.net/ns/core#Resource"/> <oslc:allowedValues> <oslc:AllowedValues> <oslc:allowedValue rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA#85f26fb6-2f9c-40db-83ff-aefe1ab69618"/> <oslc:allowedValue rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA#7dae3116-c257-4d97-88bd-a34f8f198d7c"/> <oslc:allowedValue rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA#8d078228-b25f-4609-8884-b0d38e0aa6ab"/> </oslc:AllowedValues> </oslc:allowedValues> <oslc:propertyDefinition rdf:resource="https://research.jazz:9443/rm/types/_6m0UhJUTEeGjDYB2VGA7DA"/> <oslc:range rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA"/> <oslc:defaultValue rdf:resource="https://research.jazz:9443/rm/types/_6a5Yj5UTEeGjDYB2VGA7DA#8d078228-b25f-4609-8884-b0d38e0aa6ab"/> <oslc:occurs rdf:resource="http://open-services.net/ns/core#Zero-or-one"/> <dc:description rdf:parseType="Literal"/> <oslc:name>Priority</oslc:name> </oslc:Property>
Cheers..!!
Comments
Arun Batra
Jun 06 '12, 3:21 a.m.