Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes

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 :

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.

1 vote

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


Accepted answer

Permanent link

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

1 vote

Comments
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





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"

1 vote

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,944
× 516
× 201
× 198
× 139

Question asked: Nov 08 '22, 2:55 a.m.

Question was seen: 1,216 times

Last updated: Nov 08 '22, 7:38 a.m.

Confirmation Cancel Confirm