org.eclipse.rdf4j.sail.Sail Java Examples

The following examples show how to use org.eclipse.rdf4j.sail.Sail. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FedXSailFactory.java    From CostFed with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Sail getSail(SailImplConfig config) throws SailConfigException	{
	
	if (!SAIL_TYPE.equals(config.getType())) {
		throw new SailConfigException("Invalid Sail type: " + config.getType());
	}
	
	if (!(config instanceof FedXSailConfig)) {
		throw new SailConfigException("FedXSail config expected, was " + config.getClass().getCanonicalName());
	}	
	
	FedXSailConfig fedXSailConfig = (FedXSailConfig)config;
	String fedxConfig = fedXSailConfig.getFedxConfig();
	
	if (fedxConfig==null)
		throw new SailConfigException("FedX Sail Configuration must not be null");
	
	try	{
		return FedXFactory.initializeFederation(fedxConfig, new DefaultEndpointListProvider(Collections.<String>emptyList())).getSail();
	} catch (FedXException e) {
		throw new SailConfigException(e);
	}
}
 
Example #2
Source File: FederationFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Sail getSail(SailImplConfig config) throws SailConfigException {
	if (!SAIL_TYPE.equals(config.getType())) {
		throw new SailConfigException("Invalid Sail type: " + config.getType());
	}
	assert config instanceof FederationConfig;
	FederationConfig cfg = (FederationConfig) config;
	Federation sail = new Federation();
	for (RepositoryImplConfig member : cfg.getMembers()) {
		RepositoryFactory factory = RepositoryRegistry.getInstance()
				.get(member.getType())
				.orElseThrow(() -> new SailConfigException("Unsupported repository type: " + config.getType()));
		try {
			sail.addMember(factory.getRepository(member));
		} catch (RepositoryConfigException e) {
			throw new SailConfigException(e);
		}
	}
	sail.setLocalPropertySpace(cfg.getLocalPropertySpace());
	sail.setDistinct(cfg.isDistinct());
	sail.setReadOnly(cfg.isReadOnly());
	return sail;
}
 
Example #3
Source File: MongoGeoIndexerFilterIT.java    From rya with Apache License 2.0 6 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void near_negativeDistance() throws Exception {
    final Sail sail = GeoRyaSailFactory.getInstance(conf);
    final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
    try {
        populateRya(conn);

        //Only captial
        final String query =
                "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n"
                        + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n"
                        + "SELECT * \n" //
                        + "WHERE { \n"
                        + "  <urn:geo> geo:asWKT ?point .\n"
                        + "  FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, -100))"
                        + "}";

        final TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
        while(rez.hasNext()) {
            rez.next();
        }
    } finally {
        conn.close();
        sail.shutDown();
    }
}
 
Example #4
Source File: SolrSailFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Sail getSail(SailImplConfig config) throws SailConfigException {
	if (!SAIL_TYPE.equals(config.getType())) {
		throw new SailConfigException("Invalid Sail type: " + config.getType());
	}

	LuceneSail luceneSail = new LuceneSail();
	luceneSail.setParameter(LuceneSail.INDEX_CLASS_KEY, SolrIndex.class.getName());

	if (config instanceof AbstractLuceneSailConfig) {
		AbstractLuceneSailConfig luceneConfig = (AbstractLuceneSailConfig) config;
		luceneSail.setParameter(LuceneSail.LUCENE_DIR_KEY, luceneConfig.getIndexDir());
		for (String key : luceneConfig.getParameterNames()) {
			luceneSail.setParameter(key, luceneConfig.getParameter(key));
		}
	}

	return luceneSail;
}
 
Example #5
Source File: ElasticsearchSailFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Sail getSail(SailImplConfig config) throws SailConfigException {
	if (!SAIL_TYPE.equals(config.getType())) {
		throw new SailConfigException("Invalid Sail type: " + config.getType());
	}

	LuceneSail luceneSail = new LuceneSail();
	luceneSail.setParameter(LuceneSail.INDEX_CLASS_KEY, ElasticsearchIndex.class.getName());

	if (config instanceof AbstractLuceneSailConfig) {
		AbstractLuceneSailConfig luceneConfig = (AbstractLuceneSailConfig) config;
		luceneSail.setParameter(LuceneSail.LUCENE_DIR_KEY, luceneConfig.getIndexDir());
		for (String key : luceneConfig.getParameterNames()) {
			luceneSail.setParameter(key, luceneConfig.getParameter(key));
		}
	}

	return luceneSail;
}
 
