Transactions with custom namespace

1 view
Skip to first unread message

michael...@gmail.com

unread,
Sep 16, 2014, 12:32:25 PM9/16/14
to sta...@clarkparsia.com
Hello again,
currently we face a small problem with Transactions.

Here is our triple with our custom name, that is defined in the "test" database:
mb:yw4OpdwX mb:entry "Awesome things to do in California" .


Here goes our code for inserting the triples:

        conn.database = 'test'
        conn.connection.onlineDB( { database: conn.database, strategy: "NO_WAIT" }, function () {
          conn.connection.begin({ database: conn.database }, function (body, response) {

            // Our new awesome transaction id
            txId = body;

            conn.connection.addInTransaction(
              { database: conn.database, "txId": txId, "body": triples },
              function (body2, response2) {
                conn.connection.commit({ database: conn.database, "txId": txId }, function (body3, response3) {

                  cb(null, values)
                });
              }
            );
          });
        });


Unfortunately, this method doesn't save our triples with custom namespace.
A triple like this works however:

<m.yw4OpdwX> <rdf:label> "Awesome things to do in California" .

So the Transactions knows the default namespaces but not our custom one.


Any advice here?


Kind Regards,
Michael

Mike Grove

unread,
Sep 17, 2014, 8:45:39 AM9/17/14
to stardog
Just guessing here since you've not specified what the error actually is, but you need to tell Stardog what the namespaces are that you're planning on using.  One way this can be done from the command line [1].

Cheers,

Mike


--
-- --
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

michael...@gmail.com

unread,
Sep 17, 2014, 9:05:13 AM9/17/14
to sta...@clarkparsia.com
Hallo Michael,
The Problem actually is, that stardog doesnt insert our triple with the "mb:" namespace, although we added the mb: namespace in the stardog admin.

Insertion with the query() function works fine. The problem occurs only when using the transaction method.

Mike Grove

unread,
Sep 17, 2014, 10:44:01 AM9/17/14
to stardog
Query uses transaction under the hood, so the fact that you're trying to do this in a transaction is immaterial.

It's still unclear what you're seeing, if there is an error or the insertion is silently failing.  Without more information, preferably an example that reproduces the issue, it's hard to say more.

Cheers,

Mike

michael...@gmail.com

unread,
Sep 17, 2014, 11:05:21 AM9/17/14
to sta...@clarkparsia.com
Using this method with addInTransaction does not work for the given triple. (I don't get an error but the triple is not inserted.

conn.connection.addInTransaction(
              { database: 'semantic', "txId": txId, "body": "mb:yw4OpdwX mb:entry "Awesome things to do in California" ." },


However, this way actually inserts the triple (with the same triple):

INSERT DATA {
GRAPH <urn:semantic>
{
mb:yw4OpdwX mb:entry "Awesome things to do in California" .
}


I hope you understand our problem now :)

Mike Grove

unread,
Sep 17, 2014, 1:10:20 PM9/17/14
to stardog
On Wed, Sep 17, 2014 at 11:05 AM, <michael...@gmail.com> wrote:
Using this method with addInTransaction does not work for the given triple. (I don't get an error but the triple is not inserted.

conn.connection.addInTransaction(
              { database: 'semantic', "txId": txId, "body": "mb:yw4OpdwX mb:entry "Awesome things to do in California" ." },

The body of your transaction is not valid RDF.  Stored namespaces are used for queries, not arbitrary RDF.  If you include the @prefix declaration for namespaces you're going to use, it should work.

Cheers,

Mike

Edgar Rodriguez

unread,
Sep 17, 2014, 1:14:00 PM9/17/14
to sta...@clarkparsia.com
You can take a look at the gist [1] for an example of adding triples with custom prefixes via the `addInTransaction` call with stardog.js


Cheers,
Edgar

On Wed, Sep 17, 2014 at 11:05 AM, <michael...@gmail.com> wrote:

michael...@gmail.com

unread,
Sep 17, 2014, 2:44:53 PM9/17/14
to sta...@clarkparsia.com
Thanks @Edgar and @Mike

Your solution worked! We just forgot the @prefix, that was the problem :-)

#soluted#
Reply all
Reply to author
Forward
0 new messages