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

x33g5p2x  于2022-01-19 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(263)

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

Element.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.
[中]

代码示例

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

/**
 * Similar to {@link GraphUpdateContext#update(Element, Update)} but calls
 * {@link ElementUpdateContext#updateBuiltInProperties(Date, VisibilityJson)} and
 * {@link ElementUpdateContext#setConceptType(String)} before calling
 * updateFn.
 */
public <T extends Element> UpdateFuture<T> update(
    T element,
    Date modifiedDate,
    VisibilityJson visibilityJson,
    String conceptType,
    Update<T> updateFn
) {
  checkNotNull(element, "element cannot be null");
  return update(element.prepareMutation(), modifiedDate, visibilityJson, conceptType, updateFn);
}

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

/**
 * Adds or updates a property.
 *
 * @param key        The unique key given to the property allowing for multi-valued properties.
 * @param name       The name of the property.
 * @param value      The value of the property.
 * @param visibility The visibility to give this property.
 */
default void addPropertyValue(String key, String name, Object value, Visibility visibility, Authorizations authorizations) {
  prepareMutation().addPropertyValue(key, name, value, visibility).save(authorizations);
}

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

/**
 * Sets or updates a property value. The property key will be set to a constant. This is a convenience method
 * which allows treating the multi-valued nature of properties as only containing a single value. Care must be
 * taken when using this method because properties are not only uniquely identified by just key and name but also
 * visibility so adding properties with the same name and different visibility strings is still permitted.
 *
 * @param name       The name of the property.
 * @param value      The value of the property.
 * @param metadata   The metadata to assign to this property.
 * @param visibility The visibility to give this property.
 */
default void setProperty(String name, Object value, Metadata metadata, Visibility visibility, Authorizations authorizations) {
  prepareMutation().setProperty(name, value, metadata, visibility).save(authorizations);
}

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

/**
 * Adds or updates a property.
 *
 * @param key        The unique key given to the property allowing for multi-valued properties.
 * @param name       The name of the property.
 * @param value      The value of the property.
 * @param visibility The visibility to give this property.
 */
default void addPropertyValue(String key, String name, Object value, Visibility visibility, Authorizations authorizations) {
  prepareMutation().addPropertyValue(key, name, value, visibility).save(authorizations);
}

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

/**
 * Adds or updates a property.
 *
 * @param key        The unique key given to the property allowing for multi-valued properties.
 * @param name       The name of the property.
 * @param value      The value of the property.
 * @param metadata   The metadata to assign to this property.
 * @param visibility The visibility to give this property.
 */
default void addPropertyValue(String key, String name, Object value, Metadata metadata, Visibility visibility, Authorizations authorizations) {
  prepareMutation().addPropertyValue(key, name, value, metadata, visibility).save(authorizations);
}

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

/**
 * Adds or updates a property.
 *
 * @param key        The unique key given to the property allowing for multi-valued properties.
 * @param name       The name of the property.
 * @param value      The value of the property.
 * @param metadata   The metadata to assign to this property.
 * @param visibility The visibility to give this property.
 */
default void addPropertyValue(String key, String name, Object value, Metadata metadata, Visibility visibility, Authorizations authorizations) {
  prepareMutation().addPropertyValue(key, name, value, metadata, visibility).save(authorizations);
}

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

/**
 * Sets or updates a property value. The property key will be set to a constant. This is a convenience method
 * which allows treating the multi-valued nature of properties as only containing a single value. Care must be
 * taken when using this method because properties are not only uniquely identified by just key and name but also
 * visibility so adding properties with the same name and different visibility strings is still permitted.
 *
 * @param name       The name of the property.
 * @param value      The value of the property.
 * @param visibility The visibility to give this property.
 */
default void setProperty(String name, Object value, Visibility visibility, Authorizations authorizations) {
  prepareMutation().setProperty(name, value, visibility).save(authorizations);
}

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

/**
 * Sets or updates a property value. The property key will be set to a constant. This is a convenience method
 * which allows treating the multi-valued nature of properties as only containing a single value. Care must be
 * taken when using this method because properties are not only uniquely identified by just key and name but also
 * visibility so adding properties with the same name and different visibility strings is still permitted.
 *
 * @param name       The name of the property.
 * @param value      The value of the property.
 * @param visibility The visibility to give this property.
 */
