You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2013/12/06 10:54:14 UTC
svn commit: r1548478 -
/stanbol/trunk/entityhub/indexing/source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java
Author: rwesten
Date: Fri Dec 6 09:54:14 2013
New Revision: 1548478
URL: http://svn.apache.org/r1548478
Log:
STANBOL-1200: added constructor that allows to manually construct a Sesame RDFIndexingSource for a Repository and a context
Modified:
stanbol/trunk/entityhub/indexing/source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java
Modified: stanbol/trunk/entityhub/indexing/source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java?rev=1548478&r1=1548477&r2=1548478&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java (original)
+++ stanbol/trunk/entityhub/indexing/source/sesame/src/main/java/org/apache/stanbol/entityhub/indexing/source/sesame/RdfIndexingSource.java Fri Dec 6 09:54:14 2013
@@ -100,7 +100,32 @@ public class RdfIndexingSource extends A
Repository repository;
//protected RepositoryConnection connection;
+ /**
+ * Default Constructor. Expects that the config is parsed by calling
+ * {@link #setConfiguration(Map)}
+ */
+ public RdfIndexingSource() {}
+ /**
+ *
+ * @param repository
+ * @param contexts
+ */
+ public RdfIndexingSource(Repository repository, Resource...contexts){
+ if(repository == null){
+ throw new IllegalArgumentException("The parsed Repository MUST NOT be NULL!");
+ }
+ if(!repository.isInitialized()){
+ try {
+ repository.initialize();
+ } catch (RepositoryException e) {
+ throw new IllegalStateException("Unable to Initialise the parsed Repository",e);
+ }
+ }
+ this.repository = repository;
+ this.sesameFactory = repository.getValueFactory();
+ this.contexts = contexts;
+ }
/**
* If {@link BNode} being values of outgoing triples should be followed.
@@ -124,15 +149,13 @@ public class RdfIndexingSource extends A
*/
protected final List<EntityDataIterator> entityDataIterators = new CopyOnWriteArrayList<EntityDataIterator>();
- private IndexingConfig indexingConfig;
-
private ResourceLoader loader;
private String baseUri;
@Override
public void setConfiguration(Map<String,Object> config) {
- indexingConfig = (IndexingConfig)config.get(IndexingConfig.KEY_INDEXING_CONFIG);
+ IndexingConfig indexingConfig = (IndexingConfig)config.get(IndexingConfig.KEY_INDEXING_CONFIG);
//(0) parse the baseUri
Object value = config.get(PARAM_BASE_URI);
baseUri = value == null ? DEFAULT_BASE_URI : value.toString();
@@ -300,12 +323,14 @@ public class RdfIndexingSource extends A
@Override
public boolean needsInitialisation() {
//check if we need to load resources
- return !loader.getResources(ResourceState.REGISTERED).isEmpty();
+ return loader != null && !loader.getResources(ResourceState.REGISTERED).isEmpty();
}
@Override
public void initialise() {
- loader.loadResources();
+ if(loader != null){
+ loader.loadResources();
+ }
}
@Override
@@ -484,6 +509,8 @@ public class RdfIndexingSource extends A
}
+
+
/**
* Extracts the triples that belong to the {@link Representation} with the
* parsed id from the Sesame repository.