Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPARQL Operation support for ordering results #3720

Open
chenejac opened this issue Jun 18, 2022 · 2 comments · Fixed by vivo-project/Vitro#391
Open

SPARQL Operation support for ordering results #3720

chenejac opened this issue Jun 18, 2022 · 2 comments · Fixed by vivo-project/Vitro#391

Comments

@chenejac
Copy link
Contributor

chenejac commented Jun 18, 2022

Is your feature request related to a problem? Please describe.
For the endpoint

GET http://localhost:8080/vivo/api/rest/1.0.0/geolocation/?sortBy=limit&order=ASC

this SPARQL query should be executed

SELECT ?uri ?label 
WHERE {      
  ?uri <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#GeographicLocation>
  OPTIONAL { 
      ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?label 
   } 
} 
ORDER BY ?order(??sortBy)

Before execution ?order(??sortBy) should be replaced with ASC(?limit). Neither ParameterizedSparqlString setLiteral, neither setIRI are working here. For the first (setLiteral), it produces "ASC^^xsdstring"(?"limit^^xsdstring"), for the second (setIRI) it produces (?).

Describe the solution you'd like
Probably ParameterizedSparqlString append method might resolve this issue, but redesign of the ontology description of SPARQL operation class might be needed.

@ghost
Copy link

ghost commented Jun 20, 2022

SELECT ?uri ?label
WHERE {
  ?uri <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#GeographicLocation>
  OPTIONAL {
    ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?label
  }
}
ORDER BY ?order(??sortBy)

@chenejac
Copy link
Contributor Author

chenejac commented May 19, 2023

The solution should be in accordance with the extension of Dynamic API ontology - #3878. It means, the appropriate suffix will be added before the execution of the query, if there is pageable flag set to true, and sortable flag set to true, and there are URL parameters.

  1. if http request is GET http://localhost:8080/vivo/api/rest/1.0.0/geolocation/?sortBy=name&order=ASC&limit=20&offset=60 and a SPARQL operation sortable is true, then the queryText = queryText + "ORDER BY ASC(name) LIMIT 20 OFFSET 60" (this should be set before execution of query)
  2. if http request is GET http://localhost:8080/vivo/api/rest/1.0.0/geolocation/?sortBy=name&order=ASC and a SPARQL operation sortable is true, then the queryText = queryText + "ORDER BY ASC(name)" (this should be set before execution of query)
  3. if http request is GET http://localhost:8080/vivo/api/rest/1.0.0/geolocation/?limit=20&offset=60 and a SPARQL operation sortable is true, then the queryText = queryText + "LIMIT 20 OFFSET 60" (this should be set before execution of query)

NOTE: A procedure can have more than one SPARQL Select Operations, the logic is applied only for operations which flags are turned on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To Do
Development

Successfully merging a pull request may close this issue.

1 participant