示例#1
0
 internal ServiceAlterVertexChangeset(RequestAlterVertexType myRequestAlterVertexType)
 {
     this.NewTypeName         = myRequestAlterVertexType.AlteredTypeName;
     this.Comment             = myRequestAlterVertexType.AlteredComment;
     this.ToBeAddedProperties = (myRequestAlterVertexType.ToBeAddedProperties == null)
         ? null : myRequestAlterVertexType.ToBeAddedProperties.Select(x => new ServicePropertyPredefinition(x)).ToArray();
     this.ToBeAddedIncomingEdges = (myRequestAlterVertexType.ToBeAddedIncomingEdges == null)
         ? null : myRequestAlterVertexType.ToBeAddedIncomingEdges.Select(x => new ServiceIncomingEdgePredefinition(x)).ToArray();
     this.ToBeAddedOutgoingEdges = (myRequestAlterVertexType.ToBeAddedOutgoingEdges == null)
         ? null : myRequestAlterVertexType.ToBeAddedOutgoingEdges.Select(x => new ServiceOutgoingEdgePredefinition(x)).ToArray();
     this.ToBeAddedIndices = (myRequestAlterVertexType.ToBeAddedIndices == null)
         ? null : myRequestAlterVertexType.ToBeAddedIndices.Select(x => new ServiceIndexPredefinition(x)).ToArray();
     this.ToBeAddedUniques = (myRequestAlterVertexType.ToBeAddedUniques == null)
         ? null : myRequestAlterVertexType.ToBeAddedUniques.Select(x => new ServiceUniquePredefinition(x)).ToArray();
     this.ToBeAddedMandatories = (myRequestAlterVertexType.ToBeAddedMandatories == null)
         ? null : myRequestAlterVertexType.ToBeAddedMandatories.Select(x => new ServiceMandatoryPredefinition(x)).ToArray();
     this.ToBeRemovedProperties = (myRequestAlterVertexType.ToBeRemovedProperties == null)
         ? null : myRequestAlterVertexType.ToBeRemovedProperties.ToArray();
     this.ToBeRemovedIncomingEdges = (myRequestAlterVertexType.ToBeRemovedIncomingEdges == null)
         ? null : myRequestAlterVertexType.ToBeRemovedIncomingEdges.ToArray();
     this.ToBeRemovedOutgoingEdges = (myRequestAlterVertexType.ToBeRemovedOutgoingEdges == null)
         ? null : myRequestAlterVertexType.ToBeRemovedOutgoingEdges.ToArray();
     this.ToBeRemovedIndices = myRequestAlterVertexType.ToBeRemovedIndices;
     this.ToBeRemovedUniques = (myRequestAlterVertexType.ToBeRemovedUniques == null)
         ? null : myRequestAlterVertexType.ToBeRemovedUniques.ToArray();
     this.ToBeRemovedMandatories = (myRequestAlterVertexType.ToBeRemovedMandatories == null)
         ? null : myRequestAlterVertexType.ToBeRemovedMandatories.ToArray();
     this.ToBeRenamedProperties = myRequestAlterVertexType.ToBeRenamedProperties;
     this.ToBeDefinedAttributes = (myRequestAlterVertexType.ToBeDefinedAttributes == null)
         ? null : myRequestAlterVertexType.ToBeDefinedAttributes.Select(x => new ServiceUnknownAttributePredefinition(x)).ToArray();
     this.ToBeUndefinedAttributes = (myRequestAlterVertexType.ToBeUndefinedAttributes == null)
         ? null : myRequestAlterVertexType.ToBeUndefinedAttributes.ToArray();
 }
示例#2
0
 /// <summary>
 /// Creates a new pipelineable alter type request
 /// </summary>
 /// <param name="myRequest">The alter type request</param>
 /// <param name="mySecurity">The security token of the request initiator</param>
 /// <param name="myTransactionToken">The myOutgoingEdgeVertex transaction token</param>
 public PipelineableAlterVertexTypeRequest(RequestAlterVertexType myRequest,
                                           SecurityToken mySecurityToken,
                                           Int64 myTransactionToken)
     : base(mySecurityToken, myTransactionToken)
 {
     _request = myRequest;
 }
示例#3
0
        private void ProcessMandatory(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_SetMandatory)myAlterCommand;

            foreach (var aMandatory in command.MandatoryAttributes)
            {
                result.AddMandatory(new MandatoryPredefinition(aMandatory));
            }
        }