default void setProperty(String name, Object value, Visibility visibility, Authorizations authorizations) {
  prepareMutation().setProperty(name, value, visibility).save(authorizations);
}

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

/**
 * Sets or updates a property value. The property key will be set to a constant. This is a convenience method
 * which allows treating the multi-valued nature of properties as only containing a single value. Care must be
 * taken when using this method because properties are not only uniquely identified by just key and name but also
 * visibility so adding properties with the same name and different visibility strings is still permitted.
 *
 * @param name       The name of the property.
 * @param value      The value of the property.
 * @param metadata   The metadata to assign to this property.
 * @param visibility The visibility to give this property.
 */
default void setProperty(String name, Object value, Metadata metadata, Visibility visibility, Authorizations authorizations) {
  prepareMutation().setProperty(name, value, metadata, visibility).save(authorizations);
}

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

protected ElementMutation getMutationForUpdate(
    RdfTripleImportHelper rdfTripleImportHelper,
    Authorizations authorizations
) {
  Graph graph = rdfTripleImportHelper.getGraph();
  if (getElementType() == ElementType.VERTEX) {
    return graph.prepareVertex(
        getElementId(),
        rdfTripleImportHelper.getVisibility(getElementVisibilitySource())
    );
  } else {
    Element element = getExistingElement(graph, this, authorizations);
    return element.prepareMutation();
  }
}

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

ExistingElementMutation<Element> m = element.prepareMutation();

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

@Override
  public ImportContext updateImportContext(
      ImportContext ctx,
      RdfTripleImportHelper rdfTripleImportHelper,
      Authorizations authorizations
  ) {
    // Currently Vertexium only supports updating metadata on ExistingElementMutation if that ever
    //  changes this logic can be removed, createImportContext can be renamed createImportContext
    //  and ImportContext can be removed from the parameter list
    if (!(ctx.getElementMutation() instanceof ExistingElementMutation)) {
      ctx.save(authorizations);

      Element element = getExistingElement(rdfTripleImportHelper.getGraph(), this, authorizations);
      ExistingElementMutation<Element> m = element.prepareMutation();
      return new ImportContext(getElementId(), m);
    }

    return super.updateImportContext(ctx, rdfTripleImportHelper, authorizations);
  }
}

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

ExistingElementMutation<Element> m = element.prepareMutation();

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

private void executeRemoveProperty(
    VertexiumCypherQueryContext ctx,
    CypherRemovePropertyExpressionItem removeItem,
    VertexiumCypherScope.Item item
) {
  CypherAstBase propertyExpression = removeItem.getPropertyExpression();
  if (propertyExpression instanceof CypherLookup) {
    CypherLookup cypherLookup = (CypherLookup) propertyExpression;
    Object elementObj = ctx.getExpressionExecutor().executeExpression(ctx, cypherLookup.getAtom(), item);
    if (elementObj == null) {
      return;
    }
    if (elementObj instanceof Element) {
      Element element = (Element) elementObj;
      ExistingElementMutation<Element> m = element.prepareMutation();
      ctx.removeProperty(m, cypherLookup.getProperty());
      ctx.saveElement(m);
      return;
    }
    throw new VertexiumCypherTypeErrorException(elementObj, Element.class, null);
  }
  throw new VertexiumCypherTypeErrorException(propertyExpression, CypherLookup.class);
}

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

private void executeRemoveProperty(
    VertexiumCypherQueryContext ctx,
    CypherRemovePropertyExpressionItem removeItem,
    VertexiumCypherScope.Item item
) {
  CypherAstBase propertyExpression = removeItem.getPropertyExpression();
  if (propertyExpression instanceof CypherLookup) {
    CypherLookup cypherLookup = (CypherLookup) propertyExpression;
    Object elementObj = ctx.getExpressionExecutor().executeExpression(ctx, cypherLookup.getAtom(), item);
    if (elementObj == null) {
      return;
    }
    if (elementObj instanceof Element) {
      Element element = (Element) elementObj;
      ExistingElementMutation<Element> m = element.prepareMutation();
      ctx.removeProperty(m, cypherLookup.getProperty());
      ctx.saveElement(m);
      return;
    }
    throw new VertexiumCypherTypeErrorException(elementObj, Element.class, null);
  }
  throw new VertexiumCypherTypeErrorException(propertyExpression, CypherLookup.class);
}

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

