Revision history for programmatically made changes to the database

28 views
Skip to first unread message

Olivier Dalang

unread,
Jul 21, 2014, 6:24:58 AM7/21/14
to ontowi...@googlegroups.com
Hi !

What is the best strategy to take advantage of Ontowiki's revision history for changes made to the database programmatically (bulk updates...) ?

Of course, the ideal would be to be able to use SPAQRL insert/delete data, but I doubt it's then possible to log any modifications this way ?

Is the way to go creating an extension for Ontowiki ? If so, is there by any chance a ready example ?

Thanks !

Olivier Dalang
---
Digital Humanities Lab (DHLAB) - http://dhlab.epfl.ch
EPFL CDH DHLAB  / CM 2 271
Station 10 / CH-1015 Lausanne
Tel. +41 21 693 02 46





Sebastian Nuck

unread,
Jul 21, 2014, 10:29:27 AM7/21/14
to ontowi...@googlegroups.com
Hi Oliver, 

since the versioning information are stored within Virtuoso's SQL database, you can't use SPARQL to query them. 
If you want your changes to be stored by the versioning histroy you have to trigger an action. (c.f. Erfurt's Versioning.php)

If you look at lines 361 - 387 in ResourceController.php you can see how the action is triggered and finished.

All transactions between startAction and endAction should be recorded by the versioning history. You can access
these information by the ISQL CLI or via Virtuoso's Conductor. The versioning-related tables are ef_versioning_actions
and ef_versioning_payloads. 

Best regards
Sebastian

Olivier Dalang

unread,
Oct 22, 2014, 7:50:39 AM10/22/14
to ontowi...@googlegroups.com

Hi !

OK great I've been able to make it work ! Thanks !

But I encounter some problems with <http://www.opengis.net/ont/geosparql#geometry> properties and Virtuoso's spatial index.

Whenever I try to modify such a property using Erfurt's deleteMatchingStatements() and addStatement() methods, it seems to spatial index gets messed up (and AFAIK I have to use those methods to use the revision history).

I'm not really sure what's happening, since I don't fully understand how the spatial index works internally, but :


These plain sparql queries work well (but of course, no revision history)

WITH <http://dhlab.epfl.ch/vtm/>
DELETE { ?a  ?b  ?c }
WHERE{
        ?a  ?b  ?c .
    <http://mybase/#myressource> <http://www.opengis.net/ont/geosparql#geometry> ?c . 
}            
 
INSERT IN GRAPH <http://dhlab.epfl.ch/vtm/>{
<http://
mybase/#myressource> <http://www.opengis.net/ont/geosparql#geometry> "POLYGON((12.0 45.0,12.1 45.0,12.1 45.1,12.0 45.1,12.0 45.0))"^^virtrdf:Geometry .
}

This PHP snippet messes up the spatial index (but I have a revision history in Ontowiki)

// code before and after is like here : https://github.com/AKSW/OntoWiki/blob/develop/application/controllers/ResourceController.php#L370-L384
$versioning->startAction($actionSpec);
$store->deleteMatchingStatements('
http://mybase', 'http://mybase/#myressource', 'http://www.opengis.net/ont/geosparql#geometry', null);
$store->addStatement('http://mybase', 'http://mybase/#myressource', 'http://www.opengis.net/ont/geosparql#geometry', ['value'=>'POLYGON((12.0 45.0,12.1 45.0,12.1 45.1,12.0 45.1,12.0 45.0))','type'=>"<http://www.openlinksw.com/schemas/virtrdf#Geometry>"]);
$versioning->endAction();


The results of both methods are the same in terms of stored triples (besides the history in Ontowiki), but using the second one, the spatial index doesn't work anymore for that particular triple.
This means that this filter doesn't work properly anymore in my sparql queries (it seem to filter out all features that have been changed) :

SELECT  ?subject
WHERE   {
        ?subject <http://www.opengis.net/ont/geosparql#geometry> ?geom .
        FILTER ( bif:st_intersects ( ?geom, bif:st_geomfromtext("BOX(11.0 44.0, 13.0 46.0)") ) )

Any idea about what's happening ? And about how to solve it ?


And then, I have some other questions about the versionning :

- Do I have to start one action for every single insert/delete action ? (I'm batch updating the property for tons of triples).

- Am I right that the $actionSpec['type'] is the place where to specify whether I'm updating/deleting statements, and that it's not infered directly from what actually happens in the query ?

- Is there a way to add a kind of "commit message" in the history log, saying what the modification was about and what method was used ?

Thanks in advance for your help !

--

---
You received this message because you are subscribed to the Google Groups "OntoWiki User Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ontowiki-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages