Package com.redspr.redquerybuilder.core.client.engine

Examples of com.redspr.redquerybuilder.core.client.engine.Session


public class GwtTestSuggestEditorWidget extends AbstractTest {

    @Test
    public void testDirtyKeepsValue() throws Exception {
        Session sess = getSession();

        Column col = sess.getDatabase().getMainSchema()
                .findTableOrView("PERSON").getColumn("county");

        final SuggestEditorWidget sew = new SuggestEditorWidget(sess, col);

        final List events = new ArrayList();
View Full Code Here


public class RedQueryBuilder implements EntryPoint {

    private void createCommandBuilder(final Configuration config, String sql, List args)
            throws Exception {

        final Session session = new Session(config);

        final CommandBuilder builder = new CommandBuilder(session, sql, args);

        session.getMsgBus().addHandler(TableEvent.TYPE,
                new TableEventHandler() {
                    @Override
                    public void onTable(TableEvent e) {
                        if (session.getFilters().size() > 0) {
                            config.fireOnTableChange(session.getFilters());
                            // XXX need to do distinct?
                            ObjectArray expr = ObjectArray.newInstance();
                            TableFilter tf = session.getFilters().get(0);
                            String alias = tf.getAlias();
                            for (Column col : tf.getTable().getColumns()) {
                                expr.add(new ExpressionColumn(session, null, alias,
                                    col.getName()));
                            }
                            builder.getSelect().setExpressions(expr);
                        } else {
                            builder.getSelect().setExpressions(null);
                        }
                    }
                });

        builder.addValueChangeHandler(new ValueChangeHandler<Select>() {
            @Override
            public void onValueChange(ValueChangeEvent<Select> event) {
                List<Object> args = new ArrayList<Object>();
                String sql = event.getValue().getSQL(args);

                config.fireOnSqlChange(sql, args);
            }
        });

        builderContainer.setWidget(builder);

        config.fireOnTableChange(session.getFilters());
    }
View Full Code Here

            config = createSimpleConfig();
        }

        config.setDatabase(database);

        Session session = new Session(config);

        session.setIdentifierEscaper(new IdentifierEscaper() {
           @Override
        public String quote(String id) {
               return id;
           }
        });
View Full Code Here

        assertEquals("M", sew.getValue());
    }

    @Test
    public void testDirtyKeepsValue() throws Exception {
        Session sess = getSession();

        String sql0 = "SELECT x.id FROM Person x"
                + " WHERE x.id=? OR x.id=?";
        List<Object> args = new ArrayList<Object>();
        args.add("13");
View Full Code Here

        assertEquals(null, args.get(0));
    }

    @Test
    public void testIsNull() throws Exception {
        Session sess = getSession();
        Parser p = new Parser(sess);

        Prepared prep = p.parseOnly("SELECT id FROM Person x1 WHERE x1.sex IS NULL");

        Select s = (Select) prep;
View Full Code Here

        assertEquals("SELECT ID\nFROM PERSON X1\nWHERE (X1.SEX IS NULL)", outSql);
    }

    @Test
    public void testParseAlias() throws Exception {
        Session sess = getSession();
        Parser p = new Parser(sess);

        sess.getValueRegistry().add("foo");
        Prepared prep = p.parseOnly("SELECT id FROM Person x1 WHERE x1.sex = ?");

        Select s = (Select) prep;
        assertTrue(s != null);
        ExpressionColumn ec = (ExpressionColumn) s.getExpressions().get(0);
View Full Code Here

    }

    @Test
    public void testParseAliasWithBrackets() throws Exception {
        Session sess = getSession();
        Parser p = new Parser(sess);

        sess.getValueRegistry().add("foo");
        Prepared prep = p.parseOnly("SELECT id FROM Person x1 WHERE (x1.sex = ?)");

        Select s = (Select) prep;
        assertTrue(s != null);
        ExpressionColumn ec = (ExpressionColumn) s.getExpressions().get(0);
View Full Code Here

    }

    @Test
    public void testAndOrRemove() throws Exception {
        Session s = getSession();
        Nop a = new Nop();
        Nop b = new Nop();
        ConditionAndOr toGo = new ConditionAndOr(s, 0, a, b);
        ConditionAndOr root = new ConditionAndOr(s, 0, toGo, new Nop());
        toGo.remove(a);
View Full Code Here

        assertEquals("(1=1 AND 1=1)", root.getSQL(new ArrayList()));
    }

    @Test
    public void testSetTableAddCondRemoveCond() throws Exception {
        Session s = getSession();
        CommandBuilder cb = new CommandBuilder(s);
        cb.getSelect().updateTable(
                s.getDatabase().getMainSchema().findTableOrView("PERSON"));
        cb.getSelect().getSQL(new ArrayList());

        Comparison c = new Comparison(s);

        cb.getSelect().addCondition(c);
View Full Code Here

        cb.fireDirty();
    }

    @Test
    public void testSetTableAddCondRemoveCond2() throws Exception {
        Session s = getSession();
        CommandBuilder cb = new CommandBuilder(s);
        cb.getSelect().updateTable(
                s.getDatabase().getMainSchema().findTableOrView("Log"));
        cb.getSelect().getSQL(new ArrayList());

        Comparison c = new Comparison(s);

        cb.getSelect().addCondition(c);
View Full Code Here

TOP

Related Classes of com.redspr.redquerybuilder.core.client.engine.Session

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.