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 <[email protected]>
Sent: 04 September 2018 11:06
To: [email protected]
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 <[email protected]> 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
>