org.vertexium.Graph.prepareVertex()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(151)

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

Graph.prepareVertex介绍

[英]Prepare a vertex to be added to the graph. This method provides a way to build up a vertex with it's properties to be inserted with a single operation. The id of the new vertex will be generated using an IdGenerator.
[中]准备要添加到图形的顶点。此方法提供了一种通过单个操作插入顶点的属性来构建顶点的方法。新顶点的id将使用IdGenerator生成。

代码示例

代码示例来源:origin: org.visallo/visallo-model-vertexium

private VertexBuilder prepareVertex(String prefix, String iri, String workspaceId, Visibility visibility, VisibilityJson visibilityJson) {
  if (isPublic(workspaceId)) {
    return graph.prepareVertex(prefix + iri, visibility);
  }
  String id = prefix + Hashing.sha1().hashString(workspaceId + iri, Charsets.UTF_8).toString();
  visibilityJson.addWorkspace(workspaceId);
  return graph.prepareVertex(id, visibilityTranslator.toVisibility(visibilityJson).getVisibility());
}

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

@Test
public void testNullPropertyValue() {
  try {
    graph.prepareVertex("v1", VISIBILITY_EMPTY)
        .setProperty("prop1", null, VISIBILITY_A)
        .save(AUTHORIZATIONS_A_AND_B);
    throw new VertexiumException("expected null check");
  } catch (NullPointerException ex) {
    assertTrue(ex.getMessage().contains("prop1"));
  }
}

代码示例来源:origin: visallo/vertexium

@Test
public void testNullPropertyValue() {
  try {
    graph.prepareVertex("v1", VISIBILITY_EMPTY)
        .setProperty("prop1", null, VISIBILITY_A)
        .save(AUTHORIZATIONS_A_AND_B);
    throw new VertexiumException("expected null check");
  } catch (NullPointerException ex) {
    assertTrue(ex.getMessage().contains("prop1"));
  }
}

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

@Test
public void testLargeFieldValuesThatAreMarkedWithExactMatch() {
  graph.defineProperty("field1").dataType(String.class).textIndexHint(TextIndexHint.EXACT_MATCH).define();
  StringBuilder largeText = new StringBuilder();
  for (int i = 0; i < 10000; i++) {
    largeText.append("test ");
  }
  graph.prepareVertex("v1", VISIBILITY_EMPTY)
      .addPropertyValue("", "field1", largeText.toString(), VISIBILITY_EMPTY)
      .save(AUTHORIZATIONS_EMPTY);
  graph.flush();
}

代码示例来源:origin: visallo/vertexium

@Test
public void testLargeFieldValuesThatAreMarkedWithExactMatch() {
  graph.defineProperty("field1").dataType(String.class).textIndexHint(TextIndexHint.EXACT_MATCH).define();
  StringBuilder largeText = new StringBuilder();
  for (int i = 0; i < 10000; i++) {
    largeText.append("test ");
  }
  graph.prepareVertex("v1", VISIBILITY_EMPTY)
      .addPropertyValue("", "field1", largeText.toString(), VISIBILITY_EMPTY)
      .save(AUTHORIZATIONS_EMPTY);
  graph.flush();
}

代码示例来源:origin: org.vertexium/vertexium-cypher

private Vertex executeCreateVertex(
    VertexiumCypherQueryContext ctx,
    CypherNodePattern nodePattern,
    VertexiumCypherScope.Item item
) {
  String vertexId = ctx.calculateVertexId(nodePattern, item);
  Visibility vertexVisibility = ctx.calculateVertexVisibility(nodePattern, item);
  VertexBuilder m = ctx.getGraph().prepareVertex(vertexId, vertexVisibility);
  updateVertex(ctx, m, nodePattern, item);
  return ctx.saveVertex(m);
}

代码示例来源:origin: visallo/vertexium

private Vertex executeCreateVertex(
    VertexiumCypherQueryContext ctx,
    CypherNodePattern nodePattern,
    VertexiumCypherScope.Item item
) {
  String vertexId = ctx.calculateVertexId(nodePattern, item);
  Visibility vertexVisibility = ctx.calculateVertexVisibility(nodePattern, item);
  VertexBuilder m = ctx.getGraph().prepareVertex(vertexId, vertexVisibility);
  updateVertex(ctx, m, nodePattern, item);
  return ctx.saveVertex(m);
}

