org.vertexium.Vertex.prepareMutation()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(13.3k)|赞(0)|评价(0)|浏览(120)

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

Vertex.prepareMutation介绍

[英]Prepares a mutation to allow changing multiple property values at the same time. This method is similar to Graph#prepareVertex(Visibility, Authorizations) in that it allows multiple properties to be changed and saved in a single mutation.
[中]准备一个变异以允许同时更改多个属性值。这种方法类似于Graph#prepareVertex(可见性、授权),因为它允许在一次变异中更改和保存多个属性。

代码示例

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

private void executeUpdateVertex(
    VertexiumCypherQueryContext ctx,
    CypherNodePattern nodePattern,
    Vertex vertex,
    VertexiumCypherScope.Item item
) {
  ExistingElementMutation<Vertex> m = vertex.prepareMutation();
  updateVertex(ctx, m, nodePattern, item);
  ctx.saveVertex(m);
}

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

private void executeUpdateVertex(
    VertexiumCypherQueryContext ctx,
    CypherNodePattern nodePattern,
    Vertex vertex,
    VertexiumCypherScope.Item item
) {
  ExistingElementMutation<Vertex> m = vertex.prepareMutation();
  updateVertex(ctx, m, nodePattern, item);
  ctx.saveVertex(m);
}

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

@Test
public void testEmptyPropertyMutation() {
  Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_ALL);
  v1.prepareMutation().save(AUTHORIZATIONS_ALL);
}

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

@Test
public void testEmptyPropertyMutation() {
  Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_ALL);
  v1.prepareMutation().save(AUTHORIZATIONS_ALL);
}

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

public void lrpUpdate(Vertex vertex, Graph graph, Authorizations authorizations) {
  Date updateDate = new Date();
  Long waitTimeMs = updateDate.getTime() - PingOntology.CREATE_DATE.getPropertyValueRequired(vertex).getTime();
  ElementMutation<Vertex> mutation = vertex.prepareMutation();
  PingOntology.LONG_RUNNING_PROCESS_DATE.setProperty(mutation, updateDate, VISIBILITY);
  PingOntology.LONG_RUNNING_PROCESS_HOSTNAME.setProperty(mutation, getHostname(), VISIBILITY);
  PingOntology.LONG_RUNNING_PROCESS_HOST_ADDRESS.setProperty(mutation, getHostAddress(), VISIBILITY);
  PingOntology.LONG_RUNNING_PROCESS_WAIT_TIME_MS.setProperty(mutation, waitTimeMs, VISIBILITY);
  mutation.save(authorizations);
  graph.flush();
}

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

public void gpwUpdate(Vertex vertex, Graph graph, Authorizations authorizations) {
  Date updateDate = new Date();
  Long waitTimeMs = updateDate.getTime() - PingOntology.CREATE_DATE.getPropertyValueRequired(vertex).getTime();
  ElementMutation<Vertex> mutation = vertex.prepareMutation();
  PingOntology.GRAPH_PROPERTY_WORKER_DATE.setProperty(mutation, updateDate, VISIBILITY);
  PingOntology.GRAPH_PROPERTY_WORKER_HOSTNAME.setProperty(mutation, getHostname(), VISIBILITY);
  PingOntology.GRAPH_PROPERTY_WORKER_HOST_ADDRESS.setProperty(mutation, getHostAddress(), VISIBILITY);
  PingOntology.GRAPH_PROPERTY_WORKER_WAIT_TIME_MS.setProperty(mutation, waitTimeMs, VISIBILITY);
  mutation.save(authorizations);
  graph.flush();
}

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

private byte[] createAndSaveCachedImage(Vertex vertex, String propertyKey, String url, int maxWidth, int maxHeight, int jpegQuality, Authorizations authorizations) throws IOException {
  byte[] imageData = getAndSaveImageData(vertex, url, authorizations);
  imageData = ImageUtils.resize(imageData, maxWidth, maxHeight, jpegQuality);
  StreamingPropertyValue value = new StreamingPropertyValue(new ByteArrayInputStream(imageData), byte[].class);
  value.store(true).searchIndex(false);
  ExistingElementMutation<Vertex> m = vertex.prepareMutation();
  VisalloProperties.CACHED_IMAGE.addPropertyValue(m, propertyKey, value, vertex.getVisibility());
  m.save(authorizations);
  return imageData;
}

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

private byte[] getAndSaveImageData(Vertex vertex, String url, Authorizations authorizations) throws IOException {
  String propertyKey = getPropertyKey(url, null, null, null);
  StreamingPropertyValue originalImage = VisalloProperties.CACHED_IMAGE.getPropertyValue(vertex, propertyKey);
  if (originalImage != null) {
    return IOUtils.toByteArray(originalImage.getInputStream());
  }
  byte[] imageData = httpRepository.get(url);
  StreamingPropertyValue value = new StreamingPropertyValue(new ByteArrayInputStream(imageData), byte[].class);
  value.store(true).searchIndex(false);
  ExistingElementMutation<Vertex> m = vertex.prepareMutation();
  VisalloProperties.CACHED_IMAGE.addPropertyValue(m, propertyKey, value, vertex.getVisibility());
  m.save(authorizations);
  return imageData;
}

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

