# How to create links to rtc\_cm:parent or child ChangeRequest

**URL:** <https://forum.open-services.net/t/how-to-create-links-to-rtc-cm-parent-or-child-changerequest/442>\
**Category:** Lyo\
**Created:** [November 23, 2020, 10:08am UTC](https://forum.open-services.net/t/how-to-create-links-to-rtc-cm-parent-or-child-changerequest/442 "2020-11-23T10:08:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxler05](https://forum.open-services.net/letter_avatar_proxy/v4/letter/m/ee59a6/32.png) [@maxler05](https://forum.open-services.net/u/maxler05)\
**Post date:** [November 23, 2020, 10:08am UTC](https://forum.open-services.net/t/how-to-create-links-to-rtc-cm-parent-or-child-changerequest/442/1 "2020-11-23T10:08:39Z")

</div>

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](https://XYZ/ccmf/resource/itemName/com.ibm.team.workitem.WorkItem/145204)”/\>

Many thanks…

---

<div class="post-metadata">

**Author:** ![andrew](https://forum.open-services.net/user_avatar/forum.open-services.net/andrew/32/28_2.png) [@andrew](https://forum.open-services.net/u/andrew)\
**Post date:** [November 23, 2020, 10:15am UTC](https://forum.open-services.net/t/how-to-create-links-to-rtc-cm-parent-or-child-changerequest/442/2 "2020-11-23T10:15:19Z")

</div>

Hi @maxler05,

Did you check the [https://download.eclipse.org/lyo/docs/core/2.4.0/org/eclipse/lyo/oslc4j/core/model/AbstractResource.html#getExtendedProperties--](https://download.eclipse.org/lyo/docs/core/2.4.0/org/eclipse/lyo/oslc4j/core/model/AbstractResource.html#getExtendedProperties--) method?

–Andrew

---

<div class="post-metadata">

**Author:** ![maxler05](https://forum.open-services.net/letter_avatar_proxy/v4/letter/m/ee59a6/32.png) [@maxler05](https://forum.open-services.net/u/maxler05)\
**Post date:** [November 25, 2020, 6:36am UTC](https://forum.open-services.net/t/how-to-create-links-to-rtc-cm-parent-or-child-changerequest/442/3 "2020-11-25T06:36:53Z")

</div>

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](http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/)}com.ibm.team.workitem.linktype.parentworkitem.parent” → {URI@5279} “[https://XYZ/ccmfed/resource/itemName/com.ibm.team.workitem.WorkItem/145760](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

---

<div class="post-metadata">

**Author:** ![andrew](https://forum.open-services.net/user_avatar/forum.open-services.net/andrew/32/28_2.png) [@andrew](https://forum.open-services.net/u/andrew)\
**Post date:** [November 25, 2020, 9:23pm UTC](https://forum.open-services.net/t/how-to-create-links-to-rtc-cm-parent-or-child-changerequest/442/4 "2020-11-25T21:23:34Z")

</div>

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-](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](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](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-](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

---

<div class="post-metadata">

**Author:** ![maxler05](https://forum.open-services.net/letter_avatar_proxy/v4/letter/m/ee59a6/32.png) [@maxler05](https://forum.open-services.net/u/maxler05)\
**Post date:** [December 2, 2020, 5:54am UTC](https://forum.open-services.net/t/how-to-create-links-to-rtc-cm-parent-or-child-changerequest/442/5 "2020-12-02T05:54:03Z")

</div>

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
