You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Julien Plu <ju...@redaction-developpez.com> on 2017/02/16 15:59:31 UTC

SPARQL Update over model

Hello,

I'm trying to make a SPARQL update query over a model, the problem is that
the query has to delete a triple belonging to a specific graph:

PREFIX dc:    <http://purl.org/dc/elements/1.1/>
DELETE {
        GRAPH <http://3cixty.com/cotedazur/test> {
                <
http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-55e4448ab7bf>
dc:identifier ?o .
            }
        } WHERE {
            GRAPH <http://3cixty.com/cotedazur/test> {
                <
http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-55e4448ab7bf>
dc:identifier ?o .
            }
}

which apparently has no effect when we proceed that way:

Model model = RDFDataMgr.loadModel("file.ttl");
UpdateAction.parseExecute(sparql_query, model);

I suppose it is normal as I never created the graph in the model.
Nevertheless when I do:

Model model = ModelFactory.createModelForGraph(new
SimpleGraphMaker().createGraph("http://3cixty.com/cotedazur/test"));
model.read("file.ttl");
UpdateAction.parseExecute(sparql_query, model);

It has no effect as well. Can someone guide me on how to do such thing
properly?

Thanks in advance.

Regards.
--
Julien Plu

PhD Student at Eurecom.
Personal webpage: http://jplu.developpez.com
FOAF file : http://jplu.developpez.com/julien
Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
<pl...@gmail.com>*
Phone : +33493008103
Twitter : @julienplu

Re: SPARQL Update over model

Posted by Julien Plu <ju...@redaction-developpez.com>.
Ok I found the trick:

Dataset ds = DatasetFactory.create();
ds.addNamedModel("http://3cixty.com/cotedazur/test",
RDFDataMgr.loadModel("myfile")));

Thanks a lot for the hint!!

--
Julien Plu

PhD Student at Eurecom.
Personal webpage: http://jplu.developpez.com
FOAF file : http://jplu.developpez.com/julien
Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
<pl...@gmail.com>*
Phone : +33493008103
Twitter : @julienplu

2017-02-16 18:44 GMT+01:00 Julien Plu <ju...@redaction-developpez.com>:

> Sorry but I don't understand how to use the DatasetFactory to do what I'm
> looking for, is there such method that takes two parameters, one is the
> name of the graph and the other is the model?
>
> --
> Julien Plu
>
> PhD Student at Eurecom.
> Personal webpage: http://jplu.developpez.com
> FOAF file : http://jplu.developpez.com/julien
> Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
> <pl...@gmail.com>*
> Phone : +33493008103 <04%2093%2000%2081%2003>
> Twitter : @julienplu
>
> 2017-02-16 17:13 GMT+01:00 A. Soroka <aj...@virginia.edu>:
>
>> Try starting with:
>>
>> https://jena.apache.org/documentation/javadoc/arq/org/apache
>> /jena/query/DatasetFactory.html
>>
>> (I probably should have said that to begin with.)
>>
>> ---
>> A. Soroka
>> The University of Virginia Library
>>
>> > On Feb 16, 2017, at 11:11 AM, Julien Plu <julien.plu@redaction-developp
>> ez.com> wrote:
>> >
>> > Thanks! I will try to use
>> > https://jena.apache.org/documentation/javadoc/arq/org/apache
>> /jena/sparql/core/DatasetGraphBase.html
>> > seems to be what I'm looking for.
>> >
>> > --
>> > Julien Plu
>> >
>> > PhD Student at Eurecom.
>> > Personal webpage: http://jplu.developpez.com
>> > FOAF file : http://jplu.developpez.com/julien
>> > Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
>> > <pl...@gmail.com>*
>> > Phone : +33493008103
>> > Twitter : @julienplu
>> >
>> > 2017-02-16 17:01 GMT+01:00 A. Soroka <aj...@virginia.edu>:
>> >
>> >> A model holds exactly one graph. Perhaps you want to be using a dataset
>> >> [1]?
>> >>
>> >> ---
>> >> A. Soroka
>> >> The University of Virginia Library
>> >>
>> >> [1] https://www.w3.org/TR/rdf11-concepts/#section-dataset
>> >>
>> >>> On Feb 16, 2017, at 10:59 AM, Julien Plu <julien.plu@redaction-
>> >> developpez.com> wrote:
>> >>>
>> >>> Hello,
>> >>>
>> >>> I'm trying to make a SPARQL update query over a model, the problem is
>> >> that
>> >>> the query has to delete a triple belonging to a specific graph:
>> >>>
>> >>> PREFIX dc:    <http://purl.org/dc/elements/1.1/>
>> >>> DELETE {
>> >>>       GRAPH <http://3cixty.com/cotedazur/test> {
>> >>>               <
>> >>> http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-5
>> 5e4448ab7bf>
>> >>> dc:identifier ?o .
>> >>>           }
>> >>>       } WHERE {
>> >>>           GRAPH <http://3cixty.com/cotedazur/test> {
>> >>>               <
>> >>> http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-5
>> 5e4448ab7bf>
>> >>> dc:identifier ?o .
>> >>>           }
>> >>> }
>> >>>
>> >>> which apparently has no effect when we proceed that way:
>> >>>
>> >>> Model model = RDFDataMgr.loadModel("file.ttl");
>> >>> UpdateAction.parseExecute(sparql_query, model);
>> >>>
>> >>> I suppose it is normal as I never created the graph in the model.
>> >>> Nevertheless when I do:
>> >>>
>> >>> Model model = ModelFactory.createModelForGraph(new
>> >>> SimpleGraphMaker().createGraph("http://3cixty.com/cotedazur/test"));
>> >>> model.read("file.ttl");
>> >>> UpdateAction.parseExecute(sparql_query, model);
>> >>>
>> >>> It has no effect as well. Can someone guide me on how to do such thing
>> >>> properly?
>> >>>
>> >>> Thanks in advance.
>> >>>
>> >>> Regards.
>> >>> --
>> >>> Julien Plu
>> >>>
>> >>> PhD Student at Eurecom.
>> >>> Personal webpage: http://jplu.developpez.com
>> >>> FOAF file : http://jplu.developpez.com/julien
>> >>> Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
>> >>> <pl...@gmail.com>*
>> >>> Phone : +33493008103
>> >>> Twitter : @julienplu
>> >>
>> >>
>>
>>
>

