Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

DNG 6.0 : Retrieving Requirements from a folder in DNG using OSLC

 I am new to OSLC. i have written code to pull out all the requirement list from a project in DNG. I want to retrieve requirements folder by folder instead of all once. Like, List of all the requirements inside a folder by providing its name. also List of all the folders and requirements inside folders. 
I found that there is a folder query capability for this (https://jazz.net/library/article/1197). I am not able to understand how to use that in My code. 

Here is the code i am using to retrieve all the requirement in DNG project but i need folder by folder.

try{
      String serviceProviderUrl = client.lookupServiceProviderUrl(Authentication_Impl.catalogUrl, projectArea);
      queryCapability = client.lookupQueryCapability(serviceProviderUrl, OSLCConstants.OSLC_RM_V2,OSLCConstants.RM_REQUIREMENT_TYPE);
      requirements = new ArrayList<MyRequirement>();
  ClientResponse response = null;
  OslcQueryParameters queryParams = new OslcQueryParameters();
  queryParams.setPrefix("rdf=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
  queryParams.setWhere("rdf:type=<http://open-services.net/ns/rm#Requirement>");
  OslcQuery query = new OslcQuery(client, queryCapability, 20, queryParams);
  OslcQueryResult result = query.submit();
  
    
for (String resultsUrl : result.getMembersUrls()) {
  response = client.getResource(resultsUrl, OSLCConstants.CT_RDF);
    
MyRequirement requiremnt = new MyRequirement();
Requirement req = response.getEntity(Requirement.class);
requiremnt.setId(Integer.parseInt(req.getIdentifier() ));
requiremnt.setSummary(req.getTitle());
requirements.add(requiremnt);
System.out.println("Title: "  + req.getTitle() + "Identifire :" +  req.getIdentifier() ) ;
System.out.println("");
}

Your help would greatly appreciated. :) 
 

0 votes


Accepted answer

Permanent link
Hi,
The oslc.where param must specify something like :
" oslc.where=nav:parent=<https://grarrc.ibm.com:9443/rm/folders/_RHCJYN5jEeGb6IIbvOh9Dw> "

now, in order to get the URI's of the folders ( AKA transverse the folder structure ) you can use
the capabilities described in : https://rhnaranjo.wordpress.com/2012/06/25/folder-support-added-to-rrc-4-0-oslc-rm-api-implementation/

Naveen Tyagi selected this answer as the correct answer

1 vote

Comments

i am not able to open this link (https://rhnaranjo.wordpress.com/2012/06/25/folder-support-added-to-rrc-4-0-oslc-rm-api-implementation/) since  i have limited access but I will look into this article at home and let you know for any Issue. Thanks for reply. :) :)

Thanks Garbiel!!!
Finally able to do that, Posting complete query may be help someone looking for same answer:

String serviceProviderUrl = client.lookupServiceProviderUrl(Authentication_Impl.catalogUrl, projectname);
                    queryCapability = client.lookupQueryCapability(serviceProviderUrl, OSLCConstants.OSLC_RM_V2, OSLCConstants.RM_REQUIREMENT_TYPE);
                    requirements = new ArrayList<MyRequirement>();
                    collectionsURI = new ArrayList<String>();
                    OslcQueryParameters queryParams = new OslcQueryParameters();
                    queryParams.setPrefix("nav=<http://com.ibm.rdm/navigation#>,rdf=

<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
                    queryParams.setWhere("nav:parent=<"+ folderUri +">, rdf:type=<http://open-services.net/ns/rm#Requirement>;");
                    OslcQuery query =new OslcQuery(client, queryCapability, 1500, queryParams);
                    OslcQueryResult result = query.submit();

Hi naveen,

 I tried using the same query to fetch the requirements of a folder. But I am getting following exception:

java.lang.RuntimeException: Undefined namespace prefix: nav (More info found at entry [724e36eb342202a8] in the RM application server log)</err:detailedMessage>
    <err:errorMessage rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
    >Bad Request</err:errorMessage>
    <err:errorStatus rdf:datatype="http://www.w3.org/2001/XMLSchema#long"
    >400</err:errorStatus>
  </rdf:Description>
</rdf:RDF>

My folder uri is: https://example.com:9443/rm/folders/_pCsHIeuBEeW8KYg-oqs26A.
Am i missing something?

regards,
Sud

Hi naveen,

 I tried using the same query to fetch the requirements of a folder. But I am getting following exception:

java.lang.RuntimeException: Undefined namespace prefix: nav (More info found at entry [724e36eb342202a8] in the RM application server log)</err:detailedMessage>
    <err:errorMessage rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
    >Bad Request</err:errorMessage>
    <err:errorStatus rdf:datatype="http://www.w3.org/2001/XMLSchema#long"
    >400</err:errorStatus>
  </rdf:Description>
</rdf:RDF>

My folder uri is: https://example.com:9443/rm/folders/_pCsHIeuBEeW8KYg-oqs26A.
Am i missing something?

regards,
Sud

Hi Suditp,
It seems like your query is not correct. let me give you the right query. Hope it will help.


OslcQueryParameters queryParams = new OslcQueryParameters();
if(folderUri==null)
{
queryParams.setPrefix("rdf=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
queryParams.setWhere("rdf:type=<http://open-services.net/ns/rm#Requirement>");
}

 else
{
queryParams.setPrefix("nav=<http://com.ibm.rdm/navigation#>,rdf=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
queryParams.setWhere("nav:parent=<"+ folderUri +">, rdf:type=<http://open-services.net/ns/rm#Requirement>;");
}
if you want to get all the requirements from root folder then pass null and if will execute otherwise else part contains query to get the requirements from any particular folder.

showing 5 of 7 show 2 more comments

One other answer

Permanent link
 HI Naveen looks like you have got the Stuff , i am trying to get the same i mean to get the Artifact details inside the Folders but couldn't succeed tried whatever posted in Jazz forums,  I am trying out in RESTCLIENT in firefox, let me post my query

https://<Servername>/rm/views?oslc.query=true&projectURL=https%3A%2F%2F<Servername>%2Frm%2Fprocess%2Fproject-areas%2F__xM4IkAnEeWqwKVfQayNVQ&oslc.prefix=oslc=nav=<http://com.ibm.rdm/navigation#23>,rdf=<http://www.w3.org/1999/02/22-rdf-syntax-ns#23>,dcterms=<http://purl.org/dc/terms/>&oslc.select=dcterms:title,dcterms:description,oslc:instanceShape&oslc.where=nav:parent=<https://<Servername>/rm/folders/_CyDuAVVFEeWyLqmwS3I1jg>,rdf:type=<http://open-services.net/ns/rm#23Requirement>

i dont know whats the problem in query, i am gettin Internal Error Status code 500

Can you please help

Thanks & Regards
Prasanna kUmar




0 votes

Comments

You should check rm.log file on the server side for further information. Since the URL is all messed up in the post, I cannot see whether any typos or incorrect syntax there, but you need to at least make sure all the namespaces used in "oslc.select" and "oslc.where" are specified in "oslc.prefix".

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Sep 02 '15, 9:44 a.m.

Question was seen: 3,908 times

Last updated: Sep 18 '16, 8:47 p.m.

Confirmation Cancel Confirm