How to fetch only streams from a component using GC API
Hi,
I am not able to filter configurations based on streams. Is there a way we get only stream url from a configuration.
GC Url used to fetch configuration,
i am trying to filter based on stream using this oslc_config:stream parameter as mentioned in https://jazz.net/sandbox01-gc/doc/scenario?id=QueryConfigurations
Please let me know, how can i get all streams from a component / configuration and not baselines. Currently if we try to get configurations for a component it gives streams and baselines. i am finding difficult to get only stream urls beacuse both uses rdf:type.
Thank you
Regards,
Thiru
Accepted answer
You don't say what version/ifix you're using.
Your query URL doesn't look correct because a) there's no oslc.where, and b) the query value(s) aren't URL encoded, c) it's oslc_config:Stream not oslc_config:stream (and the document you link to shows oslc_config:Stream). and d) you haven't specified the oslc_config prefix using oslc.prefix=...
This GET query for configurations in a project works for me in 7.0.2 iFix009:
with headers:
OSLC-Core-Version: 2.0
Accept: application/rdf+xml
The URL un-encoded and broken into parts is:
?oslc.select=rdf:type,dcterms:identifier
&oslc.where=rdf:type=<http://open-services.net/ns/config#Stream>
You could do exactly the same thing with prefixes by adding oslc_config.to oslc.prefix and then use oslc_config as a prefix in the oslc.where, something like this (untested):
&oslc.where=rdf:type=oslc_config:Stream
&oslc.prefix=oslc_config=<http://open-services.net/ns/config#>
(with the appropriate URL encoding for the oslc.prefix vaue, of course)
This returns just the 8 streams I expect.
A similar application-wide query looks like:
But in general it's best to avoid such wide queries because they will place a load on the server that you should preferably avoid, or at least take great care to ensure your queries doesn't impact on all the other users.
Postscript:
Looking at the query results when the rdf:type is included, it seems each result entry has multiple values for rdf:type, e.g. for a stream:
<rdf:type rdf:resource="http://open-services.net/ns/config#Configuration"/>
<rdf:type rdf:resource="http://jazz.net/ns/config_ext#SharedStream"/>
<rdf:type rdf:resource="http://open-services.net/ns/config#Stream"/>
or for a baseline:
<rdf:type rdf:resource="http://open-services.net/ns/config#Configuration"/>
<rdf:type rdf:resource="http://open-services.net/ns/config#Baseline"/>
but when using oslc.where=rdf:type=oslc_config:Stream the results do seem correctly be just the streams.
I'm no RDF expert, but I assume this means that the result is (compatible with) all of the types in its entry. Painful to filter at the XML level, though, so much easier to get the OSLC Query to work it out for you :-)
HTH
Ian
One other answer
The URI you mentioned isn't an OSLC query capability. In GCM, all the query capability base URIs are under /gc/oslc-query. However, you shouldn't hard code these, but instead use OSLC discovery to find them.
The correct usage is described in https://jazz.net/gc/doc/scenario?id=QueryConfigurations.
- Discover a query capability for configurations from the OSLC Service Provider Catalog. This might be one for a specific GCM project area, or a global one that can query across all GCM project areas.
- That will provide a query base URI.
-
Perform a GET or POST on that, specifying an
oslc.where
expression as a parameter.
-
Optionally sp[ecify an
oslc.select
parameter to define what properties of each configuration you want returned in the response. If you don't specify one, then the set of properties returned is undefined and likely to be minimal.
Regarding
oslc.prefix
, GCM has most of the common ones predefined. I think you can find these by looking at the OSLC service provider. I think
osc
and
oslc_config
are both predefined. Which means that in most cases you don't need to specify
oslc.prefix
.
Comments
Thank you David for this detailed answer. Now i am able to understand better.
The GC documentation is a pleasure to refer to, David. https://jazz.net/gc/doc/scenario?id=QueryConfigurations - I wish the other apps had something equally good.
Re: prefixes, I found I had to avoid providing prefix definitions for dcterms, oslc, rdf because they result in the query being rejected because these are already defined. Didn't have that problem with oslc_config.