It's all about the answers!

Ask a question

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


Naveen Tyagi (19774152) | asked Sep 02 '15, 9:44 a.m.
edited Sep 12 '15, 12:01 a.m. by Geoffrey Clemm (30.1k33035)
 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. :) 
 

Accepted answer


permanent link
Gabriel Ruelas (1.1k13) | answered Sep 03 '15, 7:21 a.m.
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

Comments
Naveen Tyagi commented Sep 03 '15, 7:26 a.m.

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. :) :)


Naveen Tyagi commented Oct 05 '15, 8:22 a.m.

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=


Naveen Tyagi commented Oct 05 '15, 8:22 a.m.

<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();


Sudipto Sarkar commented Aug 25 '16, 2:26 a.m.

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


Sudipto Sarkar commented Aug 25 '16, 2:29 a.m.

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


Naveen Tyagi commented Aug 25 '16, 5:39 a.m.

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>");
}


Naveen Tyagi commented Aug 25 '16, 5:42 a.m. | edited Aug 25 '16, 5:43 a.m.
 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
Prasannna Kumar (1112) | answered Sep 17 '16, 7:23 a.m.
 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





Comments
Donald Nong commented Sep 18 '16, 8:47 p.m.

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 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.