@prefix userS: <http://example.org/2017/6/user_schema#> .
@prefix user: <http://example.org/2017/6/user#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
user:account_62eb31ea-e665-49ec-9675-4282ced149da
userS:uniqueId <urn:uuid:62eb31ea-e665-49ec-9675-4282ced149da> ;
rdf:type
foaf:OnlineAccount ,
userS:Entity ;
foaf:accountName 'foo' ;
foaf:accountServiceHomepage <http://example.com/myaccount>
.
user:user_62eb31ea-e665-49ec-9675-4282ced149da
rdf:type
foaf:Person ,
userS:Administrator ,
userS:User ;
foaf:holdsAccount user:account_62eb31ea-e665-49ec-9675-4282ced149da ;
foaf:mbox <mailto:foo@example.com> ;
# some meaningless BNODE example just for demonstration purposes
# that should also be deleted
user:xxx [ user:a user:b ]
.
What I try to accomplish
- find the account by
user:uniqueId
- delete all it's triples
- find the resources that references the account by
foaf:holdsAccount <urn:uuid:62eb31ea-e665-49ec-9675-4282ced149da>
- delete all their triples as well
- also delete all triples that are related by BNODEs (if any)
What I came up with
PREFIX userS: <http://example.org/2017/6/user_schema#>
PREFIX user: <http://example.org/2017/6/user#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
WITH <http://bewellup.org/2017/6/product/bwu_product_user>
DELETE {
?s ?p ?o .
}
WHERE {
BIND (<urn:uuid:62eb31ea-e665-49ec-9675-4282ced149da> as ?accountId)
{
?s rdf:type
foaf:OnlineAccount ;
userS:uniqueId ?accountId .
?s ?p ?o .
}
UNION {
?account rdf:type
foaf:OnlineAccount ;
userS:uniqueId ?accountId .
?s foaf:holdsAccount ?account .
?s ?p ?o .
}
}
Is there a more concise or efficient way to delete all the created triples?
How do I also get the triples linked by BNODEs deleted?