代码示例来源:origin: visallo/vertexium

@Test
public void testPropertyWithValueSeparator() {
  try {
    graph.prepareVertex("v1", VISIBILITY_EMPTY)
        .addPropertyValue("prop1" + VALUE_SEPARATOR, "name1", "test", VISIBILITY_EMPTY)
        .save(AUTHORIZATIONS_EMPTY);
    throw new RuntimeException("Should have thrown a bad character exception");
  } catch (VertexiumInvalidKeyException ex) {
    // ok
  }
}

代码示例来源:origin: org.visallo/visallo-common-rdf

@Override
  public ImportContext createImportContext(
      ImportContext ctx,
      RdfTripleImportHelper rdfTripleImportHelper,
      Authorizations authorizations
  ) {
    Visibility elementVisibility = rdfTripleImportHelper.getVisibility(getElementVisibilitySource());
    VertexBuilder m = rdfTripleImportHelper.getGraph().prepareVertex(getElementId(), elementVisibility);
    return new ImportContext(getElementId(), m);
  }
}

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

@Test
public void testGraphQueryVertexHasWithSecurityCantSeeProperty() {
  graph.prepareVertex("v1", VISIBILITY_A)
      .setProperty("age", 25, VISIBILITY_B)
      .save(AUTHORIZATIONS_A_AND_B);
  Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A)
      .has("age", Compare.EQUAL, 25)
      .vertices();
  Assert.assertEquals(0, count(vertices));
}

代码示例来源:origin: visallo/vertexium

@Test
public void testGraphQueryVertexHasWithSecurityCantSeeProperty() {
  graph.prepareVertex("v1", VISIBILITY_A)
      .setProperty("age", 25, VISIBILITY_B)
      .save(AUTHORIZATIONS_A_AND_B);
  Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A)
      .has("age", Compare.EQUAL, 25)
      .vertices();
  Assert.assertEquals(0, count(vertices));
}

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

@Test
public void testExtendedDataQueryAfterDeleteForVertex() {
  graph.prepareVertex("v1", VISIBILITY_A)
      .addExtendedData("table1", "row1", "name", "value 1", VISIBILITY_A)
      .addExtendedData("table1", "row2", "name", "value 2", VISIBILITY_A)
      .save(AUTHORIZATIONS_A);
  graph.flush();
  List<ExtendedDataRow> searchResultsList = toList(graph.query(AUTHORIZATIONS_A).extendedDataRows());
  assertRowIdsAnyOrder(Lists.newArrayList("row1", "row2"), searchResultsList);
  graph.deleteVertex("v1", AUTHORIZATIONS_A);
  graph.flush();
  searchResultsList = toList(graph.query(AUTHORIZATIONS_A).extendedDataRows());
  assertRowIdsAnyOrder(Lists.newArrayList(), searchResultsList);
}

代码示例来源:origin: visallo/vertexium

@Test
public void testExtendedDataDelete() {
  graph.prepareVertex("v1", VISIBILITY_A)
      .addExtendedData("table1", "row1", "name", "value", VISIBILITY_A)
      .save(AUTHORIZATIONS_A);
  graph.flush();
  graph.deleteVertex("v1", AUTHORIZATIONS_A);
  graph.flush();
  QueryResultsIterable<? extends VertexiumObject> searchResults = graph.query("value", AUTHORIZATIONS_A)
      .search();
  assertEquals(0, searchResults.getTotalHits());
}

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

@Test
public void testExtendedDataDelete() {
  graph.prepareVertex("v1", VISIBILITY_A)
      .addExtendedData("table1", "row1", "name", "value", VISIBILITY_A)
      .save(AUTHORIZATIONS_A);
  graph.flush();
  graph.deleteVertex("v1", AUTHORIZATIONS_A);
  graph.flush();
  QueryResultsIterable<? extends VertexiumObject> searchResults = graph.query("value", AUTHORIZATIONS_A)
      .search();
  assertEquals(0, searchResults.getTotalHits());
}

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

