You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Arthur Keen <aa...@yahoo.com.INVALID> on 2014/07/31 23:47:11 UTC

How to call CREATE / DELETE GRAPH in Fuseki

For executing CREATE or DELETE GRAPH in Fuseki
I tried to use them the same way as SPARQL INSERT/DELETE by posting to ../ds/update, but this did not work
 
Which Endpoint URL pattern I should use:
http://localhost:8080/ds/update, 
http://localhost:8080/ds/graph

For Creating a graph do you use an http put or post request?
For deleting a graph do you use an http delete request

And the name of the variable to bind the query to.  Using query, update, etc as variable names, see commented out lines of code below
Thanks very much,

Any guidance would be much appreciated

Arthur


For context, here is the node.js code that I am using to call fuseki, with commented out variations of httpreq that I have tried

//http://localhost:3000/graph/create?graphName=http://testGraph
 app.get('/api/graph/create', function(req, res){
   var update = "CREATE SILENT GRAPH <?:graphName>";
   var graphName = req.param("graphName");
   update = update.replaceAll("?:"+"graphName", graphName);
           //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function (geterr, getres){
           //httpreq.post(endpoint.getGraphURL(), {parameters: {update: update}}, function (geterr, getres){
       httpreq.put(endpoint.getGraphURL(), {parameters: {query: update}}, function (geterr, getres){
           if (geterr) return console.log(geterr);
         res.send(endpoint.getGraphURL()+"   "+ update+"   "+ graphName);
       });
   });

//http://localhost:3000/graph/delete?graphName=http://testGraph

app.get('/graph/delete', function(req, res) {
    var update = "DELETE SILENT GRAPH <?:graphName>";
    var graphName = req.param("graphName");
    update = update.replaceAll("?:" + "graphName", graphName);
    //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function(geterr, getres) {
    httpreq.delete(endpoint.getGraphURL(), {parameters: {graph: update}}, function(geterr, getres) {
        if (geterr)
            return console.log(geterr);
        console.log(update);
        res.send(endpoint.getGraphURL());
    });
});

Re: How to call CREATE / DELETE GRAPH in Fuseki

Posted by Arthur Keen <aa...@yahoo.com.INVALID>.
On Aug 3, 2014, at 4:17 AM, Andy Seaborne <an...@apache.org> wrote:

> On 02/08/14 19:47, Arthur Keen wrote:
>> Pilot error: The issue was caused by my using
>> SELECT DISTINCT ?g WHERE{GRAPH ?g {?s ?p ?o}}
>> 
>> Which finds non empty named graphs (containing one or more statements).  I should have been using:
>> 
>> SELECT DISTINCT ?g WHERE {GRAPH ?g{}}
> 
> (DISTINCT not needed)
> 
>> 
>> Which finds empty graphs
> 
> Sort of :-)
> 
> The default in-memory dataset knows about empty graphs because it's a map of (URI->Graph).  TDB does not because it is a set of triples and a set of quads with no separate graph management.
> 
> So in TDB the names of all graphs is calculated by looking in the graph field of the quads with the effect that no quad (no triple in graph) means no name.  It is like (but more efficient) than the first way with {?s ?p ?o}.
> 
> 	Andy

Thanks, that explains your earlier comment about CREATE being irrelevant for quad stores - no quads; no named graph. In this particular case, the query result is dependent on the physical implementation...

Arthur