示例#4
0
        private void ProcessDropAttribute(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_DropAttributes)myAlterCommand;

            foreach (var aAttribute in command.ListOfAttributes)
            {
                result.RemoveUnknownAttribute(aAttribute);
            }
        }
示例#5
0
        private void ProcessAddIndex(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_AddIndices)myAlterCommand;

            foreach (var aIndexDefinition in command.IdxDefinitionList)
            {
                result.AddIndex(GenerateIndex(aIndexDefinition));
            }
        }
示例#6
0
        private void ProcessDropIndex(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_DropIndices)myAlterCommand;

            foreach (var aIndex in command.IdxDropList)
            {
                result.RemoveIndex(aIndex.Key, aIndex.Value);
            }
        }
示例#7
0
        private void ProcessUnique(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_SetUnique)myAlterCommand;

            foreach (var aUnique in command.UniqueAttributes)
            {
                result.AddUnique(new UniquePredefinition(aUnique));
            }
        }
示例#8
0
        private RequestAlterVertexType CreateNewRequest(IGraphDB myGraphDB, GQLPluginManager myPluginManager, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            RequestAlterVertexType result = new RequestAlterVertexType(_TypeName);

            foreach (var aAlterCommand in _AlterTypeCommand)
            {
                ProcessAlterCommand(aAlterCommand, ref result);
            }

            return(result);
        }
示例#9
0
        private void ProcessUndefineAttribute(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_UndefineAttributes)myAlterCommand;

            if (command.ListOfAttributes != null && command.ListOfAttributes.Count > 0)
            {
                foreach (var aAttribute in command.ListOfAttributes)
                {
                    result.UndefineAttribute(aAttribute);
                }
            }
        }
示例#10
0
        /// <summary>
        /// Reads an attribute definition from the GraphML File and stores
        /// it internal for later usage on vertex / edge reading.
        /// </summary>
        /// <param name='myReader'>
        /// XmlReader
        /// </param>
        private void ReadAttributeDefinition(XmlReader myReader)
        {
            #region data

            var attrId   = myReader.GetAttribute(GraphMLTokens.ID);
            var attrFor  = myReader.GetAttribute(GraphMLTokens.FOR);
            var attrName = myReader.GetAttribute(GraphMLTokens.ATTRIBUTE_NAME);
            var attrType = myReader.GetAttribute(GraphMLTokens.ATTRIBUTE_TYPE).ToLower();

            string attrDefault = null;

            using (var readerAttribute = myReader.ReadSubtree())
            {
                while (readerAttribute.Read())
                {
                    if (readerAttribute.Name == GraphMLTokens.DEFAULT)
                    {
                        attrDefault = readerAttribute.ReadElementContentAsString();
                    }
                }
            }

            // make attribute type DB conform (capitalize first letter)
            attrType = char.ToUpper(attrType[0]) + attrType.Substring(1).ToLower();
            // and store the whole definition
            _AttributeDefinitions.Add(attrId, new Tuple <string, string, string, string>(attrFor, attrName, attrType, attrDefault));
            // get GraphDB internal type
            attrType = GetInternalTypeName(attrType);

            #endregion

            #region alter vertex type with new attribute

            if (attrFor.Equals(GraphMLTokens.VERTEX))
            {
                var requestAlterVertexType = new RequestAlterVertexType(_VertexTypeName);

                var propertyPreDefinition = new PropertyPredefinition(attrName, attrType);

                propertyPreDefinition.SetDefaultValue(attrDefault);

                requestAlterVertexType.AddProperty(propertyPreDefinition);

                _GraphDB.AlterVertexType(_SecurityToken,
                                         _TransactionToken,
                                         requestAlterVertexType,
                                         (stats, vType) => vType);
            }

            #endregion
        }
示例#11
0
        private void ProcessAddAttribute(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterVertexType_AddAttributes)myAlterCommand;

            if (command.ListOfAttributes != null && command.ListOfAttributes.Count > 0)
            {
                foreach (var aAttribute in command.ListOfAttributes)
                {
                    result.AddUnknownAttribute(GenerateUnknownAttribute(aAttribute));
                }
            }
            else
            {
                if (command.BackwardEdgeInformation != null && command.BackwardEdgeInformation.Count > 0)
                {
                    foreach (var aIncomingEdge in command.BackwardEdgeInformation)
                    {
                        result.AddIncomingEdge(GenerateAIncomingEdge(aIncomingEdge));
                    }
                }
            }
        }
