Search code examples
pluginsgraphdbgeosparql

Configure/Enable GeoSPARQL plugin through RDF4J API


I am trying to automate the creation of GraphDB repos which must also have the GeoSPARQL plugin enabled. To this end, I am sending 2 INSERT statements, the first for configuring the index and accuracy and the second statement for enabling the plugin. However the conn.prepareUpdate(QueryLanguage.SPARQL, enablePluginStatement).execute() operation "seems" to run asychronously. Instead of waiting until the indexing operation is complete (as it happens when running the same INSERT query from the Workbench) it almost immediately proceeds to the following statement which is to shutdown the repository. When I execute the same code through the Netbeans debugger the same single statement takes much more time to complete and does complete the indexing properly. Any insight on this or a similar issue?

    26609 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'deduplicate.construct' to default value 'true' 
    26610 [main] INFO  com.ontotext.config.AbstractParameter  - Configured parameter 'reuse.vars.in.subselects' to default value 'false' 
    26691 [main] INFO  com.ontotext.trree.monitorRepository.MonitorRepositoryConnection  - Incoming update: 
PREFIX : <http://www.ontotext.com/plugins/geosparql#> 
INSERT DATA {    _:s :enabled "true" .  } 
    26764 [main] INFO  com.ontotext.plugin.GeoSPARQL  - >>>>>>>> GeoSPARQL: Initializing Lucene indexer... 
    26863 [main] INFO  com.ontotext.plugin.GeoSPARQL  -
        >>>>>>>> GeoSPARQL: Lucene indexer initialized! 
    26863 [main] INFO  com.ontotext.plugin.GeoSPARQL  - >>>>>>>> GeoSPARQL: Initializing indexing process... 
    32032 [main] INFO  com.ontotext.plugin.GeoSPARQL 
        - >>>>>>>> GeoSPARQL: Indexing completed! 
    52200 [main] WARN  com.ontotext.trree.free.GraphDBFreeSchemaRepository  - Closing active connection due to shut down; consider setting the org.eclipse.rdf4j.repository.debug system property 
    52596 [main] INFO  com.ontotext.trree.sdk.impl.PluginManager  - Shutting down plugins (DEFAULT)...

Solution

  • You can use composite transaction as multiple "insert where" and "delete where" expressions separated by ; can see the changes from the previous ones in the same update. As an example:

    PREFIX : <http://www.ontotext.com/plugins/geosparql#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>INSERT DATA {    _:s :enabled "true" .  } ;INSERT DATA { _:s :prefixTree "quad"; :precision "25". }
    

    With curl:

    curl 'http://localhost:7200/repositories/geosparql/statements' -H 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'update=PREFIX : <http://www.ontotext.com/plugins/geosparql#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> INSERT DATA { _:s :enabled "true" . } ; INSERT DATA { _:s :prefixTree "quad"; :precision "25". }'
    

    You should be able to first build the index and then set the precision:

    [INFO ] 2019-02-26 12:08:36,331 [repositories/geosparql | c.o.g.s.StatementsController] POST SPARQL update request to repository
    [INFO ] 2019-02-26 12:08:36,349 [repositories/geosparql | c.o.p.GeoSPARQL] >>>>>>>> GeoSPARQL: Initializing Lucene indexer...
    [INFO ] 2019-02-26 12:08:36,383 [repositories/geosparql | c.o.p.GeoSPARQL] >>>>>>>> GeoSPARQL: Lucene indexer initialized!
    [INFO ] 2019-02-26 12:08:36,383 [repositories/geosparql | c.o.p.GeoSPARQL] >>>>>>>> GeoSPARQL: Initializing indexing process...
    [INFO ] 2019-02-26 12:08:36,466 [repositories/geosparql | c.o.p.GeoSPARQL] >>>>>>>> GeoSPARQL: Indexing completed!