@Test
public void testAddVertexWithoutIndexing() {
  assumeTrue("add vertex without indexing not supported", !isDefaultSearchIndex());
  graph.prepareVertex("v1", VISIBILITY_A)
      .setProperty("prop1", "value1", VISIBILITY_A)
      .setIndexHint(IndexHint.DO_NOT_INDEX)
      .save(AUTHORIZATIONS_A);
  graph.flush();
  Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A_AND_B)
      .has("prop1", "value1")
      .vertices();
  assertVertexIds(vertices);
}

代码示例来源:origin: org.visallo/visallo-gpw-tika-text-extractor

private void createVertex(String data, String mimeType) throws UnsupportedEncodingException {
  VertexBuilder v = getGraph().prepareVertex("v1", visibility);
  StreamingPropertyValue textValue = new StreamingPropertyValue(new ByteArrayInputStream(data.getBytes("UTF-8")), byte[].class);
  textValue.searchIndex(false);
  Metadata metadata = new Metadata();
  metadata.add(VisalloProperties.MIME_TYPE.getPropertyName(), mimeType, getVisibilityTranslator().getDefaultVisibility());
  VisalloProperties.RAW.setProperty(v, textValue, metadata, visibility);
  v.save(getGraphAuthorizations());
}

代码示例来源:origin: visallo/vertexium

@Test
public void testStreamingPropertyValueReadAsString() {
  graph.prepareVertex("v1", VISIBILITY_EMPTY)
      .setProperty("spv", StreamingPropertyValue.create("Hello World"), VISIBILITY_EMPTY)
      .save(AUTHORIZATIONS_EMPTY);
  graph.flush();
  Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_EMPTY);
  assertEquals("Hello World", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString());
  assertEquals("Wor", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString(6, 3));
  assertEquals("", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString("Hello World".length(), 1));
  assertEquals("Hello World", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString(0, 100));
}

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

@Test
public void testStreamingPropertyValueReadAsString() {
  graph.prepareVertex("v1", VISIBILITY_EMPTY)
      .setProperty("spv", StreamingPropertyValue.create("Hello World"), VISIBILITY_EMPTY)
      .save(AUTHORIZATIONS_EMPTY);
  graph.flush();
  Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_EMPTY);
  assertEquals("Hello World", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString());
  assertEquals("Wor", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString(6, 3));
  assertEquals("", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString("Hello World".length(), 1));
  assertEquals("Hello World", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString(0, 100));
}

代码示例来源:origin: org.visallo/visallo-core-test

@Test
public void testExceptionDeletingSandboxedPropertiesWithVertices() throws Exception {
  createSampleOntology();
  VisibilityJson json = VisibilityJson.updateVisibilitySourceAndAddWorkspaceId(new VisibilityJson(), "", workspaceId);
  Visibility visibility = getVisibilityTranslator().toVisibility(json).getVisibility();
  VertexBuilder vb = getGraph().prepareVertex(visibility);
  vb.setProperty(SANDBOX_PROPERTY_IRI, "a value", visibility);
  vb.save(authorizations);
  thrown.expect(VisalloException.class);
  thrown.expectMessage("Unable to delete property that have elements using it");
  getOntologyRepository().deleteProperty(SANDBOX_PROPERTY_IRI, adminUser, workspaceId);
}

代码示例来源:origin: visallo/vertexium

@Test
public void testDisallowLeadingWildcardsInQueryString() {
  graph.prepareVertex("v1", VISIBILITY_A).setProperty("prop1", "value1", VISIBILITY_A).save(AUTHORIZATIONS_A);
  graph.flush();
  try {
    graph.query("*alue1", AUTHORIZATIONS_A).search().getTotalHits();
    fail("Wildcard prefix of query string should have caused an exception");
  } catch (Exception e) {
    if (!(getRootCause(e) instanceof NotSerializableExceptionWrapper)) {
      fail("Wildcard prefix of query string should have caused a NotSerializableExceptionWrapper exception");
    }
  }
}

相关文章