Re: SPARQL Update over model

Posted by Julien Plu <ju...@redaction-developpez.com>.
Sorry but I don't understand how to use the DatasetFactory to do what I'm
looking for, is there such method that takes two parameters, one is the
name of the graph and the other is the model?

--
Julien Plu

PhD Student at Eurecom.
Personal webpage: http://jplu.developpez.com
FOAF file : http://jplu.developpez.com/julien
Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
<pl...@gmail.com>*
Phone : +33493008103
Twitter : @julienplu

2017-02-16 17:13 GMT+01:00 A. Soroka <aj...@virginia.edu>:

> Try starting with:
>
> https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/
> DatasetFactory.html
>
> (I probably should have said that to begin with.)
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Feb 16, 2017, at 11:11 AM, Julien Plu <julien.plu@redaction-
> developpez.com> wrote:
> >
> > Thanks! I will try to use
> > https://jena.apache.org/documentation/javadoc/arq/org/
> apache/jena/sparql/core/DatasetGraphBase.html
> > seems to be what I'm looking for.
> >
> > --
> > Julien Plu
> >
> > PhD Student at Eurecom.
> > Personal webpage: http://jplu.developpez.com
> > FOAF file : http://jplu.developpez.com/julien
> > Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
> > <pl...@gmail.com>*
> > Phone : +33493008103
> > Twitter : @julienplu
> >
> > 2017-02-16 17:01 GMT+01:00 A. Soroka <aj...@virginia.edu>:
> >
> >> A model holds exactly one graph. Perhaps you want to be using a dataset
> >> [1]?
> >>
> >> ---
> >> A. Soroka
> >> The University of Virginia Library
> >>
> >> [1] https://www.w3.org/TR/rdf11-concepts/#section-dataset
> >>
> >>> On Feb 16, 2017, at 10:59 AM, Julien Plu <julien.plu@redaction-
> >> developpez.com> wrote:
> >>>
> >>> Hello,
> >>>
> >>> I'm trying to make a SPARQL update query over a model, the problem is
> >> that
> >>> the query has to delete a triple belonging to a specific graph:
> >>>
> >>> PREFIX dc:    <http://purl.org/dc/elements/1.1/>
> >>> DELETE {
> >>>       GRAPH <http://3cixty.com/cotedazur/test> {
> >>>               <
> >>> http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-
> 55e4448ab7bf>
> >>> dc:identifier ?o .
> >>>           }
> >>>       } WHERE {
> >>>           GRAPH <http://3cixty.com/cotedazur/test> {
> >>>               <
> >>> http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-
> 55e4448ab7bf>
> >>> dc:identifier ?o .
> >>>           }
> >>> }
> >>>
> >>> which apparently has no effect when we proceed that way:
> >>>
> >>> Model model = RDFDataMgr.loadModel("file.ttl");
> >>> UpdateAction.parseExecute(sparql_query, model);
> >>>
> >>> I suppose it is normal as I never created the graph in the model.
> >>> Nevertheless when I do:
> >>>
> >>> Model model = ModelFactory.createModelForGraph(new
> >>> SimpleGraphMaker().createGraph("http://3cixty.com/cotedazur/test"));
> >>> model.read("file.ttl");
> >>> UpdateAction.parseExecute(sparql_query, model);
> >>>
> >>> It has no effect as well. Can someone guide me on how to do such thing
> >>> properly?
> >>>
> >>> Thanks in advance.
> >>>
> >>> Regards.
> >>> --
> >>> Julien Plu
> >>>
> >>> PhD Student at Eurecom.
> >>> Personal webpage: http://jplu.developpez.com
> >>> FOAF file : http://jplu.developpez.com/julien
> >>> Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
> >>> <pl...@gmail.com>*
> >>> Phone : +33493008103
> >>> Twitter : @julienplu
> >>
> >>
>
>

