Java Code Examples for org.eclipse.rdf4j.model.util.Models#objectLiteral()
The following examples show how to use
org.eclipse.rdf4j.model.util.Models#objectLiteral() .
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: SailConfigUtil.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static SailImplConfig parseRepositoryImpl(Model m, Resource implNode) throws SailConfigException { try { Optional<Literal> typeLit = Models .objectLiteral(m.getStatements(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); } }
Example 2
Source File: CostFedRepositoryFactory.java From CostFed with GNU Affero General Public License v3.0 | 5 votes |
@Override public void parse(Model model, Resource resource) throws RepositoryConfigException { super.parse(model, resource); try { Optional<Literal> cfg = Models.objectLiteral(model.filter(resource, FILENAME, null)); setConfigFile(cfg.get().getLabel()); } catch (ModelException e) { throw new RepositoryConfigException(e.getMessage(), e); } }
Example 3
Source File: CustomGraphQueryInferencerConfig.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void parse(Model m, Resource implNode) throws SailConfigException { super.parse(m, implNode); try { Optional<Literal> language = Models.objectLiteral(m.getStatements(implNode, QUERY_LANGUAGE, null)); if (language.isPresent()) { setQueryLanguage(QueryLanguage.valueOf(language.get().stringValue())); if (null == getQueryLanguage()) { throw new SailConfigException( "Valid value required for " + QUERY_LANGUAGE + " property, found " + language.get()); } } else { setQueryLanguage(QueryLanguage.SPARQL); } Optional<Resource> object = Models.objectResource(m.getStatements(implNode, RULE_QUERY, null)); if (object.isPresent()) { Models.objectLiteral(m.getStatements(object.get(), SP.TEXT_PROPERTY, null)) .ifPresent(lit -> setRuleQuery(lit.stringValue())); } object = Models.objectResource(m.getStatements(implNode, MATCHER_QUERY, null)); if (object.isPresent()) { Models.objectLiteral(m.getStatements(object.get(), SP.TEXT_PROPERTY, null)) .ifPresent(lit -> setMatcherQuery(lit.stringValue())); } } catch (ModelException e) { throw new SailConfigException(e.getMessage(), e); } }
Example 4
Source File: SHACLManifestTestSuiteFactory.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
private Literal getLiteral(Model model, Resource subject, String pred) { ValueFactory vf = SimpleValueFactory.getInstance(); Optional<Literal> optional = Models.objectLiteral(model.getStatements(subject, vf.createIRI(pred), null)); return optional.orElseThrow(Models.modelException("Missing " + subject + " " + pred)); }
Example 5
Source File: HBaseSailConfig.java From Halyard with Apache License 2.0 | 4 votes |
private static Optional<Literal> backCompatibilityFilterObjectLiteral(Model graph, Resource subject, IRI predicate) { Optional<Literal> value = Models.objectLiteral(graph.filter(subject, predicate, null)); return value.isPresent() ? value : Models.objectLiteral(graph.filter(subject, BACK_COMPATIBILITY_MAP.get(predicate), null)); }