示例#1
0
 private void ProcessDropIndex(IEnumerable <IIndexDefinition> myToBeDroppedIndices, IVertexType vertexType, SecurityToken mySecurityToken, Int64 myTransactionToken)
 {
     foreach (var aVertexType in vertexType.GetDescendantVertexTypesAndSelf())
     {
         foreach (var aIndexDefinition in myToBeDroppedIndices)
         {
             RemoveIndexInstance(aIndexDefinition.ID, myTransactionToken, mySecurityToken);
         }
     }
 }
示例#2
0
 private void ProcessDropIndex(IEnumerable<IIndexDefinition> myToBeDroppedIndices, IVertexType vertexType, SecurityToken mySecurityToken, Int64 myTransactionToken)
 {
     foreach (var aVertexType in vertexType.GetDescendantVertexTypesAndSelf())
     {
         foreach (var aIndexDefinition in myToBeDroppedIndices)
         {
             RemoveIndexInstance(aIndexDefinition.ID, myTransactionToken, mySecurityToken);
         }
     }
 }
示例#3
0
        public override IEnumerable<IVertex> GetVertices(IVertexType myVertexType, Int64 myTransaction, SecurityToken mySecurity, Boolean includeSubtypes)
        {
            if (includeSubtypes)
            {
                return myVertexType.GetDescendantVertexTypesAndSelf().SelectMany(_ => _vertexStore.GetVerticesByTypeID(mySecurity, myTransaction, _.ID));
            }
            else
            {
                return _vertexStore.GetVerticesByTypeID(mySecurity, myTransaction, myVertexType.ID);
            }

        }
示例#4
0
 private static void CheckTargetVertices(IVertexType myTargetVertexType, IEnumerable<VertexInformation> vertexIDs)
 {
     var distinctTypeIDS = new HashSet<Int64>(vertexIDs.Select(x => x.VertexTypeID));
     var allowedTypeIDs = new HashSet<Int64>(myTargetVertexType.GetDescendantVertexTypesAndSelf().Select(x => x.ID));
     distinctTypeIDS.ExceptWith(allowedTypeIDs);
     if (distinctTypeIDS.Count > 0)
         throw new Exception("A target vertex has a type, that is not assignable to the target vertex type of the edge.");
 }
示例#5
0
        /// <summary>
        /// Adds a mandatory constraint
        /// </summary>
        /// <param name="myToBeAddedMandatories"></param>
        /// <param name="vertexType"></param>
        /// <param name="myTransactionToken"></param>
        /// <param name="mySecurityToken"></param>
        private void AddMandatoryConstraint(IEnumerable<MandatoryPredefinition> myToBeAddedMandatories, IVertexType vertexType, TransactionToken myTransactionToken, SecurityToken mySecurityToken)
        {
            if (myToBeAddedMandatories.IsNotNullOrEmpty())
            {
                foreach (var aMandatory in myToBeAddedMandatories)
                {
                    var property = vertexType.GetPropertyDefinition(aMandatory.MandatoryAttribute);
                    var defaultValue = property.DefaultValue;

                    //get new mandatory value and set it
                    if (aMandatory.DefaultValue != null)
                    {
                        var defaultValueUpdate = new VertexUpdateDefinition(null, new StructuredPropertiesUpdate(new Dictionary<long, IComparable> { { (long)AttributeDefinitions.PropertyDotDefaultValue, aMandatory.DefaultValue.ToString() } }));
                        _vertexManager.ExecuteManager.VertexStore.UpdateVertex(mySecurityToken, myTransactionToken, property.ID, (long)BaseTypes.Property, defaultValueUpdate);

                        defaultValue = aMandatory.DefaultValue.ToString();
                    }

                    var vertexDefaultValueUpdate = new VertexUpdateDefinition(null, new StructuredPropertiesUpdate(new Dictionary<long, IComparable> { { property.ID, defaultValue } }));

                    foreach (var aVertexType in vertexType.GetDescendantVertexTypesAndSelf())
                    {
                        foreach (var aVertexWithoutPropery in _vertexManager.ExecuteManager.VertexStore.GetVerticesByTypeID(mySecurityToken, myTransactionToken, vertexType.ID).Where(_ => !_.HasProperty(property.ID)).ToList())
                        {
                            if (defaultValue != null)
                            {
                                //update
                                _vertexManager.ExecuteManager.VertexStore.UpdateVertex(mySecurityToken, myTransactionToken, aVertexWithoutPropery.VertexID, aVertexWithoutPropery.VertexTypeID, vertexDefaultValueUpdate);
                            }
                            else
                            {
                                throw new MandatoryConstraintViolationException(aMandatory.MandatoryAttribute);
                            }
                        }
                    }
                }
            }
        }
