本文整理了Java中org.apache.commons.rdf.api.RDF.createTriple
方法的一些代码示例,展示了RDF.createTriple
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RDF.createTriple
方法的具体详情如下:
包路径:org.apache.commons.rdf.api.RDF
类名称:RDF
方法名:createTriple
[英]Create a triple. The returned Triple SHOULD have a Triple#getSubject() that is equal to the provided subject, a Triple#getPredicate() that is equal to the provided predicate, and a Triple#getObject() that is equal to the provided object.
[中]创建一个三元组。返回的三元组应该有一个与提供的主语相等的三元组#getSubject(),一个与提供的谓词相等的三元组#getPredicate(),以及一个与提供的对象相等的三元组#getObject()。
代码示例来源:origin: eu.optique-project/r2rml-api-core
@Override
public Set<Triple> serialize() {
Set<Triple> stmtSet = new HashSet<Triple>();
stmtSet.add(getRDF().createTriple(node, getRDF().createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), getRDF().createIRI(R2RMLVocabulary.TYPE_REF_OBJECT_MAP)));
stmtSet.add(getRDF().createTriple(node, getRDF().createIRI(R2RMLVocabulary.PROP_PARENT_TRIPLES_MAP), parent.getNode()));
for (Join j : joinList) {
stmtSet.add(getRDF().createTriple(node, getRDF().createIRI(R2RMLVocabulary.PROP_JOIN_CONDITION), j.getNode()));
stmtSet.addAll(j.serialize());
}
return stmtSet;
}
代码示例来源:origin: eu.optique-project/r2rml-api-core
@Override
public Set<Triple> serialize() {
Set<Triple> stmtSet = new HashSet<Triple>();
stmtSet.add(getRDF().createTriple(node, getRDF().createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), getRDF().createIRI(R2RMLVocabulary.TYPE_JOIN)));
stmtSet.add(getRDF().createTriple(node, getRDF().createIRI(R2RMLVocabulary.PROP_CHILD),
getRDF().createLiteral(child)));
stmtSet.add(getRDF().createTriple(node, getRDF().createIRI(R2RMLVocabulary.PROP_PARENT),
getRDF().createLiteral(parent)));
return stmtSet;
}
代码示例来源:origin: eu.optique-project/r2rml-api-core
@Override
public Set<Triple> serialize() {
Set<Triple> stmtSet = new HashSet<>();
stmtSet.addAll(super.serialize());
stmtSet.add(getRDF().createTriple(getNode(),
getRDF().createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
getRDF().createIRI(R2RMLVocabulary.TYPE_PREDICATE_MAP)));
return stmtSet;
}
代码示例来源:origin: eu.optique-project/r2rml-api-core
@Override
public Set<Triple> serialize() {
Set<Triple> stmtSet = new HashSet<>();
stmtSet.addAll(super.serialize());
stmtSet.add(getRDF().createTriple(
getNode(),
getRDF().createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
getRDF().createIRI(R2RMLVocabulary.TYPE_GRAPH_MAP)));
return stmtSet;
}
代码示例来源:origin: eu.optique-project/r2rml-api-core
@Override
public Set<Triple> serialize() {
Set<Triple> stmtSet = new HashSet<Triple>();
stmtSet.add(getRDF().createTriple(node, getRDF().createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), getRDF().createIRI(R2RMLVocabulary.TYPE_BASE_TABLE_OR_VIEW)));
stmtSet.add(getRDF().createTriple(node, getRDF().createIRI(R2RMLVocabulary.PROP_TABLE_NAME),
getRDF().createLiteral(getTableName())));
return stmtSet;
}
代码示例来源:origin: eu.optique-project/r2rml-api-core
@Override
public Set<Triple> serialize() {
Set<Triple> stmtSet = new HashSet<>();
stmtSet.add(getRDF().createTriple(getNode(), getRDF().createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), getRDF().createIRI(R2RMLVocabulary.TYPE_R2RML_VIEW)));
stmtSet.add(getRDF().createTriple(getNode(), getRDF().createIRI(R2RMLVocabulary.PROP_SQL_QUERY),
getRDF().createLiteral(getSQLQuery())));
for (IRI version : versionList) {
stmtSet.add(getRDF().createTriple(getNode(), getRDF().createIRI(R2RMLVocabulary.PROP_SQL_VERSION), version));
}
return stmtSet;
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testEntity() {
final Triple triple = rdf.createTriple(identifier, RDFS.label, rdf.createLiteral("A label"));
when(mockTrellisRequest.getContentType()).thenReturn(APPLICATION_SPARQL_UPDATE);
when(mockResource.stream(eq(PreferUserManaged))).thenAnswer(x -> of(triple));
when(mockTrellisRequest.getPath()).thenReturn("resource");
final PatchHandler patchHandler = new PatchHandler(mockTrellisRequest, insert, mockBundler, null, null);
final Response res = patchHandler.updateResource(patchHandler.initialize(mockParent, mockResource))
.toCompletableFuture().join().build();
assertEquals(NO_CONTENT, res.getStatusInfo(), "Incorrect response code!");
verify(mockIoService).update(any(Graph.class), eq(insert), eq(SPARQL_UPDATE), eq(identifier.getIRIString()));
verify(mockResourceService).replace(any(Metadata.class), any(Dataset.class));
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testDeleteWithChildren() {
when(mockVersionedResource.getInteractionModel()).thenReturn(LDP.Container);
when(mockVersionedResource.stream(eq(LDP.PreferContainment))).thenAnswer(inv -> Stream.of(
rdf.createTriple(identifier, LDP.contains, rdf.createIRI(identifier.getIRIString() + "/child"))));
final Response res = target(RESOURCE_PATH).request().delete();
assertEquals(SC_NO_CONTENT, res.getStatus(), "Unexpected response code!");
}
代码示例来源:origin: trellis-ldp/trellis
/**
* Convert triples from a skolemized form to an externa form.
*
* @param svc the resourceService
* @param baseUrl the base URL
* @return a mapping function
*/
public static Function<Triple, Triple> unskolemizeTriples(final ResourceService svc, final String baseUrl) {
return triple -> rdf.createTriple((BlankNodeOrIRI) svc.toExternal(svc.unskolemize(triple.getSubject()),
baseUrl), triple.getPredicate(), svc.toExternal(svc.unskolemize(triple.getObject()), baseUrl));
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void hashCodeTriple() throws Exception {
final IRI iri = factory.createIRI("http://example.com/");
final Triple triple = factory.createTriple(iri, iri, iri);
assertEquals(Objects.hash(iri, iri, iri), triple.hashCode());
}
代码示例来源:origin: trellis-ldp/trellis
/**
* Convert triples from an external form to a skolemized form.
*
* @param svc the resourceService
* @param baseUrl the base URL
* @return a mapping function
*/
public static Function<Triple, Triple> skolemizeTriples(final ResourceService svc, final String baseUrl) {
return triple -> rdf.createTriple((BlankNodeOrIRI) svc.toInternal(svc.skolemize(triple.getSubject()), baseUrl),
triple.getPredicate(), svc.toInternal(svc.skolemize(triple.getObject()), baseUrl));
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test(expected = Exception.class)
public void testInvalidTriplePredicate() {
final BlankNode subject = factory.createBlankNode("b1");
final BlankNode predicate = factory.createBlankNode("b2");
final BlankNode object = factory.createBlankNode("b3");
factory.createTriple(subject, (IRI) predicate, object);
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testToQuad() {
final IRI subject = rdf.createIRI("http://example.com/resource");
final Literal object = rdf.createLiteral("title");
final Triple triple = rdf.createTriple(subject, DC.title, object);
final Quad quad = rdf.createQuad(Trellis.PreferUserManaged, subject, DC.title, object);
assertEquals(quad, toQuad(Trellis.PreferUserManaged).apply(triple), "Incorrect quad from triple!");
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void testCreateTripleBnodeIRI() {
final BlankNode subject = factory.createBlankNode("b1");
final IRI predicate = factory.createIRI("http://example.com/pred");
final IRI object = factory.createIRI("http://example.com/obj");
final Triple triple = factory.createTriple(subject, predicate, object);
// bnode equivalence should be OK as we used the same
// factory and have not yet inserted Triple into a Graph
assertEquals(subject, triple.getSubject());
assertEquals(predicate, triple.getPredicate());
assertEquals(object, triple.getObject());
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void testCreateTripleBnodeBnode() {
final BlankNode subject = factory.createBlankNode("b1");
final IRI predicate = factory.createIRI("http://example.com/pred");
final BlankNode object = factory.createBlankNode("b2");
final Triple triple = factory.createTriple(subject, predicate, object);
// bnode equivalence should be OK as we used the same
// factory and have not yet inserted Triple into a Graph
assertEquals(subject, triple.getSubject());
assertEquals(predicate, triple.getPredicate());
assertEquals(object, triple.getObject());
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void testCreateTripleBnodeTriple() {
final BlankNode subject = factory.createBlankNode();
final IRI predicate = factory.createIRI("http://example.com/pred");
final Literal object = factory.createLiteral("Example", "en");
final Triple triple = factory.createTriple(subject, predicate, object);
// bnode equivalence should be OK as we used the same
// factory and have not yet inserted Triple into a Graph
assertEquals(subject, triple.getSubject());
assertEquals(predicate, triple.getPredicate());
assertEquals(object, triple.getObject());
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testOrdinaryLabelledTriple() {
final Triple triple = rdf.createTriple(
rdf.createIRI("test:value"), DC.title, rdf.createLiteral("A title"));
final LabelledTriple t = new LabelledTriple(triple, "title", null);
assertEquals("title", t.getPredicateLabel(), "Predicate label doesn't match!");
assertEquals(DC.title.getIRIString(), t.getPredicate(), "Predicate value doesn't match!");
assertEquals("A title", t.getObjectLabel(), "Object label doesn't match!");
assertEquals("A title", t.getObject(), "Object value doesn't match!");
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testBnodes() {
final BlankNode bn1 = rdf.createBlankNode();
final BlankNode bn2 = rdf.createBlankNode();
final Triple triple = rdf.createTriple(bn1, DC.subject, bn2);
final LabelledTriple t = new LabelledTriple(triple, null, null);
assertEquals(bn1.ntriplesString(), t.getSubject(), "Subject bnode value doesn't match!");
assertEquals(bn2.ntriplesString(), t.getObject(), "Object bnode value doesn't match!");
assertEquals(bn2.ntriplesString(), t.getObjectLabel(), "Object bnode label doesn't match!");
}
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testOrdinaryLabelledTriple2() {
final Triple triple = rdf.createTriple(
rdf.createIRI("test:value"), DC.title, rdf.createLiteral("A title"));
final LabelledTriple t = new LabelledTriple(triple, null, null);
assertEquals(DC.title.getIRIString(), t.getPredicateLabel(), "Predicate label doesn't match!");
assertEquals(DC.title.getIRIString(), t.getPredicate(), "Predicate value doesn't match!");
assertEquals("A title", t.getObjectLabel(), "Object label doesn't match!");
assertEquals("A title", t.getObject(), "Object value doesn't match!");
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testOrdinaryLabelledTriple3() {
final Triple triple = rdf.createTriple(
rdf.createIRI("test:value"), DC.title, rdf.createLiteral("A title"));
final LabelledTriple t = new LabelledTriple(triple, null, null);
assertEquals("test:value", t.getSubject(), "Subject value doesn't match!");
assertEquals(DC.title.getIRIString(), t.getPredicateLabel(), "Predicate label doesn't match!");
assertEquals(DC.title.getIRIString(), t.getPredicate(), "Predicate value doesn't match!");
assertEquals("A title", t.getObjectLabel(), "Object label doesn't match!");
assertEquals("A title", t.getObject(), "Object value doesn't match!");
}
内容来源于网络,如有侵权,请联系作者删除!