Package adipe.translate.ra

Examples of adipe.translate.ra.RaTermBuilder


     * @throws TypeCheckException
     * @throws WrappedException
     * @side none
     */
    private Proposition visitJoinCondition(JoinConditionContext ctx, ColumnNamesLookup columnNamesLookup) throws WrappedException, TypeCheckException, RuntimeException {
        RaTermBuilder raBuilder = RaTermBuilder.create(); // TODO use a special case builder that throws on registration of aggregates
        return ConditionTranslation.of(
            columnNamesLookup,
            raBuilder,
            ctx.searchCondition()
        ).proposition();
View Full Code Here


            throws WrappedException, IndexOutOfBoundsException, TranslationException
    {
        visitFromClause(ctx.tableExpression().fromClause());
        /* {@code state.formula} now represents the tables in the FROM clause*/

        final RaTermBuilder raBuilder = RaTermBuilder.create();
        List<Expression> selected =
                processSelectList(raBuilder, ctx.selectList());

        boolean isSelectAsterisk = (selected == null);

        if (isSelectAsterisk) {
            // TODO refactor, move to {@link processSelectList}
            selected = state.nonParameterAttributes();
        }

        /* {@link #scopeIncludingAliases} now includes column aliases, as defined in the SELECT clause,
         * used in {@link #visitColumnReference} when interpreting references to columns.
         * Will be null for SELECT * queries
         */

        GroupByClauseContext groupByClause;
        HavingClauseContext havingClause;

        groupByClause = ctx.tableExpression().groupByClause(); /* null if no GROUP BY clause is present */
        havingClause = ctx.tableExpression().havingClause();


        if (groupByClause != null && isSelectAsterisk) {
            /* SELECT * FROM.. GROUP BY.. */
            throw new TranslationException("a query cannot have the form of 'SELECT * ... GROUP BY'");
        }
        if (havingClause != null && isSelectAsterisk) {
            /* SELECT * FROM.. HAVING.. */
            throw new TranslationException("a query cannot have the form of 'SELECT * ... HAVING'");
        }

        List<SimpleColumn> groupByExpressions = null;
        if (groupByClause != null) {
            groupByExpressions = Lists.newArrayList(visitGroupByClause(groupByClause));
        } else if (havingClause != null) {
            groupByExpressions = Lists.<SimpleColumn>newArrayList();
        }

        processWhereClause(ctx.tableExpression().whereClause());

        raBuilder.select(selected);
        raBuilder.groupBy(groupByExpressions);
        raBuilder.withBaseRelation(state.rela);
        raBuilder.withQueryParameters(state.parameterAttributes());

        if (havingClause != null) {
            // TODO do not use WrappedException in InterpretsColumnReferences
            Proposition havingCondition = ConditionTranslation.of(columnNamesLookupForHaving(raBuilder), raBuilder, havingClause.searchCondition()).proposition();
            raBuilder.withHaving(havingCondition);
        }

        state.rela = raBuilder.build();

        state.updateColumnScopeWithRelationsColumns();

        // TODO test this further in SelectFromTest.SelectDistinct
        boolean selectDistinct = ctx.setQuantifier() != null && ctx.setQuantifier().DISTINCT() != null;
View Full Code Here

     * @throws TypeCheckException
     * @throws WrappedException
     * @side none
     */
    Proposition visitWhereClause(WhereClauseContext ctx) throws WrappedException, TypeCheckException, RuntimeException {
        RaTermBuilder raBuilder = RaTermBuilder.create(); // TODO replace with special case RaTermBuilder that throws on registration of aggregates
        Proposition p = ConditionTranslation.of(
                                columnNamesLookupForWhere,
                                raBuilder,
                                ctx.searchCondition()
                            ).proposition();
View Full Code Here

TOP

Related Classes of adipe.translate.ra.RaTermBuilder

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.