It's all about the answers!

Ask a question

DNG 6.0: How to fetch requirements from a folder using OSLC


Naveen Tyagi (19768152) | asked Sep 15 '15, 5:27 a.m.
i am doing GET on the following url using OSLC and Java but getting

"Exceptionjava.lang.IllegalArgumentException".
Url:
https://myserver.com/rm/views=oslc.prefix=oslc=<http://open-services.net/ns/core%23>,dcterms=<http://purl.org/dc/terms/>,nav=<http://com.ibm.rdm/navigation%23>&oslc.select=dcterms:title,dcterms:description,oslc:instanceShape&oslc.where=nav:parent=https://myserver.com/rm/folders/_zqHJMVeOEeWrg6L82g9mcQ

I have tried to user query capability but returning null value in result. Query parameters:

OslcQueryParameters queryParams = new OslcQueryParameters();
queryParams.setPrefix("nav=<http://com.ibm.rdm/navigation#>,rdf=<http://www.w3.org/1999/02/22-rdf-syntaxns#>");
queryParams.setWhere("rdf:type=<http://open-services.net/ns/rm#Requirement> and nav:parent=<" + TargetFolderUri + ">");
OslcQuery query = new OslcQuery(client, queryCapability, 5, queryParams);
OslcQueryResult result = query.submit();

can anybody let me know the correct Url and whether should in do a GET or use Query capability ? Thanks!!!!

Accepted answer


permanent link
Gabriel Ruelas (1.1k13) | answered Sep 18 '15, 7:54 a.m.
Hi,  the information is project specific, that is the reason you need to grab it from the service provider document. It must be something like :
&projectURL=https://grarrc.ibm.com:9443/jts/process/project-areas/_C7NVcttZEeG_kKBmAlkUvA
Naveen Tyagi selected this answer as the correct answer

Comments
Naveen Tyagi commented Sep 23 '15, 12:08 a.m.

Hi Gabriel, Thanks for your help.

Finally i am able to get the requirements from a folder. I was using wrong prefix that only reason i was getting not value.

OslcQueryParameters queryParams = new OslcQueryParameters();
queryParams = new OslcQueryParameters();
queryParams.setPrefix("nav=<http://com.ibm.rdm/navigation#>");
queryParams.setWhere("nav:parent=<"+ folderUri +">");
OslcQuery query =new OslcQuery(client, queryCapability, 1000, queryParams);
OslcQueryResult result = query.submit();
System.out.println("Result value : " + result.getMembersUrls().length);

Now, one more challenge i am facing, if i have all the requiremnts inside folder then it is working fine but if there one or more than collection in folder then i am getting exception and it is obvious since i am treating every artifact as requirement. so Collection object assignment in Requirements will be incompatible. now, i am wondering how do retrieve requirements but not other artifacts ?


Gabriel Ruelas commented Sep 28 '15, 11:33 a.m.

Hi,   have you tried adding another condition to the where clause ?
queryParams.setWhere("rdf:type=<http://open-services.net/ns/rm#Requirement> and nav:parent=<;" + rootFolder + ">");

One other answer



permanent link
Gabriel Ruelas (1.1k13) | answered Sep 17 '15, 8:53 a.m.
Hi, 
   From your sample query I think that project context information is not being specified. RDNG OSLC provider need a parameter that specify the project context where the query will be executed.  The project context is automatically provided if you get the query url from the project service document. Pls checl following article https://jazz.net/library/article/1197 in the section Using the query capabilities.

Best Regards.

Comments
Naveen Tyagi commented Sep 17 '15, 1:28 p.m.

 Hey Gabriel, could you please correct in the above query and post in response. i have been trying from last week but still not able to do. Thanking in advance.


Naveen Tyagi commented Sep 17 '15, 1:37 p.m.

 and also please tell me what is the correct way using GET or query.submit(). Since i have tried both but still not figured out the correct way.


Gabriel Ruelas commented Sep 17 '15, 2:19 p.m.

Hi,  the information is project specific, that is the reason you need to grab it from the service provider document. It must be something like :

&projectURL=https://grarrc.ibm.com:9443/jts/process/project-areas/_C7NVcttZEeG_kKBmAlkUvA


Naveen Tyagi commented Sep 18 '15, 6:52 a.m.

i am giving service provide url. i didn't post the complete URL in previous comment. here is the first two line i have missed in my question.

try {
//It will return service provider URl
                String serviceProviderUrl = client.lookupServiceProviderUrl(Authentication_Impl.catalogUrl, projectname);
                queryCapability = client.lookupQueryCapability(serviceProviderUrl, OSLCConstants.OSLC_RM_V2, OSLCConstants.RM_REQUIREMENT_TYPE);
                ClientResponse response = null;
OslcQueryParameters queryParams = new OslcQueryParameters();
queryParams.setPrefix("nav=<http: com.ibm.rdm="" navigation#="">,rdf=<http: www.w3.org="" 1999="" 02="" 22-rdf-syntaxns#="">");


Naveen Tyagi commented Sep 18 '15, 6:52 a.m.

queryParams.setWhere("rdf:type=<http: open-services.net="" ns="" rm#Requirement=""> and nav:parent=<;" + TargetFolderUri + ">");
OslcQuery query = new OslcQuery(client, queryCapability, 5, queryParams);
OslcQueryResult result = query.submit();


Gabriel Ruelas commented Sep 18 '15, 7:57 a.m.

you are using Eclipse Lyo, have you seen the RCFormSample in https://wiki.eclipse.org/Lyo/BuildClient

showing 5 of 6 show 1 more comments

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.