Example #1
0
 public void auditEdgeElementMutation(
     AuditAction action,
     ElementMutation<Edge> edgeElementMutation,
     Edge edge,
     Vertex sourceVertex,
     Vertex destVertex,
     String process,
     User user,
     Visibility visibility) {
   if (edgeElementMutation instanceof ExistingElementMutation) {
     Edge oldEdge = (Edge) ((ExistingElementMutation) edgeElementMutation).getElement();
     for (Property property : edgeElementMutation.getProperties()) {
       // TODO handle multi-valued properties
       Object oldPropertyValue = oldEdge.getPropertyValue(property.getName());
       Object newPropertyValue = property.getValue();
       checkNotNull(newPropertyValue, "new property value cannot be null");
       if (!newPropertyValue.equals(oldPropertyValue)) {
         auditRelationshipProperty(
             action,
             sourceVertex.getId().toString(),
             destVertex.getId().toString(),
             property.getName(),
             oldPropertyValue,
             newPropertyValue,
             edge,
             process,
             "",
             user,
             visibility);
       }
     }
   } else {
     auditRelationship(
         AuditAction.CREATE, sourceVertex, destVertex, edge, process, "", user, visibility);
     for (Property property : edgeElementMutation.getProperties()) {
       // TODO handle multi-valued properties
       Object newPropertyValue = property.getValue();
       checkNotNull(newPropertyValue, "new property value cannot be null");
       auditRelationshipProperty(
           action,
           sourceVertex.getId().toString(),
           destVertex.getId().toString(),
           property.getName(),
           null,
           newPropertyValue,
           edge,
           process,
           "",
           user,
           visibility);
     }
   }
 }
Example #2
0
 public void auditVertexElementMutation(
     AuditAction action,
     ElementMutation<Vertex> vertexElementMutation,
     Vertex vertex,
     String process,
     User user,
     Visibility visibility) {
   if (vertexElementMutation instanceof ExistingElementMutation) {
     Vertex oldVertex = (Vertex) ((ExistingElementMutation) vertexElementMutation).getElement();
     for (Property property : vertexElementMutation.getProperties()) {
       // TODO handle multi-valued properties
       Object oldPropertyValue = oldVertex.getPropertyValue(property.getName());
       Object newPropertyValue = property.getValue();
       checkNotNull(newPropertyValue, "new property value cannot be null");
       if (!newPropertyValue.equals(oldPropertyValue)
           || !oldVertex
               .getVisibility()
               .getVisibilityString()
               .equals(property.getVisibility().getVisibilityString())) {
         auditEntityProperty(
             action,
             oldVertex.getId(),
             property.getName(),
             oldPropertyValue,
             newPropertyValue,
             process,
             "",
             property.getMetadata(),
             user,
             visibility);
       }
     }
   } else {
     auditVertexCreate(vertex.getId(), process, "", user, visibility);
     for (Property property : vertexElementMutation.getProperties()) {
       // TODO handle multi-valued properties
       Object newPropertyValue = property.getValue();
       checkNotNull(newPropertyValue, "new property value cannot be null");
       auditEntityProperty(
           action,
           vertex.getId(),
           property.getName(),
           null,
           newPropertyValue,
           process,
           "",
           property.getMetadata(),
           user,
           visibility);
     }
   }
 }
Example #3
0
 /**
  * Add a mutation to set this property to the provided value.
  *
  * @param mutation the element mutation
  * @param value the new property value
  * @param metadata the property metadata
  * @param visibility the property visibility
  */
 public final void setProperty(
     final ElementMutation<?> mutation,
     final TRaw value,
     final Map<String, Object> metadata,
     final Visibility visibility) {
   mutation.setProperty(key, wrap(value), metadata, visibility);
 }
Example #4
0
 /**
  * Add a mutation to add a new value to this property.
  *
  * @param mutation the element mutation
  * @param multiKey the multi-valued property key
  * @param value the new property value
  * @param visibility the property visibility
  */
 public final void addPropertyValue(
     final ElementMutation<?> mutation,
     final String multiKey,
     final TRaw value,
     final Visibility visibility) {
   mutation.addPropertyValue(multiKey, key, wrap(value), visibility);
 }
Example #5
0
 /**
  * Add a mutation to set this property to the provided value.
  *
  * @param mutation the element mutation
  * @param value the new property value
  * @param visibility the property visibility
  */
 public final void setProperty(
     final ElementMutation<?> mutation, final TRaw value, final Visibility visibility) {
   mutation.setProperty(key, wrap(value), visibility);
 }