Package org.modeshape.sequencer.ddl.dialect.teiid.TeiidDdlConstants

Examples of org.modeshape.sequencer.ddl.dialect.teiid.TeiidDdlConstants.SchemaElementType


        // ALTER FOREIGN VIEW <identifier> <alter column options>
        // ALTER FOREIGN PROCEDURE <identifier> <alter options list>
        // ALTER FOREIGN PROCEDURE <identifier> <alter column options>

        String nodeType = null;
        SchemaElementType schemaElementType = null;
        String refNodeType = null;

        if (tokens.canConsume(DdlStatement.ALTER_TABLE.tokens())) {
            nodeType = TeiidDdlLexicon.AlterOptions.TABLE_STATEMENT;
            schemaElementType = SchemaElementType.FOREIGN;
            refNodeType = TeiidDdlLexicon.CreateTable.TABLE_STATEMENT;
        } else if (tokens.canConsume(DdlStatement.ALTER_VIEW.tokens())) {
            nodeType = TeiidDdlLexicon.AlterOptions.VIEW_STATEMENT;
            schemaElementType = SchemaElementType.FOREIGN;
            refNodeType = TeiidDdlLexicon.CreateTable.VIEW_STATEMENT;
        } else if (tokens.canConsume(DdlStatement.ALTER_PROCEDURE.tokens())) {
            nodeType = TeiidDdlLexicon.AlterOptions.PROCEDURE_STATEMENT;
            schemaElementType = SchemaElementType.FOREIGN;
            refNodeType = TeiidDdlLexicon.CreateProcedure.PROCEDURE_STATEMENT;
        } else if (tokens.canConsume(DdlStatement.ALTER_VIRTUAL_TABLE.tokens())) {
            nodeType = TeiidDdlLexicon.AlterOptions.TABLE_STATEMENT;
            schemaElementType = SchemaElementType.VIRTUAL;
            refNodeType = TeiidDdlLexicon.CreateTable.TABLE_STATEMENT;
        } else if (tokens.canConsume(DdlStatement.ALTER_VIRTUAL_VIEW.tokens())) {
            nodeType = TeiidDdlLexicon.AlterOptions.VIEW_STATEMENT;
            schemaElementType = SchemaElementType.VIRTUAL;
            refNodeType = TeiidDdlLexicon.CreateTable.VIEW_STATEMENT;
        } else if (tokens.canConsume(DdlStatement.ALTER_VIRTUAL_PROCEDURE.tokens())) {
            nodeType = TeiidDdlLexicon.AlterOptions.PROCEDURE_STATEMENT;
            schemaElementType = SchemaElementType.VIRTUAL;
            refNodeType = TeiidDdlLexicon.CreateProcedure.PROCEDURE_STATEMENT;
        } else if (tokens.canConsume(DdlStatement.ALTER_FOREIGN_TABLE.tokens())) {
            nodeType = TeiidDdlLexicon.AlterOptions.TABLE_STATEMENT;
            schemaElementType = SchemaElementType.FOREIGN;
            refNodeType = TeiidDdlLexicon.CreateTable.TABLE_STATEMENT;
        } else if (tokens.canConsume(DdlStatement.ALTER_FOREIGN_VIEW.tokens())) {
            nodeType = TeiidDdlLexicon.AlterOptions.VIEW_STATEMENT;
            schemaElementType = SchemaElementType.FOREIGN;
            refNodeType = TeiidDdlLexicon.CreateTable.VIEW_STATEMENT;
        } else if (tokens.canConsume(DdlStatement.ALTER_FOREIGN_PROCEDURE.tokens())) {
            nodeType = TeiidDdlLexicon.AlterOptions.PROCEDURE_STATEMENT;
            schemaElementType = SchemaElementType.FOREIGN;
            refNodeType = TeiidDdlLexicon.CreateProcedure.PROCEDURE_STATEMENT;
        } else {
            throw new TeiidDdlParsingException(tokens, "Unparsable alter options statement");
        }

        assert (nodeType != null) : "Create alter options node type is null";
        assert (schemaElementType != null) : "Create alter options schema element type is null";
        assert (refNodeType != null) : "Create alter options reference node type is null";

        // parse table reference
        final String tableRefName = parseIdentifier(tokens);

        final AstNode alterOptionsNode = getNodeFactory().node(tableRefName, parentNode, nodeType);
        alterOptionsNode.setProperty(TeiidDdlLexicon.SchemaElement.TYPE, schemaElementType.toDdl());

        // find referenced table node
        final AstNode tableRefNode = getNode(parentNode, tableRefName, refNodeType);

        // can't find referenced table