Example #6
Source File: RepositoryModelFactory.java    From semweb4j with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private static Repository createRepository(Properties properties) throws ModelRuntimeException {
	// find out if we need reasoning
	String reasoningProperty = properties == null ? null : properties.getProperty(REASONING);
	boolean reasoning = Reasoning.rdfs.toString().equalsIgnoreCase(reasoningProperty);
	
	// create a Sail stack
	Sail sail = new MemoryStore();
	
	if(reasoning) {
		sail = new ForwardChainingRDFSInferencer((MemoryStore)sail);
	}
	
	// create a Repository
	Repository repository = new SailRepository(sail);
	try {
		repository.initialize();
	} catch(RepositoryException e) {
		throw new ModelRuntimeException(e);
	}
	
	return repository;
}
 
Example #7
Source File: HBaseSailFactoryTest.java    From Halyard with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetSail() throws Exception {
    HBaseSailConfig hbsc = new HBaseSailConfig();
    hbsc.setCreate(false);
    hbsc.setPush(false);
    hbsc.setSplitBits(3);
    hbsc.setEvaluationTimeout(480);
    hbsc.setTablespace("testtable");
    hbsc.setElasticIndexURL("http://whatever/index");
    Sail sail = new HBaseSailFactory().getSail(hbsc);
    assertTrue(sail instanceof HBaseSail);
    HBaseSail hbs = (HBaseSail)sail;
    assertFalse(hbs.create);
    assertFalse(hbs.pushStrategy);
    assertEquals(3, hbs.splitBits);
    assertEquals("testtable", hbs.tableName);
    assertEquals(480, hbs.evaluationTimeout);
    assertEquals("http://whatever/index", hbs.elasticIndexURL);
}
 
Example #8
Source File: LuceneSailFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Sail getSail(SailImplConfig config) throws SailConfigException {
	if (!SAIL_TYPE.equals(config.getType())) {
		throw new SailConfigException("Invalid Sail type: " + config.getType());
	}

	LuceneSail luceneSail = new LuceneSail();
	luceneSail.setParameter(LuceneSail.INDEX_CLASS_KEY, LuceneIndex.class.getName());

	if (config instanceof AbstractLuceneSailConfig) {
		AbstractLuceneSailConfig luceneConfig = (AbstractLuceneSailConfig) config;
		luceneSail.setParameter(LuceneSail.LUCENE_DIR_KEY, luceneConfig.getIndexDir());
		for (String key : luceneConfig.getParameterNames()) {
			luceneSail.setParameter(key, luceneConfig.getParameter(key));
		}
	}

	return luceneSail;
}
 
Example #9
Source File: ElasticsearchStoreFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Sail getSail(SailImplConfig sailImplConfig) throws SailConfigException {
	if (!SAIL_TYPE.equals(sailImplConfig.getType())) {
		throw new SailConfigException("Invalid Sail type: " + sailImplConfig.getType());
	}

	if (sailImplConfig instanceof ElasticsearchStoreConfig) {

		ElasticsearchStoreConfig config = (ElasticsearchStoreConfig) sailImplConfig;

		config.assertRequiredValuesPresent();

		ElasticsearchStore elasticsearchStore = new ElasticsearchStore(config.getHostname(), config.getPort(),
				config.getClusterName(), config.getIndex());

		EvaluationStrategyFactory evalStratFactory = config.getEvaluationStrategyFactory();
		if (evalStratFactory != null) {
			elasticsearchStore.setEvaluationStrategyFactory(evalStratFactory);
		}

		return elasticsearchStore;

	}

	return null;
}
 