private void publishGlyphIconProperties(Edge hasImageEdge, String workspaceId, Authorizations authorizations) {
  Vertex entityVertex = hasImageEdge.getVertex(Direction.OUT, authorizations);
  checkNotNull(entityVertex, "Could not find has image source vertex " + hasImageEdge.getVertexId(Direction.OUT));
  ExistingElementMutation elementMutation = entityVertex.prepareMutation();
  Iterable<Property> glyphIconProperties = entityVertex.getProperties(VisalloProperties.ENTITY_IMAGE_VERTEX_ID.getPropertyName());
  for (Property glyphIconProperty : glyphIconProperties) {
    if (publishNewProperty(elementMutation, glyphIconProperty, workspaceId)) {
      elementMutation.save(authorizations);
      return;
    }
  }
  LOGGER.warn("new has image edge without a glyph icon property being set on vertex %s", entityVertex.getId());
}

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

@Test
public void testChangeVisibilityOnBadPropertyName() {
  graph.prepareVertex("v1", VISIBILITY_A)
      .setProperty("prop1", "value1", VISIBILITY_EMPTY)
      .setProperty("prop2", "value2", VISIBILITY_B)
      .save(AUTHORIZATIONS_A_AND_B);
  graph.flush();
  try {
    graph.getVertex("v1", AUTHORIZATIONS_A)
        .prepareMutation()
        .alterPropertyVisibility("propBad", VISIBILITY_B)
        .save(AUTHORIZATIONS_A_AND_B);
    fail("show throw");
  } catch (VertexiumException ex) {
    assertNotNull(ex);
  }
}

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

@Test
public void testChangeVisibilityOnBadPropertyName() {
  graph.prepareVertex("v1", VISIBILITY_A)
      .setProperty("prop1", "value1", VISIBILITY_EMPTY)
      .setProperty("prop2", "value2", VISIBILITY_B)
      .save(AUTHORIZATIONS_A_AND_B);
  graph.flush();
  try {
    graph.getVertex("v1", AUTHORIZATIONS_A)
        .prepareMutation()
        .alterPropertyVisibility("propBad", VISIBILITY_B)
        .save(AUTHORIZATIONS_A_AND_B);
    fail("show throw");
  } catch (VertexiumException ex) {
    assertNotNull(ex);
  }
}

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

@Test
public void testMetadataMutationsOnVertex() {
  Metadata metadataPropB = Metadata.create();
  metadataPropB.add("meta1", "meta1", VISIBILITY_A);
  Vertex vertex = graph.prepareVertex("v1", VISIBILITY_A)
      .setProperty("propBmeta", "propBmeta", metadataPropB, VISIBILITY_A)
      .save(AUTHORIZATIONS_ALL);
  graph.flush();
  ExistingElementMutation<Vertex> m = vertex.prepareMutation();
  m.setPropertyMetadata("propBmeta", "meta1", "meta2", VISIBILITY_A);
  vertex = m.save(AUTHORIZATIONS_ALL);
  assertEquals("meta2", vertex.getProperty("propBmeta").getMetadata().getEntry("meta1").getValue());
}

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

@Test
public void testMetadataMutationsOnVertex() {
  Metadata metadataPropB = Metadata.create();
  metadataPropB.add("meta1", "meta1", VISIBILITY_A);
  Vertex vertex = graph.prepareVertex("v1", VISIBILITY_A)
      .setProperty("propBmeta", "propBmeta", metadataPropB, VISIBILITY_A)
      .save(AUTHORIZATIONS_ALL);
  graph.flush();
  ExistingElementMutation<Vertex> m = vertex.prepareMutation();
  m.setPropertyMetadata("propBmeta", "meta1", "meta2", VISIBILITY_A);
  vertex = m.save(AUTHORIZATIONS_ALL);
  assertEquals("meta2", vertex.getProperty("propBmeta").getMetadata().getEntry("meta1").getValue());
}

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

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

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

@Test
public void testElementMutationDoesntChangeObjectUntilSave() {
  Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_ALL);
  v.setProperty("prop1", "value1-1", VISIBILITY_A, AUTHORIZATIONS_ALL);
  graph.flush();
  ElementMutation<Vertex> m = v.prepareMutation()
      .setProperty("prop1", "value1-2", VISIBILITY_A)
      .setProperty("prop2", "value2-2", VISIBILITY_A);
  Assert.assertEquals(1, count(v.getProperties()));
  assertEquals("value1-1", v.getPropertyValue("prop1"));
  v = m.save(AUTHORIZATIONS_A_AND_B);
  Assert.assertEquals(2, count(v.getProperties()));
  assertEquals("value1-2", v.getPropertyValue("prop1"));
  assertEquals("value2-2", v.getPropertyValue("prop2"));
}

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

