org.apache.commons.rdf.api.Dataset.clear()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中org.apache.commons.rdf.api.Dataset.clear()方法的一些代码示例,展示了Dataset.clear()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dataset.clear()方法的具体详情如下:
包路径:org.apache.commons.rdf.api.Dataset
类名称:Dataset
方法名:clear

Dataset.clear介绍

[英]Clear the dataset, removing all quads.
[中]清除数据集,删除所有四边形。

代码示例

代码示例来源:origin: org.apache.commons/commons-rdf-api

@Test(expected = IllegalStateException.class)
public void clearNotSupported() throws Exception {
  dataset.clear();
}

代码示例来源:origin: org.apache.commons/commons-rdf-api

@Test
public void clear() throws Exception {
  dataset.clear();
  assertFalse(dataset.contains(null, alice, knows, bob));
  assertEquals(0, dataset.size());
  dataset.clear(); // no-op
  assertEquals(0, dataset.size());
  assertFalse(dataset.contains(null, null, null, null)); // nothing here
}

代码示例来源:origin: org.trellisldp/trellis-test

/**
 * Test replacing a resource.
 * @throws Exception if the operation failed
 */
@Test
@DisplayName("Test replacing resource")
default void testReplaceResource() throws Exception {
  final RDF rdf = getInstance();
  final IRI identifier = rdf.createIRI(TRELLIS_DATA_PREFIX + getResourceService().generateIdentifier());
  final Dataset dataset = buildDataset(identifier, "Replacement Test", SUBJECT2);
  assertEquals(MISSING_RESOURCE, getResourceService().get(identifier).toCompletableFuture().join(),
      "Check for no pre-existing LDP-RS");
  assertDoesNotThrow(() -> getResourceService().create(Metadata.builder(identifier)
        .interactionModel(LDP.RDFSource).container(ROOT_CONTAINER).build(), dataset)
      .toCompletableFuture().join(), "Check that the LDP-RS was successfully created");
  dataset.clear();
  dataset.add(Trellis.PreferUserManaged, identifier, SKOS.prefLabel, rdf.createLiteral("preferred label"));
  dataset.add(Trellis.PreferUserManaged, identifier, SKOS.altLabel, rdf.createLiteral("alternate label"));
  dataset.add(Trellis.PreferUserManaged, identifier, type, SKOS.Concept);
  assertDoesNotThrow(() -> getResourceService().replace(Metadata.builder(identifier)
        .interactionModel(LDP.RDFSource).container(ROOT_CONTAINER).build(), dataset)
      .toCompletableFuture().join(), "Check that the LDP-RS was successfully replaced");
  final Resource res = getResourceService().get(identifier).toCompletableFuture().join();
  assertAll("Check the replaced LDP-RS stream", res.stream(Trellis.PreferUserManaged)
      .map(toQuad(Trellis.PreferUserManaged))
      .map(q -> () -> assertTrue(dataset.contains(q), "Check that the quad comes from the dataset: " + q)));
  assertEquals(3L, res.stream(Trellis.PreferUserManaged).count(), "Check the total user-managed triple count");
}

代码示例来源:origin: trellis-ldp/trellis

/**
 * Test replacing a resource.
 * @throws Exception if the operation failed
 */
@Test
@DisplayName("Test replacing resource")
default void testReplaceResource() throws Exception {
  final RDF rdf = getInstance();
  final IRI identifier = rdf.createIRI(TRELLIS_DATA_PREFIX + getResourceService().generateIdentifier());
  final Dataset dataset = buildDataset(identifier, "Replacement Test", SUBJECT2);
  assertEquals(MISSING_RESOURCE, getResourceService().get(identifier).toCompletableFuture().join(),
      "Check for no pre-existing LDP-RS");
  assertDoesNotThrow(() -> getResourceService().create(Metadata.builder(identifier)
        .interactionModel(LDP.RDFSource).container(ROOT_CONTAINER).build(), dataset)
      .toCompletableFuture().join(), "Check that the LDP-RS was successfully created");
  dataset.clear();
  dataset.add(Trellis.PreferUserManaged, identifier, SKOS.prefLabel, rdf.createLiteral("preferred label"));
  dataset.add(Trellis.PreferUserManaged, identifier, SKOS.altLabel, rdf.createLiteral("alternate label"));
  dataset.add(Trellis.PreferUserManaged, identifier, type, SKOS.Concept);
  assertDoesNotThrow(() -> getResourceService().replace(Metadata.builder(identifier)
        .interactionModel(LDP.RDFSource).container(ROOT_CONTAINER).build(), dataset)
      .toCompletableFuture().join(), "Check that the LDP-RS was successfully replaced");
  final Resource res = getResourceService().get(identifier).toCompletableFuture().join();
  assertAll("Check the replaced LDP-RS stream", res.stream(Trellis.PreferUserManaged)
      .map(toQuad(Trellis.PreferUserManaged))
      .map(q -> () -> assertTrue(dataset.contains(q), "Check that the quad comes from the dataset: " + q)));
  assertEquals(3L, res.stream(Trellis.PreferUserManaged).count(), "Check the total user-managed triple count");
}

代码示例来源:origin: trellis-ldp/trellis

dataset.clear();
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);
dataset.add(Trellis.PreferUserManaged, child, DC.title, rdf.createLiteral("child"));
dataset.clear();
dataset.add(Trellis.PreferAudit, bnode, RDF.type, AS.Delete);
dataset.add(Trellis.PreferAudit, bnode, RDF.type, PROV.Activity);

