Search in sources :

Example 1 with DcCommonsJdbiPlugin

use of de.digitalcollections.commons.jdbi.DcCommonsJdbiPlugin in project cudami by dbmdz.

the class SpringConfigBackendDatabase method jdbi.

@Bean
public JdbiFactoryBean jdbi(DataSource ds, ObjectMapper objectMapper) throws Exception {
    JdbiFactoryBean jdbiFactoryBean = new JdbiFactoryBean(ds);
    List plugins = new ArrayList();
    plugins.add(new SqlObjectPlugin());
    plugins.add(new PostgresPlugin());
    plugins.add(new DcCommonsJdbiPlugin());
    plugins.add(new JsonbJdbiPlugin(objectMapper));
    jdbiFactoryBean.setPlugins(plugins);
    return jdbiFactoryBean;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) SqlObjectPlugin(org.jdbi.v3.sqlobject.SqlObjectPlugin) JdbiFactoryBean(org.jdbi.v3.spring5.JdbiFactoryBean) DcCommonsJdbiPlugin(de.digitalcollections.commons.jdbi.DcCommonsJdbiPlugin) JsonbJdbiPlugin(de.digitalcollections.cudami.server.backend.impl.jdbi.plugins.JsonbJdbiPlugin) PostgresPlugin(org.jdbi.v3.postgres.PostgresPlugin) JdbiFactoryBean(org.jdbi.v3.spring5.JdbiFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with DcCommonsJdbiPlugin

use of de.digitalcollections.commons.jdbi.DcCommonsJdbiPlugin in project cudami by dbmdz.

the class SpringConfigBackendDatabase method jdbi.

@Bean
Jdbi jdbi(ObjectMapper objectMapper, DataSource dataSource) {
    Jdbi jdbi = Jdbi.create(dataSource);
    jdbi.installPlugin(new SqlObjectPlugin());
    jdbi.installPlugin(new DcCommonsJdbiPlugin());
    jdbi.installPlugin(new PostgresPlugin());
    jdbi.installPlugin(new JsonbJdbiPlugin(objectMapper));
    if (!isMigrated) {
        synchronized (isMigrated) {
            Map<String, String> placeholders = Map.of("iiifBaseUrl", "foo");
            Flyway flyway = Flyway.configure().dataSource(dataSource).placeholders(placeholders).locations("classpath:/de/digitalcollections/cudami/server/backend/impl/database/migration").load();
            flyway.migrate();
            isMigrated = true;
        }
    }
    return jdbi;
}
Also used : Flyway(org.flywaydb.core.Flyway) Jdbi(org.jdbi.v3.core.Jdbi) SqlObjectPlugin(org.jdbi.v3.sqlobject.SqlObjectPlugin) DcCommonsJdbiPlugin(de.digitalcollections.commons.jdbi.DcCommonsJdbiPlugin) JsonbJdbiPlugin(de.digitalcollections.cudami.server.backend.impl.jdbi.plugins.JsonbJdbiPlugin) PostgresPlugin(org.jdbi.v3.postgres.PostgresPlugin) Bean(org.springframework.context.annotation.Bean)

Aggregations

DcCommonsJdbiPlugin (de.digitalcollections.commons.jdbi.DcCommonsJdbiPlugin)2 JsonbJdbiPlugin (de.digitalcollections.cudami.server.backend.impl.jdbi.plugins.JsonbJdbiPlugin)2 PostgresPlugin (org.jdbi.v3.postgres.PostgresPlugin)2 SqlObjectPlugin (org.jdbi.v3.sqlobject.SqlObjectPlugin)2 Bean (org.springframework.context.annotation.Bean)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Flyway (org.flywaydb.core.Flyway)1 Jdbi (org.jdbi.v3.core.Jdbi)1 JdbiFactoryBean (org.jdbi.v3.spring5.JdbiFactoryBean)1