Re: SPARQL Update over model

Posted by "A. Soroka" <aj...@virginia.edu>.
Try starting with:

https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/DatasetFactory.html

(I probably should have said that to begin with.)

---
A. Soroka
The University of Virginia Library

> On Feb 16, 2017, at 11:11 AM, Julien Plu <ju...@redaction-developpez.com> wrote:
> 
> Thanks! I will try to use
> https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/sparql/core/DatasetGraphBase.html
> seems to be what I'm looking for.
> 
> --
> Julien Plu
> 
> PhD Student at Eurecom.
> Personal webpage: http://jplu.developpez.com
> FOAF file : http://jplu.developpez.com/julien
> Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
> <pl...@gmail.com>*
> Phone : +33493008103
> Twitter : @julienplu
> 
> 2017-02-16 17:01 GMT+01:00 A. Soroka <aj...@virginia.edu>:
> 
>> A model holds exactly one graph. Perhaps you want to be using a dataset
>> [1]?
>> 
>> ---
>> A. Soroka
>> The University of Virginia Library
>> 
>> [1] https://www.w3.org/TR/rdf11-concepts/#section-dataset
>> 
>>> On Feb 16, 2017, at 10:59 AM, Julien Plu <julien.plu@redaction-
>> developpez.com> wrote:
>>> 
>>> Hello,
>>> 
>>> I'm trying to make a SPARQL update query over a model, the problem is
>> that
>>> the query has to delete a triple belonging to a specific graph:
>>> 
>>> PREFIX dc:    <http://purl.org/dc/elements/1.1/>
>>> DELETE {
>>>       GRAPH <http://3cixty.com/cotedazur/test> {
>>>               <
>>> http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-55e4448ab7bf>
>>> dc:identifier ?o .
>>>           }
>>>       } WHERE {
>>>           GRAPH <http://3cixty.com/cotedazur/test> {
>>>               <
>>> http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-55e4448ab7bf>
>>> dc:identifier ?o .
>>>           }
>>> }
>>> 
>>> which apparently has no effect when we proceed that way:
>>> 
>>> Model model = RDFDataMgr.loadModel("file.ttl");
>>> UpdateAction.parseExecute(sparql_query, model);
>>> 
>>> I suppose it is normal as I never created the graph in the model.
>>> Nevertheless when I do:
>>> 
>>> Model model = ModelFactory.createModelForGraph(new
>>> SimpleGraphMaker().createGraph("http://3cixty.com/cotedazur/test"));
>>> model.read("file.ttl");
>>> UpdateAction.parseExecute(sparql_query, model);
>>> 
>>> It has no effect as well. Can someone guide me on how to do such thing
>>> properly?
>>> 
>>> Thanks in advance.
>>> 
>>> Regards.
>>> --
>>> Julien Plu
>>> 
>>> PhD Student at Eurecom.
>>> Personal webpage: http://jplu.developpez.com
>>> FOAF file : http://jplu.developpez.com/julien
>>> Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
>>> <pl...@gmail.com>*
>>> Phone : +33493008103
>>> Twitter : @julienplu
>> 
>> 


Re: SPARQL Update over model

Posted by Julien Plu <ju...@redaction-developpez.com>.
Thanks! I will try to use
https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/sparql/core/DatasetGraphBase.html
seems to be what I'm looking for.

