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();
}
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());
}
}
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()));
}
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;
}
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());
}
}
Aggregations