You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Charles Abela <ch...@gmail.com> on 2015/06/02 10:20:48 UTC
delete/insert issue
Hi,
I'm working with a dynamic environment and have instances with some of
their properties that get updated with time, such as the rank property below
<http://jena.apache.org/documentation/tdb/tdb_transactions.html>
a <http://test.org/vocabulary/actions/Node> ;
<http://test.org/vocabulary/actions/id>
92 ;
<http://test.org/vocabulary/actions/rank>
"2.181"^^<http://www.w3.org/2001/XMLSchema#double> ,
"1.672"^^<http://www.w3.org/2001/XMLSchema#double> , "0.233"^^<
http://www.w3.org/2001/XMLSchema#double> , "0.466"^^<
http://www.w3.org/2001/XMLSchema#double> , "0.274"^^<
http://www.w3.org/2001/XMLSchema#double> , "0.543"^^<
http://www.w3.org/2001/XMLSchema#double> , "0.86"^^<
http://www.w3.org/2001/XMLSchema#double> , "1.234"^^<
http://www.w3.org/2001/XMLSchema#double> .
>From the excerpt it can be seen that multiple rank values are being added.
I'm using sparql's combination of delete/insert to delete the current value
and add the updated one, as follows:
String pre = StrUtils.strjoinNL
(" PREFIX : <http://test.org/vocabulary/actions/>"
, "PREFIX text: <http://jena.apache.org/text#>"
, "PREFIX rdfs: <
http://www.w3.org/2000/01/rdf-schema#>"
,"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>"
," PREFIX actions: <
http://test.org/vocabulary/actions/>"
,"PREFIX rdf: <
http://www.w3.org/1999/02/22-rdf-syntax-ns#>") ;
String prop = StrUtils.strjoinNL(
node,
" actions:rank ?rank . ");
dataset.begin(ReadWrite.WRITE) ;
String dq = StrUtils.strjoinNL
(
"DELETE { ",
prop, " }",
"INSERT {", data, "}",
"WHERE { ",
prop," }"
);
try {
UpdateRequest update = UpdateFactory.create(pre+"\n"+dq);
GraphStore graphStore = GraphStoreFactory.create(dataset);
UpdateAction.execute(update,graphStore);
dataset.commit();
}catch(Exception ex){
ex.printStackTrace();
}finally { dataset.end() ; }
any ideas as to why the values are not being deleted?
thanks in advance.
Re: delete/insert issue
Posted by Andy Seaborne <an...@apache.org>.
> text-config.ttl
Do you have text index attached?
By a complete, minimal example, I mean something that I can run with
zero or very little change (details matter - filling in missing
information risks the wrong details), and is as small as possible that
illustrates the point.
Some things are still unclear -
How do you know that items are still there?
Are you making a query? Printing the data? What do you get and what do
you expect?
(The text index does not delete entries - it does not contain triples).
> is it possible that the problem has to do with the prefix resolution
> or with the model?
Those are possibilities; the hint there is a text index is another. i
can't tell from where I am.
By the way, you can combine changes into a single action by using ";"
between operations.
------------------
PREFIX ...
DELETE WHERE {
...
} ;
INSERT DATA {
...
}
------------------
On 02/06/15 17:35, Charles Abela wrote:
> Andy
>
> below is a typical instance:
>
> <http://permalink.gmane.org/gmane.comp.apache.jena.user/7020>
> a <http://test.org/vocabulary/actions/Node> ;
> <http://test.org/vocabulary/actions/id> 90 ;
> <http://test.org/vocabulary/actions/rank> "0.233"^^<
> http://www.w3.org/2001/XMLSchema#double> .
>
> String delete = StrUtils.strjoinNL(
> "DELETE WHERE { ",
> "<
> http://permalink.gmane.org/gmane.comp.apache.jena.user/7020> ",
> " actions:rank ?r . } ");
>
> String data = StrUtils.strjoinNL
> (" INSERT{ <
> http://permalink.gmane.org/gmane.comp.apache.jena.user/7020> ",
> "actions:rank \""+rank+"\"^^xsd:double ;",
> "actions:id \""+id+"\"^^xsd:integer . } ");
>
> I'm creating the dataset using:
>
> Dataset ds = DatasetFactory.assemble("text-config.ttl", "
> http://localhost/jena_example/#text_dataset") ;//where text-config.ttl is a
> typical config file
>
> and am using to delete
> dataset.begin(ReadWrite.WRITE) ;
> try {
> UpdateRequest update = UpdateFactory.create(pre+"\n"+delete);
> System.out.println(update);
> UpdateAction.execute(update,m);
> dataset.commit();
> }catch(Exception ex){
> System.out.println("Error executing delete");
> ex.printStackTrace();
> }finally { dataset.end() ; }
>
>
> and am using to insert
>
> dataset.begin(ReadWrite.WRITE) ;
> try {
> UpdateRequest update = UpdateFactory.create(pre+"\n"+data);
> System.out.println(update);
> UpdateAction.execute(update,m);
> dataset.commit();
> }catch(Exception ex){
> System.out.println(" Error executing update");
> ex.printStackTrace();
> }finally { dataset.end() ; }
>
>
> and I checked the UpdateRequest strings when deleting and inserting, here
> is an example:
>
> =======DELETE========
>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> PREFIX text: <http://jena.apache.org/text#>
> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX actions: <http://test.org/vocabulary/actions/>
>
> DELETE WHERE {
> <http://permalink.gmane.org/gmane.comp.apache.jena.user/7020>
> actions:rank ?r .
> }
>
> =======INSERT========
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> PREFIX text: <http://jena.apache.org/text#>
> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX actions: <http://test.org/vocabulary/actions/>
>
> INSERT DATA {
> <http://permalink.gmane.org/gmane.comp.apache.jena.user/7020>
> actions:rank "0.502"^^xsd:double .
> <http://permalink.gmane.org/gmane.comp.apache.jena.user/7020> actions:id
> 90 .
> }
>
>
> is it possible that the problem has to do with the prefix resolution or
> with the model?
>
> C
>
> On Tue, Jun 2, 2015 at 4:43 PM, Andy Seaborne <an...@apache.org> wrote:
>
>> Charles,
>>
>> It works for me. I'm having to fill in the details from your description,
>> so something in the detail is different.
>>
>> Do you have a complete, minimal example?
>>
>> (You can use TDFCatory.createDataset() to get a in-memory TDB dataset -
>> they ar enot very efficient but they are a complete simulation of TDB
>> because it's just a the most basic disk access operations replaced by a
>> simple RAM disk).
>>
>> Andy
>>
>>
>> On 02/06/15 14:02, Charles Abela wrote:
>>
>>> Thanks for ypour reply Andy,
>>>
>>>
>>> On Tue, Jun 2, 2015 at 2:50 PM, Andy Seaborne <an...@apache.org> wrote:
>>>
>>> On 02/06/15 09:20, Charles Abela wrote:
>>>>
>>>> Hi,
>>>>> I'm working with a dynamic environment and have instances with some of
>>>>> their properties that get updated with time, such as the rank property
>>>>> below
>>>>>
>>>>> <http://jena.apache.org/documentation/tdb/tdb_transactions.html>
>>>>> a <http://test.org/vocabulary/actions/Node> ;
>>>>> <http://test.org/vocabulary/actions/id>
>>>>> 92 ;
>>>>> <http://test.org/vocabulary/actions/rank>
>>>>> "2.181"^^<http://www.w3.org/2001/XMLSchema#double> ,
>>>>> "1.672"^^<http://www.w3.org/2001/XMLSchema#double> , "0.233"^^<
>>>>> http://www.w3.org/2001/XMLSchema#double> , "0.466"^^<
>>>>> http://www.w3.org/2001/XMLSchema#double> , "0.274"^^<
>>>>> http://www.w3.org/2001/XMLSchema#double> , "0.543"^^<
>>>>> http://www.w3.org/2001/XMLSchema#double> , "0.86"^^<
>>>>> http://www.w3.org/2001/XMLSchema#double> , "1.234"^^<
>>>>> http://www.w3.org/2001/XMLSchema#double> .
>>>>>
>>>>>
>>>> A double can be written shorthand as 1.234e0 -- the "e0" indicates a
>>>> double and wil be part of the lexical form.
>>>>
>>>> @prefix : <http://test.org/vocabulary/actions/> .
>>>> @prefix text: <http://jena.apache.org/text#> .
>>>> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
>>>> @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
>>>> @prefix actions: <http://test.org/vocabulary/actions/> .
>>>> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
>>>>
>>>> <http://jena.apache.org/documentation/tdb/tdb_transactions.html>
>>>> rdf:type actions:Node ;
>>>> actions:id 92 ;
>>>> actions:rank "2.181"^^xsd:double ;
>>>> actions:rank "1.672"^^xsd:double ;
>>>> actions:rank "0.233"^^xsd:double ;
>>>> actions:rank "0.466"^^xsd:double ;
>>>> actions:rank "0.274"^^xsd:double ;
>>>> actions:rank "0.543"^^xsd:double ;
>>>> actions:rank "0.86"^^xsd:double ;
>>>> actions:rank "1.234"^^xsd:double .
>>>>
>>>>
>>>> From the excerpt it can be seen that multiple rank values are being
>>>>
>>>>> added.
>>>>>
>>>>> I'm using sparql's combination of delete/insert to delete the current
>>>>> value
>>>>> and add the updated one, as follows:
>>>>>
>>>>> String pre = StrUtils.strjoinNL
>>>>> (" PREFIX : <http://test.org/vocabulary/actions/>"
>>>>>
>>>>>
>>>> Not that it wil have any effect, you have the same namespace twice :
>>>>
>>>>
>>>> noted :)
>>>
>>>
>>> PREFIX : <http://test.org/vocabulary/actions/>
>>>> PREFIX actions: <http://test.org/vocabulary/actions/>
>>>>
>>>> , "PREFIX text: <http://jena.apache.org/text#
>>>>> "
>>>>
>>>>> , "PREFIX rdfs: <
>>>>> http://www.w3.org/2000/01/rdf-schema#>"
>>>>> ,"PREFIX xsd: <
>>>>> http://www.w3.org/2001/XMLSchema#>"
>>>>> ," PREFIX actions: <
>>>>> http://test.org/vocabulary/actions/>"
>>>>> ,"PREFIX rdf: <
>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#>") ;
>>>>>
>>>>> String prop = StrUtils.strjoinNL(
>>>>> node,
>>>>>
>>>>>
>>>> What's the string 'node'?
>>>>
>>>>
>>> node is essentially a placeholder for the object, in the case of the code
>>> above it will be bound to <
>>> http://jena.apache.org/documentation/tdb/tdb_transactions.html>, and that
>>> will change depending on the data being accessed.
>>>
>>>
>>>> " actions:rank ?rank . ");
>>>>
>>>>>
>>>>> dataset.begin(ReadWrite.WRITE) ;
>>>>>
>>>>>
>>>> This is TDB right?
>>>>
>>>> yes
>>>
>>>
>>>> String dq = StrUtils.strjoinNL
>>>>
>>>>> (
>>>>> "DELETE { ",
>>>>> prop, " }",
>>>>> "INSERT {", data, "}",
>>>>>
>>>>>
>>>> What's data?
>>>>
>>>>
>>> data is a string with the data that will be inserted
>>>
>>>
>>>> "WHERE { ",
>>>>
>>>>> prop," }"
>>>>> );
>>>>>
>>>>>
>>>> Looks sort of OK. Something readable would be nice.
>>>>
>>>> Printing the update to check is good for checkign things are happenign as
>>>> expected:
>>>>
>>>> try {
>>>>
>>>>> UpdateRequest update = UpdateFactory.create(pre+"\n"+dq);
>>>>>
>>>>>
>>>> System.out.println(update) ;
>>>>
>>>>
>>>> GraphStore graphStore = GraphStoreFactory.create(dataset);
>>>>
>>>>> UpdateAction.execute(update,graphStore);
>>>>> dataset.commit();
>>>>> }catch(Exception ex){
>>>>> ex.printStackTrace();
>>>>> }finally { dataset.end() ; }
>>>>>
>>>>> any ideas as to why the values are not being deleted?
>>>>>
>>>>>
>>>> Possibly node is wrong.
>>>>
>>>> have checked this and it is correct
>>>
>>>
>>>> Does data get inserted?
>>>>
>>>>
>>> yes data gets inserted, thus the multiple values for the same property...
>>> some other values like <http://test.org/vocabulary/actions/id> 92 ;
>>> do not change, and only one entry per instance exists
>>>
>>> Is teh data in the
>>>
>>>>
>>>> Personally, I'd write:
>>>>
>>>> DELETE WHERE { ... } ;
>>>> INSERT DATA { ... }
>>>>
>>>>
>>> but that's a style thing.
>>>>
>>>> Andy
>>>>
>>>>
>>>> thanks in advance.
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>
Re: delete/insert issue
Posted by Charles Abela <ch...@gmail.com>.
Andy
below is a typical instance:
<http://permalink.gmane.org/gmane.comp.apache.jena.user/7020>
a <http://test.org/vocabulary/actions/Node> ;
<http://test.org/vocabulary/actions/id> 90 ;
<http://test.org/vocabulary/actions/rank> "0.233"^^<
http://www.w3.org/2001/XMLSchema#double> .
String delete = StrUtils.strjoinNL(
"DELETE WHERE { ",
"<
http://permalink.gmane.org/gmane.comp.apache.jena.user/7020> ",
" actions:rank ?r . } ");
String data = StrUtils.strjoinNL
(" INSERT{ <
http://permalink.gmane.org/gmane.comp.apache.jena.user/7020> ",
"actions:rank \""+rank+"\"^^xsd:double ;",
"actions:id \""+id+"\"^^xsd:integer . } ");
I'm creating the dataset using:
Dataset ds = DatasetFactory.assemble("text-config.ttl", "
http://localhost/jena_example/#text_dataset") ;//where text-config.ttl is a
typical config file
and am using to delete
dataset.begin(ReadWrite.WRITE) ;
try {
UpdateRequest update = UpdateFactory.create(pre+"\n"+delete);
System.out.println(update);
UpdateAction.execute(update,m);
dataset.commit();
}catch(Exception ex){
System.out.println("Error executing delete");
ex.printStackTrace();
}finally { dataset.end() ; }
and am using to insert
dataset.begin(ReadWrite.WRITE) ;
try {
UpdateRequest update = UpdateFactory.create(pre+"\n"+data);
System.out.println(update);
UpdateAction.execute(update,m);
dataset.commit();
}catch(Exception ex){
System.out.println(" Error executing update");
ex.printStackTrace();
}finally { dataset.end() ; }
and I checked the UpdateRequest strings when deleting and inserting, here
is an example:
=======DELETE========
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX text: <http://jena.apache.org/text#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX actions: <http://test.org/vocabulary/actions/>
DELETE WHERE {
<http://permalink.gmane.org/gmane.comp.apache.jena.user/7020>
actions:rank ?r .
}
=======INSERT========
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX text: <http://jena.apache.org/text#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX actions: <http://test.org/vocabulary/actions/>
INSERT DATA {
<http://permalink.gmane.org/gmane.comp.apache.jena.user/7020>
actions:rank "0.502"^^xsd:double .
<http://permalink.gmane.org/gmane.comp.apache.jena.user/7020> actions:id
90 .
}
is it possible that the problem has to do with the prefix resolution or
with the model?
C
On Tue, Jun 2, 2015 at 4:43 PM, Andy Seaborne <an...@apache.org> wrote:
> Charles,
>
> It works for me. I'm having to fill in the details from your description,
> so something in the detail is different.
>
> Do you have a complete, minimal example?
>
> (You can use TDFCatory.createDataset() to get a in-memory TDB dataset -
> they ar enot very efficient but they are a complete simulation of TDB
> because it's just a the most basic disk access operations replaced by a
> simple RAM disk).
>
> Andy
>
>
> On 02/06/15 14:02, Charles Abela wrote:
>
>> Thanks for ypour reply Andy,
>>
>>
>> On Tue, Jun 2, 2015 at 2:50 PM, Andy Seaborne <an...@apache.org> wrote:
>>
>> On 02/06/15 09:20, Charles Abela wrote:
>>>
>>> Hi,
>>>> I'm working with a dynamic environment and have instances with some of
>>>> their properties that get updated with time, such as the rank property
>>>> below
>>>>
>>>> <http://jena.apache.org/documentation/tdb/tdb_transactions.html>
>>>> a <http://test.org/vocabulary/actions/Node> ;
>>>> <http://test.org/vocabulary/actions/id>
>>>> 92 ;
>>>> <http://test.org/vocabulary/actions/rank>
>>>> "2.181"^^<http://www.w3.org/2001/XMLSchema#double> ,
>>>> "1.672"^^<http://www.w3.org/2001/XMLSchema#double> , "0.233"^^<
>>>> http://www.w3.org/2001/XMLSchema#double> , "0.466"^^<
>>>> http://www.w3.org/2001/XMLSchema#double> , "0.274"^^<
>>>> http://www.w3.org/2001/XMLSchema#double> , "0.543"^^<
>>>> http://www.w3.org/2001/XMLSchema#double> , "0.86"^^<
>>>> http://www.w3.org/2001/XMLSchema#double> , "1.234"^^<
>>>> http://www.w3.org/2001/XMLSchema#double> .
>>>>
>>>>
>>> A double can be written shorthand as 1.234e0 -- the "e0" indicates a
>>> double and wil be part of the lexical form.
>>>
>>> @prefix : <http://test.org/vocabulary/actions/> .
>>> @prefix text: <http://jena.apache.org/text#> .
>>> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
>>> @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
>>> @prefix actions: <http://test.org/vocabulary/actions/> .
>>> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
>>>
>>> <http://jena.apache.org/documentation/tdb/tdb_transactions.html>
>>> rdf:type actions:Node ;
>>> actions:id 92 ;
>>> actions:rank "2.181"^^xsd:double ;
>>> actions:rank "1.672"^^xsd:double ;
>>> actions:rank "0.233"^^xsd:double ;
>>> actions:rank "0.466"^^xsd:double ;
>>> actions:rank "0.274"^^xsd:double ;
>>> actions:rank "0.543"^^xsd:double ;
>>> actions:rank "0.86"^^xsd:double ;
>>> actions:rank "1.234"^^xsd:double .
>>>
>>>
>>> From the excerpt it can be seen that multiple rank values are being
>>>
>>>> added.
>>>>
>>>> I'm using sparql's combination of delete/insert to delete the current
>>>> value
>>>> and add the updated one, as follows:
>>>>
>>>> String pre = StrUtils.strjoinNL
>>>> (" PREFIX : <http://test.org/vocabulary/actions/>"
>>>>
>>>>
>>> Not that it wil have any effect, you have the same namespace twice :
>>>
>>>
>>> noted :)
>>
>>
>> PREFIX : <http://test.org/vocabulary/actions/>
>>> PREFIX actions: <http://test.org/vocabulary/actions/>
>>>
>>> , "PREFIX text: <http://jena.apache.org/text#
>>> >"
>>>
>>>> , "PREFIX rdfs: <
>>>> http://www.w3.org/2000/01/rdf-schema#>"
>>>> ,"PREFIX xsd: <
>>>> http://www.w3.org/2001/XMLSchema#>"
>>>> ," PREFIX actions: <
>>>> http://test.org/vocabulary/actions/>"
>>>> ,"PREFIX rdf: <
>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#>") ;
>>>>
>>>> String prop = StrUtils.strjoinNL(
>>>> node,
>>>>
>>>>
>>> What's the string 'node'?
>>>
>>>
>> node is essentially a placeholder for the object, in the case of the code
>> above it will be bound to <
>> http://jena.apache.org/documentation/tdb/tdb_transactions.html>, and that
>> will change depending on the data being accessed.
>>
>>
>>> " actions:rank ?rank . ");
>>>
>>>>
>>>> dataset.begin(ReadWrite.WRITE) ;
>>>>
>>>>
>>> This is TDB right?
>>>
>>> yes
>>
>>
>>> String dq = StrUtils.strjoinNL
>>>
>>>> (
>>>> "DELETE { ",
>>>> prop, " }",
>>>> "INSERT {", data, "}",
>>>>
>>>>
>>> What's data?
>>>
>>>
>> data is a string with the data that will be inserted
>>
>>
>>> "WHERE { ",
>>>
>>>> prop," }"
>>>> );
>>>>
>>>>
>>> Looks sort of OK. Something readable would be nice.
>>>
>>> Printing the update to check is good for checkign things are happenign as
>>> expected:
>>>
>>> try {
>>>
>>>> UpdateRequest update = UpdateFactory.create(pre+"\n"+dq);
>>>>
>>>>
>>> System.out.println(update) ;
>>>
>>>
>>> GraphStore graphStore = GraphStoreFactory.create(dataset);
>>>
>>>> UpdateAction.execute(update,graphStore);
>>>> dataset.commit();
>>>> }catch(Exception ex){
>>>> ex.printStackTrace();
>>>> }finally { dataset.end() ; }
>>>>
>>>> any ideas as to why the values are not being deleted?
>>>>
>>>>
>>> Possibly node is wrong.
>>>
>>> have checked this and it is correct
>>
>>
>>> Does data get inserted?
>>>
>>>
>> yes data gets inserted, thus the multiple values for the same property...
>> some other values like <http://test.org/vocabulary/actions/id> 92 ;
>> do not change, and only one entry per instance exists
>>
>> Is teh data in the
>>
>>>
>>> Personally, I'd write:
>>>
>>> DELETE WHERE { ... } ;
>>> INSERT DATA { ... }
>>>
>>>
>> but that's a style thing.
>>>
>>> Andy
>>>
>>>
>>> thanks in advance.
>>>>
>>>>
>>>>
>>>
>>
>
Re: delete/insert issue
Posted by Andy Seaborne <an...@apache.org>.
Charles,
It works for me. I'm having to fill in the details from your
description, so something in the detail is different.
Do you have a complete, minimal example?
(You can use TDFCatory.createDataset() to get a in-memory TDB dataset -
they ar enot very efficient but they are a complete simulation of TDB
because it's just a the most basic disk access operations replaced by a
simple RAM disk).
Andy
On 02/06/15 14:02, Charles Abela wrote:
> Thanks for ypour reply Andy,
>
>
> On Tue, Jun 2, 2015 at 2:50 PM, Andy Seaborne <an...@apache.org> wrote:
>
>> On 02/06/15 09:20, Charles Abela wrote:
>>
>>> Hi,
>>> I'm working with a dynamic environment and have instances with some of
>>> their properties that get updated with time, such as the rank property
>>> below
>>>
>>> <http://jena.apache.org/documentation/tdb/tdb_transactions.html>
>>> a <http://test.org/vocabulary/actions/Node> ;
>>> <http://test.org/vocabulary/actions/id>
>>> 92 ;
>>> <http://test.org/vocabulary/actions/rank>
>>> "2.181"^^<http://www.w3.org/2001/XMLSchema#double> ,
>>> "1.672"^^<http://www.w3.org/2001/XMLSchema#double> , "0.233"^^<
>>> http://www.w3.org/2001/XMLSchema#double> , "0.466"^^<
>>> http://www.w3.org/2001/XMLSchema#double> , "0.274"^^<
>>> http://www.w3.org/2001/XMLSchema#double> , "0.543"^^<
>>> http://www.w3.org/2001/XMLSchema#double> , "0.86"^^<
>>> http://www.w3.org/2001/XMLSchema#double> , "1.234"^^<
>>> http://www.w3.org/2001/XMLSchema#double> .
>>>
>>
>> A double can be written shorthand as 1.234e0 -- the "e0" indicates a
>> double and wil be part of the lexical form.
>>
>> @prefix : <http://test.org/vocabulary/actions/> .
>> @prefix text: <http://jena.apache.org/text#> .
>> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
>> @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
>> @prefix actions: <http://test.org/vocabulary/actions/> .
>> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
>>
>> <http://jena.apache.org/documentation/tdb/tdb_transactions.html>
>> rdf:type actions:Node ;
>> actions:id 92 ;
>> actions:rank "2.181"^^xsd:double ;
>> actions:rank "1.672"^^xsd:double ;
>> actions:rank "0.233"^^xsd:double ;
>> actions:rank "0.466"^^xsd:double ;
>> actions:rank "0.274"^^xsd:double ;
>> actions:rank "0.543"^^xsd:double ;
>> actions:rank "0.86"^^xsd:double ;
>> actions:rank "1.234"^^xsd:double .
>>
>>
>> From the excerpt it can be seen that multiple rank values are being
>>> added.
>>>
>>> I'm using sparql's combination of delete/insert to delete the current
>>> value
>>> and add the updated one, as follows:
>>>
>>> String pre = StrUtils.strjoinNL
>>> (" PREFIX : <http://test.org/vocabulary/actions/>"
>>>
>>
>> Not that it wil have any effect, you have the same namespace twice :
>>
>>
> noted :)
>
>
>> PREFIX : <http://test.org/vocabulary/actions/>
>> PREFIX actions: <http://test.org/vocabulary/actions/>
>>
>> , "PREFIX text: <http://jena.apache.org/text#>"
>>> , "PREFIX rdfs: <
>>> http://www.w3.org/2000/01/rdf-schema#>"
>>> ,"PREFIX xsd: <
>>> http://www.w3.org/2001/XMLSchema#>"
>>> ," PREFIX actions: <
>>> http://test.org/vocabulary/actions/>"
>>> ,"PREFIX rdf: <
>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#>") ;
>>>
>>> String prop = StrUtils.strjoinNL(
>>> node,
>>>
>>
>> What's the string 'node'?
>>
>
> node is essentially a placeholder for the object, in the case of the code
> above it will be bound to <
> http://jena.apache.org/documentation/tdb/tdb_transactions.html>, and that
> will change depending on the data being accessed.
>
>>
>> " actions:rank ?rank . ");
>>>
>>> dataset.begin(ReadWrite.WRITE) ;
>>>
>>
>> This is TDB right?
>>
> yes
>
>>
>> String dq = StrUtils.strjoinNL
>>> (
>>> "DELETE { ",
>>> prop, " }",
>>> "INSERT {", data, "}",
>>>
>>
>> What's data?
>>
>
> data is a string with the data that will be inserted
>
>>
>> "WHERE { ",
>>> prop," }"
>>> );
>>>
>>
>> Looks sort of OK. Something readable would be nice.
>>
>> Printing the update to check is good for checkign things are happenign as
>> expected:
>>
>> try {
>>> UpdateRequest update = UpdateFactory.create(pre+"\n"+dq);
>>>
>>
>> System.out.println(update) ;
>>
>>
>> GraphStore graphStore = GraphStoreFactory.create(dataset);
>>> UpdateAction.execute(update,graphStore);
>>> dataset.commit();
>>> }catch(Exception ex){
>>> ex.printStackTrace();
>>> }finally { dataset.end() ; }
>>>
>>> any ideas as to why the values are not being deleted?
>>>
>>
>> Possibly node is wrong.
>>
> have checked this and it is correct
>
>>
>> Does data get inserted?
>>
>
> yes data gets inserted, thus the multiple values for the same property...
> some other values like <http://test.org/vocabulary/actions/id> 92 ;
> do not change, and only one entry per instance exists
>
> Is teh data in the
>>
>> Personally, I'd write:
>>
>> DELETE WHERE { ... } ;
>> INSERT DATA { ... }
>>
>
>> but that's a style thing.
>>
>> Andy
>>
>>
>>> thanks in advance.
>>>
>>>
>>
>
Re: delete/insert issue
Posted by Charles Abela <ch...@gmail.com>.
Thanks for ypour reply Andy,
On Tue, Jun 2, 2015 at 2:50 PM, Andy Seaborne <an...@apache.org> wrote:
> On 02/06/15 09:20, Charles Abela wrote:
>
>> Hi,
>> I'm working with a dynamic environment and have instances with some of
>> their properties that get updated with time, such as the rank property
>> below
>>
>> <http://jena.apache.org/documentation/tdb/tdb_transactions.html>
>> a <http://test.org/vocabulary/actions/Node> ;
>> <http://test.org/vocabulary/actions/id>
>> 92 ;
>> <http://test.org/vocabulary/actions/rank>
>> "2.181"^^<http://www.w3.org/2001/XMLSchema#double> ,
>> "1.672"^^<http://www.w3.org/2001/XMLSchema#double> , "0.233"^^<
>> http://www.w3.org/2001/XMLSchema#double> , "0.466"^^<
>> http://www.w3.org/2001/XMLSchema#double> , "0.274"^^<
>> http://www.w3.org/2001/XMLSchema#double> , "0.543"^^<
>> http://www.w3.org/2001/XMLSchema#double> , "0.86"^^<
>> http://www.w3.org/2001/XMLSchema#double> , "1.234"^^<
>> http://www.w3.org/2001/XMLSchema#double> .
>>
>
> A double can be written shorthand as 1.234e0 -- the "e0" indicates a
> double and wil be part of the lexical form.
>
> @prefix : <http://test.org/vocabulary/actions/> .
> @prefix text: <http://jena.apache.org/text#> .
> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
> @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
> @prefix actions: <http://test.org/vocabulary/actions/> .
> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
>
> <http://jena.apache.org/documentation/tdb/tdb_transactions.html>
> rdf:type actions:Node ;
> actions:id 92 ;
> actions:rank "2.181"^^xsd:double ;
> actions:rank "1.672"^^xsd:double ;
> actions:rank "0.233"^^xsd:double ;
> actions:rank "0.466"^^xsd:double ;
> actions:rank "0.274"^^xsd:double ;
> actions:rank "0.543"^^xsd:double ;
> actions:rank "0.86"^^xsd:double ;
> actions:rank "1.234"^^xsd:double .
>
>
> From the excerpt it can be seen that multiple rank values are being
>> added.
>>
>> I'm using sparql's combination of delete/insert to delete the current
>> value
>> and add the updated one, as follows:
>>
>> String pre = StrUtils.strjoinNL
>> (" PREFIX : <http://test.org/vocabulary/actions/>"
>>
>
> Not that it wil have any effect, you have the same namespace twice :
>
>
noted :)
> PREFIX : <http://test.org/vocabulary/actions/>
> PREFIX actions: <http://test.org/vocabulary/actions/>
>
> , "PREFIX text: <http://jena.apache.org/text#>"
>> , "PREFIX rdfs: <
>> http://www.w3.org/2000/01/rdf-schema#>"
>> ,"PREFIX xsd: <
>> http://www.w3.org/2001/XMLSchema#>"
>> ," PREFIX actions: <
>> http://test.org/vocabulary/actions/>"
>> ,"PREFIX rdf: <
>> http://www.w3.org/1999/02/22-rdf-syntax-ns#>") ;
>>
>> String prop = StrUtils.strjoinNL(
>> node,
>>
>
> What's the string 'node'?
>
node is essentially a placeholder for the object, in the case of the code
above it will be bound to <
http://jena.apache.org/documentation/tdb/tdb_transactions.html>, and that
will change depending on the data being accessed.
>
> " actions:rank ?rank . ");
>>
>> dataset.begin(ReadWrite.WRITE) ;
>>
>
> This is TDB right?
>
yes
>
> String dq = StrUtils.strjoinNL
>> (
>> "DELETE { ",
>> prop, " }",
>> "INSERT {", data, "}",
>>
>
> What's data?
>
data is a string with the data that will be inserted
>
> "WHERE { ",
>> prop," }"
>> );
>>
>
> Looks sort of OK. Something readable would be nice.
>
> Printing the update to check is good for checkign things are happenign as
> expected:
>
> try {
>> UpdateRequest update = UpdateFactory.create(pre+"\n"+dq);
>>
>
> System.out.println(update) ;
>
>
> GraphStore graphStore = GraphStoreFactory.create(dataset);
>> UpdateAction.execute(update,graphStore);
>> dataset.commit();
>> }catch(Exception ex){
>> ex.printStackTrace();
>> }finally { dataset.end() ; }
>>
>> any ideas as to why the values are not being deleted?
>>
>
> Possibly node is wrong.
>
have checked this and it is correct
>
> Does data get inserted?
>
yes data gets inserted, thus the multiple values for the same property...
some other values like <http://test.org/vocabulary/actions/id> 92 ;
do not change, and only one entry per instance exists
Is teh data in the
>
> Personally, I'd write:
>
> DELETE WHERE { ... } ;
> INSERT DATA { ... }
>
> but that's a style thing.
>
> Andy
>
>
>> thanks in advance.
>>
>>
>
Re: delete/insert issue
Posted by Andy Seaborne <an...@apache.org>.
On 02/06/15 09:20, Charles Abela wrote:
> Hi,
> I'm working with a dynamic environment and have instances with some of
> their properties that get updated with time, such as the rank property below
>
> <http://jena.apache.org/documentation/tdb/tdb_transactions.html>
> a <http://test.org/vocabulary/actions/Node> ;
> <http://test.org/vocabulary/actions/id>
> 92 ;
> <http://test.org/vocabulary/actions/rank>
> "2.181"^^<http://www.w3.org/2001/XMLSchema#double> ,
> "1.672"^^<http://www.w3.org/2001/XMLSchema#double> , "0.233"^^<
> http://www.w3.org/2001/XMLSchema#double> , "0.466"^^<
> http://www.w3.org/2001/XMLSchema#double> , "0.274"^^<
> http://www.w3.org/2001/XMLSchema#double> , "0.543"^^<
> http://www.w3.org/2001/XMLSchema#double> , "0.86"^^<
> http://www.w3.org/2001/XMLSchema#double> , "1.234"^^<
> http://www.w3.org/2001/XMLSchema#double> .
A double can be written shorthand as 1.234e0 -- the "e0" indicates a
double and wil be part of the lexical form.
@prefix : <http://test.org/vocabulary/actions/> .
@prefix text: <http://jena.apache.org/text#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix actions: <http://test.org/vocabulary/actions/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://jena.apache.org/documentation/tdb/tdb_transactions.html>
rdf:type actions:Node ;
actions:id 92 ;
actions:rank "2.181"^^xsd:double ;
actions:rank "1.672"^^xsd:double ;
actions:rank "0.233"^^xsd:double ;
actions:rank "0.466"^^xsd:double ;
actions:rank "0.274"^^xsd:double ;
actions:rank "0.543"^^xsd:double ;
actions:rank "0.86"^^xsd:double ;
actions:rank "1.234"^^xsd:double .
> From the excerpt it can be seen that multiple rank values are being added.
>
> I'm using sparql's combination of delete/insert to delete the current value
> and add the updated one, as follows:
>
> String pre = StrUtils.strjoinNL
> (" PREFIX : <http://test.org/vocabulary/actions/>"
Not that it wil have any effect, you have the same namespace twice :
PREFIX : <http://test.org/vocabulary/actions/>
PREFIX actions: <http://test.org/vocabulary/actions/>
> , "PREFIX text: <http://jena.apache.org/text#>"
> , "PREFIX rdfs: <
> http://www.w3.org/2000/01/rdf-schema#>"
> ,"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>"
> ," PREFIX actions: <
> http://test.org/vocabulary/actions/>"
> ,"PREFIX rdf: <
> http://www.w3.org/1999/02/22-rdf-syntax-ns#>") ;
>
> String prop = StrUtils.strjoinNL(
> node,
What's the string 'node'?
> " actions:rank ?rank . ");
>
> dataset.begin(ReadWrite.WRITE) ;
This is TDB right?
> String dq = StrUtils.strjoinNL
> (
> "DELETE { ",
> prop, " }",
> "INSERT {", data, "}",
What's data?
> "WHERE { ",
> prop," }"
> );
Looks sort of OK. Something readable would be nice.
Printing the update to check is good for checkign things are happenign
as expected:
> try {
> UpdateRequest update = UpdateFactory.create(pre+"\n"+dq);
System.out.println(update) ;
> GraphStore graphStore = GraphStoreFactory.create(dataset);
> UpdateAction.execute(update,graphStore);
> dataset.commit();
> }catch(Exception ex){
> ex.printStackTrace();
> }finally { dataset.end() ; }
>
> any ideas as to why the values are not being deleted?
Possibly node is wrong.
Does data get inserted?
Is teh data in the
Personally, I'd write:
DELETE WHERE { ... } ;
INSERT DATA { ... }
but that's a style thing.
Andy
>
> thanks in advance.
>