Skip to content

Feature: Save and restore full SPARQL queries via API#860

Draft
dennisvang wants to merge 31 commits intosupport/1.19.xfrom
feature/852-sparql-saved
Draft

Feature: Save and restore full SPARQL queries via API#860
dennisvang wants to merge 31 commits intosupport/1.19.xfrom
feature/852-sparql-saved

Conversation

@dennisvang
Copy link
Copy Markdown
Contributor

@dennisvang dennisvang commented Mar 20, 2026

Adds save/load support for the full SPARQL queries introduced in v1.19.0.

Rationale

The existing FDP implementation (<=v1.19.0) offers support for saving/loading restricted SPARQL queries by storing SearchSavedQuery objects in the relational database:

This contains the restricted query in terms of user input, i.e. the values entered by the user:

public class SearchQueryVariablesDTO {
@NotNull
private String prefixes;
@NotNull
private String graphPattern;
@NotNull
private String ordering;
}

These values are used to render the query template:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>
{{prefixes}}
SELECT ?entity ?rdfType ?title ?description
WHERE {
?entity rdf:type ?rdfType .
?entity dct:title ?title .
OPTIONAL { ?entity dct:description ?description }
{{graphPattern}}
}
ORDER BY {{ordering}}
LIMIT 50

This PR adds the ability to save/load full SPARQL queries that are not restricted to this template.

TODO:

  • add the ability to save raw sparql queries (in addition to the restricted sparql queries)

follow up on #853

@dennisvang dennisvang force-pushed the feature/852-sparql-saved branch 10 times, most recently from 573acad to 66cc0e2 Compare March 26, 2026 14:14
the ability to save/load full sparql queries is a new feature
to improve encapsulation and readability
because we're just going to add a field to SearchSavedQuery instead

This reverts commit 76ed8e6.
the enum is now part of SearchSavedQuery
using string array fields defaultGraphUris and namedGraphUris we can specify multiple graphs in a natural way
…earchQueryVariablesDTO

we're not renaming the entity field "variabes", so data migration is not needed
for consistency with SparqlQueryRestricted
…riablesDTO for consistency

actually this is a 1-1 mapping, so it is redundant, but I'm following the approach of the existing code
(which is to be the hobgoblin from PEP 8...)
@dennisvang dennisvang force-pushed the feature/852-sparql-saved branch from 2f34c6b to 926e80b Compare March 27, 2026 15:50
…QueryController

this way the DTO mapping is done at the boundary, where is makes most sense to me
also the SearchSavedQueryService.create method now only knows about domain objects
this is an intentional break in consistency with the existing codebase
…thod instead of SearchSavedQueryMapper

again an intentional break in consistency with the existing code base,
because I think this makes more sense
@dennisvang dennisvang changed the title Ability to save and restore full SPARQL queries via API Feature: Save and restore full SPARQL queries via API Mar 27, 2026
and adapt existing mapper and controlled methods accordingly
@dennisvang
Copy link
Copy Markdown
Contributor Author

WIP: Now we can save a full sparql query, but not all HTTP methods are supported yet. I'm also not happy with the fact that we need to duplicate a lot of code. Perhaps just step back to a single changeDTO with optional fields for variables and sparqlQuery (like the actualy entity...). This is not so clear for API users, but a lot less code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant