コード例 #1
0
ファイル: AlterEdgeTypeNode.cs プロジェクト: anukat2015/sones
        private void ProcessRenameAttribute(AAlterTypeCommand myAlterCommand,
                                            ref RequestAlterEdgeType result)
        {
            var command = (AlterType_RenameAttribute)myAlterCommand;

            result.RenameAttribute(command.OldName, command.NewName);
        }
コード例 #2
0
ファイル: AlterEdgeTypeNode.cs プロジェクト: anukat2015/sones
        private void ProcessDropAttribute(AAlterTypeCommand myAlterCommand,
                                            ref RequestAlterEdgeType result)
        {
            var command = (AlterType_DropAttributes)myAlterCommand;

            foreach (var aAttribute in command.ListOfAttributes)
            {
                result.RemoveUnknownAttribute(aAttribute);
            }
        }
コード例 #3
0
ファイル: AlterEdgeTypeNode.cs プロジェクト: anukat2015/sones
        private void ProcessAlterCommand(AAlterTypeCommand myAlterCommand, ref RequestAlterEdgeType result)
        {
            switch (myAlterCommand.AlterType)
            {
                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:
                    ProcessRenameType(myAlterCommand, ref result);
                    break;

                case TypesOfAlterCmd.ChangeComment:
                    ProcessChangeComment(myAlterCommand, ref result);
                    break;

                default:
                    break;
            }
        }
コード例 #4
0
ファイル: AlterEdgeTypeNode.cs プロジェクト: anukat2015/sones
        private void ProcessChangeComment(AAlterTypeCommand myAlterCommand, 
                                            ref RequestAlterEdgeType result)
        {
            var command = (AlterType_ChangeComment)myAlterCommand;

            result.SetComment(command.NewComment);
        }
コード例 #5
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);
                }
            }
        }
コード例 #6
0
        public void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            if (HasChildNodes(parseNode))
            {

                switch (parseNode.ChildNodes[0].Token.Text.ToLower())
                {
                    case "add":

                        #region add

                        #region data

                        var listOfToBeAddedAttributes = new List<AttributeDefinition>();

                        #endregion

                        #region add attributes

                        foreach (ParseTreeNode aNode in parseNode.ChildNodes[2].ChildNodes)
                        {
                            if (aNode.AstNode is EdgeTypeAttributeDefinitionNode)
                                listOfToBeAddedAttributes.Add(((EdgeTypeAttributeDefinitionNode)aNode.AstNode).AttributeDefinition);
                            else
                                throw new NotImplementedException(aNode.AstNode.GetType().ToString());
                        }

                        AlterTypeCommand = new AlterEdgeType_AddAttributes(listOfToBeAddedAttributes);

                        #endregion

                        #endregion

                        break;

                    case "drop":

                        #region drop

                        #region data

                        List<String> listOfToBeDroppedAttributes = new List<string>();

                        #endregion

                        foreach (ParseTreeNode aNode in parseNode.ChildNodes[2].ChildNodes)
                        {
                            listOfToBeDroppedAttributes.Add(aNode.Token.ValueString);
                        }

                        AlterTypeCommand = new AlterType_DropAttributes(listOfToBeDroppedAttributes);

                        #endregion

                        break;

                    case "rename":

                        #region rename

                        if (parseNode.ChildNodes.Count > 3)
                            AlterTypeCommand = new AlterType_RenameAttribute() 
                                                    { OldName = parseNode.ChildNodes[2].Token.ValueString, 
                                                      NewName = parseNode.ChildNodes[4].Token.ValueString };
                        else if (parseNode.ChildNodes.Count <= 3)
                            AlterTypeCommand = new AlterType_RenameType() 
                                                    { NewName = parseNode.ChildNodes[2].Token.ValueString };

                        #endregion

                        break;

                    case "comment":

                        #region comment

                        AlterTypeCommand = new AlterType_ChangeComment() 
                                                { NewComment = parseNode.ChildNodes[2].Token.ValueString };

                        #endregion

                        break;

                    case "undefine":

                        #region undefine

                        #region data

                        var listOfUndefAttributes = new List<String>();

                        #endregion

                        #region undefine attributes

                        parseNode.ChildNodes[2].ChildNodes.ForEach(node => listOfUndefAttributes.Add(node.Token.ValueString));

                        AlterTypeCommand = new AlterType_UndefineAttributes(listOfUndefAttributes);

                        #endregion

                        #endregion

                        break;

                    case "define":

                        #region define

                        #region data

                        var listOfDefinedAttributes = new List<AttributeDefinition>();

                        #endregion

                        parseNode
                            .ChildNodes[2]
                            .ChildNodes
                            .ForEach(node => listOfDefinedAttributes.Add(((VertexTypeAttributeDefinitionNode)node.AstNode).AttributeDefinition));

                        AlterTypeCommand = new AlterType_DefineAttributes(listOfDefinedAttributes);
                        
                        #endregion

                        break;
                }
            }
        }
