You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Kris McGlinn <Kr...@scss.tcd.ie> on 2018/09/04 09:43:53 UTC

Jena DataAccessor and the Parliament triplestore

Hi There,

I have successfully used DatasetAccessor accessor = 
DatasetAccessorFactory.createHTTP("http://localhost:3030/test/data"); to 
load a Jena model directly into fuseki.

I was wondering if it is possible to use this same technique with 
Parliament triplestore? And if not, what is the recommended way for 
injecting a Jena model into Parliament?

Kind regards,

Kris.

-- 
Kris McGlinn, Ph.D.
Research Fellow,
ADAPT Centre,
F 33, School of Computer Science and Statistics,
Trinity College Dublin
+353 (0)1 896 4992


RE: Jena DataAccessor and the Parliament triplestore

Posted by Greg Albiston <gr...@hotmail.com>.
Hi Kris,

I've previously managed to get Parliament working through the API.
Parliament still uses Jena 2.9.4 and Joseki (precursor to Fuseki). 
There are significant package name changes between Jena 2.x and 3.x so they aren't compatible.

Below is code that I managed to put together through a lot of trial and error using Jena 2.9.4.
It may seem excessive but from reading the source code there seem to be some gaps in triggering the spatial indexes.
This process can be adjusted to pass in named graphs using:

Node graphNode = Node.createURI(graphName);
KbGraph namedGraph = KbGraphFactory.createNamedGraph();

You will need to setup the environment variables for Parliament as outlined in its documentation.
Configuration of Parliament also needs to be done in the ParliamentConfig.txt file.
The created spatial indexes will appear in the "indexes" folder of the knowledge base folder.

Hope this helps,

Greg


import com.bbn.parliament.jena.graph.KbGraph;
import com.bbn.parliament.jena.graph.KbGraphFactory;
import com.bbn.parliament.jena.graph.KbGraphStore;
import com.bbn.parliament.jena.graph.index.IndexFactoryRegistry;
import com.bbn.parliament.jena.graph.index.IndexManager;
import com.bbn.parliament.jena.graph.index.spatial.Constants;
import com.bbn.parliament.jena.graph.index.spatial.SpatialIndexFactory;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import java.io.File;
import java.lang.invoke.MethodHandles;
import java.net.MalformedURLException;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 *
 */
public class Parliament {

    private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

    public static final void load(File sourceRDFFile) {

        SpatialIndexFactory spatialIndexFactory = createSpatialIndexFactory();
        IndexFactoryRegistry.getInstance().setIndexingEnabledByDefault(true);
        IndexManager indexManager = IndexManager.getInstance();

        //Parliament graph store that contains all graphs. Requires default graph for constructor.
        KbGraph defaultGraph = KbGraphFactory.createDefaultGraph();
        KbGraphStore graphStore = new KbGraphStore(defaultGraph);
        Model defaultModel = ModelFactory.createModelForGraph(defaultGraph);

        try {
            graphStore.initialize();

            //Register named graph and index with IndexManager.
            indexManager.createAndRegister(defaultGraph, KbGraphStore.DEFAULT_GRAPH_NODE, spatialIndexFactory);

            defaultModel.read(sourceRDFFile.toURI().toURL().toString(), "N-TRIPLE");

            graphStore.setIndexingEnabled(KbGraphStore.DEFAULT_GRAPH_NODE, true);
            indexManager.createAndRegister(defaultGraph, KbGraphStore.DEFAULT_GRAPH_NODE, spatialIndexFactory);

            //Force the building of the index for the graph.
            indexManager.rebuild(defaultGraph);
            indexManager.flush(defaultGraph);
            indexManager.closeAll(defaultGraph);

        } catch (MalformedURLException ex) {
            LOGGER.error("Exception: {}", ex.getMessage());
        } finally {
            graphStore.flush();
            graphStore.close();
        }

    }

    private static SpatialIndexFactory createSpatialIndexFactory() {
        //Create spatial index factory and configure for GeoSPARQL.
        SpatialIndexFactory factory = new SpatialIndexFactory();
        Properties properties = new Properties();
        properties.setProperty(Constants.GEOMETRY_INDEX_TYPE, Constants.GEOMETRY_INDEX_RTREE);
        properties.setProperty(Constants.GEOSPARQL_ENABLED, Boolean.TRUE.toString());
        factory.configure(properties);

        //Register spatial index factory. Enable indexing for all graphs. Enabling individual graphs in the graph store does not work.
        IndexFactoryRegistry.getInstance().register(factory);
        return factory;
    }

}

-----Original Message-----
From: ajs6f <aj...@apache.org> 
Sent: 04 September 2018 11:06
To: users@jena.apache.org
Subject: Re: Jena DataAccessor and the Parliament triplestore

This seems like a question much better put to the maintainers of that software [1].

It's not a product of the Jena project, to my knowledge, although it reuses Jena components, and I see the name of at least one Jena committer amongst its contributors. It doesn't seem very live any more with no mail since 2015 [2]-- is there some particular reason you are trying to use it from Jena?

