예제 #1
0
        public override void Delete(RequestDelete myDeleteRequest, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            var toBeProcessedVertices = GetVertices(myDeleteRequest.ToBeDeletedVertices, myTransactionToken, mySecurityToken);

            if (myDeleteRequest.ToBeDeletedAttributes.IsNotNullOrEmpty())
            {
                List<long> toBeDeletedStructuredPropertiesUpdate = new List<long>();
                List<String> tobeDeletedUnstructuredProperties = new List<String>();
                List<long> toBeDeletedBinaryProperties = new List<long>();
                List<long> toBeDeletedSingleEdges = new List<long>();
                List<long> toBeDeletedHyperEdges = new List<long>();
                Dictionary<Int64, IPropertyDefinition> toBeDeletedProperties = new Dictionary<long, IPropertyDefinition>();
                Dictionary<Int64, IOutgoingEdgeDefinition> toBeDeletedEdges = new Dictionary<long, IOutgoingEdgeDefinition>();
                Dictionary<Int64, IBinaryPropertyDefinition> toBeDeletedBinaries = new Dictionary<long, IBinaryPropertyDefinition>();
                HashSet<String> toBeDeletedUndefinedAttributes = new HashSet<string>();

                //remove the attributes
                foreach (var aVertexTypeGroup in toBeProcessedVertices.GroupBy(_ => _.VertexTypeID))
                {
                    var vertexType = _vertexTypeManager.ExecuteManager.GetType(aVertexTypeGroup.Key, myTransactionToken, mySecurityToken);

                    #region prepare update definition

                    toBeDeletedStructuredPropertiesUpdate.Clear();
                    StructuredPropertiesUpdate structuredProperties = new StructuredPropertiesUpdate(null, toBeDeletedStructuredPropertiesUpdate);

                    tobeDeletedUnstructuredProperties.Clear();
                    UnstructuredPropertiesUpdate unstructuredProperties = new UnstructuredPropertiesUpdate(null, tobeDeletedUnstructuredProperties);

                    toBeDeletedBinaryProperties.Clear();
                    BinaryPropertiesUpdate binaryProperties = new BinaryPropertiesUpdate(null, toBeDeletedBinaryProperties);

                    toBeDeletedSingleEdges.Clear();
                    SingleEdgeUpdate singleEdges = new SingleEdgeUpdate(null, toBeDeletedSingleEdges);

                    toBeDeletedHyperEdges.Clear();
                    HyperEdgeUpdate hyperEdges = new HyperEdgeUpdate(null, toBeDeletedHyperEdges);

                    VertexUpdateDefinition update = new VertexUpdateDefinition(null, structuredProperties, unstructuredProperties, binaryProperties, singleEdges, hyperEdges);

                    #endregion

                    #region sorting attributes

                    toBeDeletedProperties.Clear();
                    toBeDeletedEdges.Clear();
                    toBeDeletedBinaries.Clear();
                    toBeDeletedUndefinedAttributes.Clear();

                    foreach (var aToBeDeleted in myDeleteRequest.ToBeDeletedAttributes)
                    {
                        if (!vertexType.HasAttribute(aToBeDeleted))
                        {
                            toBeDeletedUndefinedAttributes.Add(aToBeDeleted);
                        }

                        var attribute = vertexType.GetAttributeDefinition(aToBeDeleted);
                        myDeleteRequest.AddDeletedAttribute(attribute.ID);

                        switch (attribute.Kind)
                        {
                            case AttributeType.Property:
                                toBeDeletedProperties.Add(attribute.ID, (IPropertyDefinition)attribute);
                                break;

                            case AttributeType.OutgoingEdge:
                                toBeDeletedEdges.Add(attribute.ID, (IOutgoingEdgeDefinition)attribute);
                                break;

                            case AttributeType.BinaryProperty:
                                toBeDeletedBinaries.Add(attribute.ID, (IBinaryPropertyDefinition)attribute);
                                break;
                        }
                    }

                    #endregion

                    foreach (var aVertex in aVertexTypeGroup.ToList())
                    {
                        #region fetch to be deleted attributes

                        #region properties

                        foreach (var aToBeDeletedProperty in toBeDeletedProperties)
                        {
                            foreach (var aIndexDefinition in aToBeDeletedProperty.Value.InIndices)
                            {
                                RemoveFromIndices(aVertex, 
                                    _indexManager.GetIndices(vertexType, aIndexDefinition.IndexedProperties, mySecurityToken, myTransactionToken));
                            }
                            toBeDeletedStructuredPropertiesUpdate.Add(aToBeDeletedProperty.Key);
                        }

                        #endregion

                        #region edges

                        foreach (var aToBeDeltedEdge in toBeDeletedEdges)
                        {
                            if (aVertex.HasOutgoingEdge(aToBeDeltedEdge.Key))
                            {
                                switch (aToBeDeltedEdge.Value.Multiplicity)
                                {
                                    case EdgeMultiplicity.SingleEdge:

                                        toBeDeletedSingleEdges.Add(aToBeDeltedEdge.Key);

                                        break;
                                    case EdgeMultiplicity.MultiEdge:
                                    case EdgeMultiplicity.HyperEdge:

                                        toBeDeletedHyperEdges.Add(aToBeDeltedEdge.Key);

                                        break;
                                }
                            }
                        }

                        #endregion

                        #region binaries

                        foreach (var aBinaryProperty in toBeDeletedBinaryProperties)
                        {
                            //TODO: Add HasBinaryProperty to IVertex
                            if (aVertex.GetAllBinaryProperties((_, __) => _ == aBinaryProperty).Count() > 0)
                            {
                                toBeDeletedBinaryProperties.Add(aBinaryProperty);
                            }
                        }

                        #endregion

                        #region undefined data

                        foreach (var aUnstructuredProperty in toBeDeletedUndefinedAttributes)
                        {
                            if (aVertex.HasUnstructuredProperty(aUnstructuredProperty))
                            {
                                tobeDeletedUnstructuredProperties.Add(aUnstructuredProperty);
                            }
                        }

                        #endregion

                        #endregion

                        _vertexStore.UpdateVertex(mySecurityToken, myTransactionToken, aVertex.VertexID, aVertex.VertexTypeID, update, true, aVertex.EditionName, aVertex.VertexRevisionID, false);
                    }
                }
            }
            else
            {
                //remove the nodes
                foreach (var aVertexTypeGroup in toBeProcessedVertices.GroupBy(_ => _.VertexTypeID))
                {
                    var vertexType = _vertexTypeManager.ExecuteManager.GetType(aVertexTypeGroup.Key, myTransactionToken, mySecurityToken);

                    foreach (var aVertex in aVertexTypeGroup.ToList())
                    {
                        myDeleteRequest.AddDeletedVertex(aVertex.VertexID);
                        RemoveVertex(aVertex, vertexType, mySecurityToken, myTransactionToken);
                    }
                }
            }
        }
