-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Simplify adding, editing and deleting triples in data sources
Pitch
Many applications use the same form of query for querying, adding, removing and editing queries.
As of right now every single one of these actions can require a long chain of synchronous function.
With comunica:
- create a query engine
- create a string query
- use the engine to query
- (optionally) get quad/bindingStream from result
- register listeners/convert results to array.
This has to be done for every action to the datasource.
For example a list of friends:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?friend ?friendName ?friendDOB
WHERE {
?person foaf:knows ?friend ;
?friend foaf:name ?friendName ;
foaf:birthday ?friendDOB .
}
We can add another friend by
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
INSERT DATA {
<http://example.org/person1> foaf:knows <http://example.org/friend2> .
<http://example.org/friend2> foaf:name "Friend Two" ;
foaf:birthday "1990-01-01"^^<http://www.w3.org/2001/XMLSchema#date> .
}
The only thing we didn't know for this query where the name, webID and DOB . The structure and ontology used can all be extracted from the first query.
Same for deleting a friend:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DELETE {
<http://example.org/person1> foaf:knows <http://example.org/person2> ;
<http://example.org/person2> foaf:name "Friend's Name" ;
foaf:birthday "1990-01-01"^^<http://www.w3.org/2001/XMLSchema#date> .
}
Where the only additional thing we need is the triple from the first query we wish to remove.
This scenario, which is a reoccurring scenario, can be simplified for developers.
Often this is a collection of data in one source (additional info might be needed from other sources e.g. fetch the name from webID.)
Desired solution
Create a class/object that's constructed by a query. This class/object then queries for the results (e.g. with comunica), streams the results in a certain form e.g. {id, result}.
This object can than parse the query it got constructed with and use the id to implement the following functions:
QueryHelper obj = new QueryHelper("select ?name ?dob where....");
obj.get(offset, limit);
obj.deleteTriple(id);
obj.addTriple(jsonObject); // where the json object has the same form as result
obj.editTriple(id, jsonObject) ;Acceptance criteria
The class/object working for the example in the pitch.
- The class/object can be constructed with a query
- We can do pagination with the
.getfunction. - We can remove a triple with the id without having to create another string query.
- We can add a triple without having to create another string query.
Pointers
- https://comunica.dev/
- https://github.com/RubenVerborgh/SPARQL.js
- https://github.com/SolidLabResearch/generic-data-viewer-react-admin (which already implements the for pagination)