ParseCreateNodeEdgeViewStatement() public method

public ParseCreateNodeEdgeViewStatement ( string query, IList &errors ) : WSqlFragment
query string
errors IList
return WSqlFragment
Example #1
0
        /// <summary>
        /// Creates Edge View using CREATE EDGE VIEW statement
        /// </summary>
        /// <param name="query"></param>
        public void CreateEdgeView(string query)
        {
            IList<ParseError> errors;
            var parser = new GraphViewParser();
            var script = parser.ParseCreateNodeEdgeViewStatement(query, out errors) as WSqlScript;
            if (errors.Count > 0)
                throw new SyntaxErrorException(errors);

            if (script == null || script.Batches.Count == 0)
            {
                throw new SyntaxErrorException("Invalid CREATE VIEW statement.");
            }

            var statement = script.Batches[0].Statements[0] as WCreateViewStatement;
            if (statement == null)
                throw new SyntaxErrorException("Not a CREATE VIEW statement");
            var edgeViewObjectName = statement.SchemaObjectName;
            string schema = edgeViewObjectName.DatabaseIdentifier == null
                ? "dbo"
                : edgeViewObjectName.DatabaseIdentifier.Value;
            if (edgeViewObjectName.SchemaIdentifier == null)
                throw new SyntaxErrorException(
                    "Source node type should be specified. Format: <Node name>.<Edgeview Name>");
            string nodeName = edgeViewObjectName.SchemaIdentifier.Value;
            string edgeViewName = edgeViewObjectName.BaseIdentifier.Value;
            var visitor = new EdgeViewSelectStatementVisitor();
            List<Tuple<string, string>> edges;
            List<string> edgeAttribute;
            List<Tuple<string, List<Tuple<string, string, string>>>> attributeMapping;
            visitor.Invoke(schema, statement.SelectStatement, out edges, out edgeAttribute, out attributeMapping);
            CreateEdgeView(schema, nodeName, edgeViewName, edges, edgeAttribute, null, attributeMapping);
            statement.SchemaObjectName =
                new WSchemaObjectName(new Identifier
                {
                    Value = string.Format("{0}_{1}_{2}_Sampling", schema, nodeName, edgeViewName)
                });
            string a = statement.ToString();
            //ExecuteNonQuery(statement.ToString());

        }
Example #2
0
        public void CreateNodeView(string query)
        {
            IList<ParseError> errors;
            var parser = new GraphViewParser();
            var script = parser.ParseCreateNodeEdgeViewStatement(query, out errors) as WSqlScript;
            if (errors.Count > 0)
                throw new SyntaxErrorException(errors);

            if (script == null || script.Batches.Count == 0)
            {
                throw new SyntaxErrorException("Invalid CREATE VIEW statement.");
            }

            var statement = script.Batches[0].Statements[0] as WCreateViewStatement;
            if (statement == null)
                throw new SyntaxErrorException("Not a CREATE VIEW statement");
            var nodeViewObjectName = statement.SchemaObjectName;
            string schema = nodeViewObjectName.SchemaIdentifier == null
                ? "dbo"
                : nodeViewObjectName.SchemaIdentifier.Value;
            string nodeViewName = nodeViewObjectName.BaseIdentifier.Value;
            var visitor = new NodeViewSelectStatementVisitor();
            List<string> tableObjList;
            List<Tuple<string, List<Tuple<string, string>>>> propertymapping;
            visitor.Invoke(schema, statement.SelectStatement, out tableObjList, out propertymapping);
            CreateNodeView(schema, nodeViewName, tableObjList, propertymapping);
        }