Package org.openengsb.core.edbi.jdbc.sql

Examples of org.openengsb.core.edbi.jdbc.sql.Table


        if (exists(index)) {
            LOG.debug("Skipping schema creation for {}. Schema exists.", index.getName());
            return;
        }

        Table headTable = headTableEngine.create(index);
        Table histTable = historyTableEngine.create(index);

        index.setHeadTableName(headTable.getName());
        index.setHistoryTableName(histTable.getName());
    }
View Full Code Here


        this.columnNameTranslator = columnNameTranslator;
    }

    @Override
    public Table create(JdbcIndex<?> index) {
        final Table table = new Table();

        onBeforeCreate(table, index);

        if (table.getName() == null) {
            table.setName(getIndexNameTranslator().translate(index));
        }

        LOG.info("Creating table {} for index {}", table.getName(), index.getName());

        index.accept(new IndexFieldVisitor() {
            @Override
            public void visit(IndexField<?> field) {
                onBeforeFieldVisit(table, field);

                DataType type = getTypeMap().getType(field.getType());
                if (type == null) {
                    onMissingTypeVisit(table, field);
                    return;
                }
                ((JdbcIndexField) field).setMappedType(type);

                Column column = new Column(getColumnNameTranslator().translate(field), type);

                table.addElement(column);
                onAfterFieldVisit(table, column, field);
            }
        });

        onAfterCreate(table, index);
View Full Code Here

    @Test
    public void create_setsTableNamesCorreclty() throws Exception {
        JdbcIndex<?> index = new JdbcIndex<>();

        when(headTableEngine.create(index)).thenReturn(new Table("headTableName"));
        when(historyTableEngine.create(index)).thenReturn(new Table("historyTableName"));

        mapper.create(index);

        assertEquals("headTableName", index.getHeadTableName());
        assertEquals("historyTableName", index.getHistoryTableName());
View Full Code Here

        engine.get(testIndex);
    }

    @Test
    public void get_onExistingIndex_returnsCorrectTable() throws Exception {
        Table t = engine.create(testIndex);

        assertEquals(t, engine.get(testIndex));
    }
View Full Code Here

        service = new JdbcService(getDataSource());

        jdbc = new JdbcTemplate(getDataSource());
        jdbcn = new NamedParameterJdbcTemplate(getDataSource());

        table = new Table("TEST",
            new Column("ID", new DataType("IDENTITY")),
            new Column("NAME", new DataType("VARCHAR")),
            new Column("AGE", new DataType("INT")));

        table.addElement(new PrimaryKeyConstraint("ID"));
View Full Code Here

    public Table get(JdbcIndex<?> index) {
        if (!exists(index)) {
            throw new NoSuchTableException("Table for index " + index.getName() + " does not exist");
        }

        Table table = registry.get(index);

        if (table == null) {
            table = getTableFactory().create(index); // TODO: proper load function
            registry.put(index, table);
        }
View Full Code Here

        return table;
    }

    @Override
    public Table create(JdbcIndex<?> index) {
        Table table = getTableFactory().create(index);

        if (exists(index)) {
            throw new TableExistsException("Table for index " + index.getName() + " exists");
        }

        // TODO: sql independence
        String sql =
            String.format("CREATE TABLE `%s` ( %s );", table.getName(), new TableElementCompiler(table).toSql());

        LOG.info("Creating table for Index {}. SQL is: {}", index.getName(), sql);

        jdbc().execute(sql);
View Full Code Here

    public void execute(DeleteOperation operation) {
        throw new UnsupportedOperationException();
    }

    protected void execute(InsertOperation operation, IndexRecordCallback callback) {
        Table table = get(operation.getIndex());

        insert(table, collectRecords(operation, callback));
    }
View Full Code Here

        insert(table, collectRecords(operation, callback));
    }

    protected void execute(UpdateOperation operation, IndexRecordCallback callback) {
        Table table = get(operation.getIndex());

        update(table, collectRecords(operation, callback));
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.edbi.jdbc.sql.Table

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.