eclipse-lyo / lyo.client

Lyo project repository (lyo.client)
11 stars 16 forks source link

Query allowed values for a resource #73

Closed umeckel closed 3 years ago

umeckel commented 5 years ago

Is it possible to query the "allowedValue"s for a resource as described in the resourceShape?

For example in the TestResult Resource Shape

<rdf:Description rdf:nodeID="A78">
        <oslc:allowedValue rdf:resource="http://jazz.net/ns/qm/rqm#com.ibm.rqm.execution.common.state.part_blocked"/>
        <oslc:allowedValue rdf:resource="http://jazz.net/ns/qm/rqm#com.ibm.rqm.execution.common.state.failed"/>
...
jadelkhoury commented 5 years ago

Are you considering using the query mechanisms of OSLC? See https://open-services.net/resources/oslc-primer/#query-mechanisms for an intro.

If you have the resource shape and know what the allowed values can be, I am sure you can then query for resources, where the particular property has the desired allowed value.

umeckel commented 5 years ago

Hi, i hoped that the client can give me the oppertunity to query allowed values for a field in an oslc resource with the help of the resource shape.

Of cource i can use client.lookupCreationFactoryResource(...).getResourceShapes() and parse them myself, but i hoped there is already an implementation for this?

jadelkhoury commented 5 years ago

Let's first work out which library (client or query) is most suitable for you, before we can decide which to extend.

I am not sure I undersood exactly what you want to find. A sevice or a resource?

umeckel commented 5 years ago

Sorry for my bad explanation. My use case is that i want to push test results in an alm system with oslc and i know there is a resource TestResult there i can define which result to store. But in this resource only a limited values are allowed ("<oslc:allowedValue ..."). These possible values i want to store in a list to use them later to build a generic gui for whatever values the system is offer me to evaluate my test.

Hope this makes it clear? So i look for possible values in a known(findable) resource.

berezovskyi commented 5 years ago

@umeckel, I thought I understood your case until I didn't :)

OSLC Query is designed for the case when you have many resources but you want to filter resources (not values) that match certain criteria. Unfortunately, OSLC does not define a way to query all OSLC Shapes on the server and I thought that's what you were asking. But given that you

look for possible values in a known(findable) resource.

I don't think there is any value in the Query because it will just return you the same set of shapes as client.lookupCreationFactoryResource(...).getResourceShapes()

Actually, you will only get the URIs that you'd later have to fetch yourself. I see you point. We (me) were planning to change the signatures before in way to let you follow the OSLC link more like clicking in the browser than doing HTTP requests manually along the way.

I did not have yet time to test it, but here is a PR with two helper methods to make your life easier along the way: https://github.com/eclipse/lyo.client/pull/74 Please comment on the PR if you get a chance to try it out. The way you'd use it is this:

shapeLinks = client.lookupCreationFactoryResource(...).getResourceShapes();
shapes = client.followLinks(shapeLinks, ResourceShape.class);
umeckel commented 5 years ago

Oh i missed there is already an ResourceShape.class ...

I will try it out with the helper methods in #74 .

Thanks a lot.

berezovskyi commented 3 years ago

Please reopen if not fully solved.