示例#12
0
        /// <summary>
        /// Checks if the specified mandatory attribute exist on type.
        /// </summary>
        /// <param name="myAlterTypeRequest">The request.</param>
        /// <param name="myType">The type.</param>
        private static void CheckToBeAddedMandatory(RequestAlterVertexType myAlterTypeRequest,
                                                    IVertexType myType)
        {
            var mandatories   = myAlterTypeRequest.ToBeAddedMandatories;
            var addProperties = myAlterTypeRequest.ToBeAddedProperties;

            if (mandatories == null)
            {
                return;
            }

            var attributes = myType.GetAttributeDefinitions(false).ToList();

            foreach (var aMandatory in mandatories)
            {
                if (!attributes.Any(_ => _.Name == aMandatory.MandatoryAttribute) &&
                    !addProperties.Any(x => x.AttributeName == aMandatory.MandatoryAttribute))
                {
                    throw new AttributeDoesNotExistException(aMandatory.MandatoryAttribute, myType.Name);
                }
            }
        }
示例#13
0
        /// <summary>
        /// Checks if the specified unique attribute exist on type.
        /// </summary>
        /// <param name="myAlterTypeRequest">The request.</param>
        /// <param name="myType">The type.</param>
        private static void CheckToBeAddedUniques(RequestAlterVertexType myAlterTypeRequest,
                                                  IVertexType myType)
        {
            var uniques       = myAlterTypeRequest.ToBeAddedUniques;
            var addProperties = myAlterTypeRequest.ToBeAddedProperties;

            if (uniques == null)
            {
                return;
            }

            var attributes = myType.GetAttributeDefinitions(false).ToList();

            foreach (var aUnique in uniques)
            {
                foreach (var aAttribute in aUnique.Properties)
                {
                    if (!attributes.Any(_ => _.Name == aAttribute) && !addProperties.Any(x => x.AttributeName == aAttribute))
                    {
                        throw new AttributeDoesNotExistException(aAttribute, myType.Name);
                    }
                }
            }
        }
示例#14
0
        private void ProcessChangeComment(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_ChangeComment)myAlterCommand;

            result.SetComment(command.NewComment);
        }
示例#15
0
        public static RequestAlterVertexType MakeRequestAlterVertexType(ServiceVertexType myVertexType, ServiceAlterVertexChangeset myChangeset)
        {
            var Request = new RequestAlterVertexType(myVertexType.Name);

            #region Add Attributes

            if (myChangeset.ToBeAddedProperties != null)
            {
                foreach (var toAdd in myChangeset.ToBeAddedProperties)
                {
                    Request.AddProperty(toAdd.ToPropertyPredefinition());
                }
            }

            if (myChangeset.ToBeAddedIncomingEdges != null)
            {
                foreach (var toAdd in myChangeset.ToBeAddedIncomingEdges)
                {
                    Request.AddIncomingEdge(toAdd.ToIncomingEdgePredefinition());
                }
            }

            if (myChangeset.ToBeAddedOutgoingEdges != null)
            {
                foreach (var toAdd in myChangeset.ToBeAddedOutgoingEdges)
                {
                    Request.AddOutgoingEdge(toAdd.ToOutgoingEdgePredefinition());
                }
            }

            if (myChangeset.ToBeAddedUniques != null)
            {
                foreach (var toAdd in myChangeset.ToBeAddedUniques)
                {
                    Request.AddUnique(toAdd.ToUniquePredefinition());
                }
            }

            if (myChangeset.ToBeAddedMandatories != null)
            {
                foreach (var toAdd in myChangeset.ToBeAddedMandatories)
                {
                    Request.AddMandatory(toAdd.ToMandatoryPredefinition());
                }
            }

            if (myChangeset.ToBeAddedIndices != null)
            {
                foreach (var toAdd in myChangeset.ToBeAddedIndices)
                {
                    Request.AddIndex(toAdd.ToIndexPredefinition());
                }
            }


            #endregion

            #region Remove Attributes

            if (myChangeset.ToBeRemovedProperties != null)
            {
                foreach (var toDel in myChangeset.ToBeRemovedProperties)
                {
                    Request.RemoveProperty(toDel);
                }
            }

            if (myChangeset.ToBeRemovedIncomingEdges != null)
            {
                foreach (var toDel in myChangeset.ToBeRemovedIncomingEdges)
                {
                    Request.RemoveIncomingEdge(toDel);
                }
            }

            if (myChangeset.ToBeRemovedOutgoingEdges != null)
            {
                foreach (var toDel in myChangeset.ToBeRemovedOutgoingEdges)
                {
                    Request.RemoveOutgoingEdge(toDel);
                }
            }

            if (myChangeset.ToBeRemovedUniques != null)
            {
                foreach (var toDel in myChangeset.ToBeRemovedUniques)
                {
                    Request.RemoveUnique(toDel);
                }
            }

            if (myChangeset.ToBeRemovedMandatories != null)
            {
                foreach (var toDel in myChangeset.ToBeRemovedMandatories)
                {
                    Request.RemoveMandatory(toDel);
                }
            }

            if (myChangeset.ToBeRemovedIndices != null)
            {
                foreach (var toDel in myChangeset.ToBeRemovedIndices)
                {
                    Request.RemoveIndex(toDel.Key, toDel.Value);
                }
            }

            #endregion

            #region define / undefine

            if (myChangeset.ToBeDefinedAttributes != null)
            {
                foreach (var toDefine in myChangeset.ToBeDefinedAttributes)
                {
                    Request.DefineAttribute(toDefine.ToUnknownAttributePredefinition());
                }
            }

            if (myChangeset.ToBeUndefinedAttributes != null)
            {
                foreach (var toUndefine in myChangeset.ToBeUndefinedAttributes)
                {
                    Request.UndefineAttribute(toUndefine);
                }
            }

            #endregion

            #region Rename Task

            if (myChangeset.ToBeRenamedProperties != null)
            {
                foreach (var toRename in myChangeset.ToBeRenamedProperties)
                {
                    Request.RenameAttribute(toRename.Key, toRename.Value);
                }
            }

            #endregion

            if (myChangeset.Comment != null)
            {
                Request.SetComment(myChangeset.Comment);
            }

            if (myChangeset.NewTypeName != null)
            {
                Request.RenameType(myChangeset.NewTypeName);
            }

            //todo add unknown attribute

            return(Request);
        }
