OSLC Query: Artifacts with a specific type [BASE ARTIFACTS ONLY]
Hi All
With following the Query I am able to get the Artifact Type T - Requirement in a specific Project:
string QueryURL = "https://jazz.xxx.com/rm/views?oslc.query=true" + "&projectURL=https://jazz.xxx.com/rm/process/project-areas/" + selectedProject.itemId + "&oslc.prefix=rm=<http://www.ibm.com/xmlns/rdm/rdf/>" + "&oslc.select=*&oslc.where=rm:ofType=<https://jazz.xxx.com/rm/types/OT_Hwvzh3hLEeyCz8SUQBPl2w>";
The catch is that I am getting ALL Artifacts of the type T - Rquirements Base Artifacts and Module Artifacts
I am only interested in the base Artifacts...
I am wondering if its possible to get this constraint (Base Artifacts ONLY) with one Query.
As work around I'd probably do the query against all Base Artifacts folder...
Any help or suggestion is highly appreciated
Philipp
|
Accepted answer
Ian Barnard (2.3k●6●13)
| answered Nov 08 '22, 3:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Nov 08 '22, 4:02 a.m. Hi Philipp
OSLC Query doesn't currently have the ability to eliminate or exclude based on presence or absence of a property value, and the difference between a module binding of an artifact (i.e. reuse) and the core artifact is that the core artifact has a rm_nav:parent property which is the URI of the folder where the artifact is held. Bindings don't have this.
So AFAIK it's not possible to get only base artifacts in a query for a specific artifact type - the workaround is to add rm_nav:parent to the oslc.select in the query and then post-filter the results excluding any artifact without a value for rm_nav:parent, i.e. filtering out module bindings.
HTH
Ian
Philipp Thomann selected this answer as the correct answer
Comments
Philipp Thomann
commented Nov 08 '22, 6:24 a.m.
Many Thanks for this promising suggestion. However, I am not sure if I implemented it correctly, please find bold my changes:
....
oslc.query=true" +
&projectURL=https://jazz.xxxx.com/rm/process/project-areas/" + selectedProject.itemId +
&oslc.prefix=rm=<http://www.ibm.com/xmlns/rdm/rdf/>" +
"&oslc.prefix=rm_nav=<http://jazz.net/ns/rm/navigation#>" + "&oslc.select=*&oslc.where=rm:ofType=<" + predicatReader_Services.Link_T_Req + ">,rm_nav:Parent;
Response NEW:
Instead OF:
The rm_nav:parent property somehow wasn't added
Update: I've figured out that the query gets messed up when I added:
"&oslc.prefix=rm_nav=<http://jazz.net/ns/rm/navigation#>" + regardless of the "select"
Update 2#
Based on your suggestion I found an similar - or most likely even the same way (Without adjusting my query) to determine if an entity is a Base Artifact or a Modul Artifact respectively a way to Post-Process it:
All entities which entail the following:
are Base artifacts
Many thanks for taking the time to help me!
Have a good day
//Philipp
1
Ian Barnard
commented Nov 08 '22, 7:35 a.m.
| edited Nov 08 '22, 7:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Make sure to URL encode the oslc.prefix value too - if unencoded it contains # which unencoded denotes a fragment. This is an example of why you should *always* URL encode the parameter values.
> All entities which entail the following:
Yes that's my "post-filter the results excluding any artifact without a value for rm_nav:parent"
|
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.
Comments
Although it may not matter for simple cases, in general you should be careful to URL encode the values (the bit after the first =) for all your query parameters - for example :
I appreciate your suggestion :)! --> I will implement it in my project