コード例 #7
0
        private void ProcessRenameVertexType(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_RenameType)myAlterCommand;

            result.RenameType(command.NewName);
        }
コード例 #8
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);
            }
        }
コード例 #9
0
        private void ProcessDropUnique(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_DropUnique)myAlterCommand;

            result.RemoveUnique(command.DroppedUnique);
        }
コード例 #10
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));
            }

        }
コード例 #11
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));
            }
        }
コード例 #12
0
        private void ProcessDropMandatory(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_DropMandatory)myAlterCommand;

            result.RemoveMandatory(command.DroppedMandatory);
        }
コード例 #13
0
        private void ProcessAddIndex(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result)
        {
            var command = (AlterType_AddIndices)myAlterCommand;

            foreach (var aIndexDefinition in command.IdxDefinitionList)
            {
                result.AddIndex(GenerateIndex(aIndexDefinition));
            }
        }
コード例 #14
0
ファイル: AlterEdgeTypeNode.cs プロジェクト: anukat2015/sones
        private void ProcessAddAttribute(AAlterTypeCommand myAlterCommand,
                                            ref RequestAlterEdgeType result)
        {
            var command = (AlterEdgeType_AddAttributes)myAlterCommand;

            if (command.ListOfAttributes != null && command.ListOfAttributes.Count > 0)
                foreach (var aAttribute in command.ListOfAttributes)
                {
                    result.AddUnknownAttribute(GenerateUnknownAttribute(aAttribute));
                }
        }
コード例 #15
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));
                    }
                }
            }
            
        }