示例#16
0
        public TResult AlterVertexType <TResult>(SecurityToken mySecurityToken, Int64 myTransactionToken, RequestAlterVertexType myRequestAlterVertexType, Converter.AlterVertexTypeResultConverter <TResult> myOutputconverter)
        {
            var executedRequest = _requestManager.SynchronExecution(new PipelineableAlterVertexTypeRequest(myRequestAlterVertexType,
                                                                                                           mySecurityToken,
                                                                                                           myTransactionToken));

            return(((PipelineableAlterVertexTypeRequest)executedRequest).GenerateRequestResult(myOutputconverter));
        }
示例#17
0
 public TResult AlterVertexType <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, Int64 myTransactionToken, RequestAlterVertexType myRequestAlterVertexType, Converter.AlterVertexTypeResultConverter <TResult> myOutputconverter)
 {
     return(_iGraphDB.AlterVertexType <TResult>(
                mySecurityToken,
                myTransactionToken,
                myRequestAlterVertexType,
                myOutputconverter));
 }
示例#18
0
 public TResult AlterVertexType <TResult>(SecurityToken mySecurityToken, Int64 myTransactionToken, RequestAlterVertexType myRequestAlterVertexType, Converter.AlterVertexTypeResultConverter <TResult> myOutputconverter)
 {
     throw new NotImplementedException();
 }