Example #10
Source File: LuceneSpinSailFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Sail getSail(SailImplConfig config) throws SailConfigException {
	if (!SAIL_TYPE.equals(config.getType())) {
		throw new SailConfigException("Invalid Sail type: " + config.getType());
	}

	LuceneSpinSail sail = new LuceneSpinSail();
	Properties params = sail.getParameters();

	// set up parameters
	params.setProperty(LuceneSail.INDEX_CLASS_KEY, LuceneSail.DEFAULT_INDEX_CLASS);

	if (config instanceof AbstractLuceneSailConfig) {
		AbstractLuceneSailConfig luceneConfig = (AbstractLuceneSailConfig) config;
		log.debug("Lucene indexDir: {}", luceneConfig.getIndexDir());
		params.setProperty(LuceneSail.LUCENE_DIR_KEY, luceneConfig.getIndexDir());
		for (String key : luceneConfig.getParameterNames()) {
			params.setProperty(key, luceneConfig.getParameter(key));
		}
	}

	return sail;
}
 
Example #11
Source File: AccumuloRyaSinkTask.java    From rya with Apache License 2.0 6 votes vote down vote up
@Override
protected Sail makeSail(final Map<String, String> taskConfig) throws ConnectException {
    requireNonNull(taskConfig);

    // Parse the configuration object.
    final AccumuloRyaSinkConfig config = new AccumuloRyaSinkConfig(taskConfig);

    // Move the configuration into a Rya Configuration object.
    final AccumuloRdfConfiguration ryaConfig = new AccumuloRdfConfiguration();
    ryaConfig.setTablePrefix( config.getRyaInstanceName() );
    ryaConfig.setAccumuloZookeepers( config.getZookeepers() );
    ryaConfig.setAccumuloInstance( config.getClusterName() );
    ryaConfig.setAccumuloUser( config.getUsername() );
    ryaConfig.setAccumuloPassword( config.getPassword() );
    ryaConfig.setFlush(false);

    // Create the Sail object.
    try {
        return RyaSailFactory.getInstance(ryaConfig);
    } catch (SailException | AccumuloException | AccumuloSecurityException | RyaDAOException | InferenceEngineException e) {
        throw new ConnectException("Could not connect to the Rya Instance named " + config.getRyaInstanceName(), e);
    }
}
 
Example #12
Source File: MongoGeoIndexerFilterIT.java    From rya with Apache License 2.0 6 votes vote down vote up
@Test(expected = QueryEvaluationException.class)
public void tooManyArgumentsTest() throws Exception {
    final Sail sail = GeoRyaSailFactory.getInstance(conf);
    final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
    try {
        populateRya(conn);

        // Only captial
        final String query =
                "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n"
                        + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n"
                        + "SELECT * \n" //
                        + "WHERE { \n" + "  <urn:geo> geo:asWKT ?point .\n"
                        + "  FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 100, 1000, 10))"
                        + "}";

        conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
    } finally {
        conn.close();
        sail.shutDown();
    }
}
 
Example #13
Source File: CustomGraphQueryInferencerFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Sail getSail(SailImplConfig config) throws SailConfigException {
	if (!SAIL_TYPE.equals(config.getType())) {
		throw new SailConfigException("Invalid Sail type: " + config.getType());
	}
	CustomGraphQueryInferencer sail = new CustomGraphQueryInferencer();
	if (config instanceof CustomGraphQueryInferencerConfig) {
		CustomGraphQueryInferencerConfig customConfig = (CustomGraphQueryInferencerConfig) config;
		try {
			sail.setFields(customConfig.getQueryLanguage(), customConfig.getRuleQuery(),
					customConfig.getMatcherQuery());
		} catch (RDF4JException e) {
			throw new SailConfigException("Problem occured parsing rule or matcher query text.", e);
		}
	}
	return sail;
}
 
Example #14
Source File: MemoryStoreFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Sail getSail(SailImplConfig config) throws SailConfigException {
	if (!SAIL_TYPE.equals(config.getType())) {
		throw new SailConfigException("Invalid Sail type: " + config.getType());
	}

	MemoryStore memoryStore = new MemoryStore();

	if (config instanceof MemoryStoreConfig) {
		MemoryStoreConfig memConfig = (MemoryStoreConfig) config;

		memoryStore.setPersist(memConfig.getPersist());
		memoryStore.setSyncDelay(memConfig.getSyncDelay());

		if (memConfig.getIterationCacheSyncThreshold() > 0) {
			memoryStore.setIterationCacheSyncThreshold(memConfig.getIterationCacheSyncThreshold());
		}

		EvaluationStrategyFactory evalStratFactory = memConfig.getEvaluationStrategyFactory();
		if (evalStratFactory != null) {
			memoryStore.setEvaluationStrategyFactory(evalStratFactory);
		}
	}

	return memoryStore;
}
 