コード例 #16
0
ファイル: AlterCommandNode.cs プロジェクト: loubo/sones
        public void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            if (HasChildNodes(parseNode))
            {

                switch (parseNode.ChildNodes[0].Token.Text.ToLower())
                {
                    case "drop":

                        #region drop

                        if (parseNode.ChildNodes[1].AstNode is IndexDropOnAlterType)
                        {
                            var dropNodeExcept = (IndexDropOnAlterType)parseNode.ChildNodes[1].AstNode;

                            AlterTypeCommand = new AlterType_DropIndices(dropNodeExcept.DropIndexList);

                            break;
                        }

                        if (parseNode.ChildNodes.Count == 4 && parseNode.ChildNodes[1].Token.Text.ToLower() == SonesGQLGrammar.TERMINAL_UNIQUE.ToLower())
                        {
                            AlterTypeCommand = new AlterType_DropUnique(parseNode.ChildNodes[3].Token.ValueString);
                            break;
                        }

                        if (parseNode.ChildNodes.Count == 4 && parseNode.ChildNodes[1].Token.Text.ToUpper() == SonesGQLGrammar.TERMINAL_MANDATORY.ToUpper())
                        {
                            AlterTypeCommand = new AlterType_DropMandatory(parseNode.ChildNodes[3].Token.ValueString);
                            break;
                        }

                        #region data

                        List<String> listOfToBeDroppedAttributes = new List<string>();

                        #endregion

                        foreach (ParseTreeNode aNode in parseNode.ChildNodes[2].ChildNodes)
                        {
                            listOfToBeDroppedAttributes.Add(aNode.Token.ValueString);
                        }

                        AlterTypeCommand = new AlterType_DropAttributes(listOfToBeDroppedAttributes);

                        #endregion

                        break;

                    case "add":

                        #region add

                        if (parseNode.ChildNodes[1].AstNode is IndexOnCreateTypeNode)
                        {
                            #region data

                            var _IndexInformation = new List<IndexDefinition>();

                            #endregion

                            #region add indices

                            var indexOnCreateTypeNode = (IndexOnCreateTypeNode)parseNode.ChildNodes[1].AstNode;

                            _IndexInformation.AddRange(indexOnCreateTypeNode.ListOfIndexDefinitions);

                            AlterTypeCommand = new AlterType_AddIndices(_IndexInformation);

                            #endregion
                        }
                        else
                        {
                            #region data

                            var listOfToBeAddedAttributes = new List<AttributeDefinition>();
                            var _BackwardEdgeInformation = new List<IncomingEdgeDefinition>();

                            #endregion

                            #region add attributes

                            foreach (ParseTreeNode aNode in parseNode.ChildNodes[2].ChildNodes)
                            {
                                if (aNode.AstNode is AttributeDefinitionNode)
                                {
                                    listOfToBeAddedAttributes.Add(((AttributeDefinitionNode)aNode.AstNode).AttributeDefinition);
                                }
                                else if (aNode.AstNode is IncomingEdgeNode)
                                {
                                    _BackwardEdgeInformation.Add((aNode.AstNode as IncomingEdgeNode).BackwardEdgeDefinition);
                                }
                                else
                                {
                                    throw new NotImplementedException(aNode.AstNode.GetType().ToString());
                                }
                            }

                            AlterTypeCommand = new AlterType_AddAttributes(listOfToBeAddedAttributes, _BackwardEdgeInformation);

                            #endregion
                        }

                        #endregion

                        break;

                    case "rename":

                        #region rename

                        if (parseNode.ChildNodes.Count > 3)
                        {
                            if (parseNode.ChildNodes[1].Token.Text.ToUpper() == SonesGQLConstants.INCOMINGEDGE)
                            {
                                AlterTypeCommand = new AlterType_RenameIncomingEdge() { OldName = parseNode.ChildNodes[2].Token.ValueString, NewName = parseNode.ChildNodes[4].Token.ValueString };
                            }
                            else
                            {
                                AlterTypeCommand = new AlterType_RenameAttribute() { OldName = parseNode.ChildNodes[2].Token.ValueString, NewName = parseNode.ChildNodes[4].Token.ValueString };
                            }
                        }
                        else if (parseNode.ChildNodes.Count <= 3)
                        {
                            AlterTypeCommand = new AlterType_RenameVertexType() { NewName = parseNode.ChildNodes[2].Token.ValueString };
                        }

                        #endregion

                        break;

                    case "comment":

                        #region comment

                        AlterTypeCommand = new AlterType_ChangeComment() { NewComment = parseNode.ChildNodes[2].Token.ValueString };

                        #endregion

                        break;

                    case "undefine":

                        #region data

                        var listOfUndefAttributes = new List<String>();

                        #endregion

                        #region undefine attributes

                        parseNode.ChildNodes[2].ChildNodes.ForEach(node => listOfUndefAttributes.Add(node.Token.ValueString));

                        AlterTypeCommand = new AlterType_UndefineAttributes(listOfUndefAttributes);

                        #endregion

                        break;

                    case "define":

                        #region data

                        var listOfDefinedAttributes = new List<AttributeDefinition>();

                        #endregion

                        parseNode.ChildNodes[2].ChildNodes.ForEach(node => listOfDefinedAttributes.Add(((AttributeDefinitionNode)node.AstNode).AttributeDefinition));

                        AlterTypeCommand = new AlterType_DefineAttributes(listOfDefinedAttributes);

                        break;
                }
            }
        }
コード例 #17
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;
            }
        }