示例#19
0
        public override IVertexType AlterType(IRequestAlterType myAlterTypeRequest,
                                              Int64 myTransactionToken,
                                              SecurityToken mySecurityToken,
                                              out RequestUpdate myUpdateRequest)
        {
            CheckRequestType(myAlterTypeRequest);

            RequestAlterVertexType myRequest = myAlterTypeRequest as RequestAlterVertexType;

            var vertexType = _TypeManager.GetType(myRequest.TypeName,
                                                  myTransactionToken,
                                                  mySecurityToken);

            #region check to be added

            if (myRequest.ToBeAddedUnknownAttributes != null)
            {
                var toBeConverted = myRequest.ToBeAddedUnknownAttributes.ToArray();

                foreach (var unknown in toBeConverted)
                {
                    if (BinaryPropertyPredefinition.TypeName.Equals(unknown.AttributeType))
                    {
                        var prop = ConvertUnknownToBinaryProperty(unknown);

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

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

                myRequest.ResetUnknown();
            }

            #endregion

            #region check to be removed

            if (myRequest.ToBeRemovedUnknownAttributes != null)
            {
                foreach (var unknownProp in myRequest.ToBeRemovedUnknownAttributes)
                {
                    var attrDef = vertexType.GetAttributeDefinition(unknownProp);

                    if (attrDef == null)
                    {
                        throw new AttributeDoesNotExistException(unknownProp);
                    }

                    switch (attrDef.Kind)
                    {
                    case AttributeType.Property:
                        myRequest.RemoveProperty(unknownProp);
                        break;

                    case AttributeType.OutgoingEdge:
                        myRequest.RemoveOutgoingEdge(unknownProp);
                        break;

                    case AttributeType.IncomingEdge:
                        myRequest.RemoveIncomingEdge(unknownProp);
                        break;

                    case AttributeType.BinaryProperty:
                        myRequest.RemoveBinaryProperty(unknownProp);
                        break;

                    default:
                        throw new Exception("The enumeration AttributeType was changed, but not this switch statement.");
                    }
                }

                myRequest.ClearToBeRemovedUnknownAttributes();
            }

            #endregion

            #region check attributes to be defined
            if (myRequest.ToBeDefinedAttributes != null)
            {
                foreach (var unknownProp in myRequest.ToBeDefinedAttributes)
                {
                    var toBeDefined = myRequest.ToBeDefinedAttributes.ToArray();

                    foreach (var unknown in toBeDefined)
                    {
                        if (BinaryPropertyPredefinition.TypeName.Equals(unknown.AttributeType))
                        {
                            throw new InvalidDefineAttributeTypeException(BinaryPropertyPredefinition.TypeName, vertexType.Name);
                        }
                        else if (unknown.AttributeType.Contains(IncomingEdgePredefinition.TypeSeparator))
                        {
                            throw new InvalidDefineAttributeTypeException("incoming edge", vertexType.Name);
                        }
                        else if (!_baseTypeManager.IsBaseType(unknown.AttributeType))
                        {
                            throw new InvalidDefineAttributeTypeException("user defined", vertexType.Name);
                        }
                    }
                }
            }
            #endregion

            #region check attributes to be undefined

            if (myRequest.ToBeUndefinedAttributes != null)
            {
                foreach (var attr in myRequest.ToBeUndefinedAttributes)
                {
                    var attrDef = vertexType.GetAttributeDefinition(attr);

                    if (attrDef == null)
                    {
                        throw new AttributeDoesNotExistException(attr);
                    }

                    switch (attrDef.Kind)
                    {
                    case AttributeType.Property:
                        break;

                    case AttributeType.OutgoingEdge:
                        throw new InvalidUndefineAttributeTypeException("Outgoing Edge", vertexType.Name);

                    case AttributeType.IncomingEdge:
                        throw new InvalidUndefineAttributeTypeException("Incoming Edge", vertexType.Name);

                    case AttributeType.BinaryProperty:
                        throw new InvalidUndefineAttributeTypeException(BinaryPropertyPredefinition.TypeName, vertexType.Name);

                    default:
                        throw new Exception("The enumeration AttributeType was changed, but not this switch statement.");
                    }
                }
            }

            #endregion

            #region checks

            CallCheckFunctions(myAlterTypeRequest, vertexType, myTransactionToken, mySecurityToken);

            #endregion

            myUpdateRequest = new RequestUpdate();

            return(null);
        }
示例#20
0
        private void ProcessAlterCommand(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            switch (myAlterCommand.AlterType)
            {
            case TypesOfAlterCmd.DropIndex:

                ProcessDropIndex(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.AddIndex:

                ProcessAddIndex(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.AddAttribute:

                ProcessAddAttribute(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.DropAttribute:

                ProcessDropAttribute(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.RenameAttribute:

                ProcessRenameAttribute(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.RenameType:

                ProcessRenameVertexType(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.RenameIncomingEdge:

                ProcessRenameIncomingEdge(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.Unqiue:

                ProcessUnique(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.DropUnqiue:

                ProcessDropUnique(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.Mandatory:

                ProcessMandatory(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.DropMandatory:

                ProcessDropMandatory(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.ChangeComment:

                ProcessChangeComment(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.DefineAttribute:

                ProcessDefineAttribute(myAlterCommand, ref result);

                break;

            case TypesOfAlterCmd.UndefineAttribute:

                ProcessUndefineAttribute(myAlterCommand, ref result);

                break;

            default:
                break;
            }
        }
示例#21
0
        private void ProcessDropMandatory(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_DropMandatory)myAlterCommand;

            result.RemoveMandatory(command.DroppedMandatory);
        }
示例#22
0
        private void ProcessRenameAttribute(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_RenameAttribute)myAlterCommand;

            result.RenameAttribute(command.OldName, command.NewName);
        }
示例#23
0
        private void ProcessDropUnique(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_DropUnique)myAlterCommand;

            result.RemoveUnique(command.DroppedUnique);
        }