ajs6f

[1] http://parliament.semwebcentral.org/
[2] http://semwebcentral.org/pipermail/parliament-users/

> On Sep 4, 2018, at 5:43 AM, Kris McGlinn <Kr...@scss.tcd.ie> wrote:
> 
> Hi There,
> 
> I have successfully used DatasetAccessor accessor = DatasetAccessorFactory.createHTTP("http://localhost:3030/test/data"); to load a Jena model directly into fuseki.
> 
> I was wondering if it is possible to use this same technique with Parliament triplestore? And if not, what is the recommended way for injecting a Jena model into Parliament?
> 
> Kind regards,
> 
> Kris.
> 
> --
> Kris McGlinn, Ph.D.
> Research Fellow,
> ADAPT Centre,
> F 33, School of Computer Science and Statistics, Trinity College 
> Dublin
> +353 (0)1 896 4992
> 


Re: Jena DataAccessor and the Parliament triplestore

Posted by ajs6f <aj...@apache.org>.
This seems like a question much better put to the maintainers of that software [1].

It's not a product of the Jena project, to my knowledge, although it reuses Jena components, and I see the name of at least one Jena committer amongst its contributors. It doesn't seem very live any more with no mail since 2015 [2]-- is there some particular reason you are trying to use it from Jena?

ajs6f

[1] http://parliament.semwebcentral.org/
[2] http://semwebcentral.org/pipermail/parliament-users/

> On Sep 4, 2018, at 5:43 AM, Kris McGlinn <Kr...@scss.tcd.ie> wrote:
> 
> Hi There,
> 
> I have successfully used DatasetAccessor accessor = DatasetAccessorFactory.createHTTP("http://localhost:3030/test/data"); to load a Jena model directly into fuseki.
> 
> I was wondering if it is possible to use this same technique with Parliament triplestore? And if not, what is the recommended way for injecting a Jena model into Parliament?
> 
> Kind regards,
> 
> Kris.
> 
> -- 
> Kris McGlinn, Ph.D.
> Research Fellow,
> ADAPT Centre,
> F 33, School of Computer Science and Statistics,
> Trinity College Dublin
> +353 (0)1 896 4992
> 


RE: Spatial Searches with SPARQL

Posted by Greg Albiston <gr...@hotmail.com>.
Hi Kris,

As Lorenz says I have an implementation of GeoSPARQL for Jena 3.x but need to make some changes and additional tests.
I'm planning to make it available as a separate project soon.

Querying of polygons using geof:sfWithin is supported.

Thanks,

Greg


-----Original Message-----
From: Lorenz B. <bu...@informatik.uni-leipzig.de> 
Sent: 05 September 2018 10:37
To: users@jena.apache.org
Subject: Re: Spatial Searches with SPARQL

Hello Kris,

you're the one from the StackOverflow discussion [1] right? Good that you asked here for support. As I said, so far there is no GeoSPARQL support, but quite recently this was discussed with a possible future implementation from Greg Albiston here [2].


Cheers,
Lorenz

[1]
https://stackoverflow.com/questions/52094346/jena-dataaccessorfactory-with-the-parliament-triplestore
[2]
https://lists.apache.org/thread.html/2f09f9c3cfc749c84d09b6c5d2cb40f962986f9fd2890f0a32e109f4@%3Cusers.jena.apache.org%3E

> Hi All,
>
> I configured fuseki to support added spatial searches. I was wondering 
> if there is anyway to query polygons? The documentation gives a 
> "spatial:withinBox", but I was looking for something closer to 
> geof:sfWithin?
>
> Kind regards,
>
> Kris.
>
>
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center


Re: Spatial Searches with SPARQL

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
Hello Kris,

you're the one from the StackOverflow discussion [1] right? Good that
you asked here for support. As I said, so far there is no GeoSPARQL
support, but quite recently this was discussed with a possible future
implementation from Greg Albiston here [2].


Cheers,
Lorenz

[1]
https://stackoverflow.com/questions/52094346/jena-dataaccessorfactory-with-the-parliament-triplestore
[2]
https://lists.apache.org/thread.html/2f09f9c3cfc749c84d09b6c5d2cb40f962986f9fd2890f0a32e109f4@%3Cusers.jena.apache.org%3E

> Hi All,
>
> I configured fuseki to support added spatial searches. I was wondering
> if there is anyway to query polygons? The documentation gives a
> "spatial:withinBox", but I was looking for something closer to
> geof:sfWithin?
>
> Kind regards,
>
> Kris.
>
>
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center


Spatial Searches with SPARQL

Posted by Kris McGlinn <Kr...@scss.tcd.ie>.
Hi All,

I configured fuseki to support added spatial searches. I was wondering 
if there is anyway to query polygons? The documentation gives a 
"spatial:withinBox", but I was looking for something closer to 
geof:sfWithin?

Kind regards,

Kris.



-- 
Kris McGlinn, Ph.D.
Research Fellow,
ADAPT Centre,
F 33, School of Computer Science and Statistics,
Trinity College Dublin
+353 (0)1 896 4992