Example #15
Source File: MongoEntityIndexIT.java    From rya with Apache License 2.0 6 votes vote down vote up
@Test
public void ensureInEntityStore_Test() throws Exception {
    final Sail sail = RyaSailFactory.getInstance(conf);
    final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
    conn.begin();

    try(MongoEntityIndexer indexer = new MongoEntityIndexer()) {
        indexer.setConf(conf);
        indexer.init();

        setupTypes(indexer);
        addStatements(conn);

        final EntityStorage entities = indexer.getEntityStorage();
        final RyaIRI subject = new RyaIRI("urn:alice");
        final Optional<Entity> alice = entities.get(subject);
        assertTrue(alice.isPresent());
    } finally {
        conn.close();
    }
}
 
Example #16
Source File: MongoGeoIndexerFilterIT.java    From rya with Apache License 2.0 6 votes vote down vote up
@Test(expected = MalformedQueryException.class)
public void near_invalidDistance() throws Exception {
    final Sail sail = GeoRyaSailFactory.getInstance(conf);
    final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
    try {
        populateRya(conn);

        //Only captial
        final String query =
                "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n"
                        + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n"
                        + "SELECT * \n" //
                        + "WHERE { \n"
                        + "  <urn:geo> geo:asWKT ?point .\n"
                        + "  FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, distance))"
                        + "}";

        conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
    } finally {
        conn.close();
        sail.shutDown();
    }
}
 
Example #17
Source File: MongoStatementMetadataIT.java    From rya with Apache License 2.0 5 votes vote down vote up
@Test
public void simpleQueryWithoutBindingSet() throws Exception {
    final Sail sail = RyaSailFactory.getInstance(conf);
    final MongoDBRyaDAO dao = new MongoDBRyaDAO();
    try {
        dao.setConf(conf);
        dao.init();

        final StatementMetadata metadata = new StatementMetadata();
        metadata.addMetadata(new RyaIRI("http://createdBy"), new RyaType("Joe"));
        metadata.addMetadata(new RyaIRI("http://createdOn"), new RyaType(XMLSchema.DATE, "2017-01-04"));

        final RyaStatement statement = new RyaStatement(new RyaIRI("http://Joe"), new RyaIRI("http://worksAt"),
                new RyaType("CoffeeShop"), new RyaIRI("http://context"), "", metadata);
        dao.add(statement);

        final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
        final TupleQueryResult result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query1).evaluate();

        final QueryBindingSet bs = new QueryBindingSet();
        bs.addBinding("x", VF.createLiteral("CoffeeShop"));
        bs.addBinding("y", VF.createLiteral("Joe"));

        final List<BindingSet> bsList = new ArrayList<>();
        while (result.hasNext()) {
            bsList.add(result.next());
        }

        assertEquals(1, bsList.size());
        assertEquals(bs, bsList.get(0));
        dao.delete(statement, conf);
    } finally {
        dao.destroy();
        sail.shutDown();
    }
}
 
Example #18
Source File: ConnectionsGroup.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
ConnectionsGroup(ShaclSail sail, SailConnection baseConnection,
		SailConnection previousStateConnection, Sail addedStatements, Sail removedStatements,
		Stats stats, RdfsSubClassOfReasonerProvider rdfsSubClassOfReasonerProvider) {
	this.sail = sail;
	this.baseConnection = baseConnection;
	this.previousStateConnection = previousStateConnection;
	this.addedStatements = addedStatements;
	this.removedStatements = removedStatements;
	this.stats = stats;
	this.rdfsSubClassOfReasonerProvider = rdfsSubClassOfReasonerProvider;
}
 
Example #19
Source File: SailRepository.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private <T> T findSailOf(Sail sail, Class<T> type) {
	if (type.isInstance(sail)) {
		return type.cast(sail);
	} else if (sail instanceof StackableSail) {
		return findSailOf(((StackableSail) sail).getBaseSail(), type);
	} else {
		return null;
	}
}
 
Example #20
Source File: FederationTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected Sail createSail() throws SailException {
	Federation sail = new Federation();
	sail.addMember(new SailRepository(new MemoryStore()));
	sail.addMember(new SailRepository(new MemoryStore()));
	sail.addMember(new SailRepository(new MemoryStore()));
	sail.initialize();
	return sail;
}
 
