use of org.eclipse.rdf4j.model.Resource in project rdf4j by eclipse.
the class ModelsTest method testSubjectURI.
public void testSubjectURI() {
model1.add(foo, bar, foo);
model1.add(foo, foo, foo);
model1.add(baz, foo, foo);
model1.add(bar, foo, foo);
Resource result = Models.subjectIRI(model1).orElse(null);
assertNotNull(result);
assertTrue(result.equals(bar) || result.equals(foo));
}
use of org.eclipse.rdf4j.model.Resource in project rdf4j by eclipse.
the class ModelsTest method testSubject.
public void testSubject() {
model1.add(foo, bar, foo);
model1.add(foo, foo, foo);
model1.add(bar, foo, foo);
model1.add(baz, foo, foo);
Resource result = Models.subject(model1).orElse(null);
assertNotNull(result);
assertTrue(result.equals(bar) || result.equals(foo) || result.equals(baz));
}
use of org.eclipse.rdf4j.model.Resource in project rdf4j by eclipse.
the class StatementsTest method testMultipleContexts.
@Test
public void testMultipleContexts() {
Resource c1 = vf.createIRI("urn:c1");
Resource c2 = vf.createIRI("urn:c1");
Resource c3 = vf.createIRI("urn:c1");
Model m = Statements.create(vf, FOAF.AGE, RDF.TYPE, RDF.PROPERTY, new TreeModel(), c1, c2, null, c3);
assertFalse(m.isEmpty());
assertTrue(m.contains(FOAF.AGE, RDF.TYPE, RDF.PROPERTY, (Resource) null));
assertTrue(m.contains(FOAF.AGE, RDF.TYPE, RDF.PROPERTY, c1));
assertTrue(m.contains(FOAF.AGE, RDF.TYPE, RDF.PROPERTY, c2));
assertTrue(m.contains(FOAF.AGE, RDF.TYPE, RDF.PROPERTY, c3));
}
use of org.eclipse.rdf4j.model.Resource in project rdf4j by eclipse.
the class RDFCollectionsTest method testRemove.
@Test
public void testRemove() {
Resource head = vf.createBNode();
Model m = RDFCollections.asRDF(values, head, new TreeModel());
// add something to the model that is not part of the RDF collection.
m.add(RDF.TYPE, RDF.TYPE, RDF.PROPERTY);
// remove the entire collection
RDFCollections.extract(m, head, st -> m.remove(st));
assertFalse(m.contains(null, RDF.FIRST, a));
assertFalse(m.contains(null, RDF.FIRST, b));
assertFalse(m.contains(null, RDF.FIRST, c));
assertFalse(m.contains(head, null, null));
assertTrue(m.contains(RDF.TYPE, RDF.TYPE, RDF.PROPERTY));
}
use of org.eclipse.rdf4j.model.Resource in project rdf4j by eclipse.
the class RepositoryConfigUtil method updateRepositoryConfigs.
/**
* Update the specified RepositoryConnection with the specified set of RepositoryConfigs. This will
* overwrite all existing configurations in the Repository that have a Repository ID occurring in these
* RepositoryConfigs. Note: this method does NOT commit the updates on the connection.
*
* @param con
* the repository connection to perform the update on
* @param configs
* The RepositoryConfigs that should be added to or updated in the Repository. The
* RepositoryConfig's ID may already occur in the Repository, in which case all previous
* configuration data for that Repository will be cleared before the RepositoryConfig is added.
* @throws RepositoryException
* @throws RepositoryConfigException
*/
@Deprecated
public static void updateRepositoryConfigs(RepositoryConnection con, RepositoryConfig... configs) throws RepositoryException, RepositoryConfigException {
ValueFactory vf = con.getRepository().getValueFactory();
con.begin();
for (RepositoryConfig config : configs) {
Resource context = getContext(con, config.getID());
if (context != null) {
con.clear(context);
} else {
context = vf.createBNode();
}
con.add(context, RDF.TYPE, REPOSITORY_CONTEXT);
Model graph = new LinkedHashModel();
config.export(graph);
con.add(graph, context);
}
con.commit();
}
Aggregations