示例#6
0
        /// <summary>
        /// Removes unique constaints
        /// </summary>
        /// <param name="myUniqueConstraints"></param>
        /// <param name="myVertexType"></param>
        /// <param name="myTransactionToken"></param>
        /// <param name="mySecurityToken"></param>
        private void RemoveUniqueConstraint(IEnumerable<string> myUniqueConstraints, IVertexType myVertexType, TransactionToken myTransactionToken, SecurityToken mySecurityToken)
        {
            if (myUniqueConstraints.IsNotNullOrEmpty())
            {
                foreach (var aUniqueConstraint in myUniqueConstraints)
                {
                    foreach (var item in myVertexType.GetDescendantVertexTypesAndSelf())
                    {
                        foreach (var aUniqueDefinition in item.GetUniqueDefinitions(false))
                        {
                            if (aUniqueDefinition.CorrespondingIndex.IndexedProperties.All(_ => _.Name == aUniqueConstraint))
                            {
                                _indexManager.RemoveIndexInstance(aUniqueDefinition.CorrespondingIndex.ID, myTransactionToken, mySecurityToken);
                            }
                        }

                    }
                }
            }
        }
示例#7
0
        /// <summary>
        /// Checks if the to be added attributes exist in the given vertex type or derived oness
        /// </summary>
        /// <param name="myAlterVertexTypeRequest"></param>
        /// <param name="vertexType"></param>
        private static void CheckToBeAddedAttributes(RequestAlterVertexType myAlterVertexTypeRequest, IVertexType vertexType)
        {
            foreach (var aVertexType in vertexType.GetDescendantVertexTypesAndSelf())
            {
                var attributesOfCurrentVertexType = aVertexType.GetAttributeDefinitions(false).ToList();

                #region binary properties
                if (myAlterVertexTypeRequest.ToBeAddedBinaryProperties != null)
                {
                    foreach (var aToBeAddedAttribute in myAlterVertexTypeRequest.ToBeAddedBinaryProperties)
                    {
                        if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName))
                        {
                            throw new VertexAttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName);
                        }
                    }
                }

                #endregion

                #region outgoing edges

                if (myAlterVertexTypeRequest.ToBeAddedOutgoingEdges != null)
                {
                    foreach (var aToBeAddedAttribute in myAlterVertexTypeRequest.ToBeAddedOutgoingEdges)
                    {
                        if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName))
                        {
                            throw new VertexAttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName);
                        }
                    }
                }

                #endregion

                #region Incoming edges
                if (myAlterVertexTypeRequest.ToBeAddedIncomingEdges != null)
                {
                    foreach (var aToBeAddedAttribute in myAlterVertexTypeRequest.ToBeAddedIncomingEdges)
                    {
                        if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName))
                        {
                            throw new VertexAttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName);
                        }
                    }
                }

                #endregion

                #region property

                if (myAlterVertexTypeRequest.ToBeAddedProperties != null)
                {
                    foreach (var aToBeAddedAttribute in myAlterVertexTypeRequest.ToBeAddedProperties)
                    {
                        if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName))
                        {
                            throw new VertexAttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName);
                        }
                    }
                }

                #endregion

                #region unknown attributes

                if (myAlterVertexTypeRequest.ToBeAddedUnknownAttributes != null)
                {
                    foreach (var aToBeAddedAttribute in myAlterVertexTypeRequest.ToBeAddedUnknownAttributes)
                    {
                        if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName))
                        {
                            throw new VertexAttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName);
                        }
                    }
                }

                #endregion
            }
        }