public <T extends Element> VisibilityAndElementMutation<T> updateElementVisibilitySource(
    Element element,
    SandboxStatus sandboxStatus,
    String visibilitySource,
    String workspaceId,
    Authorizations authorizations
) {
  Visibility defaultVisibility = visibilityTranslator.getDefaultVisibility();
  VisibilityJson visibilityJson = VisalloProperties.VISIBILITY_JSON.getPropertyValue(element);
  visibilityJson = sandboxStatus != SandboxStatus.PUBLIC
      ? VisibilityJson.updateVisibilitySourceAndAddWorkspaceId(visibilityJson, visibilitySource, workspaceId)
      : VisibilityJson.updateVisibilitySource(visibilityJson, visibilitySource);
  VisalloVisibility visalloVisibility = visibilityTranslator.toVisibility(visibilityJson);
  Visibility visibility = visalloVisibility.getVisibility();
  ExistingElementMutation<T> m = element.<T>prepareMutation().alterElementVisibility(visibility);
  VisalloProperties.VISIBILITY_JSON.setProperty(m, visibilityJson, defaultVisibility);
  m.save(authorizations);
  return new VisibilityAndElementMutation<>(visalloVisibility, m);
}

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

);
ExistingElementMutation<T> m = element.<T>prepareMutation()
    .alterPropertyVisibility(property, newVisibility);
VisalloProperties.VISIBILITY_JSON_METADATA.setMetadata(m, property, newVisibilityJson, defaultVisibility);

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

private void executeSetProperty(
    VertexiumCypherQueryContext ctx,
    CypherSetProperty setItem,
    VertexiumCypherScope.Item item
) {
  Object left = ctx.getExpressionExecutor().executeExpression(ctx, setItem.getLeft().getAtom(), item);
  VertexiumCypherTypeErrorException.assertType(left, Element.class, null);
  if (left == null) {
    return;
  }
  String propertyName = setItem.getLeft().getProperty();
  Object value = ctx.getExpressionExecutor().executeExpression(ctx, setItem.getRight(), item);
  Element element = (Element) left;
  ExistingElementMutation<Element> m = element.prepareMutation();
  switch (setItem.getOp()) {
    case EQUAL:
      if (value == null) {
        ctx.removeProperty(m, propertyName);
      } else {
        ctx.setProperty(m, propertyName, value);
      }
      break;
    default:
      throw new VertexiumCypherNotImplemented("" + setItem);
  }
  ctx.saveElement(m);
}

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

private void executeSetProperty(
    VertexiumCypherQueryContext ctx,
    CypherSetProperty setItem,
    VertexiumCypherScope.Item item
) {
  Object left = ctx.getExpressionExecutor().executeExpression(ctx, setItem.getLeft().getAtom(), item);
  VertexiumCypherTypeErrorException.assertType(left, Element.class, null);
  if (left == null) {
    return;
  }
  String propertyName = setItem.getLeft().getProperty();
  Object value = ctx.getExpressionExecutor().executeExpression(ctx, setItem.getRight(), item);
  Element element = (Element) left;
  ExistingElementMutation<Element> m = element.prepareMutation();
  switch (setItem.getOp()) {
    case EQUAL:
      if (value == null) {
        ctx.removeProperty(m, propertyName);
      } else {
        ctx.setProperty(m, propertyName, value);
      }
      break;
    default:
      throw new VertexiumCypherNotImplemented("" + setItem);
  }
  ctx.saveElement(m);
}

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

propertyMetadata = VertexiumMetadataUtil.mergeMetadata(propertyMetadata, metadata);
ExistingElementMutation<T> elementMutation = element.prepareMutation();

相关文章