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

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

本文整理了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

  1. /**
  2. * Similar to {@link GraphUpdateContext#update(Element, Update)} but calls
  3. * {@link ElementUpdateContext#updateBuiltInProperties(Date, VisibilityJson)} and
  4. * {@link ElementUpdateContext#setConceptType(String)} before calling
  5. * updateFn.
  6. */
  7. public <T extends Element> UpdateFuture<T> update(
  8. T element,
  9. Date modifiedDate,
  10. VisibilityJson visibilityJson,
  11. String conceptType,
  12. Update<T> updateFn
  13. ) {
  14. checkNotNull(element, "element cannot be null");
  15. return update(element.prepareMutation(), modifiedDate, visibilityJson, conceptType, updateFn);
  16. }

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

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

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

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

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

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

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

  1. /**
  2. * Adds or updates a property.
  3. *
  4. * @param key The unique key given to the property allowing for multi-valued properties.
  5. * @param name The name of the property.
  6. * @param value The value of the property.
  7. * @param metadata The metadata to assign to this property.
  8. * @param visibility The visibility to give this property.
  9. */
  10. default void addPropertyValue(String key, String name, Object value, Metadata metadata, Visibility visibility, Authorizations authorizations) {
  11. prepareMutation().addPropertyValue(key, name, value, metadata, visibility).save(authorizations);
  12. }

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

  1. /**
  2. * Adds or updates a property.
  3. *
  4. * @param key The unique key given to the property allowing for multi-valued properties.
  5. * @param name The name of the property.
  6. * @param value The value of the property.
  7. * @param metadata The metadata to assign to this property.
  8. * @param visibility The visibility to give this property.
  9. */
  10. default void addPropertyValue(String key, String name, Object value, Metadata metadata, Visibility visibility, Authorizations authorizations) {
  11. prepareMutation().addPropertyValue(key, name, value, metadata, visibility).save(authorizations);
  12. }

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

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

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

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

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

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

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

  1. protected ElementMutation getMutationForUpdate(
  2. RdfTripleImportHelper rdfTripleImportHelper,
  3. Authorizations authorizations
  4. ) {
  5. Graph graph = rdfTripleImportHelper.getGraph();
  6. if (getElementType() == ElementType.VERTEX) {
  7. return graph.prepareVertex(
  8. getElementId(),
  9. rdfTripleImportHelper.getVisibility(getElementVisibilitySource())
  10. );
  11. } else {
  12. Element element = getExistingElement(graph, this, authorizations);
  13. return element.prepareMutation();
  14. }
  15. }

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

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

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

  1. @Override
  2. public ImportContext updateImportContext(
  3. ImportContext ctx,
  4. RdfTripleImportHelper rdfTripleImportHelper,
  5. Authorizations authorizations
  6. ) {
  7. // Currently Vertexium only supports updating metadata on ExistingElementMutation if that ever
  8. // changes this logic can be removed, createImportContext can be renamed createImportContext
  9. // and ImportContext can be removed from the parameter list
  10. if (!(ctx.getElementMutation() instanceof ExistingElementMutation)) {
  11. ctx.save(authorizations);
  12. Element element = getExistingElement(rdfTripleImportHelper.getGraph(), this, authorizations);
  13. ExistingElementMutation<Element> m = element.prepareMutation();
  14. return new ImportContext(getElementId(), m);
  15. }
  16. return super.updateImportContext(ctx, rdfTripleImportHelper, authorizations);
  17. }
  18. }

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

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

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

  1. private void executeRemoveProperty(
  2. VertexiumCypherQueryContext ctx,
  3. CypherRemovePropertyExpressionItem removeItem,
  4. VertexiumCypherScope.Item item
  5. ) {
  6. CypherAstBase propertyExpression = removeItem.getPropertyExpression();
  7. if (propertyExpression instanceof CypherLookup) {
  8. CypherLookup cypherLookup = (CypherLookup) propertyExpression;
  9. Object elementObj = ctx.getExpressionExecutor().executeExpression(ctx, cypherLookup.getAtom(), item);
  10. if (elementObj == null) {
  11. return;
  12. }
  13. if (elementObj instanceof Element) {
  14. Element element = (Element) elementObj;
  15. ExistingElementMutation<Element> m = element.prepareMutation();
  16. ctx.removeProperty(m, cypherLookup.getProperty());
  17. ctx.saveElement(m);
  18. return;
  19. }
  20. throw new VertexiumCypherTypeErrorException(elementObj, Element.class, null);
  21. }
  22. throw new VertexiumCypherTypeErrorException(propertyExpression, CypherLookup.class);
  23. }

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

  1. private void executeRemoveProperty(
  2. VertexiumCypherQueryContext ctx,
  3. CypherRemovePropertyExpressionItem removeItem,
  4. VertexiumCypherScope.Item item
  5. ) {
  6. CypherAstBase propertyExpression = removeItem.getPropertyExpression();
  7. if (propertyExpression instanceof CypherLookup) {
  8. CypherLookup cypherLookup = (CypherLookup) propertyExpression;
  9. Object elementObj = ctx.getExpressionExecutor().executeExpression(ctx, cypherLookup.getAtom(), item);
  10. if (elementObj == null) {
  11. return;
  12. }
  13. if (elementObj instanceof Element) {
  14. Element element = (Element) elementObj;
  15. ExistingElementMutation<Element> m = element.prepareMutation();
  16. ctx.removeProperty(m, cypherLookup.getProperty());
  17. ctx.saveElement(m);
  18. return;
  19. }
  20. throw new VertexiumCypherTypeErrorException(elementObj, Element.class, null);
  21. }
  22. throw new VertexiumCypherTypeErrorException(propertyExpression, CypherLookup.class);
  23. }

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

  1. public <T extends Element> VisibilityAndElementMutation<T> updateElementVisibilitySource(
  2. Element element,
  3. SandboxStatus sandboxStatus,
  4. String visibilitySource,
  5. String workspaceId,
  6. Authorizations authorizations
  7. ) {
  8. Visibility defaultVisibility = visibilityTranslator.getDefaultVisibility();
  9. VisibilityJson visibilityJson = VisalloProperties.VISIBILITY_JSON.getPropertyValue(element);
  10. visibilityJson = sandboxStatus != SandboxStatus.PUBLIC
  11. ? VisibilityJson.updateVisibilitySourceAndAddWorkspaceId(visibilityJson, visibilitySource, workspaceId)
  12. : VisibilityJson.updateVisibilitySource(visibilityJson, visibilitySource);
  13. VisalloVisibility visalloVisibility = visibilityTranslator.toVisibility(visibilityJson);
  14. Visibility visibility = visalloVisibility.getVisibility();
  15. ExistingElementMutation<T> m = element.<T>prepareMutation().alterElementVisibility(visibility);
  16. VisalloProperties.VISIBILITY_JSON.setProperty(m, visibilityJson, defaultVisibility);
  17. m.save(authorizations);
  18. return new VisibilityAndElementMutation<>(visalloVisibility, m);
  19. }

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

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

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

  1. private void executeSetProperty(
  2. VertexiumCypherQueryContext ctx,
  3. CypherSetProperty setItem,
  4. VertexiumCypherScope.Item item
  5. ) {
  6. Object left = ctx.getExpressionExecutor().executeExpression(ctx, setItem.getLeft().getAtom(), item);
  7. VertexiumCypherTypeErrorException.assertType(left, Element.class, null);
  8. if (left == null) {
  9. return;
  10. }
  11. String propertyName = setItem.getLeft().getProperty();
  12. Object value = ctx.getExpressionExecutor().executeExpression(ctx, setItem.getRight(), item);
  13. Element element = (Element) left;
  14. ExistingElementMutation<Element> m = element.prepareMutation();
  15. switch (setItem.getOp()) {
  16. case EQUAL:
  17. if (value == null) {
  18. ctx.removeProperty(m, propertyName);
  19. } else {
  20. ctx.setProperty(m, propertyName, value);
  21. }
  22. break;
  23. default:
  24. throw new VertexiumCypherNotImplemented("" + setItem);
  25. }
  26. ctx.saveElement(m);
  27. }

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

  1. private void executeSetProperty(
  2. VertexiumCypherQueryContext ctx,
  3. CypherSetProperty setItem,
  4. VertexiumCypherScope.Item item
  5. ) {
  6. Object left = ctx.getExpressionExecutor().executeExpression(ctx, setItem.getLeft().getAtom(), item);
  7. VertexiumCypherTypeErrorException.assertType(left, Element.class, null);
  8. if (left == null) {
  9. return;
  10. }
  11. String propertyName = setItem.getLeft().getProperty();
  12. Object value = ctx.getExpressionExecutor().executeExpression(ctx, setItem.getRight(), item);
  13. Element element = (Element) left;
  14. ExistingElementMutation<Element> m = element.prepareMutation();
  15. switch (setItem.getOp()) {
  16. case EQUAL:
  17. if (value == null) {
  18. ctx.removeProperty(m, propertyName);
  19. } else {
  20. ctx.setProperty(m, propertyName, value);
  21. }
  22. break;
  23. default:
  24. throw new VertexiumCypherNotImplemented("" + setItem);
  25. }
  26. ctx.saveElement(m);
  27. }

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

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

相关文章