代码示例来源:origin: trellis-ldp/trellis

dataset.clear();
dataset.add(Trellis.PreferUserManaged, members, DC.title, rdf.createLiteral("member resource"));
dataset.clear();
dataset.add(Trellis.PreferUserManaged, child, DC.title, rdf.createLiteral("ldp-dc child resource"));

代码示例来源:origin: trellis-ldp/trellis

dataset.clear();
dataset.add(Trellis.PreferUserManaged, child, DC.title, rdf.createLiteral("title"));
dataset.add(Trellis.PreferUserManaged, child, RDFS.label, rdf.createLiteral("label"));
dataset.clear();
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Update);
dataset.add(Trellis.PreferUserManaged, child, RDFS.seeAlso, rdf.createIRI("http://www.example.com/"));

代码示例来源:origin: trellis-ldp/trellis

dataset.clear();
dataset.add(Trellis.PreferUserManaged, resource3, DC.title, rdf.createLiteral("title"));
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);

代码示例来源:origin: trellis-ldp/trellis

dataset.clear();
dataset.add(Trellis.PreferAudit, bnode, RDF.type, AS.Create);
dataset.add(Trellis.PreferAudit, bnode, RDF.type, PROV.Activity);
dataset.clear();
dataset.add(Trellis.PreferUserManaged, child, SKOS.prefLabel, label);
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);

代码示例来源:origin: trellis-ldp/trellis

dataset.clear();
dataset.add(Trellis.PreferUserManaged, child, DC.title, rdf.createLiteral("ldp-dc (self) child resource"));

代码示例来源:origin: trellis-ldp/trellis

dataset.clear();
dataset.add(Trellis.PreferUserManaged, child, DC.title, rdf.createLiteral("child"));
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);
dataset.clear();
dataset.add(Trellis.PreferUserManaged, child, DC.description, rdf.createLiteral("a description"));
dataset.add(Trellis.PreferUserManaged, child, RDFS.label, rdf.createLiteral("other title"));

代码示例来源:origin: trellis-ldp/trellis

dataset.clear();
final BlankNode bnode2 = rdf.createBlankNode();
dataset.add(Trellis.PreferAudit, bnode2, RDF.type, AS.Create);
dataset.clear();
dataset.add(Trellis.PreferUserManaged, child, SKOS.prefLabel, label1);
dataset.add(Trellis.PreferUserManaged, child, SKOS.prefLabel, label2);

代码示例来源:origin: trellis-ldp/trellis

dataset.clear();
dataset.add(Trellis.PreferUserManaged, members, DC.title, rdf.createLiteral("Membership resource"));
dataset.add(Trellis.PreferAudit, members, PROV.wasGeneratedBy, bnode1);
dataset.clear();
dataset.add(Trellis.PreferUserManaged, child, SKOS.prefLabel, label);
dataset.add(Trellis.PreferAudit, child, PROV.wasGeneratedBy, bnode2);

代码示例来源:origin: trellis-ldp/trellis

svc.get(root).thenAccept(checkRoot(later, 1L)).toCompletableFuture()).join();
dataset.clear();
dataset.add(Trellis.PreferUserManaged, resource2, DC.title, rdf.createLiteral("Second LDP-DC"));
dataset.add(Trellis.PreferUserManaged, resource2, LDP.membershipResource, members);
dataset.clear();
dataset.add(Trellis.PreferUserManaged, members, DC.title, rdf.createLiteral("Membership resource"));
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);
dataset.clear();
dataset.add(Trellis.PreferUserManaged, child, DC.title, rdf.createLiteral("Child resource"));
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);
dataset.clear();
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);
dataset.add(Trellis.PreferUserManaged, child2, DC.title, rdf.createLiteral("Second child resource"));

代码示例来源:origin: trellis-ldp/trellis

svc.get(root).thenAccept(checkRoot(later, 1L)).toCompletableFuture()).join();
dataset.clear();
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);
dataset.add(Trellis.PreferUserManaged, resource2, DC.title, rdf.createLiteral("second LDP-DC"));
dataset.clear();
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);
dataset.add(Trellis.PreferUserManaged, members, DC.title, rdf.createLiteral("member resource"));
dataset.clear();
dataset.add(Trellis.PreferUserManaged, child, DC.title, rdf.createLiteral("ldp-dc (1) child resource"));
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);
dataset.clear();
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);
dataset.add(Trellis.PreferUserManaged, child2, DC.title, rdf.createLiteral("ldp-dc (2) child resource"));

代码示例来源:origin: trellis-ldp/trellis

svc.get(root).thenAccept(checkRoot(later, 1L)).toCompletableFuture()).join();
dataset.clear();
dataset.add(Trellis.PreferUserManaged, resource2, DC.title, rdf.createLiteral("Second LDP-IC"));
dataset.add(Trellis.PreferUserManaged, resource2, LDP.membershipResource, members);
dataset.clear();
dataset.add(Trellis.PreferUserManaged, members, DC.title, rdf.createLiteral("Shared member resource"));
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);
dataset.clear();
dataset.add(Trellis.PreferUserManaged, child, SKOS.prefLabel, label);
dataset.add(Trellis.PreferAudit, rdf.createBlankNode(), RDF.type, AS.Create);
dataset.clear();
dataset.add(Trellis.PreferUserManaged, child2, SKOS.prefLabel, label2);
dataset.add(Trellis.PreferAudit, child2, PROV.wasGeneratedBy, bnode2);

相关文章