Add turtle in transaction

1 view
Skip to first unread message

sita...@gmail.com

unread,
Mar 27, 2013, 11:22:54 PM3/27/13
to sta...@clarkparsia.com
I'm using stardog.js to update a database.


I've got two issues:

1. It only works if I post it one triple at a time. When I post the whole thing at once I get a 200 response code, but nothing in the database.
2. When I push it, my blank nodes are not reassigned ids - they are stored as literal ids, it seems. This means that when they are pushed one-by-one (and persist) they are meaningful, but it means that I have to use unique blank node identifiers.

I've tested my turtle at http://turtlescript.trikelane.com/validator, and it seems to be valid.

I'm adding it like this:

  for (var triple = 0; triple < ntriples.length; triple ++){
            conn.addInTransaction(database, txID, ntriples[triple], addInTransactionCallback, 'text/turtle');
        }

Where I either break my turtle up into individual statements (works), or send it as a single statement (doesn't work).

Any hints?

Here's my turtle:

 _:b0  <http://www.redhat.com/2013/schema-parser#rootNodeOf>  <http://www.atmayoga.com.au/> .  _:b0  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://schema.org/Blog> .  _:b0  <http://www.w3.org/2002/07/owl#sameAs>  <http://www.atmayoga.com.au#Example> . _:b0  <http://www.redhat.com/2013/schema-parser#itemtypeWithoutAnyProperty>  <http://schema.org/Blog> . _:b1  <http://www.redhat.com/2013/schema-parser#nestedIn>  _:b0 . _:e0  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.redhat.com/2013/schema-parser#unintelligibleType> . _:e0  <http://www.redhat.com/2013/schema-parser#specifiedType>  "http://schema.org/LocalBusinesss" . _:b10  <http://www.redhat.com/2013/schema-parser#missingItemScope>  "http://schema.org/LocalBusinesss" . _:b10  <http://schema.org/name>  "Atma Yoga" . _:b10  <http://schema.org/description>  "Yoga studio in the Brisbane CBD." . _:b10  <http://schema.org/address>  _:s0 . _:s0  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://schema.org/PostalAddress> . _:s0  <http://schema.org/streetAddress>  "1st Floor, 99 Elizabeth Street" . _:s0  <http://schema.org/addressLocality>  "Brisbane" . _:e2  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>   <http://www.redhat.com/2013/schema-parser#unintelligibleProperty> . _:e2  <http://www.redhat.com/2013/schema-parser#specifiedProperty>  "http://schema.org/telephonee" . _:N0  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.redhat.com/2013/schema-parser#itemscopeWithoutItemtype> . _:N0  <http://www.redhat.com/2013/schema-parser#rootNodeOf>  <http://www.atmayoga.com.au/> . _:e3  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.redhat.com/2013/schema-parser#orphanedProperty> . _:e3  <http://www.redhat.com/2013/schema-parser#specifiedProperty>  <http://schema.org/author> .


- Josh

Edgar Rodriguez

unread,
Mar 28, 2013, 12:08:43 PM3/28/13
to sta...@clarkparsia.com
Hi,


On Wed, Mar 27, 2013 at 11:22 PM, <sita...@gmail.com> wrote:
I'm using stardog.js to update a database.


I've got two issues:

1. It only works if I post it one triple at a time. When I post the whole thing at once I get a 200 response code, but nothing in the database.

This is weird, are you calling the `commit` function after the `addInTransaction` function?

I did a small test case for your data, and it seems to be working: https://gist.github.com/edgarRd/5264217
Having the stardog.js code from master branch, you should be able to run it with (in the repo):

    $ node_modules/jasmine-node/bin/jasmine-node spec/testAddInTransaction.js

Running the test in a clean DB works fine adding all the 20 triples. After running the test case, you can query the DB and all triples should be there.

After running the test in 1. I found the blank nodes to be fine (not literals), here's the output of querying the DB after running the test case in 1.

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
 
 

Mike Grove

unread,
Mar 28, 2013, 12:11:57 PM3/28/13
to stardog
On Thu, Mar 28, 2013 at 12:08 PM, Edgar Rodriguez <ed...@clarkparsia.com> wrote:
Hi,


On Wed, Mar 27, 2013 at 11:22 PM, <sita...@gmail.com> wrote:
I'm using stardog.js to update a database.


I've got two issues:

1. It only works if I post it one triple at a time. When I post the whole thing at once I get a 200 response code, but nothing in the database.

This is weird, are you calling the `commit` function after the `addInTransaction` function?

I did a small test case for your data, and it seems to be working: https://gist.github.com/edgarRd/5264217
Having the stardog.js code from master branch, you should be able to run it with (in the repo):

    $ node_modules/jasmine-node/bin/jasmine-node spec/testAddInTransaction.js

Running the test in a clean DB works fine adding all the 20 triples. After running the test case, you can query the DB and all triples should be there.

After running the test in 1. I found the blank nodes to be fine (not literals), here's the output of querying the DB after running the test case in 1.
 
2. When I push it, my blank nodes are not reassigned ids - they are stored as literal ids, it seems. This means that when they are pushed one-by-one (and persist) they are meaningful, but it means that I have to use unique blank node identifiers.

It's unclear what you mean by 'literal ids'. 

Further, are you expecting the database to assign new id's to your bnodes?

Note that bnode identifiers are only meaningful within the document in which they appear, _:b0 in two different RDF documents means they're two different nodes, regardless of the fact they have the same label.

Cheers,

Mike
Reply all
Reply to author
Forward
0 new messages