本文整理汇总了Java中org.apache.commons.rdf.api.Triple类的典型用法代码示例。如果您正苦于以下问题:Java Triple类的具体用法?Java Triple怎么用?Java Triple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Triple类属于org.apache.commons.rdf.api包,在下文中一共展示了Triple类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkModelConstraints
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
private Function<Triple, Stream<ConstraintViolation>> checkModelConstraints(final IRI model, final String domain) {
requireNonNull(model, "The interaction model must not be null!");
return triple -> {
final Stream.Builder<ConstraintViolation> builder = Stream.builder();
of(triple).filter(propertyFilter(model)).map(t -> new ConstraintViolation(Trellis.InvalidProperty, t))
.ifPresent(builder::accept);
of(triple).filter(typeFilter).map(t -> new ConstraintViolation(Trellis.InvalidType, t))
.ifPresent(builder::accept);
of(triple).filter(uriRangeFilter).map(t -> new ConstraintViolation(Trellis.InvalidRange, t))
.ifPresent(builder::accept);
of(triple).filter(inDomainRangeFilter(domain)).map(t -> new ConstraintViolation(Trellis.InvalidRange, t))
.ifPresent(builder::accept);
return builder.build();
};
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:21,代码来源:LdpConstraints.java
示例2: testResourcePast
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Test
public void testResourcePast() {
final Instant time = parse("2017-02-15T11:00:00Z");
final Resource res = service.get(identifier, time).get();
assertEquals(identifier, res.getIdentifier());
assertEquals(LDP.Container, res.getInteractionModel());
assertFalse(res.getMembershipResource().isPresent());
assertFalse(res.getMemberRelation().isPresent());
assertFalse(res.getMemberOfRelation().isPresent());
assertFalse(res.getInsertedContentRelation().isPresent());
assertFalse(res.getBinary().isPresent());
assertTrue(res.isMemento());
assertEquals(parse("2017-02-15T10:05:00Z"), res.getModified());
assertEquals(0L, res.getExtraLinkRelations().count());
assertEquals(0L, res.stream().filter(TestUtils.isContainment.or(TestUtils.isMembership)).count());
final List<Triple> triples = res.stream().filter(TestUtils.isUserManaged)
.map(Quad::asTriple).collect(toList());
assertEquals(0L, triples.size());
final List<VersionRange> mementos = res.getMementos();
assertEquals(1L, mementos.size());
assertEquals(parse("2017-02-15T10:05:00Z"), mementos.get(0).getFrom());
assertEquals(parse("2017-02-15T11:15:00Z"), mementos.get(0).getUntil());
}
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:26,代码来源:FileResourceServiceTest.java
示例3: testUpdate
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Test
public void testUpdate() {
final Graph graph = rdf.createGraph();
getTriples().forEach(graph::add);
assertEquals(3L, graph.size());
service.update(graph, "DELETE WHERE { ?s <http://purl.org/dc/terms/title> ?o }", "test:info");
assertEquals(2L, graph.size());
service.update(graph, "INSERT { " +
"<> <http://purl.org/dc/terms/title> \"Other title\" } WHERE {}",
"trellis:repository/resource");
assertEquals(3L, graph.size());
service.update(graph, "DELETE WHERE { ?s ?p ?o };" +
"INSERT { <> <http://purl.org/dc/terms/title> \"Other title\" } WHERE {}",
"trellis:repository");
assertEquals(1L, graph.size());
assertEquals("<trellis:repository>", graph.stream().findFirst().map(Triple::getSubject)
.map(RDFTerm::ntriplesString).get());
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:19,代码来源:IOServiceTest.java
示例4: testResourcePast
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Test
public void testResourcePast() {
final Instant time = parse("2017-02-15T11:00:00Z");
final Resource res = VersionedResource.find(file, identifier, time).get();
assertEquals(identifier, res.getIdentifier());
assertEquals(LDP.BasicContainer, res.getInteractionModel());
assertFalse(res.getMembershipResource().isPresent());
assertFalse(res.getMemberRelation().isPresent());
assertFalse(res.getMemberOfRelation().isPresent());
assertFalse(res.getInsertedContentRelation().isPresent());
assertFalse(res.getBinary().isPresent());
assertTrue(res.isMemento());
assertEquals(parse("2017-02-15T10:05:00Z"), res.getModified());
assertEquals(0L, res.getExtraLinkRelations().count());
assertEquals(0L, res.stream().filter(TestUtils.isContainment.or(TestUtils.isMembership)).count());
final List<Triple> triples = res.stream().filter(TestUtils.isUserManaged).map(Quad::asTriple).collect(toList());
assertEquals(0L, triples.size());
final List<VersionRange> mementos = res.getMementos();
assertEquals(1L, mementos.size());
assertEquals(parse("2017-02-15T10:05:00Z"), mementos.get(0).getFrom());
assertEquals(parse("2017-02-15T11:15:00Z"), mementos.get(0).getUntil());
}
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:25,代码来源:LdpBasicContainerTest.java
示例5: checkCardinality
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
private static Predicate<Graph> checkCardinality(final IRI model) {
return graph -> {
final Map<IRI, Long> cardinality = graph.stream()
.filter(triple -> propertiesWithUriRange.contains(triple.getPredicate()))
.collect(groupingBy(Triple::getPredicate, counting()));
if (LDP.IndirectContainer.equals(model)) {
if (isNull(cardinality.get(LDP.insertedContentRelation)) || !hasMembershipProps(cardinality)) {
return true;
}
} else if (LDP.DirectContainer.equals(model) && !hasMembershipProps(cardinality)) {
return true;
}
return cardinality.entrySet().stream().map(Map.Entry::getValue).anyMatch(val -> val > 1);
};
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:18,代码来源:LdpConstraints.java
示例6: updateGraph
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
private List<Triple> updateGraph(final Resource res, final IRI graphName) {
final List<Triple> triples;
// Update existing graph
try (final TrellisGraph graph = TrellisGraph.createGraph()) {
try (final Stream<? extends Triple> stream = res.stream(graphName)) {
stream.forEachOrdered(graph::add);
}
ioService.update(graph.asGraph(), sparqlUpdate, TRELLIS_PREFIX + req.getPath() +
(ACL.equals(req.getExt()) ? "?ext=acl" : ""));
triples = graph.stream().collect(toList());
} catch (final RuntimeTrellisException ex) {
LOGGER.warn(ex.getMessage());
throw new BadRequestException("Invalid RDF: " + ex.getMessage());
}
return triples;
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:18,代码来源:PatchHandler.java
示例7: testEntity
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Test
public void testEntity() {
final Triple triple = rdf.createTriple(identifier, RDFS.label, rdf.createLiteral("A label"));
when(mockResource.stream(eq(Trellis.PreferUserManaged))).thenAnswer(x -> of(triple));
when(mockLdpRequest.getPath()).thenReturn("resource");
final PatchHandler patchHandler = new PatchHandler(mockLdpRequest, insert,
mockResourceService, mockIoService, null);
final Response res = patchHandler.updateResource(mockResource).build();
assertEquals(NO_CONTENT, res.getStatusInfo());
verify(mockIoService).update(any(Graph.class), eq(insert), eq(identifier.getIRIString()));
verify(mockResourceService).put(eq(identifier), eq(LDP.RDFSource), any(Dataset.class));
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:18,代码来源:PatchHandlerTest.java
示例8: testResourcePast
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Test
public void testResourcePast() {
final Instant time = parse("2017-02-15T11:00:00Z");
final Resource res = VersionedResource.find(file, identifier, time).get();
assertEquals(identifier, res.getIdentifier());
assertFalse(res.hasAcl());
assertEquals(LDP.Container, res.getInteractionModel());
assertFalse(res.getMembershipResource().isPresent());
assertFalse(res.getMemberRelation().isPresent());
assertFalse(res.getMemberOfRelation().isPresent());
assertFalse(res.getInsertedContentRelation().isPresent());
assertFalse(res.getBinary().isPresent());
assertTrue(res.isMemento());
assertEquals(parse("2017-02-15T10:05:00Z"), res.getModified());
assertEquals(0L, res.getExtraLinkRelations().count());
assertEquals(0L, res.stream().filter(TestUtils.isContainment.or(TestUtils.isMembership)).count());
final List<Triple> triples = res.stream().filter(TestUtils.isUserManaged).map(Quad::asTriple).collect(toList());
assertEquals(0L, triples.size());
final List<VersionRange> mementos = res.getMementos();
assertEquals(1L, mementos.size());
assertEquals(parse("2017-02-15T10:05:00Z"), mementos.get(0).getFrom());
assertEquals(parse("2017-02-15T11:15:00Z"), mementos.get(0).getUntil());
}
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:26,代码来源:LdpContainerTest.java
示例9: scan
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Override
public Stream<Triple> scan(final String partition) {
if (partitionData.containsKey(partition)) {
try {
return walk(new File(partitionData.get(partition)).toPath(), FileUtils.MAX + 2)
.filter(p -> p.endsWith(RESOURCE_CACHE)).map(Path::getParent).map(Path::toFile)
.map(CachedResource::read)
// TODO - JDK9 optional to stream
.flatMap(res -> res.map(Stream::of).orElseGet(Stream::empty)).map(data ->
rdf.createTriple(rdf.createIRI(data.getId()), RDF.type, rdf.createIRI(data.getLdpType())));
} catch (final IOException ex) {
LOGGER.error("Error reading partition root: {}", ex.getMessage());
}
}
return empty();
}
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:17,代码来源:FileResourceService.java
示例10: testResourcePast
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Test
public void testResourcePast() {
final Instant time = parse("2017-02-15T11:00:00Z");
final Resource res = VersionedResource.find(file, identifier, time).get();
assertEquals(identifier, res.getIdentifier());
assertEquals(LDP.RDFSource, res.getInteractionModel());
assertFalse(res.getMembershipResource().isPresent());
assertFalse(res.getMemberRelation().isPresent());
assertFalse(res.getMemberOfRelation().isPresent());
assertFalse(res.getInsertedContentRelation().isPresent());
assertFalse(res.getBinary().isPresent());
assertTrue(res.isMemento());
assertFalse(res.hasAcl());
assertFalse(res.getInbox().isPresent());
assertEquals(parse("2017-02-15T10:05:00Z"), res.getModified());
assertEquals(0L, res.getTypes().size());
assertEquals(0L, res.stream().filter(TestUtils.isContainment.or(TestUtils.isMembership)).count());
final List<Triple> triples = res.stream().filter(TestUtils.isUserManaged).map(Quad::asTriple).collect(toList());
assertEquals(0L, triples.size());
final List<VersionRange> mementos = res.getMementos();
assertEquals(1L, mementos.size());
assertEquals(parse("2017-02-15T10:05:00Z"), mementos.get(0).getFrom());
assertEquals(parse("2017-02-15T11:15:00Z"), mementos.get(0).getUntil());
}
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:27,代码来源:LdpRdfTest.java
示例11: testResourcePast
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Test
public void testResourcePast() {
final Instant time = parse("2017-02-15T11:00:00Z");
final Resource res = VersionedResource.find(file, identifier, time).get();
assertEquals(identifier, res.getIdentifier());
assertEquals(LDP.DirectContainer, res.getInteractionModel());
assertFalse(res.getMembershipResource().isPresent());
assertFalse(res.getMemberRelation().isPresent());
assertFalse(res.getMemberOfRelation().isPresent());
assertEquals(of(LDP.MemberSubject), res.getInsertedContentRelation());
assertFalse(res.getBinary().isPresent());
assertTrue(res.isMemento());
assertFalse(res.getInbox().isPresent());
assertEquals(parse("2017-02-15T10:05:00Z"), res.getModified());
assertEquals(0L, res.getTypes().size());
assertEquals(0L, res.stream().filter(TestUtils.isContainment.or(TestUtils.isMembership)).count());
final List<Triple> triples = res.stream().filter(TestUtils.isUserManaged).map(Quad::asTriple).collect(toList());
assertEquals(0L, triples.size());
final List<VersionRange> mementos = res.getMementos();
assertEquals(2L, mementos.size());
assertEquals(parse("2017-02-15T10:05:00Z"), mementos.get(0).getFrom());
assertEquals(parse("2017-02-15T11:15:00Z"), mementos.get(0).getUntil());
}
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:26,代码来源:LdpDirectContainerTest.java
示例12: testResourcePast
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Test
public void testResourcePast() {
final Instant time = parse("2017-02-15T11:00:00Z");
final Resource res = VersionedResource.find(file, identifier, time).get();
assertEquals(identifier, res.getIdentifier());
assertEquals(LDP.BasicContainer, res.getInteractionModel());
assertFalse(res.getMembershipResource().isPresent());
assertFalse(res.getMemberRelation().isPresent());
assertFalse(res.getMemberOfRelation().isPresent());
assertFalse(res.getInsertedContentRelation().isPresent());
assertFalse(res.getBinary().isPresent());
assertTrue(res.isMemento());
assertFalse(res.getInbox().isPresent());
assertEquals(parse("2017-02-15T10:05:00Z"), res.getModified());
assertEquals(0L, res.getTypes().size());
assertEquals(0L, res.stream().filter(TestUtils.isContainment.or(TestUtils.isMembership)).count());
final List<Triple> triples = res.stream().filter(TestUtils.isUserManaged).map(Quad::asTriple).collect(toList());
assertEquals(0L, triples.size());
final List<VersionRange> mementos = res.getMementos();
assertEquals(1L, mementos.size());
assertEquals(parse("2017-02-15T10:05:00Z"), mementos.get(0).getFrom());
assertEquals(parse("2017-02-15T11:15:00Z"), mementos.get(0).getUntil());
}
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:26,代码来源:LdpBasicContainerTest.java
示例13: testResourcePast
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Test
public void testResourcePast() {
final Instant time = parse("2017-02-15T11:00:00Z");
final Resource res = VersionedResource.find(file, identifier, time).get();
assertEquals(identifier, res.getIdentifier());
assertFalse(res.hasAcl());
assertEquals(LDP.Container, res.getInteractionModel());
assertFalse(res.getMembershipResource().isPresent());
assertFalse(res.getMemberRelation().isPresent());
assertFalse(res.getMemberOfRelation().isPresent());
assertFalse(res.getInsertedContentRelation().isPresent());
assertFalse(res.getBinary().isPresent());
assertTrue(res.isMemento());
assertFalse(res.getInbox().isPresent());
assertEquals(parse("2017-02-15T10:05:00Z"), res.getModified());
assertEquals(0L, res.getTypes().size());
assertEquals(0L, res.stream().filter(TestUtils.isContainment.or(TestUtils.isMembership)).count());
final List<Triple> triples = res.stream().filter(TestUtils.isUserManaged).map(Quad::asTriple).collect(toList());
assertEquals(0L, triples.size());
final List<VersionRange> mementos = res.getMementos();
assertEquals(1L, mementos.size());
assertEquals(parse("2017-02-15T10:05:00Z"), mementos.get(0).getFrom());
assertEquals(parse("2017-02-15T11:15:00Z"), mementos.get(0).getUntil());
}
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:27,代码来源:LdpContainerTest.java
示例14: testCacheWriter2
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Test
public void testCacheWriter2() throws IOException {
CachedResource.write(directory4, identifier.getIRIString());
final Optional<Resource> resource = CachedResource.find(directory4, identifier);
assertTrue(resource.isPresent());
resource.ifPresent(res -> {
assertEquals(identifier, res.getIdentifier());
assertEquals(LDP.RDFSource, res.getInteractionModel());
assertFalse(res.getMembershipResource().isPresent());
assertFalse(res.getMemberRelation().isPresent());
assertFalse(res.getMemberOfRelation().isPresent());
assertFalse(res.getInsertedContentRelation().isPresent());
assertFalse(res.getBinary().isPresent());
assertFalse(res.isMemento());
assertEquals(0L, res.getExtraLinkRelations().count());
assertEquals(parse("2017-02-15T10:05:00Z"), res.getModified());
assertEquals(0L, res.stream().filter(TestUtils.isContainment.or(TestUtils.isMembership)).count());
final List<Triple> triples = res.stream().filter(TestUtils.isUserManaged).map(Quad::asTriple)
.collect(toList());
assertEquals(0L, triples.size());
final List<VersionRange> mementos = res.getMementos();
assertEquals(0L, mementos.size());
});
}
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:27,代码来源:ResourceWriterTest.java
示例15: write
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@Override
public void write(final Stream<? extends Triple> triples, final OutputStream output, final RDFSyntax syntax,
final IRI... profiles) {
requireNonNull(triples, "The triples stream may not be null!");
requireNonNull(output, "The output stream may not be null!");
requireNonNull(syntax, "The RDF syntax value may not be null!");
try {
if (RDFA.equals(syntax)) {
htmlSerializer.write(output, triples, profiles.length > 0 ? profiles[0] : null);
} else {
final Lang lang = rdf.asJenaLang(syntax).orElseThrow(() ->
new RuntimeTrellisException("Invalid content type: " + syntax.mediaType()));
final RDFFormat format = defaultSerialization(lang);
if (nonNull(format)) {
LOGGER.debug("Writing stream-based RDF: {}", format);
final StreamRDF stream = getWriterStream(output, format);
stream.start();
ofNullable(nsService).ifPresent(svc -> svc.getNamespaces().forEach(stream::prefix));
triples.map(rdf::asJenaTriple).forEachOrdered(stream::triple);
stream.finish();
} else {
LOGGER.debug("Writing buffered RDF: {}", lang);
final org.apache.jena.graph.Graph graph = createDefaultGraph();
ofNullable(nsService).map(NamespaceService::getNamespaces)
.ifPresent(graph.getPrefixMapping()::setNsPrefixes);
triples.map(rdf::asJenaTriple).forEachOrdered(graph::add);
if (JSONLD.equals(lang)) {
writeJsonLd(output, DatasetGraphFactory.create(graph), profiles);
} else {
RDFDataMgr.write(output, graph, lang);
}
}
}
} catch (final AtlasException ex) {
throw new RuntimeTrellisException(ex);
}
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:41,代码来源:JenaIOService.java
示例16: getTitle
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
/**
* Get the title.
*
* @return a title for the resource
*/
public String getTitle() {
final Map<IRI, List<String>> titles = triples.stream()
.filter(triple -> titleCandidates.contains(triple.getPredicate()))
.filter(triple -> triple.getObject() instanceof Literal)
.collect(groupingBy(Triple::getPredicate, mapping(triple ->
((Literal) triple.getObject()).getLexicalForm(), toList())));
return titleCandidates.stream().filter(titles::containsKey)
.map(titles::get).flatMap(List::stream).findFirst()
.orElseGet(this::getSubject);
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:16,代码来源:HtmlData.java
示例17: getTriples
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
private static Stream<Triple> getTriples() {
final Node sub = createURI("trellis:repository/resource");
return of(
create(sub, title.asNode(), createLiteral("A title")),
create(sub, spatial.asNode(), createURI("http://sws.geonames.org/4929022/")),
create(sub, type, Text.asNode()))
.map(rdf::asTriple);
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:9,代码来源:IOServiceTest.java
示例18: getComplexTriples
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
private static Stream<Triple> getComplexTriples() {
final Node sub = createURI("trellis:repository/resource");
final Node bn = createBlankNode();
return of(
create(sub, title.asNode(), createLiteral("A title")),
create(sub, subject.asNode(), bn),
create(bn, title.asNode(), createLiteral("Other title")),
create(sub, spatial.asNode(), createURI("http://sws.geonames.org/4929022/")),
create(sub, type, Text.asNode()))
.map(rdf::asTriple);
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:13,代码来源:IOServiceTest.java
示例19: testOrdinaryLabelledTriple
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@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());
assertEquals(DC.title.getIRIString(), t.getPredicate());
assertEquals("A title", t.getObjectLabel());
assertEquals("A title", t.getObject());
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:11,代码来源:LabelledTripleTest.java
示例20: testOrdinaryLabelledTriple3
import org.apache.commons.rdf.api.Triple; //导入依赖的package包/类
@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());
assertEquals(DC.title.getIRIString(), t.getPredicateLabel());
assertEquals(DC.title.getIRIString(), t.getPredicate());
assertEquals("A title", t.getObjectLabel());
assertEquals("A title", t.getObject());
}
开发者ID:trellis-ldp,项目名称:trellis,代码行数:12,代码来源:LabelledTripleTest.java
注:本文中的org.apache.commons.rdf.api.Triple类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论