Search in sources :

Example 6 with JdbcQueryBuilder

use of org.ff4j.store.JdbcQueryBuilder in project ff4j by ff4j.

the class JdbcFeatureStoreSchemaTest method testCreateSchema.

@Test
public void testCreateSchema() {
    DataSource ds = testedStore.getDataSource();
    JdbcQueryBuilder qb = testedStore.getQueryBuilder();
    // Given
    Assert.assertFalse(isTableExist(ds, qb.getTableNameFeatures()));
    Assert.assertFalse(isTableExist(ds, qb.getTableNameRoles()));
    Assert.assertFalse(isTableExist(ds, qb.getTableNameCustomProperties()));
    // When
    testedStore.createSchema();
    // then
    Assert.assertTrue(isTableExist(ds, qb.getTableNameFeatures()));
    Assert.assertTrue(isTableExist(ds, qb.getTableNameRoles()));
    Assert.assertTrue(isTableExist(ds, qb.getTableNameCustomProperties()));
    // When (no error)
    testedStore.createSchema();
}
Also used : JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 7 with JdbcQueryBuilder

use of org.ff4j.store.JdbcQueryBuilder in project ff4j by ff4j.

the class FeatureStoreSpringJdbc method createSchema.

/**
 * {@inheritDoc}
 */
@Override
@Transactional
public void createSchema() {
    JdbcQueryBuilder qb = getQueryBuilder();
    String dbSchema = queryBuilder.getDbSchema();
    if (!JdbcUtils.isTableExist(dataSource, qb.getTableNameFeatures(), dbSchema)) {
        getJdbcTemplate().update(qb.sqlCreateTableFeatures());
    }
    if (!JdbcUtils.isTableExist(dataSource, qb.getTableNameCustomProperties(), dbSchema)) {
        getJdbcTemplate().update(qb.sqlCreateTableCustomProperties());
    }
    if (!JdbcUtils.isTableExist(dataSource, qb.getTableNameRoles(), dbSchema)) {
        getJdbcTemplate().update(qb.sqlCreateTableRoles());
    }
}
Also used : JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with JdbcQueryBuilder

use of org.ff4j.store.JdbcQueryBuilder in project ff4j by ff4j.

the class SpringJdbcStoresCreateSchema method testCreateSchema.

@Test
public void testCreateSchema() {
    JdbcQueryBuilder qb = testedStore.getQueryBuilder();
    // Given
    Assert.assertFalse(JdbcUtils.isTableExist(testedStore.getJdbcTemplate().getDataSource(), qb.getTableNameFeatures()));
    Assert.assertFalse(JdbcUtils.isTableExist(testedStore.getJdbcTemplate().getDataSource(), qb.getTableNameRoles()));
    Assert.assertFalse(JdbcUtils.isTableExist(testedStore.getJdbcTemplate().getDataSource(), qb.getTableNameCustomProperties()));
    // When
    testedStore.createSchema();
    propertyStore.createSchema();
    // then
    Assert.assertTrue(JdbcUtils.isTableExist(testedStore.getJdbcTemplate().getDataSource(), qb.getTableNameFeatures()));
    Assert.assertTrue(JdbcUtils.isTableExist(testedStore.getJdbcTemplate().getDataSource(), qb.getTableNameRoles()));
    Assert.assertTrue(JdbcUtils.isTableExist(testedStore.getJdbcTemplate().getDataSource(), qb.getTableNameCustomProperties()));
}
Also used : JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) Test(org.junit.Test)

Example 9 with JdbcQueryBuilder

use of org.ff4j.store.JdbcQueryBuilder in project ff4j by ff4j.

the class SpringJdbcFeatureStorePrefixTest method initStore.

/**
 * {@inheritDoc}
 */
@Override
protected FeatureStore initStore() {
    builder = new EmbeddedDatabaseBuilder();
    db = builder.setType(// 
    EmbeddedDatabaseType.HSQL).addScript(// 
    "classpath:ddl-prefix-schema.sql").addScript("classpath:ddl-prefix-data.sql").build();
    FeatureStoreSpringJdbc jdbcStore = new FeatureStoreSpringJdbc();
    jdbcStore.setQueryBuilder(new JdbcQueryBuilder("T_FF4J_", "_01"));
    jdbcStore.setDataSource(db);
    return jdbcStore;
}
Also used : JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) FeatureStoreSpringJdbc(org.ff4j.springjdbc.store.FeatureStoreSpringJdbc)

Example 10 with JdbcQueryBuilder

use of org.ff4j.store.JdbcQueryBuilder in project ff4j by ff4j.

the class JdbcEventRepository method createSchema.

/**
 * {@inheritDoc}
 */
@Override
public void createSchema() {
    DataSource ds = getDataSource();
    JdbcQueryBuilder qb = getQueryBuilder();
    if (!isTableExist(ds, qb.getTableNameAudit())) {
        executeUpdate(ds, qb.sqlCreateTableAudit());
    }
}
Also used : JdbcQueryBuilder(org.ff4j.store.JdbcQueryBuilder) DataSource(javax.sql.DataSource)

Aggregations

JdbcQueryBuilder (org.ff4j.store.JdbcQueryBuilder)14 Test (org.junit.Test)7 DataSource (javax.sql.DataSource)6 EmbeddedDatabaseBuilder (org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder)4 EventQueryDefinition (org.ff4j.audit.EventQueryDefinition)1 JdbcPropertyStore (org.ff4j.property.store.JdbcPropertyStore)1 FeatureStoreSpringJdbc (org.ff4j.springjdbc.store.FeatureStoreSpringJdbc)1 PropertyStoreSpringJdbc (org.ff4j.springjdbc.store.PropertyStoreSpringJdbc)1 JdbcFeatureStore (org.ff4j.store.JdbcFeatureStore)1 Transactional (org.springframework.transaction.annotation.Transactional)1