use of org.eclipse.rdf4j.model.Resource in project rdf4j by eclipse.
the class RepositoryConfigUtil method getRepositoryConfig.
public static RepositoryConfig getRepositoryConfig(Model model, String repositoryID) {
Statement idStatement = getIDStatement(model, repositoryID);
if (idStatement == null) {
// No such config
return null;
}
Resource repositoryNode = idStatement.getSubject();
Resource context = idStatement.getContext();
Model contextGraph = model.filter(null, null, null, context);
return RepositoryConfig.create(contextGraph, repositoryNode);
}
use of org.eclipse.rdf4j.model.Resource in project rdf4j by eclipse.
the class RepositoryConfigUtil method getContext.
@Deprecated
public static Resource getContext(RepositoryConnection con, String repositoryID) throws RepositoryException, RepositoryConfigException {
Resource context = null;
Statement idStatement = getIDStatement(con, repositoryID);
if (idStatement != null) {
context = idStatement.getContext();
}
return context;
}
use of org.eclipse.rdf4j.model.Resource in project rdf4j by eclipse.
the class RDFXMLPrettyWriterTest method sequenceItemsAreAbbreviated.
@Test
public void sequenceItemsAreAbbreviated() throws RDFHandlerException, IOException {
StringWriter writer = new StringWriter();
RDFWriter rdfWriter = rdfWriterFactory.getWriter(writer);
rdfWriter.startRDF();
Resource res = vf.createIRI("http://example.com/#");
rdfWriter.handleStatement(vf.createStatement(res, RDF.TYPE, RDF.BAG));
rdfWriter.handleStatement(vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_1"), vf.createIRI("http://example.com/#1")));
rdfWriter.handleStatement(vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_2"), vf.createIRI("http://example.com/#2")));
rdfWriter.endRDF();
List<String> rdfLines = rdfOpenTags(writer.toString());
assertEquals(Arrays.asList("<rdf:RDF", "<rdf:Bag", "<rdf:li", "<rdf:li"), rdfLines);
}
use of org.eclipse.rdf4j.model.Resource in project rdf4j by eclipse.
the class RDFXMLPrettyWriterTest method outOfSequenceItemsAreNotAbbreviated.
@Test
public void outOfSequenceItemsAreNotAbbreviated() throws RDFHandlerException, IOException {
StringWriter writer = new StringWriter();
RDFWriter rdfWriter = rdfWriterFactory.getWriter(writer);
rdfWriter.startRDF();
Resource res = vf.createIRI("http://example.com/#");
rdfWriter.handleStatement(vf.createStatement(res, RDF.TYPE, RDF.BAG));
rdfWriter.handleStatement(vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_0"), vf.createIRI("http://example.com/#0")));
rdfWriter.handleStatement(vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_2"), vf.createIRI("http://example.com/#2")));
rdfWriter.endRDF();
List<String> rdfLines = rdfOpenTags(writer.toString());
assertEquals(Arrays.asList("<rdf:RDF", "<rdf:Bag", "<rdf:_0", "<rdf:_2"), rdfLines);
}
use of org.eclipse.rdf4j.model.Resource in project rdf4j by eclipse.
the class Models method findMatchingStatements.
private static List<Statement> findMatchingStatements(Statement st, Model model, Map<Resource, Resource> bNodeMapping) {
Resource s = isBlank(st.getSubject()) ? null : st.getSubject();
IRI p = st.getPredicate();
Value o = isBlank(st.getObject()) ? null : st.getObject();
Resource[] g = isBlank(st.getContext()) ? new Resource[0] : new Resource[] { st.getContext() };
List<Statement> result = new ArrayList<Statement>();
for (Statement modelSt : model.filter(s, p, o, g)) {
if (statementsMatch(st, modelSt, bNodeMapping)) {
// All components possibly match
result.add(modelSt);
}
}
return result;
}
Aggregations