--
Julien Plu

PhD Student at Eurecom.
Personal webpage: http://jplu.developpez.com
FOAF file : http://jplu.developpez.com/julien
Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
<pl...@gmail.com>*
Phone : +33493008103
Twitter : @julienplu

2017-02-16 17:01 GMT+01:00 A. Soroka <aj...@virginia.edu>:

> A model holds exactly one graph. Perhaps you want to be using a dataset
> [1]?
>
> ---
> A. Soroka
> The University of Virginia Library
>
> [1] https://www.w3.org/TR/rdf11-concepts/#section-dataset
>
> > On Feb 16, 2017, at 10:59 AM, Julien Plu <julien.plu@redaction-
> developpez.com> wrote:
> >
> > Hello,
> >
> > I'm trying to make a SPARQL update query over a model, the problem is
> that
> > the query has to delete a triple belonging to a specific graph:
> >
> > PREFIX dc:    <http://purl.org/dc/elements/1.1/>
> > DELETE {
> >        GRAPH <http://3cixty.com/cotedazur/test> {
> >                <
> > http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-55e4448ab7bf>
> > dc:identifier ?o .
> >            }
> >        } WHERE {
> >            GRAPH <http://3cixty.com/cotedazur/test> {
> >                <
> > http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-55e4448ab7bf>
> > dc:identifier ?o .
> >            }
> > }
> >
> > which apparently has no effect when we proceed that way:
> >
> > Model model = RDFDataMgr.loadModel("file.ttl");
> > UpdateAction.parseExecute(sparql_query, model);
> >
> > I suppose it is normal as I never created the graph in the model.
> > Nevertheless when I do:
> >
> > Model model = ModelFactory.createModelForGraph(new
> > SimpleGraphMaker().createGraph("http://3cixty.com/cotedazur/test"));
> > model.read("file.ttl");
> > UpdateAction.parseExecute(sparql_query, model);
> >
> > It has no effect as well. Can someone guide me on how to do such thing
> > properly?
> >
> > Thanks in advance.
> >
> > Regards.
> > --
> > Julien Plu
> >
> > PhD Student at Eurecom.
> > Personal webpage: http://jplu.developpez.com
> > FOAF file : http://jplu.developpez.com/julien
> > Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
> > <pl...@gmail.com>*
> > Phone : +33493008103
> > Twitter : @julienplu
>
>

Re: SPARQL Update over model

Posted by "A. Soroka" <aj...@virginia.edu>.
A model holds exactly one graph. Perhaps you want to be using a dataset [1]?

---
A. Soroka
The University of Virginia Library

[1] https://www.w3.org/TR/rdf11-concepts/#section-dataset

> On Feb 16, 2017, at 10:59 AM, Julien Plu <ju...@redaction-developpez.com> wrote:
> 
> Hello,
> 
> I'm trying to make a SPARQL update query over a model, the problem is that
> the query has to delete a triple belonging to a specific graph:
> 
> PREFIX dc:    <http://purl.org/dc/elements/1.1/>
> DELETE {
>        GRAPH <http://3cixty.com/cotedazur/test> {
>                <
> http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-55e4448ab7bf>
> dc:identifier ?o .
>            }
>        } WHERE {
>            GRAPH <http://3cixty.com/cotedazur/test> {
>                <
> http://data.linkedevents.org/event/51f5ecc8-55b4-3a1b-98de-55e4448ab7bf>
> dc:identifier ?o .
>            }
> }
> 
> which apparently has no effect when we proceed that way:
> 
> Model model = RDFDataMgr.loadModel("file.ttl");
> UpdateAction.parseExecute(sparql_query, model);
> 
> I suppose it is normal as I never created the graph in the model.
> Nevertheless when I do:
> 
> Model model = ModelFactory.createModelForGraph(new
> SimpleGraphMaker().createGraph("http://3cixty.com/cotedazur/test"));
> model.read("file.ttl");
> UpdateAction.parseExecute(sparql_query, model);
> 
> It has no effect as well. Can someone guide me on how to do such thing
> properly?
> 
> Thanks in advance.
> 
> Regards.
> --
> Julien Plu
> 
> PhD Student at Eurecom.
> Personal webpage: http://jplu.developpez.com
> FOAF file : http://jplu.developpez.com/julien
> Email address : julien.plu@eurecom.fr && *plu.julien@gmail.com
> <pl...@gmail.com>*
> Phone : +33493008103
> Twitter : @julienplu