Hello,
using oslc4j I can create a ChangeRequest and provide related.
But how is it possible to create links to parent or child ChangeRequest?
When I look in the rdf representation of a CCM item, I can find parent item.
How can I get and create parent items by using the oslc4j?
<rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.parent rdf:resource=“https://XYZ/ccmf/resource/itemName/com.ibm.team.workitem.WorkItem/145204 ”/>
Many thanks…
andrew
November 23, 2020, 10:15am
2
Hi Andrew,
thanks for your response.
I tried it now with extendedProperties:
The first step was to take a workitem which has an parent relation, and checking if I can find it with the oslc api → I could find it under extendendProperties, same for child releations:
{QName@5278} “{RtcCmVocabulary < LinkedData < TWiki }com.ibm.team.workitem.linktype.parentworkitem.parent” → {URI@5279} “https://XYZ/ccmfed/resource/itemName/com.ibm.team.workitem.WorkItem/145760 ”
Now I tried with the QName from the example above:
String type = "com.ibm.team.workitem.workItemType.featurerequest";
String configurationContext = "_yoMVoBT6Eeu9VOClgNyCps";
ChangeRequest changeRequest = new ChangeRequest();
changeRequest.setTitle("TITLE");
changeRequest.setDescription("DESC");
changeRequest.getExtendedProperties().put(new QName("http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/", "com.ibm.team.workitem.linktype.parentworkitem.parent"), "https://XYZ/ccmfed/resource/itemName/com.ibm.team.workitem.WorkItem/145760");
String factoryUrl = JAZZ_CONNECTION.getUrl() + "/oslc/contexts/" + configurationContext + "/workitems/" + type;
javax.ws.rs.core.Response creationResponse = OslcClientHelper.getOslcClient(JAZZ_CONNECTION).createResource(
factoryUrl, changeRequest,
OslcMediaType.APPLICATION_RDF_XML,
OslcMediaType.APPLICATION_RDF_XML);
This failed with the following message:
<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:nodeID="A0">
<oslc:message>Missing expected parameter: http://www.w3.org/1999/02/22-rdf-syntax-ns#resource</oslc:message>
<oslc:statusCode>400</oslc:statusCode>
<rdf:type rdf:resource="http://open-services.net/ns/core#Error"/>
</rdf:Description>
</rdf:RDF>
Any ideas why this happens and how to solve that…
Best regards
Steve
andrew
November 25, 2020, 9:23pm
4
Hello Steve,
First, changeRequest.getExtendedProperties().put(new QName("http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/", "com.ibm.team.workitem.linktype.parentworkitem.parent"), "https://XYZ/ccmfed/resource/itemName/com.ibm.team.workitem.WorkItem/145760");
should be URI.create("https://XYZ/ccmfed/resource/itemName/com.ibm.team.workitem.WorkItem/145760")
. RDF is strict on typing.
Second, http://www.w3.org/1999/02/22-rdf-syntax-ns#resource
is essentially the subject of the RDF resource. You can supply it via https://download.eclipse.org/lyo/docs/core/2.4.0/org/eclipse/lyo/oslc4j/core/model/AbstractResource.html#AbstractResource-java.net.URI- . If you get confused about RDF easily, I recommend using Apache Jena RIOT tools or https://www.easyrdf.org/converter if you are in a hurry and convert the RDF/XML or JSON-LD or N-Triples (all legal RDF formats) to Turtle (the most human-readable format).
I have no idea about the specific requirements for the URI required by Jazz CF endpoint. See https://github.com/OSLC/lyo-samples/blob/master/oslc4j-client-samples/src/main/java/org/eclipse/lyo/oslc4j/client/samples/EWMSample.java#L171-L203 as well. It does not seem to set any URI in the constructor there, so I am not entirely sure as to what’s going on. Try making a random URI, creation factories frequently ignore it and return you a new URI for the created resource. Wait a second, why are you creating a resource? I think you should call https://download.eclipse.org/lyo/docs/oslc-java-client/latest/org/eclipse/lyo/client/oslc/OslcClient.html#updateResource-java.lang.String-java.lang.Object-java.lang.String- ?
–Andrew
1 Like
Andrew,
thanks for your good hints (e.g. strict typing, easyrdf, updateResource).
You was right, you can only link parents of already existing workitems -> take an existing ChangeRequest + add the link as shown in my example code + updating that ChnageRequest works.
-Steve
1 Like