Thanks for ypour reply Andy,
On Tue, Jun 2, 2015 at 2:50 PM, Andy Seaborne <[email protected]> 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. >> >> >
