It's all about the answers!

Ask a question

OSLC Query: Artifacts with a specific type [BASE ARTIFACTS ONLY]


Philipp Thomann (305) | asked Nov 08 '22, 2:55 a.m.
edited Nov 08 '22, 2:57 a.m.
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

Comments
1
Ian Barnard commented Nov 08 '22, 5:03 a.m. | edited Nov 08 '22, 5:10 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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 :

should be encoded to:
* &oslc.prefix=rm%3D%3Chttp%3A%2F%2Fwww.ibm.com%2Fxmlns%2Frdm%2Frdf%2F%3E

Also, in your example you're constructing the query URL from scratch - this may work well enough with the version you're currently using but isn't future-proof - for future-proofing you should be getting the base URL from the query capability and only adding to it the oslc.prefix, oslc.select, oslc.where and the configuration context.


Philipp Thomann commented Nov 08 '22, 5:41 a.m. | edited Nov 08 '22, 6:36 a.m.

I appreciate your suggestion :)! --> I will implement it in my project

Accepted answer


permanent link
Ian Barnard (1.9k613) | 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:

Philipp Thomann commented Nov 08 '22, 6:24 a.m. | edited Nov 08 '22, 6:42 a.m.

....

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"


Philipp Thomann commented Nov 08 '22, 7:01 a.m. | edited Nov 08 '22, 7:06 a.m.
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


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.