Example #21
Source File: SailRepositoryFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Sail createSailStack(SailImplConfig config) throws RepositoryConfigException, SailConfigException {
	Sail sail = createSail(config);

	if (config instanceof DelegatingSailImplConfig) {
		SailImplConfig delegateConfig = ((DelegatingSailImplConfig) config).getDelegate();
		if (delegateConfig != null) {
			addDelegate(delegateConfig, sail);
		}
	}

	return sail;
}
 
Example #22
Source File: MongoRyaSinkTask.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
protected Sail makeSail(final Map<String, String> taskConfig) {
    requireNonNull(taskConfig);

    // Parse the configuration object.
    final MongoRyaSinkConfig config = new MongoRyaSinkConfig(taskConfig);

    // Move the configuration into a Rya Configuration object.
    final MongoDBRdfConfiguration ryaConfig = new MongoDBRdfConfiguration();
    ConfigUtils.setUseMongo(ryaConfig, true);
    ryaConfig.setMongoDBName( config.getRyaInstanceName() );
    ryaConfig.setTablePrefix( config.getRyaInstanceName() );
    ryaConfig.setMongoHostname( config.getHostname() );
    ryaConfig.setMongoPort( "" + config.getPort() );

    if(!Strings.isNullOrEmpty(config.getUsername()) && !Strings.isNullOrEmpty(config.getPassword())) {
        ryaConfig.setMongoUser( config.getUsername() );
        ryaConfig.setMongoPassword( config.getPassword() );
    }

    // Create the Sail object.
    try {
        return RyaSailFactory.getInstance(ryaConfig);
    } catch (final SailException | AccumuloException | AccumuloSecurityException | RyaDAOException | InferenceEngineException e) {
        throw new ConnectException("Could not connect to the Rya Instance named " + config.getRyaInstanceName(), e);
    }
}
 
Example #23
Source File: RyaSinkTask.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
public void start(final Map<String, String> props) throws ConnectException {
    requireNonNull(props);

    // Ensure the configured Rya Instance is installed within the configured database.
    checkRyaInstanceExists(props);

    // Create the Sail object that is connected to the Rya Instance.
    final Sail sail = makeSail(props);
    sailRepo = new SailRepository( sail );
    conn = sailRepo.getConnection();
}
 
Example #24
Source File: PcjIntegrationTestingUtil.java    From rya with Apache License 2.0 5 votes vote down vote up
public static SailRepository getAccumuloPcjRepo(final String tablePrefix, final String instance)
        throws AccumuloException, AccumuloSecurityException,
        RyaDAOException, RepositoryException, InferenceEngineException,
        NumberFormatException, UnknownHostException, SailException {

    final AccumuloRdfConfiguration pcjConf = new AccumuloRdfConfiguration();
    pcjConf.set(ConfigUtils.USE_PCJ, "true");
    pcjConf.set(PrecomputedJoinIndexerConfig.PCJ_STORAGE_TYPE,PrecomputedJoinStorageType.ACCUMULO.name());
    populateAccumuloConfig(instance, tablePrefix, pcjConf);

    final Sail pcjSail = RyaSailFactory.getInstance(pcjConf);
    final SailRepository pcjRepo = new SailRepository(pcjSail);
    return pcjRepo;
}
 
Example #25
Source File: MongoStatementMetadataIT.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Tests if results are filtered correctly using the metadata properties. In
 * this case, the date for the ingested RyaStatement differs from the date
 * specified in the query.
 *
 * @throws MalformedQueryException
 * @throws QueryEvaluationException
 * @throws RyaDAOException
 */
