Lyo Store - OSLC Query with SPARQL, issues with the where clause



I am trying to use the Lyo Store library to implement OSLC Query capability in my OSLC adapter. I managed to setup the Store, and getting individual resources or querying for all resources works fine. However, I am unable to get any results when using queries with a where clause. The result always contains zero resources.
I am using 2.4.0.M1 (also tried the 4.0.0-SNAPSHOT), and I am using Apache Jena Fuseki as the SPARQL server (also tried RDF4J Server).

When I do a query for all resources (with no where clause), like this: http://localhost:8080/AnacondaOSLC/services/Automation/A0/resources/queryAutomationResult
I get a response with a list of AutomationResult resources. One of which contains a property <dcterms:identifier>0</dcterms:identifier>
But when I do another query with a where clause to find the resource with identifier equal to zero, like this:
The response returns zero resources found.

This is what my implementation of the query capability generated by Lyo looks like:

public static List<AutomationResult> queryAutomationResults(HttpServletRequest httpServletRequest, final String serviceProviderId, String where, int page, int limit)
    List<AutomationResult> resources = null;
    // Start of user code queryAutomationResults
    try {
    	if (where == null)
    		where = "";

		String oslcPrefixes = httpServletRequest.getParameter("oslc.prefix");
    	Model jenaModel = store.getResources(new URI("http://autoResults"), oslcPrefixes, where, limit, page);
    	resources = getResourcesFromModel(jenaModel, AutomationResult.class);

	} catch (StoreAccessException | ModelUnmarshallingException | URISyntaxException e) {
		// TODO Auto-generated catch block
    // End of user code
    return resources;

I would like to kindly ask for help with this issue. Any suggestions on what am I doing wrong or what could cause the problem are greatly appreciated.




Thanks for giving Lyo Store a try! Initially, it was not designed to support OSLC Query but experimental support has been added by @jad. Hopefully he can help you. He will likely need more info, so I have added a log statement into the getResources method to help you:

Just re-run your code with Store 4.0.0-SNAPSHOT and logger at the TRACE level to see what kind of SPARQL query is generated by Lyo Store to see where the problem lies.

Happy Easter!



Thanks for the reply.

I see, so the OSLC Query support is still experimental. It is very useful feature to have in the Store, as it allowed me to add persistence and query capabilities to my OSLC adapter with minimal effort. Hope the implementation eventually gets finished.

I already have logs of the query from the Jena Fuseki server logger and they look like this (after url decoding):

[2019-04-20 20:53:57] Fuseki     INFO  [26] GET http://localhost:8081/fuseki/anaconda_automation/query?query=ASK
  { GRAPH <http://automation_resources>
      { ?s  ?p  ?o }

[2019-04-20 20:53:57] Fuseki     INFO  [26] Query = ASK WHERE   { GRAPH <http://automation_resources>       { ?s  ?p  ?o }   } 
[2019-04-20 20:53:57] Fuseki     INFO  [26] 200 OK (2 ms)
[2019-04-20 20:53:57] Fuseki     INFO  [27] GET http://localhost:8081/fuseki/anaconda_automation/query?query=PREFIX  rdf:  <>
PREFIX  dcterms: <>

  { GRAPH <http://automation_resources>
      { ?s  ?p  ?o
        { SELECT DISTINCT  ?s
            { ?s  ?p                  ?o ;
                  dcterms:identifier  0 ;
                  rdf:type            <>
          LIMIT   20

[2019-04-20 20:53:57] Fuseki     INFO  [27] Query = PREFIX  rdf:  <> PREFIX  dcterms: <>  DESCRIBE ?s WHERE   { GRAPH <http://automation_resources>       { ?s  ?p  ?o         { SELECT DISTINCT  ?s           WHERE             { ?s  ?p                  ?o ;                   dcterms:identifier  0 ;                   rdf:type            <>             }           LIMIT   20         }       }   } 
[2019-04-20 20:53:57] Fuseki     INFO  [27] 200 OK (6 ms)

Is this log fine, or should I make a new one using the log statement you have added?

I have switched to Store 4.0.0-SNAPSHOT already and started using oslc.searchTerms which works fine. Still cant get oslc.where to work though. My implementation of the Lyo query capability has changed like this (a bit cleaner and straight forward):

if (where == null)
    where = "";
String oslcPrefixes = httpServletRequest.getParameter("oslc.prefix");
String searchTerms = httpServletRequest.getParameter("oslc.searchTerms");
return store.getResources(namedGraph, clazz, oslcPrefixes, where, searchTerms, limit, page);

To be honest, I dont know much about SPARQL and getting the oslc.where to work is not essential for me right now. So I will be happy if @jad could just confirm whether oslc.where is currently working in Lyo Store, and maybe give me a simple example of a query GET request for Lyo Store.

Thanks again, any help is much appreciated!



The fact that you are getting a SPARQL query is a good sign. we just need to fine-tune it to make it respond to your query.

Could you please do the following for me:

  1. Run the sparql query without the 8th line ( dcterms:identifier 0 ;).
  2. From the response you receive, can you please post to me one or two resources that you believe should have been included in your query.

Although you are expecting dcterms:identifier to be 0, I wonder if the paramter is being sent in the most appropriate way. For example, should you be sending (a) dcterms:identifier=“0” or (b) dcterms:identifier=0 or © dcterms:identifier=“0”^^

The formatting for the query parameters is unfortuantly not so well documented, and I myself normally need to reverse-engineering the SPARQL query to work out how to best set my OSLC-query paramters.


and BTW, the query capability is as experimental/mature as the rest of the Store. And I use it quite often as well. It is experimental in the sense that it does not cover (yet) the full OSLC Query language. I am only expanding it as the needs for it arise.