View Full Code Here


        // CREATE VIEW <identifier> <create table body>
        // CREATE VIEW <identifier> <create table body> AS <query expression>

        boolean view = true;
        DdlStatement stmt = null;
        SchemaElementType schemaElementType = null;

        if (tokens.canConsume(DdlStatement.CREATE_FOREIGN_TABLE.tokens())) {
            stmt = DdlStatement.CREATE_FOREIGN_TABLE;
            view = false;
            schemaElementType = SchemaElementType.FOREIGN;
        } else if (tokens.canConsume(DdlStatement.CREATE_VIRTUAL_VIEW.tokens())) {
            stmt = DdlStatement.CREATE_VIRTUAL_VIEW;
            schemaElementType = SchemaElementType.VIRTUAL;
        } else if (tokens.canConsume(DdlStatement.CREATE_VIEW.tokens())) {
            stmt = DdlStatement.CREATE_VIEW;
            schemaElementType = SchemaElementType.FOREIGN;
        } else {
            throw new TeiidDdlParsingException(tokens, "Unparsable create table statement");
        }

        assert (stmt != null) : "Create table statement is null";

        // parse identifier
        final String id = parseIdentifier(tokens);
        final AstNode tableNode = getNodeFactory().node(id,
                                                        parentNode,
                                                        (view ? TeiidDdlLexicon.CreateTable.VIEW_STATEMENT : TeiidDdlLexicon.CreateTable.TABLE_STATEMENT));
        tableNode.setProperty(TeiidDdlLexicon.SchemaElement.TYPE, schemaElementType.toDdl());

        // must have a table body
        parseTableBody(tokens, tableNode);

        // may have an AS clause
View Full Code Here

    @Override
    AstNode parse( final DdlTokenStream tokens,
                   final AstNode parentNode ) throws ParsingException {
        boolean procedure = true;
        DdlStatement stmt = null;
        SchemaElementType schemaElementType = null;

        if (tokens.canConsume(DdlStatement.CREATE_VIRTUAL_FUNCTION.tokens())) {
            stmt = DdlStatement.CREATE_VIRTUAL_FUNCTION;
            schemaElementType = SchemaElementType.VIRTUAL;
            procedure = false;
        } else if (tokens.canConsume(DdlStatement.CREATE_VIRTUAL_PROCEDURE.tokens())) {
            stmt = DdlStatement.CREATE_VIRTUAL_PROCEDURE;
            schemaElementType = SchemaElementType.VIRTUAL;
        } else if (tokens.canConsume(DdlStatement.CREATE_FOREIGN_FUNCTION.tokens())) {
            stmt = DdlStatement.CREATE_FOREIGN_FUNCTION;
            schemaElementType = SchemaElementType.FOREIGN;
            procedure = false;
        } else if (tokens.canConsume(DdlStatement.CREATE_FOREIGN_PROCEDURE.tokens())) {
            stmt = DdlStatement.CREATE_FOREIGN_PROCEDURE;
            schemaElementType = SchemaElementType.FOREIGN;
        } else if (tokens.canConsume(DdlStatement.CREATE_FUNCTION.tokens())) {
            stmt = DdlStatement.CREATE_FUNCTION;
            schemaElementType = SchemaElementType.FOREIGN;
            procedure = false;
        } else if (tokens.canConsume(DdlStatement.CREATE_PROCEDURE.tokens())) {
            stmt = DdlStatement.CREATE_PROCEDURE;
            schemaElementType = SchemaElementType.FOREIGN;
        } else {
            throw new TeiidDdlParsingException(tokens, "Unparsable create procedure statement");
        }

        assert (stmt != null) : "Create procedure statement is null";
        assert (schemaElementType != null) : "Create procedure schema element type is null";

        // parse identifier
        final String id = parseIdentifier(tokens);
        final AstNode procedureNode = getNodeFactory().node(id,
                                                            parentNode,
                                                            (procedure ? TeiidDdlLexicon.CreateProcedure.PROCEDURE_STATEMENT : TeiidDdlLexicon.CreateProcedure.FUNCTION_STATEMENT));
        procedureNode.setProperty(TeiidDdlLexicon.SchemaElement.TYPE, schemaElementType.toDdl());

        // must have parens after identifier and may have one or more parameters
        parseProcedureParameters(tokens, procedureNode);

        // may have a returns clause
View Full Code Here

TOP

Related Classes of org.modeshape.sequencer.ddl.dialect.teiid.TeiidDdlConstants.SchemaElementType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.