Search in sources :

Example 1 with SqlJsonDB

use of io.syndesis.server.jsondb.impl.SqlJsonDB in project syndesis by syndesisio.

the class DataStoreConfiguration method jsonDB.

@Bean
@Autowired
@SuppressWarnings("PMD.EmptyCatchBlock")
public SqlJsonDB jsonDB(DBI dbi, Optional<List<Index>> beanIndexes) {
    ArrayList<Index> indexes = new ArrayList<>();
    if (beanIndexes.isPresent()) {
        indexes.addAll(beanIndexes.get());
    }
    for (Kind kind : Kind.values()) {
        addIndex(indexes, kind, kind.getModelClass().getAnnotation(UniqueProperty.class));
        UniqueProperty.Multiple ump = kind.getModelClass().getAnnotation(UniqueProperty.Multiple.class);
        if (ump != null) {
            for (UniqueProperty p : ump.value()) {
                addIndex(indexes, kind, p);
            }
        }
        addIndex(indexes, kind, kind.getModelClass().getAnnotation(IndexedProperty.class));
        IndexedProperty.Multiple imp = kind.getModelClass().getAnnotation(IndexedProperty.Multiple.class);
        if (imp != null) {
            for (IndexedProperty p : imp.value()) {
                addIndex(indexes, kind, p);
            }
        }
    }
    SqlJsonDB jsondb = new SqlJsonDB(dbi, null, indexes);
    try {
        jsondb.createTables();
    } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception ignore) {
        LOG.debug("Could not create tables", ignore);
    }
    return jsondb;
}
Also used : SqlJsonDB(io.syndesis.server.jsondb.impl.SqlJsonDB) IndexedProperty(io.syndesis.common.util.IndexedProperty) Kind(io.syndesis.common.model.Kind) ArrayList(java.util.ArrayList) Index(io.syndesis.server.jsondb.impl.Index) UniqueProperty(io.syndesis.common.model.validation.UniqueProperty) Autowired(org.springframework.beans.factory.annotation.Autowired) Bean(org.springframework.context.annotation.Bean)

Example 2 with SqlJsonDB

use of io.syndesis.server.jsondb.impl.SqlJsonDB in project syndesis by syndesisio.

the class ActivityTrackingControllerTest method before.

@Before
public void before() {
    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL("jdbc:h2:mem:t;DB_CLOSE_DELAY=-1;MODE=PostgreSQL");
    this.dbi = new DBI(ds);
    this.jsondb = new SqlJsonDB(dbi, null);
    this.jsondb.createTables();
}
Also used : SqlJsonDB(io.syndesis.server.jsondb.impl.SqlJsonDB) JdbcDataSource(org.h2.jdbcx.JdbcDataSource) DBI(org.skife.jdbi.v2.DBI) Before(org.junit.Before)

Example 3 with SqlJsonDB

use of io.syndesis.server.jsondb.impl.SqlJsonDB in project syndesis by syndesisio.

the class MetricsCollectorTest method before.

@Before
public void before() throws IOException, ParseException {
    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=PostgreSQL");
    DBI dbi = new DBI(ds);
    this.jsondb = new SqlJsonDB(dbi, null, Arrays.asList(new Index("/pair", "key")));
    try {
        this.jsondb.dropTables();
    } catch (Exception e) {
    }
    this.jsondb.createTables();
    jsondbRM = new JsonDBRawMetrics(jsondb);
    load();
    CacheManager cacheManager = new LRUCacheManager(100);
    EncryptionComponent encryptionComponent = new EncryptionComponent(null);
    ResourceLoader resourceLoader = new DefaultResourceLoader();
    // Create Data Manager
    dataManager = new DataManager(cacheManager, Collections.emptyList(), null, encryptionComponent, resourceLoader);
    intMH = new IntegrationMetricsHandler(dataManager);
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) JdbcDataSource(org.h2.jdbcx.JdbcDataSource) EncryptionComponent(io.syndesis.server.dao.manager.EncryptionComponent) DBI(org.skife.jdbi.v2.DBI) Index(io.syndesis.server.jsondb.impl.Index) DataManager(io.syndesis.server.dao.manager.DataManager) ParseException(java.text.ParseException) IOException(java.io.IOException) SqlJsonDB(io.syndesis.server.jsondb.impl.SqlJsonDB) LRUCacheManager(io.syndesis.common.util.cache.LRUCacheManager) CacheManager(io.syndesis.common.util.cache.CacheManager) LRUCacheManager(io.syndesis.common.util.cache.LRUCacheManager) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Before(org.junit.Before)

Aggregations

SqlJsonDB (io.syndesis.server.jsondb.impl.SqlJsonDB)3 Index (io.syndesis.server.jsondb.impl.Index)2 JdbcDataSource (org.h2.jdbcx.JdbcDataSource)2 Before (org.junit.Before)2 DBI (org.skife.jdbi.v2.DBI)2 Kind (io.syndesis.common.model.Kind)1 UniqueProperty (io.syndesis.common.model.validation.UniqueProperty)1 IndexedProperty (io.syndesis.common.util.IndexedProperty)1 CacheManager (io.syndesis.common.util.cache.CacheManager)1 LRUCacheManager (io.syndesis.common.util.cache.LRUCacheManager)1 DataManager (io.syndesis.server.dao.manager.DataManager)1 EncryptionComponent (io.syndesis.server.dao.manager.EncryptionComponent)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Bean (org.springframework.context.annotation.Bean)1 DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)1 ResourceLoader (org.springframework.core.io.ResourceLoader)1