public SpinSailConfig(SailImplConfig delegate) { super(SpinSailFactory.SAIL_TYPE, delegate); if ("openrdf:ForwardChainingRDFSInferencer".equals(delegate.getType())) { setAxiomClosureNeeded(false); } }
@Override public Resource export(Model m) { Resource implNode = super.export(m); if (delegate != null) { Resource delegateNode = delegate.export(m); m.add(implNode, DELEGATE, delegateNode); } return implNode; }
@Override public void validate() throws SailConfigException { super.validate(); if (delegate == null) { throw new SailConfigException("No delegate specified for " + getType() + " Sail"); } delegate.validate(); }
public static SailImplConfig parseRepositoryImpl(Model m, Resource implNode) throws SailConfigException { try { Optional<Literal> typeLit = Models.objectLiteral( m.filter(implNode, SailConfigSchema.SAILTYPE, null)); if (typeLit.isPresent()) { Optional<SailFactory> factory = SailRegistry.getInstance().get(typeLit.get().getLabel()); if (factory.isPresent()) { SailImplConfig implConfig = factory.get().getConfig(); implConfig.parse(m, implNode); return implConfig; } else { throw new SailConfigException("Unsupported Sail type: " + typeLit.get().getLabel()); } } return null; } catch (ModelException e) { throw new SailConfigException(e.getMessage(), e); } } }
@Override public void validate() throws SailConfigException { super.validate(); if (delegate == null) { throw new SailConfigException("No delegate specified for " + getType() + " Sail"); } delegate.validate(); }
public static SailImplConfig parseRepositoryImpl(Model m, Resource implNode) throws SailConfigException { try { Optional<Literal> typeLit = Models.objectLiteral( m.filter(implNode, SailConfigSchema.SAILTYPE, null)); if (typeLit.isPresent()) { Optional<SailFactory> factory = SailRegistry.getInstance().get(typeLit.get().getLabel()); if (factory.isPresent()) { SailImplConfig implConfig = factory.get().getConfig(); implConfig.parse(m, implNode); return implConfig; } else { throw new SailConfigException("Unsupported Sail type: " + typeLit.get().getLabel()); } } return null; } catch (ModelException e) { throw new SailConfigException(e.getMessage(), e); } } }
@Override public Resource export(Model m) { Resource implNode = super.export(m); if (delegate != null) { Resource delegateNode = delegate.export(m); m.add(implNode, DELEGATE, delegateNode); } return implNode; }
@Override public void validate() throws RepositoryConfigException { super.validate(); if (sailImplConfig == null) { throw new RepositoryConfigException("No Sail implementation specified for Sail repository"); } try { sailImplConfig.validate(); } catch (SailConfigException e) { throw new RepositoryConfigException(e.getMessage(), e); } }
@Override public void parse(Model model, Resource repImplNode) throws RepositoryConfigException { try { Optional<Resource> sailImplNode = Models.objectResource( model.filter(repImplNode, SAILIMPL, null)); if (sailImplNode.isPresent()) { Models.objectLiteral(model.filter(sailImplNode.get(), SAILTYPE, null)).ifPresent(typeLit -> { SailFactory factory = SailRegistry.getInstance().get(typeLit.getLabel()).orElseThrow( () -> new RepositoryConfigException( "Unsupported Sail type: " + typeLit.getLabel())); sailImplConfig = factory.getConfig(); sailImplConfig.parse(model, sailImplNode.get()); }); } } catch (ModelException e) { throw new RepositoryConfigException(e.getMessage(), e); } catch (SailConfigException e) { throw new RepositoryConfigException(e.getMessage(), e); } } }
@Override public Resource export(Model model) { Resource repImplNode = super.export(model); if (sailImplConfig != null) { model.setNamespace("sr", NAMESPACE); Resource sailImplNode = sailImplConfig.export(model); model.add(repImplNode, SAILIMPL, sailImplNode); } return repImplNode; }
public SpinSailConfig(SailImplConfig delegate) { super(SpinSailFactory.SAIL_TYPE, delegate); if ("openrdf:ForwardChainingRDFSInferencer".equals(delegate.getType())) { setAxiomClosureNeeded(false); } }
private Sail createSail(SailImplConfig config) throws RepositoryConfigException, SailConfigException { SailFactory sailFactory = SailRegistry.getInstance().get(config.getType()).orElseThrow( () -> new RepositoryConfigException("Unsupported Sail type: " + config.getType())); return sailFactory.getSail(config); }
@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()); } return spinSail; } }
@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()); } return spinSail; } }
@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; }
@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 HBaseSailConfig) { HBaseSailConfig hconfig = (HBaseSailConfig) config; //instantiate the sail HBaseSail sail = new HBaseSail(HBaseConfiguration.create(), hconfig.getTablespace(), hconfig.isCreate(), hconfig.getSplitBits(), hconfig.isPush(), hconfig.getEvaluationTimeout(), hconfig.getElasticIndexURL(), null); return sail; } else { throw new SailConfigException("Invalid configuration: " + config); } }
@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; } }