0

I have a question about the deletion of elements from a triplestore (fuseki) using SPARQL. I have stored the following elements in a graph:

<ChargingRequest/66769> a keak-ev:ChargingRequest ;
cnr:priority 2 ; 
keak-ev:chargingNeed [
 keak-eval:temporalContext [
    keak-time:start "2015-09-15T12:00:00Z"^^xsd:dateTime ;
    keak-time:end "2015-09-15T18:00:00Z"^^xsd:dateTime
  ] ;
  keak-eval:minimalValue [ # the powerMin
    qudt:unit qudt-unit:Watt ; 
    qudt:numericValue "7000"^^xsd:double 
  ] ;
] .

i would like to delete the node < ChargingRequest/66769> and all his properties.

i tried

   DELETE WHERE {
     <http://localhost:3030/keak/ChargingRequest/66769>  ?p ?o.
     keak-ev:chargingNeed ?p ?o
  }

but it doesn't delete the nodes below

keak-eval:temporalContext [
    keak-time:start "2015-09-15T12:00:00Z"^^xsd:dateTime ;
    keak-time:end "2015-09-15T18:00:00Z"^^xsd:dateTime
  ] ;
  keak-eval:minimalValue [ # the powerMin
    qudt:unit qudt-unit:Watt ; 
    qudt:numericValue "7000"^^xsd:double 
  ] ;

Please help me, and thank you for your time.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
user2431419
  • 53
  • 1
  • 1
  • 5

2 Answers2

2

There are various way to do this but I think that 3 operations in one single request is the clearest: note this is one request - see the ";" separating the operations.

  # Delete 3-deep
  DELETE {
    ?x ?p ?o 
  } WHERE {
     <http://localhost:3030/keak/ChargingRequest/66769>  ?q ?n1.
     ?n1 ?p1 ?x .
     ?x ?p ?o .
  } ;

  # Delete 2-deep
  DELETE {
    ?x ?p ?o 
  } WHERE {
     <http://localhost:3030/keak/ChargingRequest/66769>  ?q ?x.
     ?x ?p ?o .
  } ;
  # Delete immediate
  DELETE WHERE { <http://localhost:3030/keak/ChargingRequest/66769>  ?q ?x. }
AndyS
  • 16,345
  • 17
  • 21
  • Thank you AbdyS, but It's not working could you please check my comment below . – user2431419 Dec 30 '15 at 15:33
  • It does for me. Check that relative URI `` in the data really is `` Then do simple updates until something does happen to find out what is wrong in your setup. – AndyS Dec 30 '15 at 19:20
0

I managed to make it work, this is the final solution

WITH <http://localhost:3030/keak/>  
 DELETE { 
  ?x ?p ?o 
} WHERE { 
  <http://localhost:3030/keak/ChargingRequest/66769>  ?q ?n1.
  ?n1 ?p1 ?x .
  ?x ?p ?o .
};

WITH <http://localhost:3030/keak/>  
 DELETE {
  ?x ?p ?o 
 } WHERE  {
   <http://localhost:3030/keak/ChargingRequest/66769>  ?q ?x.
   ?x ?p ?o .
 };

WITH <http://localhost:3030/keak/>  
 DELETE {
   <http://localhost:3030/keak/ChargingRequest/66769> ?q ?x 
 } WHERE  {
    <http://localhost:3030/keak/ChargingRequest/66769>  ?q ?x.
}

Thank you very much for your answer

user2431419
  • 53
  • 1
  • 1
  • 5