예제 #1
0
        public override IVertexType AlterVertexType(RequestAlterVertexType myAlterVertexTypeRequest, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
        {
            var vertexType =  _vertexTypeManager.GetVertexType(myAlterVertexTypeRequest.VertexTypeName, myTransactionToken, mySecurityToken);

            if (myAlterVertexTypeRequest.ToBeAddedUnknownAttributes != null)
            {
                var toBeConverted = myAlterVertexTypeRequest.ToBeAddedUnknownAttributes.ToArray();
                foreach (var unknown in toBeConverted)
                {
                    if (BinaryPropertyPredefinition.TypeName.Equals(unknown.AttributeType))
                    {
                        var prop = ConvertUnknownToBinaryProperty(unknown);

                        myAlterVertexTypeRequest.AddBinaryProperty(prop);
                    }
                    else if (IsBaseType(unknown.AttributeType))
                    {
                        var prop = ConvertUnknownToProperty(unknown);

                        myAlterVertexTypeRequest.AddProperty(prop);
                    }
                    else if (unknown.AttributeType.Contains(IncomingEdgePredefinition.TypeSeparator))
                    {
                        var prop = ConvertUnknownToIncomingEdge(unknown);
                        myAlterVertexTypeRequest.AddIncomingEdge(prop);
                    }
                    else
                    {
                        var prop = ConvertUnknownToOutgoingEdge(unknown);
                        myAlterVertexTypeRequest.AddOutgoingEdge(prop);
                    }
                }
                myAlterVertexTypeRequest.ResetUnknown();
            }

            if (myAlterVertexTypeRequest.ToBeRemovedUnknownAttributes != null)
            {
                foreach (var unknownProp in myAlterVertexTypeRequest.ToBeRemovedUnknownAttributes)
                {
                    var attrDef = vertexType.GetAttributeDefinition(unknownProp);
                    if (attrDef == null)
                        throw new VertexAttributeIsNotDefinedException(unknownProp);

                    switch (attrDef.Kind)
                    {
                        case AttributeType.Property:
                            myAlterVertexTypeRequest.RemoveProperty(unknownProp);
                            break;
                        case AttributeType.OutgoingEdge:
                            myAlterVertexTypeRequest.RemoveOutgoingEdge(unknownProp);
                            break;
                        case AttributeType.IncomingEdge:
                            myAlterVertexTypeRequest.RemoveIncomingEdge(unknownProp);
                            break;
                        case AttributeType.BinaryProperty:
                            myAlterVertexTypeRequest.RemoveBinaryProperty(unknownProp);
                            break;
                        default:
                            throw new Exception("The enumeration AttributeType was changed, but not this switch statement.");
                    }
                }
                myAlterVertexTypeRequest.ClearToBeRemovedUnknownAttributes();
            }

            #region checks

            CheckToBeAddedAttributes(myAlterVertexTypeRequest, vertexType);
            CheckToBeRemovedAttributes(myAlterVertexTypeRequest, vertexType);
            CheckToBeRenamedAttributes(myAlterVertexTypeRequest, vertexType);
            CheckNewVertexTypeName(myAlterVertexTypeRequest.AlteredVertexTypeName, mySecurityToken, myTransactionToken);
            CheckToBeAddedMandatory(myAlterVertexTypeRequest, vertexType);
            CheckToBeAddedUniques(myAlterVertexTypeRequest, vertexType);
            CheckToBeRemovedMandatoryAndUnique(myAlterVertexTypeRequest.ToBeRemovedMandatories, myAlterVertexTypeRequest.ToBeRemovedUniques, vertexType);
            CheckToBeAddedIndices(myAlterVertexTypeRequest.ToBeAddedIndices, vertexType);
            CheckToBeRemovedIndices(myAlterVertexTypeRequest.ToBeRemovedIndices, vertexType);

            #endregion

            return null;
        }