It's all about the answers!

Ask a question

How to fetch only streams from a component using GC API


Thiruvenkadam Dhanaraj (259) | asked May 12, 9:22 a.m.

 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


permanent link
Ian Barnard (1.2k613) | answered May 12, 11:31 a.m.
JAZZ DEVELOPER
edited May 12, 12:45 p.m.

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:


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

Thiruvenkadam Dhanaraj selected this answer as the correct answer

Comments
Thiruvenkadam Dhanaraj commented May 13, 1:16 a.m.

Yes it worked. Thank you Ian. 

One other answer



permanent link
David Honey (7756) | answered May 12, 11:32 p.m.
JAZZ DEVELOPER
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.

  • 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
Thiruvenkadam Dhanaraj commented May 13, 1:17 a.m.

Thank you David for this detailed answer. Now i am able to understand better. 


Ian Barnard commented May 13, 3:25 a.m.
JAZZ DEVELOPER

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.

Your answer


Register or to post your answer.