Search in sources :

Example 1 with NikitaODataToSQLWalker

use of nikita.webapp.odata.NikitaODataToSQLWalker in project nikita-noark5-core by HiOA-ABI.

the class TestODataApp method main.

public static void main(String[] args) throws Exception {
    System.out.println("Starting OData parser test");
    System.out.println("Picks first line from odata_samples.txt in " + "resources folder.");
    try {
        AfterApplicationStartup afterApplicationStartup = new AfterApplicationStartup(null);
        afterApplicationStartup.populateTranslatedNames();
        TestODataApp app = new TestODataApp();
        ODataLexer lexer = new ODataLexer(CharStreams.fromStream(app.getInputStreamForParseFile("odata" + File.separator + "odata_samples.txt")));
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        ODataParser parser = new ODataParser(tokens);
        ParseTree tree = parser.odataURL();
        ParseTreeWalker walker = new ParseTreeWalker();
        // Make the SQL Statement
        NikitaODataToSQLWalker sqlWalker = new NikitaODataToSQLWalker();
        walker.walk(sqlWalker, tree);
        System.out.println(sqlWalker.getSqlStatement());
    } catch (RecognitionException e) {
        throw new IllegalStateException("Recognition exception");
    }
}
Also used : ODataParser(nikita.webapp.odata.ODataParser) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) ODataLexer(nikita.webapp.odata.ODataLexer) ParseTree(org.antlr.v4.runtime.tree.ParseTree) ParseTreeWalker(org.antlr.v4.runtime.tree.ParseTreeWalker) NikitaODataToSQLWalker(nikita.webapp.odata.NikitaODataToSQLWalker) RecognitionException(org.antlr.v4.runtime.RecognitionException)

Aggregations

NikitaODataToSQLWalker (nikita.webapp.odata.NikitaODataToSQLWalker)1 ODataLexer (nikita.webapp.odata.ODataLexer)1 ODataParser (nikita.webapp.odata.ODataParser)1 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)1 RecognitionException (org.antlr.v4.runtime.RecognitionException)1 ParseTree (org.antlr.v4.runtime.tree.ParseTree)1 ParseTreeWalker (org.antlr.v4.runtime.tree.ParseTreeWalker)1