@Test
public void testElementMutationDoesntChangeObjectUntilSave() {
  Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_ALL);
  v.setProperty("prop1", "value1-1", VISIBILITY_A, AUTHORIZATIONS_ALL);
  graph.flush();
  ElementMutation<Vertex> m = v.prepareMutation()
      .setProperty("prop1", "value1-2", VISIBILITY_A)
      .setProperty("prop2", "value2-2", VISIBILITY_A);
  Assert.assertEquals(1, count(v.getProperties()));
  assertEquals("value1-1", v.getPropertyValue("prop1"));
  v = m.save(AUTHORIZATIONS_A_AND_B);
  Assert.assertEquals(2, count(v.getProperties()));
  assertEquals("value1-2", v.getPropertyValue("prop1"));
  assertEquals("value2-2", v.getPropertyValue("prop2"));
}

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

@Test
public void testMutationChangePropertyVisibilityFollowedByMetadataUsingPropertyObject() {
  Metadata prop1Metadata = Metadata.create();
  prop1Metadata.add("prop1_key1", "valueOld", VISIBILITY_A);
  graph.prepareVertex("v1", VISIBILITY_A)
      .setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A)
      .save(AUTHORIZATIONS_A_AND_B);
  graph.flush();
  Vertex v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
  Property p1 = v1.getProperty("prop1", VISIBILITY_A);
  v1.prepareMutation()
      .alterPropertyVisibility(p1, VISIBILITY_B)
      .setPropertyMetadata(p1, "prop1_key1", "valueNew", VISIBILITY_B)
      .save(AUTHORIZATIONS_A_AND_B);
  graph.flush();
  v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
  assertEquals("valueNew", v1.getProperty("prop1", VISIBILITY_B).getMetadata().getEntry("prop1_key1", VISIBILITY_B).getValue());
}

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

@Test
public void testDeleteElement() {
  Vertex v = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_ALL);
  v.prepareMutation()
      .setProperty("prop1", "value1", VISIBILITY_A)
      .save(AUTHORIZATIONS_ALL);
  graph.flush();
  v = graph.getVertex("v1", AUTHORIZATIONS_A);
  assertNotNull(v);
  Assert.assertEquals(1, count(graph.query(AUTHORIZATIONS_A_AND_B).has("prop1", "value1").vertices()));
  graph.deleteVertex(v.getId(), AUTHORIZATIONS_A_AND_B);
  graph.flush();
  v = graph.getVertex("v1", AUTHORIZATIONS_A);
  assertNull(v);
  Assert.assertEquals(0, count(graph.query(AUTHORIZATIONS_A_AND_B).has("prop1", "value1").vertices()));
}

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

@Test
public void testDeleteElement() {
  Vertex v = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_ALL);
  v.prepareMutation()
      .setProperty("prop1", "value1", VISIBILITY_A)
      .save(AUTHORIZATIONS_ALL);
  graph.flush();
  v = graph.getVertex("v1", AUTHORIZATIONS_A);
  assertNotNull(v);
  Assert.assertEquals(1, count(graph.query(AUTHORIZATIONS_A_AND_B).has("prop1", "value1").vertices()));
  graph.deleteVertex(v.getId(), AUTHORIZATIONS_A_AND_B);
  graph.flush();
  v = graph.getVertex("v1", AUTHORIZATIONS_A);
  assertNull(v);
  Assert.assertEquals(0, count(graph.query(AUTHORIZATIONS_A_AND_B).has("prop1", "value1").vertices()));
}

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

@Override
public void execute(InputStream in, GraphPropertyWorkData data) throws Exception {
  String fileName = VisalloProperties.FILE_NAME.getOnlyPropertyValue(data.getElement());
  String mimeType = getMimeType(in, fileName);
  if (mimeType == null) {
    return;
  }
  ExistingElementMutation<Vertex> m = ((Vertex) data.getElement()).prepareMutation();
  Metadata mimeTypeMetadata = data.createPropertyMetadata(getUser());
  VisalloProperties.MIME_TYPE.addPropertyValue(m, getMultiKey(data.getProperty()), mimeType, mimeTypeMetadata, data.getProperty().getVisibility());
  m.setPropertyMetadata(data.getProperty(), VisalloProperties.MIME_TYPE.getPropertyName(), mimeType, getVisibilityTranslator().getDefaultVisibility());
  m.save(getAuthorizations());
  getGraph().flush();
  runPostMimeTypeWorkers(mimeType, data);
  getWorkQueueRepository().pushGraphPropertyQueue(data.getElement(), data.getProperty(), data.getWorkspaceId(), data.getVisibilitySource(), data.getPriority());
}

相关文章