@Test
public void simpleQueryWithoutBindingSetInvalidProperty() throws Exception {
    final Sail sail = RyaSailFactory.getInstance(conf);
    final MongoDBRyaDAO dao = new MongoDBRyaDAO();
    try {
        dao.setConf(conf);
        dao.init();
        final StatementMetadata metadata = new StatementMetadata();
        metadata.addMetadata(new RyaIRI("http://createdBy"), new RyaType("Doug"));
        metadata.addMetadata(new RyaIRI("http://createdOn"), new RyaType(XMLSchema.DATE, "2017-02-15"));

        final RyaStatement statement = new RyaStatement(new RyaIRI("http://Joe"), new RyaIRI("http://worksAt"),
                new RyaType("CoffeeShop"), new RyaIRI("http://context"), "", metadata);
        dao.add(statement);

        final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
        final TupleQueryResult result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query1).evaluate();

        final List<BindingSet> bsList = new ArrayList<>();
        while (result.hasNext()) {
            bsList.add(result.next());
        }
        assertEquals(0, bsList.size());
        dao.delete(statement, conf);
    } finally {
        dao.destroy();
        sail.shutDown();
    }
}
 
Example #26
Source File: AccumuloRyaSailFactoryLoadFilesIT.java    From rya with Apache License 2.0 5 votes vote down vote up
private static RyaSailRepository createRyaSailRepository(final RdfCloudTripleStoreConfiguration config) throws SailException {
    log.info("Connecting to Sail Repository.");

    try {
        final Sail extSail = RyaSailFactory.getInstance(config);
        final RyaSailRepository repository = new RyaSailRepository(extSail);
        return repository;
    } catch (final Exception e) {
        throw new SailException("Failed to create Rya Sail Repository", e);
    }
}
 
Example #27
Source File: ShaclSailFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Sail getSail(SailImplConfig config) throws SailConfigException {
	if (!SAIL_TYPE.equals(config.getType())) {
		throw new SailConfigException("Invalid Sail type: " + config.getType());
	}

	ShaclSail sail = new ShaclSail();

	if (config instanceof ShaclSailConfig) {
		ShaclSailConfig shaclSailConfig = (ShaclSailConfig) config;

		if (shaclSailConfig.isValidationEnabled()) {
			sail.enableValidation();
		} else {
			sail.disableValidation();
		}

		sail.setCacheSelectNodes(shaclSailConfig.isCacheSelectNodes());
		sail.setUndefinedTargetValidatesAllSubjects(shaclSailConfig.isUndefinedTargetValidatesAllSubjects());
		sail.setIgnoreNoShapesLoadedException(shaclSailConfig.isIgnoreNoShapesLoadedException());
		sail.setLogValidationPlans(shaclSailConfig.isLogValidationPlans());
		sail.setLogValidationViolations(shaclSailConfig.isLogValidationViolations());
		sail.setParallelValidation(shaclSailConfig.isParallelValidation());
		sail.setGlobalLogValidationExecution(shaclSailConfig.isGlobalLogValidationExecution());
		sail.setPerformanceLogging(shaclSailConfig.isPerformanceLogging());
		sail.setSerializableValidation(shaclSailConfig.isSerializableValidation());
		sail.setRdfsSubClassReasoning(shaclSailConfig.isRdfsSubClassReasoning());
	}

	return sail;

}
 
Example #28
Source File: SpinSailFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Sail getSail(SailImplConfig config) throws SailConfigException {
	if (!SAIL_TYPE.equals(config.getType())) {
		throw new SailConfigException("Invalid Sail type: " + config.getType());
	}

	SpinSail spinSail = new SpinSail();
	if (config instanceof SpinSailConfig) {
		spinSail.setAxiomClosureNeeded(((SpinSailConfig) config).isAxiomClosureNeeded());
		spinSail.setValidateConstraints(((SpinSailConfig) config).isValidateConstraints());

	}

	return spinSail;
}
 
Example #29
Source File: MongoBatchUpdatePCJ.java    From rya with Apache License 2.0 5 votes vote down vote up
private Sail connectToRya(final String ryaInstanceName) throws RyaClientException {
    try {
        final MongoDBRdfConfiguration ryaConf = connectionDetails.build(ryaInstanceName);
        return RyaSailFactory.getInstance(ryaConf);
    } catch (SailException | AccumuloException | AccumuloSecurityException | RyaDAOException | InferenceEngineException e) {
        throw new RyaClientException("Could not connect to the Rya instance named '" + ryaInstanceName + "'.", e);
    }
}
 
Example #30
Source File: SpinSail.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void setBaseSail(Sail baseSail) {
	super.setBaseSail(baseSail);
	if (baseSail instanceof ForwardChainingRDFSInferencer) {
		this.setAxiomClosureNeeded(false);
	}
}