예제 #2
0
 public void Delete(RequestDelete myDeleteRequest, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
 {
     GetVertices(myDeleteRequest.ToBeDeletedVertices, myTransactionToken, mySecurityToken);
 }
예제 #3
0
 /// <summary>
 /// Deletes a set of vertices
 /// </summary>
 /// <param name="myDeleteRequest">The request that represents the delete operation</param>
 /// <param name="mySecurityToken">The current security token</param>
 /// <param name="myTransactionToken">The current transaction token</param>
 public abstract void Delete(RequestDelete myDeleteRequest, SecurityToken mySecurityToken, Int64 myTransactionToken);
예제 #4
0
        public static RequestDelete MakeRequestDelete(ServiceVertexType myVertexType, IEnumerable<Int64> myVertexIDs = null, ServiceDeletePayload myDeletePayload = null)
        {
            RequestGetVertices PreRequest = null;
            if (myVertexIDs != null)
            {
                PreRequest = new RequestGetVertices(myVertexType.Name, myVertexIDs);
            }
            else
            {
                PreRequest = new RequestGetVertices(myVertexType.Name);
            }

            RequestDelete Request = new RequestDelete(PreRequest);
            if (myDeletePayload != null)
            {
                foreach (var toDel in myDeletePayload.ToBeDeletedAttributes)
                {
                    Request.AddAttribute(toDel);

                }
            }
            return Request;
        }
예제 #5
0
 internal ServiceDeletePayload(RequestDelete myRequestDelete)
 {
     this.ToBeDeletedAttributes = (myRequestDelete.ToBeDeletedAttributes == null)
         ? null : myRequestDelete.ToBeDeletedAttributes.ToList();
 }
예제 #6
0
        public TResult Delete <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestDelete myRequestDelete, sones.GraphDB.Request.Converter.DeleteResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();
            var       result      = _GraphDSService.Delete(mySecurityToken, myTransactionID,
                                                           new ServiceVertexType(myRequestDelete.ToBeDeletedVertices.VertexTypeName),
                                                           myRequestDelete.ToBeDeletedVertices.VertexIDs.ToList(),
                                                           new ServiceDeletePayload(myRequestDelete));

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), result.Item1.Select(x => (IComparable)x), result.Item2.Select(x => (IComparable)x)));
        }