HTTP call for adding link to requirement

How do I add a link, e.g. a ‘link to’, to an existing requirement? Please answer with Java code example.

Hello @reimer,

Your question does not have enough details to give you a piece of (working) code.

Let’s start at the beginning: when you say requirement, I assume you mean http://docs.oasis-open.org/oslc-domains/oslc-rm/v2.1/cs01/part2-requirements-management-vocab/oslc-rm-v2.1-cs01-part2-requirements-management-vocab.html#requirement. Then, I assume by a link you mean a property like oslc_rm:affectedBy.

Now, I also assume you already have an OSLC Server running with requirements. Then, you should use an OslcClient class to connect to your server. Here is some sample code how to add links.

Hope it helps.

/Andrew

Hi Andrea,
Can you provide code details for linking requirement? I have gone through DoorsOauthSample.java but most of the code is deprecated now can you provide ?

  1. I am getting requirement.
  2. need to add link as validate by .
    Thanks In advance,

Thanks
Abhay

Hi @abhayfegade,

The most up-to-date example is lyo-samples/EWMSample.java at master · OSLC/lyo-samples · GitHub . Unfortunately, I don’t have time now to update the rest but if you adapt lyo-samples/ERMSample.java at master · OSLC/lyo-samples · GitHub to your needs, please contribute the changes back via a PR.

Cheers,
Andrew

Thanks andrew for the help, I have tried below code, i am able to update title, description of requirement but not able to update link. Code not giving any error but link is not showing in IBM doors, is anything missing from my end, providing code snippet for the reference.

Requirement requirement = new Requirement();
Response getResponse = client.getResource(“https://jazz.net/sandbox01-rm/resources/BI_y0eL-_tyEeyF1qE36n3T2w”,OslcMediaType.APPLICATION_RDF_XML);

					requirement = getResponse.readEntity(Requirement.class);
					// Get the eTAG, we need it to update
					String etag = getResponse.getStringHeaders().getFirst(OSLCConstants.ETAG);
					requirement.setTitle("Testing Artifact");
					requirement.setShortTitle("Testing");
					requirement.setDescription("Updated by Abhay");
					
					//requirement.addImplementedBy(new Link(new URI("http://google.com"), "Link created by an Eclipse Lyo user"));
					requirement.addSatisfies(new Link(new URI("http://google.com"), "Link created by an Eclipse Lyo user"));
			
					
					// Update the requirement with the proper etag
					Response updateResponse = client.updateResource("https://jazz.net/sandbox01-rm/resources/BI_y0eL-_tyEeyF1qE36n3T2w",
							requirement, OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_RDF_XML, etag);

Thanks andrew for the help, I have tried below code, i am able to update title, description of requirement but not able to update link. Code not giving any error but link is not showing in IBM doors, is anything missing from my end, providing code snippet for the reference.

Requirement requirement = new Requirement();
Response getResponse = client.getResource(“https://jazz.net/sandbox01-rm/resources/BI_y0eL-_tyEeyF1qE36n3T2w”,OslcMediaType.APPLICATION_RDF_XML);

				requirement = getResponse.readEntity(Requirement.class);
				// Get the eTAG, we need it to update
				String etag = getResponse.getStringHeaders().getFirst(OSLCConstants.ETAG);
				requirement.setTitle("Testing Artifact");
				requirement.setShortTitle("Testing");
				requirement.setDescription("Updated by Abhay");
				
				//requirement.addImplementedBy(new Link(new URI("http://google.com"), "Link created by an Eclipse Lyo user"));
				requirement.addSatisfies(new Link(new URI("http://google.com"), "Link created by an Eclipse Lyo user"));
		
				
				// Update the requirement with the proper etag
				Response updateResponse = client.updateResource("https://jazz.net/sandbox01-rm/resources/BI_y0eL-_tyEeyF1qE36n3T2w",
						requirement, OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_RDF_XML, etag);
[/quote]

If you are successfully able to update some properties (title & description), then you are making the correct calls, and Doors seems to be receiving your requests.

When you first get the requirement, can you check that these properties implementedBy/satisfies even exist for a Requirement? What values do they have?

Could it be that Doors has some special rules/logic on how to update the particular property ?
Could it be that Doors does not like setting them to something as generic as http://google.com? Maybe you can try with some values that are very close to the original values (for example, belonging to the same domain, etc).

Do the Doors logs give you any hints?

This seems to be a recurring issue with DNG. Please see for example this previous thread How to Remove OSLC Links from an Artifact?

Maybe it’s a question to IBM DNG/Jazz afterall.