Package adipe.translate.ra

Examples of adipe.translate.ra.Schema


            @Override
            public void run() {
                /* translating the first query, then writing the first spreadsheet file take longer time, so let's
                 * warm up here */
                Schema schema = Schemas.fromDDL(DEFAULT_SCHEMA_TEXT);
                try {
                    Term translated = Queries.getRaOf(schema, DEFAULT_QUERY_TEXT);
                    Result result = translated.execute();
                    try (OutputStream os = new OutputStream() {
                        @Override
View Full Code Here


        boolean includeOpenOption0;

        try {
            final String createTableStatements  = schemaTextArea.getText();
            String sqlSource              = queryTextArea.getText();
            final Schema databaseSchema = Schemas.fromDDL(createTableStatements);
            // TODO show a meaningful error message if syntax error in the CREATE TABLE statement, e.g.,
            // duplicate table names
            // TODO show a meaningful error message if the CREATE TABLE statements are broken
            // TODO extract the code that parses the schema and the query from the two translateAnd* functions
            List<String> queries          = Lists.newArrayList();
            List<Term> formulas           = Lists.newArrayList();
            List<Term> inputTables        = Lists.newArrayList();
            final List<Result> results    = Lists.newArrayList();

            declareTablesThenTranslate(sqlSource, databaseSchema, queries, formulas, inputTables);

            Iterator<String> tableNamesIter = databaseSchema.tableNames().iterator();
            for (Term inputTable : inputTables) {
                // add input tables to {@link results} so that they get borders
                // also add labels with column names
                // TODO refactor this and move to QuietSpreadsheetLayout
                Result result = inputTable.execute();
                ColumnLabels labels = result.getLabels();
                String tableName = tableNamesIter.next();
                ColumnNamesImpl cn = databaseSchema.schemaTable(tableName);
                ColumnIndexesImpl ci = cn.asColumnIndexesLookup();
                Iterator<SimpleColumn> scs = ci.iterator();
                for (Column c : result.getResultRelation()) {
                    SimpleColumn sc = scs.next();
                    labels.put(c, tableName+"."+sc.name());
View Full Code Here

            }
        });
    }

    private void translateAndShowInAlgebraResultsDialog(String createTableStatements, String sqlSource) {
        Schema databaseSchema = null;
        String resultsText = null;

        try {
            databaseSchema = Schemas.fromDDL(createTableStatements);
        } catch (Exception e) {
View Full Code Here

        return new NamedColumn(new SimpleColumn(type, name),name.toLowerCase());
    }

    private static void givenDdlExpectTablesAndColumns(String ddlStatement, String tableName, NamedColumn... expectedColumns)
    {
        Schema s = Schemas.fromDDL(ddlStatement);

        assertThat(s.tableNames())
            .containsOnly(tableName);

        assertThat(s.schemaTable(tableName).namedColumns())
            .usingElementComparator(COMPARE_BY_NAME_AND_TYPE)
            .containsExactly(expectedColumns);
    }
View Full Code Here

TOP

Related Classes of adipe.translate.ra.Schema

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.