> 
>> 
>> On Aug 1, 2014, at 3:49 PM, Arthur Keen <aa...@yahoo.com.INVALID> wrote:
>> 
>>> Andy,
>>> 
>>> Thanks for clearing that up.  One cannot underestimate Occam's Razor.  I switched my code back to update and replaced DELETE with DROP and that is working, and INSERT also works to create graphs, but using CREATE on update is not creating graphs.
>>> 
>>> When I tried the same queries from the Fuseki control panel and observed the same behavior, ie., the CREATE query
>>> 
>>> In SPARQL Update Panel
>>> 	CREATE SILENT GRAPH <http://testGraph10.com/graph10>
>>> 
>>> In SPARQL Query Panel
>>> 	SELECT DISTINCT ?g WHERE{GRAPH ?g {?s ?p ?o}}
>>> 	---------------------------
>>> 	| g                       |
>>> 	===========================
>>> 	| <http://testGraph1>     |
>>> 	| <http://booger.com/boo> |
>>> 	| <http://queries>        |
>>> 	---------------------------
>>> Am I missing something in the CREATE?
>>> 
>>> Arthur
>>> 
>>> On Aug 1, 2014, at 5:44 AM, Andy Seaborne <an...@apache.org> wrote:
>>> 
>>>> It's DROP not DELETE in SPARQL Update.
>>>> 
>>>> DELETE is for triples, DROP is for whole graphs.
>>>> 
>>>> http://www.w3.org/TR/sparql11-update/#graphManagement
>>>> 
>>>> On 31/07/14 22:47, Arthur Keen wrote:
>>>>> For executing CREATE or DELETE GRAPH in Fuseki
>>>>> I tried to use them the same way as SPARQL INSERT/DELETE by posting to ../ds/update, but this did not work
>>>>> 
>>>>> Which Endpoint URL pattern I should use:
>>>>> http://localhost:8080/ds/update,
>>>>> http://localhost:8080/ds/graph
>>>> 
>>>> There are two things here:
>>>> 
>>>> 1/ SPARQL Update -- CREATE and DROP -- use the "update" endpoint
>>>> 
>>>> 2/ SPARQL Graph Store Protocol -- this is not SPARQL Update -- use a writeable GSP endpoint.
>>>> 
>>>> GSP is normal HTTP usage on web resource GET/PUT/POST/DELETE/HEAD
>>>> 
>>>> http://www.w3.org/TR/sparql11-http-rdf-update/
>>>> 
>>>> what that document does is really explain how the REST(ish) use of HTTP applies to graph store.  It isn't defining anything new except the naming scheme for graphs.
>>>> 
>>>> In GSP, the app (HTTP) PUT RDF syntax (Turtle, N-triples, JSON-LD) to create or replace the contents of a graph and POST to create or add to a graph.
>>>> 
>>>> HTTP DELETE deletes a web resource as normal.
>>>> 
>>>>> 
>>>>> For Creating a graph do you use an http put or post request?
>>>>> For deleting a graph do you use an http delete request
>>>>> 
>>>>> And the name of the variable to bind the query to.  Using query, update, etc as variable names, see commented out lines of code below
>>>>> Thanks very much,
>>>> 
>>>> They don't take variables.
>>>> 
>>>> Just do e.g.
>>>> 
>>>> INSERT DATA { GRAPH :g { :s :p :o } }
>>>> 
>>>> and a graph is created for :g
>>>> 
>>>> INSERT
>>>> { GRAPH ?g { :s :p :o } }
>>>> WHERE
>>>> { ... ?g ... }
>>>> 
>>>> Whether CREATE is necessary in other situations depends on the storage
>>>> implementation. In Fuseki, with all the Jena provided storage
>>>> alternative, it is not needed.
>>>> 
>>>> It's possible other storage layers need graphs creating beforehand. I
>>>> don't know of any. In a quad store, it's fairly irrelevant distinction.
>>>> 
>>>>> 
>>>>> Any guidance would be much appreciated
>>>>> 
>>>>> Arthur
>>>> 
>>>> 	Hope that makes it clearer,
>>>> 	Andy
>>>> 
>>>>> For context, here is the node.js code that I am using to call fuseki, with commented out variations of httpreq that I have tried
>>>>> 
>>>>> //http://localhost:3000/graph/create?graphName=http://testGraph
>>>>> app.get('/api/graph/create', function(req, res){
>>>>>   var update = "CREATE SILENT GRAPH <?:graphName>";
>>>>>   var graphName = req.param("graphName");
>>>>>   update = update.replaceAll("?:"+"graphName", graphName);
>>>>>           //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function (geterr, getres){
>>>>>           //httpreq.post(endpoint.getGraphURL(), {parameters: {update: update}}, function (geterr, getres){
>>>>>       httpreq.put(endpoint.getGraphURL(), {parameters: {query: update}}, function (geterr, getres){
>>>>>           if (geterr) return console.log(geterr);
>>>>>         res.send(endpoint.getGraphURL()+"   "+ update+"   "+ graphName);
>>>>>       });
>>>>>   });
>>>>> 
>>>>> //http://localhost:3000/graph/delete?graphName=http://testGraph
>>>> 
>>>> If you are using the default naming /delete and /create don't exist as services.
>>>> 
>>>>> 
>>>>> app.get('/graph/delete', function(req, res) {
>>>>>    var update = "DELETE SILENT GRAPH <?:graphName>";
>>>>>    var graphName = req.param("graphName");
>>>>>    update = update.replaceAll("?:" + "graphName", graphName);
>>>>>    //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function(geterr, getres) {
>>>>>    httpreq.delete(endpoint.getGraphURL(), {parameters: {graph: update}}, function(geterr, getres) {
>>>>>        if (geterr)
>>>>>            return console.log(geterr);
>>>>>        console.log(update);
>>>>>        res.send(endpoint.getGraphURL());
>>>>>    });
>>>>> });
>>>> 
>>>> 
>>>> If you want security, you can either front Fuseki with httpd/nginx (that's advisable anyway for any java web container), or wait for Fuseki2.
>>>> 
>>>> 	Andy
>>> 
>> 
>> 
> 


Re: How to call CREATE / DELETE GRAPH in Fuseki

Posted by Andy Seaborne <an...@apache.org>.
On 02/08/14 19:47, Arthur Keen wrote:
> Pilot error: The issue was caused by my using
> SELECT DISTINCT ?g WHERE{GRAPH ?g {?s ?p ?o}}
>
> Which finds non empty named graphs (containing one or more statements).  I should have been using:
>
> SELECT DISTINCT ?g WHERE {GRAPH ?g{}}

(DISTINCT not needed)

>
> Which finds empty graphs

Sort of :-)

