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

Query for specific tagged workitem by OSLC dcterms:subject

 Hello,

I'm using the OSLC to fetch the expected tagged workitems with 
dcterms:subject in ["tvt","mustfix"]
like format, which is one example in example6. 
My URL is like
https://rb-alm-20-p.de.bosch.com/ccm/oslc/contexts/_QjsBsp5aEeq2u-M0ATM71Q/workitems/bugv2.0?oslc.where=dc:subject in ["stability"]&oslc.prefix=dcterms=<http://purl.org/dc/terms/>
and I do encode the URL by utf-8.But the response is still all the bugs without tag filter.
Does someone know how to fix this by OSLC or REST API of RTC?

0 votes



2 answers

Permanent link

I assume you are using an OSLC query capability - see https://docs.oasis-open-projects.org/oslc-op/query/v3.0/os/oslc-query.html.

You should URL encode all the values for parameters including oslc.where and oslc.prefix . See the specification for details with examples.

0 votes

Comments

Hi David,

Thanks for your answer. But i did encode all the parameter in the URL like the following:
oslc.where%3Ddcterms%3Asubject%20in%20%5B%22sop5_bug%22%5D%26oslc.prefix%3Ddcterms%3D%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Fterms%2F%3E%26oslc.select%3D%2A%26oslc.paging%3Dtrue%26oslc.pageSize%3D200, which uses UTf-8.
It still gives back all the items without tags filtered.

That's not correct - you are encoding more than each parameter value Assuming you're trying to use the following parameters:

Parameter Value
oslc.where dcterms:subject in ["sop5_bug"]
oslc.prefix dcterms=<http://purl.org/dc/terms/>
oslc.select *
oslc.paging true
oslc.pageSize 200

the correct encoding in a request would be: oslc.where=dcterms%3Asubject%20in%20%5B%22sop5_bug%22%5D&oslc.prefix=dcterms%3D%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Fterms%2F%3E&oslc.select=*&oslc.paging=true&oslc.pageSize=200


Permanent link
I don't know where/how you got your query base URL but my 7.0.2 iFix009 test env doesn't have any query capability with bugv2.0 in it. YMMV.

For my test environment the project-specific work items query URL base for my project is https://jazz.ibm.com:9443/ccm/oslc/contexts/_pag-MkB1EeuDvqpPB-fV1g/workitems

This is discovered starting from rootservices, details after the Discovery heading below.  

Then the full OSLC Query URL in this case for tags"asd" and "mobile":


With headers:
  OSLC-Core-Version: 2.0
  Accept: application/rdf+xml

With the encoding removed and with the query parameters broken out this looks like:

  • oslc.prefix=dcterms=<http://purl.org/dc/terms/>
  • oslc.where=dcterms:subject in ["asd","mobile"]
  • oslc.select=*
  • oslc.paging=true
  • oslc.pageSize=200
The paging and pagesize are optional - but your code needs to be prepared for paging of results even if you don't specify these :-)

NOTE using oslc.select=* increases the load on the server so avoid if at all possible, to minimize the impact of your queries on users.
.
Discovery of OSLC Query base URL

I'm using 7.0.2 iFix009 - although AFAIK the steps below would work back to at least 6.0.2.

For all requests below you MUST provide headers:
* OSLC-Core-Version: 2.0
* Accept: application/rdf+xml

If you don't provide these headers then the sequence below won't work because you'll get different (non-OSLC 2.0) responses.

The querybases (there are two in my test environment) are in the project's services.xml., in my case this is at https://jazz.ibm.com:9443/ccm/oslc/contexts/_pag-MkB1EeuDvqpPB-fV1g/workitems/services.xml

You discover this starting from rootservices:


(this request doesn't require you to be authenticated)

Look for the entry:

  <oslc_cm:cmServiceProviders
          xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/"
          rdf:resource="https://jazz.ibm.com:9443/ccm/oslc/workitems/catalog" />

Then:


(your client code will have to be authenticated to get the catalog and any other requests from now on, if your user doesn't have permission to access then you won't get the data)

This is the catalog of projects on your server. Find the project by looking for the dcterms:title tag with title of your project, then the services catalog for that project is in the rdf:about of the containing oslc:ServiceProvider tag:

<oslc:serviceProvider>
<dcterms:title rdf:parseType="Literal">My Project</dcterms:title>
<jfs_proc:supportLinkDiscoveryViaLinkIndexProvider rdf:parseType="Literal">false</jfs_proc:supportLinkDiscoveryViaLinkIndexProvider>
<jfs_proc:supportContributionsToLinkIndexProvider rdf:parseType="Literal">true</jfs_proc:supportContributionsToLinkIndexProvider>
<jfs_proc:globalConfigurationAware rdf:parseType="Literal">compatible</jfs_proc:globalConfigurationAware>
</oslc:ServiceProvider>
</oslc:serviceProvider>



Then to find the correct query base URL search for an oslc:QueryCapability tag containing a tag oslc:resourceType for http://open-services.net/ns/cm#ChangeRequest, and the query base is the oslc:queryBase tag alongside it.

<oslc:queryCapability>
<oslc:QueryCapability>
<dcterms:title rdf:parseType="Literal">Change request queries</dcterms:title>
<oslc:resourceType rdf:resource="http://open-services.net/ns/cm#ChangeRequest"/>
</oslc:QueryCapability>
</oslc:queryCapability>

HTH
Ian

0 votes

Comments

Hi Ian,

Thanks for your answer!
What I discovered from the  'Discovery Mechanism' is like below
<dc:title>Location for creation of Bug change requests </dc:title>
</oslc_cm:factory>
This is from https://rb-alm-20-p.de.bosch.com/ccm/oslc/contexts/_QjsBsp5aEeq2u-M0ATM71Q/workitems/services.xml, and I didn't see a tag named oslc:queryBase you described.
I use the select and page setup as yours but the result is still the same where no filter on tags.

That URL definitely won't work as query because, as it shows in your XML, it's the "Location for creation of Bug change requests", and it's in a oslc_cm:factory tag, i.e. it isn't a OSLC Query base URL.


You're probably not providing the header OSLC-Core-Version: 2.0 - this is required.

I added to my answer details of how to find the correct query base URL for work items.

I would suggest to have a look here: https://rsjazz.wordpress.com/2022/02/22/ewm-oslc-query-api/ this also covers the discovery process. I agree with the statements with respect to the URL as well as the headers.  

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,936
× 515

Question asked: Apr 22 '22, 10:57 a.m.

Question was seen: 1,728 times

Last updated: Apr 25 '22, 6:37 a.m.

Confirmation Cancel Confirm