DNG 6.0: How to fetch requirements from a folder using OSLC
"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
&projectURL=https://grarrc.ibm.com:9443/jts/process/project-areas/_C7NVcttZEeG_kKBmAlkUvA
Comments
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 ?
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
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
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.
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.
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
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#="">");
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();
you are using Eclipse Lyo, have you seen the RCFormSample in https://wiki.eclipse.org/Lyo/BuildClient