The default in-memory dataset knows about empty graphs because it's a 
map of (URI->Graph).  TDB does not because it is a set of triples and a 
set of quads with no separate graph management.

So in TDB the names of all graphs is calculated by looking in the graph 
field of the quads with the effect that no quad (no triple in graph) 
means no name.  It is like (but more efficient) than the first way with 
{?s ?p ?o}.

	Andy

>
> On Aug 1, 2014, at 3:49 PM, Arthur Keen <aa...@yahoo.com.INVALID> wrote:
>
>> Andy,
>>
>> Thanks for clearing that up.  One cannot underestimate Occam's Razor.  I switched my code back to update and replaced DELETE with DROP and that is working, and INSERT also works to create graphs, but using CREATE on update is not creating graphs.
>>
>> When I tried the same queries from the Fuseki control panel and observed the same behavior, ie., the CREATE query
>>
>> In SPARQL Update Panel
>> 	CREATE SILENT GRAPH <http://testGraph10.com/graph10>
>>
>> In SPARQL Query Panel
>> 	SELECT DISTINCT ?g WHERE{GRAPH ?g {?s ?p ?o}}
>> 	---------------------------
>> 	| g                       |
>> 	===========================
>> 	| <http://testGraph1>     |
>> 	| <http://booger.com/boo> |
>> 	| <http://queries>        |
>> 	---------------------------
>> Am I missing something in the CREATE?
>>
>> Arthur
>>
>> On Aug 1, 2014, at 5:44 AM, Andy Seaborne <an...@apache.org> wrote:
>>
>>> It's DROP not DELETE in SPARQL Update.
>>>
>>> DELETE is for triples, DROP is for whole graphs.
>>>
>>> http://www.w3.org/TR/sparql11-update/#graphManagement
>>>
>>> On 31/07/14 22:47, Arthur Keen wrote:
>>>> For executing CREATE or DELETE GRAPH in Fuseki
>>>> I tried to use them the same way as SPARQL INSERT/DELETE by posting to ../ds/update, but this did not work
>>>>
>>>> Which Endpoint URL pattern I should use:
>>>> http://localhost:8080/ds/update,
>>>> http://localhost:8080/ds/graph
>>>
>>> There are two things here:
>>>
>>> 1/ SPARQL Update -- CREATE and DROP -- use the "update" endpoint
>>>
>>> 2/ SPARQL Graph Store Protocol -- this is not SPARQL Update -- use a writeable GSP endpoint.
>>>
>>> GSP is normal HTTP usage on web resource GET/PUT/POST/DELETE/HEAD
>>>
>>> http://www.w3.org/TR/sparql11-http-rdf-update/
>>>
>>> what that document does is really explain how the REST(ish) use of HTTP applies to graph store.  It isn't defining anything new except the naming scheme for graphs.
>>>
>>> In GSP, the app (HTTP) PUT RDF syntax (Turtle, N-triples, JSON-LD) to create or replace the contents of a graph and POST to create or add to a graph.
>>>
>>> HTTP DELETE deletes a web resource as normal.
>>>
>>>>
>>>> For Creating a graph do you use an http put or post request?
>>>> For deleting a graph do you use an http delete request
>>>>
>>>> And the name of the variable to bind the query to.  Using query, update, etc as variable names, see commented out lines of code below
>>>> Thanks very much,
>>>
>>> They don't take variables.
>>>
>>> Just do e.g.
>>>
>>> INSERT DATA { GRAPH :g { :s :p :o } }
>>>
>>> and a graph is created for :g
>>>
>>> INSERT
>>> { GRAPH ?g { :s :p :o } }
>>> WHERE
>>> { ... ?g ... }
>>>
>>> Whether CREATE is necessary in other situations depends on the storage
>>> implementation. In Fuseki, with all the Jena provided storage
>>> alternative, it is not needed.
>>>
>>> It's possible other storage layers need graphs creating beforehand. I
>>> don't know of any. In a quad store, it's fairly irrelevant distinction.
>>>
>>>>
>>>> Any guidance would be much appreciated
>>>>
>>>> Arthur
>>>
>>> 	Hope that makes it clearer,
>>> 	Andy
>>>
>>>> For context, here is the node.js code that I am using to call fuseki, with commented out variations of httpreq that I have tried
>>>>
>>>> //http://localhost:3000/graph/create?graphName=http://testGraph
>>>> app.get('/api/graph/create', function(req, res){
>>>>    var update = "CREATE SILENT GRAPH <?:graphName>";
>>>>    var graphName = req.param("graphName");
>>>>    update = update.replaceAll("?:"+"graphName", graphName);
>>>>            //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function (geterr, getres){
>>>>            //httpreq.post(endpoint.getGraphURL(), {parameters: {update: update}}, function (geterr, getres){
>>>>        httpreq.put(endpoint.getGraphURL(), {parameters: {query: update}}, function (geterr, getres){
>>>>            if (geterr) return console.log(geterr);
>>>>          res.send(endpoint.getGraphURL()+"   "+ update+"   "+ graphName);
>>>>        });
>>>>    });
>>>>
>>>> //http://localhost:3000/graph/delete?graphName=http://testGraph
>>>
>>> If you are using the default naming /delete and /create don't exist as services.
>>>
>>>>
>>>> app.get('/graph/delete', function(req, res) {
>>>>     var update = "DELETE SILENT GRAPH <?:graphName>";
>>>>     var graphName = req.param("graphName");
>>>>     update = update.replaceAll("?:" + "graphName", graphName);
>>>>     //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function(geterr, getres) {
>>>>     httpreq.delete(endpoint.getGraphURL(), {parameters: {graph: update}}, function(geterr, getres) {
>>>>         if (geterr)
>>>>             return console.log(geterr);
>>>>         console.log(update);
>>>>         res.send(endpoint.getGraphURL());
>>>>     });
>>>> });
>>>
>>>
>>> If you want security, you can either front Fuseki with httpd/nginx (that's advisable anyway for any java web container), or wait for Fuseki2.
>>>
>>> 	Andy
>>
>
>


Re: How to call CREATE / DELETE GRAPH in Fuseki

Posted by Arthur Keen <aa...@yahoo.com.INVALID>.
Pilot error: The issue was caused by my using
SELECT DISTINCT ?g WHERE{GRAPH ?g {?s ?p ?o}}

Which finds non empty named graphs (containing one or more statements).  I should have been using:

SELECT DISTINCT ?g WHERE {GRAPH ?g{}} 

Which finds empty graphs

On Aug 1, 2014, at 3:49 PM, Arthur Keen <aa...@yahoo.com.INVALID> wrote:

> Andy,
> 
> Thanks for clearing that up.  One cannot underestimate Occam's Razor.  I switched my code back to update and replaced DELETE with DROP and that is working, and INSERT also works to create graphs, but using CREATE on update is not creating graphs.  
> 
> When I tried the same queries from the Fuseki control panel and observed the same behavior, ie., the CREATE query
> 
> In SPARQL Update Panel
> 	CREATE SILENT GRAPH <http://testGraph10.com/graph10>
> 
> In SPARQL Query Panel
> 	SELECT DISTINCT ?g WHERE{GRAPH ?g {?s ?p ?o}}
> 	---------------------------
> 	| g                       |
> 	===========================
> 	| <http://testGraph1>     |
> 	| <http://booger.com/boo> |
> 	| <http://queries>        |
> 	---------------------------
> Am I missing something in the CREATE?
> 
> Arthur
> 
> On Aug 1, 2014, at 5:44 AM, Andy Seaborne <an...@apache.org> wrote:
> 
>> It's DROP not DELETE in SPARQL Update.
>> 
>> DELETE is for triples, DROP is for whole graphs.
>> 
>> http://www.w3.org/TR/sparql11-update/#graphManagement
>> 
>> On 31/07/14 22:47, Arthur Keen wrote:
>>> For executing CREATE or DELETE GRAPH in Fuseki
>>> I tried to use them the same way as SPARQL INSERT/DELETE by posting to ../ds/update, but this did not work
>>> 
>>> Which Endpoint URL pattern I should use:
>>> http://localhost:8080/ds/update,
>>> http://localhost:8080/ds/graph
>> 
>> There are two things here:
>> 
>> 1/ SPARQL Update -- CREATE and DROP -- use the "update" endpoint
>> 
>> 2/ SPARQL Graph Store Protocol -- this is not SPARQL Update -- use a writeable GSP endpoint.
>> 
>> GSP is normal HTTP usage on web resource GET/PUT/POST/DELETE/HEAD
>> 
>> http://www.w3.org/TR/sparql11-http-rdf-update/
>> 
>> what that document does is really explain how the REST(ish) use of HTTP applies to graph store.  It isn't defining anything new except the naming scheme for graphs.
>> 
>> In GSP, the app (HTTP) PUT RDF syntax (Turtle, N-triples, JSON-LD) to create or replace the contents of a graph and POST to create or add to a graph.
>> 
>> HTTP DELETE deletes a web resource as normal.
>> 
>>> 
>>> For Creating a graph do you use an http put or post request?
>>> For deleting a graph do you use an http delete request
>>> 
>>> And the name of the variable to bind the query to.  Using query, update, etc as variable names, see commented out lines of code below
>>> Thanks very much,
>> 
>> They don't take variables.
>> 
>> Just do e.g.
>> 
>> INSERT DATA { GRAPH :g { :s :p :o } }
>> 
>> and a graph is created for :g
>> 
>> INSERT
>> { GRAPH ?g { :s :p :o } }
>> WHERE
>> { ... ?g ... }
>> 
>> Whether CREATE is necessary in other situations depends on the storage
>> implementation. In Fuseki, with all the Jena provided storage
>> alternative, it is not needed.
>> 
>> It's possible other storage layers need graphs creating beforehand. I
>> don't know of any. In a quad store, it's fairly irrelevant distinction.
>> 
>>> 
>>> Any guidance would be much appreciated
>>> 
>>> Arthur
>> 
>> 	Hope that makes it clearer,
>> 	Andy
>> 
>>> For context, here is the node.js code that I am using to call fuseki, with commented out variations of httpreq that I have tried
>>> 
>>> //http://localhost:3000/graph/create?graphName=http://testGraph
>>> app.get('/api/graph/create', function(req, res){
>>>   var update = "CREATE SILENT GRAPH <?:graphName>";
>>>   var graphName = req.param("graphName");
>>>   update = update.replaceAll("?:"+"graphName", graphName);
>>>           //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function (geterr, getres){
>>>           //httpreq.post(endpoint.getGraphURL(), {parameters: {update: update}}, function (geterr, getres){
>>>       httpreq.put(endpoint.getGraphURL(), {parameters: {query: update}}, function (geterr, getres){
>>>           if (geterr) return console.log(geterr);
>>>         res.send(endpoint.getGraphURL()+"   "+ update+"   "+ graphName);
>>>       });
>>>   });
>>> 
>>> //http://localhost:3000/graph/delete?graphName=http://testGraph
>> 
>> If you are using the default naming /delete and /create don't exist as services.
>> 
>>> 
>>> app.get('/graph/delete', function(req, res) {
>>>    var update = "DELETE SILENT GRAPH <?:graphName>";
>>>    var graphName = req.param("graphName");
>>>    update = update.replaceAll("?:" + "graphName", graphName);
>>>    //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function(geterr, getres) {
>>>    httpreq.delete(endpoint.getGraphURL(), {parameters: {graph: update}}, function(geterr, getres) {
>>>        if (geterr)
>>>            return console.log(geterr);
>>>        console.log(update);
>>>        res.send(endpoint.getGraphURL());
>>>    });
>>> });
>> 
>> 
>> If you want security, you can either front Fuseki with httpd/nginx (that's advisable anyway for any java web container), or wait for Fuseki2.
>> 
>> 	Andy
> 


Re: How to call CREATE / DELETE GRAPH in Fuseki

Posted by Arthur Keen <aa...@yahoo.com.INVALID>.
Andy,

Thanks for clearing that up.  One cannot underestimate Occam's Razor.  I switched my code back to update and replaced DELETE with DROP and that is working, and INSERT also works to create graphs, but using CREATE on update is not creating graphs.  

When I tried the same queries from the Fuseki control panel and observed the same behavior, ie., the CREATE query

In SPARQL Update Panel
	CREATE SILENT GRAPH <http://testGraph10.com/graph10>

In SPARQL Query Panel
	SELECT DISTINCT ?g WHERE{GRAPH ?g {?s ?p ?o}}
	---------------------------
	| g                       |
	===========================
	| <http://testGraph1>     |
	| <http://booger.com/boo> |
	| <http://queries>        |
	---------------------------
Am I missing something in the CREATE?

Arthur

On Aug 1, 2014, at 5:44 AM, Andy Seaborne <an...@apache.org> wrote:

> It's DROP not DELETE in SPARQL Update.
> 
> DELETE is for triples, DROP is for whole graphs.
> 
> http://www.w3.org/TR/sparql11-update/#graphManagement
> 
> On 31/07/14 22:47, Arthur Keen wrote:
>> For executing CREATE or DELETE GRAPH in Fuseki
>> I tried to use them the same way as SPARQL INSERT/DELETE by posting to ../ds/update, but this did not work
>> 
>> Which Endpoint URL pattern I should use:
>> http://localhost:8080/ds/update,
>> http://localhost:8080/ds/graph
> 
> There are two things here:
> 
> 1/ SPARQL Update -- CREATE and DROP -- use the "update" endpoint
> 
> 2/ SPARQL Graph Store Protocol -- this is not SPARQL Update -- use a writeable GSP endpoint.
> 
> GSP is normal HTTP usage on web resource GET/PUT/POST/DELETE/HEAD
> 
> http://www.w3.org/TR/sparql11-http-rdf-update/
> 
> what that document does is really explain how the REST(ish) use of HTTP applies to graph store.  It isn't defining anything new except the naming scheme for graphs.
> 
> In GSP, the app (HTTP) PUT RDF syntax (Turtle, N-triples, JSON-LD) to create or replace the contents of a graph and POST to create or add to a graph.
> 
> HTTP DELETE deletes a web resource as normal.
> 
>> 
>> For Creating a graph do you use an http put or post request?
>> For deleting a graph do you use an http delete request
>> 
>> And the name of the variable to bind the query to.  Using query, update, etc as variable names, see commented out lines of code below
>> Thanks very much,
> 
> They don't take variables.
> 
> Just do e.g.
> 
> INSERT DATA { GRAPH :g { :s :p :o } }
> 
> and a graph is created for :g
> 
> INSERT
> { GRAPH ?g { :s :p :o } }
> WHERE
> { ... ?g ... }
> 
> Whether CREATE is necessary in other situations depends on the storage
> implementation. In Fuseki, with all the Jena provided storage
> alternative, it is not needed.
> 
> It's possible other storage layers need graphs creating beforehand. I
> don't know of any. In a quad store, it's fairly irrelevant distinction.
> 
>> 
>> Any guidance would be much appreciated
>> 
>> Arthur
> 
> 	Hope that makes it clearer,
> 	Andy
> 
>> For context, here is the node.js code that I am using to call fuseki, with commented out variations of httpreq that I have tried
>> 
>> //http://localhost:3000/graph/create?graphName=http://testGraph
>>  app.get('/api/graph/create', function(req, res){
>>    var update = "CREATE SILENT GRAPH <?:graphName>";
>>    var graphName = req.param("graphName");
>>    update = update.replaceAll("?:"+"graphName", graphName);
>>            //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function (geterr, getres){
>>            //httpreq.post(endpoint.getGraphURL(), {parameters: {update: update}}, function (geterr, getres){
>>        httpreq.put(endpoint.getGraphURL(), {parameters: {query: update}}, function (geterr, getres){
>>            if (geterr) return console.log(geterr);
>>          res.send(endpoint.getGraphURL()+"   "+ update+"   "+ graphName);
>>        });
>>    });
>> 
>> //http://localhost:3000/graph/delete?graphName=http://testGraph
> 
> If you are using the default naming /delete and /create don't exist as services.
> 
>> 
>> app.get('/graph/delete', function(req, res) {
>>     var update = "DELETE SILENT GRAPH <?:graphName>";
>>     var graphName = req.param("graphName");
>>     update = update.replaceAll("?:" + "graphName", graphName);
>>     //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function(geterr, getres) {
>>     httpreq.delete(endpoint.getGraphURL(), {parameters: {graph: update}}, function(geterr, getres) {
>>         if (geterr)
>>             return console.log(geterr);
>>         console.log(update);
>>         res.send(endpoint.getGraphURL());
>>     });
>> });
> 
> 
> If you want security, you can either front Fuseki with httpd/nginx (that's advisable anyway for any java web container), or wait for Fuseki2.
> 
> 	Andy


Re: How to call CREATE / DELETE GRAPH in Fuseki

Posted by Andy Seaborne <an...@apache.org>.
It's DROP not DELETE in SPARQL Update.

DELETE is for triples, DROP is for whole graphs.

http://www.w3.org/TR/sparql11-update/#graphManagement

On 31/07/14 22:47, Arthur Keen wrote:
> For executing CREATE or DELETE GRAPH in Fuseki
> I tried to use them the same way as SPARQL INSERT/DELETE by posting to ../ds/update, but this did not work
>
> Which Endpoint URL pattern I should use:
> http://localhost:8080/ds/update,
> http://localhost:8080/ds/graph

There are two things here:

1/ SPARQL Update -- CREATE and DROP -- use the "update" endpoint

2/ SPARQL Graph Store Protocol -- this is not SPARQL Update -- use a 
writeable GSP endpoint.

GSP is normal HTTP usage on web resource GET/PUT/POST/DELETE/HEAD

http://www.w3.org/TR/sparql11-http-rdf-update/

what that document does is really explain how the REST(ish) use of HTTP 
applies to graph store.  It isn't defining anything new except the 
naming scheme for graphs.

In GSP, the app (HTTP) PUT RDF syntax (Turtle, N-triples, JSON-LD) to 
create or replace the contents of a graph and POST to create or add to a 
graph.

HTTP DELETE deletes a web resource as normal.

>
> For Creating a graph do you use an http put or post request?
> For deleting a graph do you use an http delete request
>
> And the name of the variable to bind the query to.  Using query, update, etc as variable names, see commented out lines of code below
> Thanks very much,

They don't take variables.

Just do e.g.

INSERT DATA { GRAPH :g { :s :p :o } }

and a graph is created for :g

INSERT
{ GRAPH ?g { :s :p :o } }
WHERE
{ ... ?g ... }

Whether CREATE is necessary in other situations depends on the storage
implementation. In Fuseki, with all the Jena provided storage
alternative, it is not needed.

It's possible other storage layers need graphs creating beforehand. I
don't know of any. In a quad store, it's fairly irrelevant distinction.

>
> Any guidance would be much appreciated
>
> Arthur

	Hope that makes it clearer,
	Andy

> For context, here is the node.js code that I am using to call fuseki, with commented out variations of httpreq that I have tried
>
> //http://localhost:3000/graph/create?graphName=http://testGraph
>   app.get('/api/graph/create', function(req, res){
>     var update = "CREATE SILENT GRAPH <?:graphName>";
>     var graphName = req.param("graphName");
>     update = update.replaceAll("?:"+"graphName", graphName);
>             //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function (geterr, getres){
>             //httpreq.post(endpoint.getGraphURL(), {parameters: {update: update}}, function (geterr, getres){
>         httpreq.put(endpoint.getGraphURL(), {parameters: {query: update}}, function (geterr, getres){
>             if (geterr) return console.log(geterr);
>           res.send(endpoint.getGraphURL()+"   "+ update+"   "+ graphName);
>         });
>     });
>
> //http://localhost:3000/graph/delete?graphName=http://testGraph

If you are using the default naming /delete and /create don't exist as 
services.

>
> app.get('/graph/delete', function(req, res) {
>      var update = "DELETE SILENT GRAPH <?:graphName>";
>      var graphName = req.param("graphName");
>      update = update.replaceAll("?:" + "graphName", graphName);
>      //httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}}, function(geterr, getres) {
>      httpreq.delete(endpoint.getGraphURL(), {parameters: {graph: update}}, function(geterr, getres) {
>          if (geterr)
>              return console.log(geterr);
>          console.log(update);
>          res.send(endpoint.getGraphURL());
>      });
> });


If you want security, you can either front Fuseki with httpd/nginx 
(that's advisable anyway for any java web container), or wait for Fuseki2.

	Andy