private void ProcessRenameAttribute(AAlterTypeCommand myAlterCommand, ref RequestAlterEdgeType result) { var command = (AlterType_RenameAttribute)myAlterCommand; result.RenameAttribute(command.OldName, command.NewName); }
private void ProcessDropAttribute(AAlterTypeCommand myAlterCommand, ref RequestAlterEdgeType result) { var command = (AlterType_DropAttributes)myAlterCommand; foreach (var aAttribute in command.ListOfAttributes) { result.RemoveUnknownAttribute(aAttribute); } }
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; } }
private void ProcessChangeComment(AAlterTypeCommand myAlterCommand, ref RequestAlterEdgeType result) { var command = (AlterType_ChangeComment)myAlterCommand; result.SetComment(command.NewComment); }
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); } } }
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; } } }
private void ProcessRenameVertexType(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result) { var command = (AlterType_RenameType)myAlterCommand; result.RenameType(command.NewName); }
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); } }
private void ProcessDropUnique(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result) { var command = (AlterType_DropUnique)myAlterCommand; result.RemoveUnique(command.DroppedUnique); }
private void ProcessUnique(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result) { var command = (AlterType_SetUnique)myAlterCommand; foreach (var aUnique in command.UniqueAttributes) { result.AddUnique(new UniquePredefinition(aUnique)); } }
private void ProcessMandatory(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result) { var command = (AlterType_SetMandatory)myAlterCommand; foreach (var aMandatory in command.MandatoryAttributes) { result.AddMandatory(new MandatoryPredefinition(aMandatory)); } }
private void ProcessDropMandatory(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result) { var command = (AlterType_DropMandatory)myAlterCommand; result.RemoveMandatory(command.DroppedMandatory); }
private void ProcessAddIndex(AAlterTypeCommand myAlterCommand, ref RequestAlterVertexType result) { var command = (AlterType_AddIndices)myAlterCommand; foreach (var aIndexDefinition in command.IdxDefinitionList) { result.AddIndex(GenerateIndex(aIndexDefinition)); } }
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)); } }
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)); } } } }
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; } } }
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; } }