Пример #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);
     }
   }
 }
Пример #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);
     }
   }
 }