use of org.jdbi.v3.postgres.PostgresPlugin in project baremaps by baremaps.
the class Studio method call.
@Override
public Integer call() throws Exception {
// Configure serialization
ObjectMapper mapper = defaultObjectMapper();
// Configure jdbi and set the ObjectMapper
DataSource datasource = PostgresUtils.datasource(this.database);
Jdbi jdbi = Jdbi.create(datasource).installPlugin(new PostgresPlugin()).installPlugin(new Jackson2Plugin()).configure(Jackson2Config.class, config -> config.setMapper(mapper));
// Initialize the application
ResourceConfig application = new ResourceConfig().registerClasses(SwaggerResource.class, RootResource.class, CorsFilter.class, ConformanceResource.class, CollectionsResource.class, StylesResource.class, TilesetsResource.class, StudioResource.class, ImportResource.class, MultiPartFeature.class).register(new ApiResource("studio-openapi.yaml")).register(contextResolverFor(mapper)).register(new AbstractBinder() {
@Override
protected void configure() {
bind(datasource).to(DataSource.class);
bind(jdbi).to(Jdbi.class);
}
});
BlockingStreamingHttpService httpService = new HttpJerseyRouterBuilder().buildBlockingStreaming(application);
ServerContext serverContext = HttpServers.forPort(port).listenBlockingStreamingAndAwait(httpService);
logger.info("Listening on {}", serverContext.listenAddress());
serverContext.awaitShutdown();
return 0;
}
use of org.jdbi.v3.postgres.PostgresPlugin 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;
}
use of org.jdbi.v3.postgres.PostgresPlugin 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;
}
use of org.jdbi.v3.postgres.PostgresPlugin in project nzyme by lennartkoopmann.
the class Database method initializeAndMigrate.
public void initializeAndMigrate() throws LiquibaseException {
this.jdbi = Jdbi.create("jdbc:" + configuration.databasePath()).installPlugin(new PostgresPlugin()).installPlugin(new JodaTimePlugin()).registerRowMapper(new MeasurementMapper()).registerRowMapper(new BeaconRateMapper()).registerRowMapper(new SignalIndexHistogramHistoryDBEntryMapper()).registerRowMapper(new AlertDatabaseEntryMapper()).registerRowMapper(new BanditMapper()).registerRowMapper(new BanditIdentifierMapper()).registerRowMapper(new ContactMapper()).registerRowMapper(new SentrySSIDMapper()).registerRowMapper(new DeauthenticationMonitorRecordingMapper()).registerRowMapper(new EventRecordMapper()).registerRowMapper(new ScheduledReportEntryMapper()).registerRowMapper(new ExecutionLogEntryMapper()).registerRowMapper(new ContactRecordMapper()).registerRowMapper(new ContactRecordValueAggregationMapper()).registerRowMapper(new ContactRecorderHistogramEntryMapper());
// Run migrations against underlying JDBC connection.
JdbcConnection connection = new JdbcConnection(jdbi.open().getConnection());
try {
liquibase.database.Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection);
Liquibase liquibase = new liquibase.Liquibase("db/migrations.xml", new ClassLoaderResourceAccessor(), database);
liquibase.update(new Contexts(), new LabelExpression());
} finally {
connection.close();
}
}
use of org.jdbi.v3.postgres.PostgresPlugin in project marquez by MarquezProject.
the class MarquezApp method registerResources.
public void registerResources(@NonNull MarquezConfig config, @NonNull Environment env, @NonNull DataSource source) {
final JdbiFactory factory = new JdbiFactory();
final Jdbi jdbi = factory.build(env, config.getDataSourceFactory(), (ManagedDataSource) source, DB_POSTGRES).installPlugin(new SqlObjectPlugin()).installPlugin(new PostgresPlugin());
SqlLogger sqlLogger = new InstrumentedSqlLogger(env.metrics());
if (isSentryEnabled(config)) {
sqlLogger = new TracingSQLLogger(sqlLogger);
}
jdbi.setSqlLogger(sqlLogger);
final MarquezContext context = MarquezContext.builder().jdbi(jdbi).tags(config.getTags()).build();
if (config.getGraphql().isEnabled()) {
env.servlets().addServlet("api/v1-beta/graphql", context.getGraphqlServlet()).addMapping("/api/v1-beta/graphql", "/api/v1/schema.json");
}
log.debug("Registering resources...");
for (final Object resource : context.getResources()) {
env.jersey().register(resource);
}
}
Aggregations