Skip to content

Commit

Permalink
chore: compare ada_pots
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-QuanLeA committed May 8, 2024
1 parent 7683ad8 commit bb254bb
Show file tree
Hide file tree
Showing 43 changed files with 1,071 additions and 1,045 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
@SpringBootApplication
public class VerifierDataAppApplication {

public static void main(String[] args) {
SpringApplication.run(VerifierDataAppApplication.class, args);
}

public static void main(String[] args) {
SpringApplication.run(VerifierDataAppApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package org.cardanofoundation.ledgersync.verifier.data.app.config;

import java.util.Objects;

import javax.sql.DataSource;

import lombok.RequiredArgsConstructor;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
Expand All @@ -11,41 +16,37 @@
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;
import java.util.Objects;

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "dbSyncEntityManagerFactory",
transactionManagerRef = "dbSyncTransactionManager",
basePackages = {"org.cardanofoundation.ledgersync.verifier.data.app.repository.dbsync"})
entityManagerFactoryRef = "dbSyncEntityManagerFactory",
transactionManagerRef = "dbSyncTransactionManager",
basePackages = {"org.cardanofoundation.ledgersync.verifier.data.app.repository.dbsync"})
@RequiredArgsConstructor
public class DbSyncDatasourceConfig {

private final MultiDataSourceProperties multiDataSourceProperties;

@Bean(name = "dbSyncDataSource")
public DataSource ledgerSyncDataSource() {
return multiDataSourceProperties.buildDataSource(
multiDataSourceProperties.getDatasourceDbSync());
}

@Bean(name = "dbSyncEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(
EntityManagerFactoryBuilder builder, @Qualifier("dbSyncDataSource") DataSource dataSource) {
return builder
.dataSource(dataSource)
.packages(
"org.cardanofoundation.ledgersync.verifier.data.app.entity.dbsync")
.build();
}

@Bean(name = "dbSyncTransactionManager")
public PlatformTransactionManager dbSyncTransactionManager(
@Qualifier("dbSyncEntityManagerFactory")
LocalContainerEntityManagerFactoryBean ledgerSyncEntityManagerFactory) {
return new JpaTransactionManager(
Objects.requireNonNull(ledgerSyncEntityManagerFactory.getObject()));
}
private final MultiDataSourceProperties multiDataSourceProperties;

@Bean(name = "dbSyncDataSource")
public DataSource ledgerSyncDataSource() {
return multiDataSourceProperties.buildDataSource(
multiDataSourceProperties.getDatasourceDbSync());
}

@Bean(name = "dbSyncEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(
EntityManagerFactoryBuilder builder, @Qualifier("dbSyncDataSource") DataSource dataSource) {
return builder
.dataSource(dataSource)
.packages("org.cardanofoundation.ledgersync.verifier.data.app.entity.dbsync")
.build();
}

@Bean(name = "dbSyncTransactionManager")
public PlatformTransactionManager dbSyncTransactionManager(
@Qualifier("dbSyncEntityManagerFactory")
LocalContainerEntityManagerFactoryBean ledgerSyncEntityManagerFactory) {
return new JpaTransactionManager(
Objects.requireNonNull(ledgerSyncEntityManagerFactory.getObject()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.cardanofoundation.ledgersync.verifier.data.app.config;

import javax.sql.DataSource;

import lombok.RequiredArgsConstructor;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

@Configuration
@RequiredArgsConstructor
public class JdbcTemplateConfig {
@Bean(name = "ledgerSyncJdbcTemplate")
public JdbcTemplate ledgerSyncJdbcTemplate(
@Qualifier("ledgerSyncDataSource") DataSource dataSource) {
return new JdbcTemplate(dataSource);
}

@Bean(name = "dbSyncJdbcTemplate")
public JdbcTemplate dbSyncJdbcTemplate(@Qualifier("dbSyncDataSource") DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import rest.koios.client.backend.api.address.AddressService;
import rest.koios.client.backend.api.block.BlockService;
import rest.koios.client.backend.api.transactions.TransactionsService;
Expand All @@ -11,47 +12,46 @@
@Configuration
public class KoiosConfig {

/**
* Creates a bean for accessing the Koios preprod backend service.
*
* @return BackendService instance for Koios preprod.
*/
@Bean
public BackendService createBackendServiceBean() {
return BackendFactory.getKoiosPreprodService();
}
/**
* Creates a bean for accessing the Koios preprod backend service.
*
* @return BackendService instance for Koios preprod.
*/
@Bean
public BackendService createBackendServiceBean() {
return BackendFactory.getKoiosPreprodService();
}

/**
* Creates a bean for accessing the address service provided by the backend service.
*
* @param backendService The backend service instance.
* @return AddressService instance for interacting with address-related data.
*/
@Bean
public AddressService createAddressServiceBean(BackendService backendService) {
return backendService.getAddressService();
}
/**
* Creates a bean for accessing the address service provided by the backend service.
*
* @param backendService The backend service instance.
* @return AddressService instance for interacting with address-related data.
*/
@Bean
public AddressService createAddressServiceBean(BackendService backendService) {
return backendService.getAddressService();
}

/**
* Creates a bean for accessing the transactions service provided by the backend service.
*
* @param backendService The backend service instance.
* @return TransactionsService instance for interacting with transaction-related data.
*/
@Bean
public TransactionsService createTransactionServiceBean(BackendService backendService) {
return backendService.getTransactionsService();
}
/**
* Creates a bean for accessing the transactions service provided by the backend service.
*
* @param backendService The backend service instance.
* @return TransactionsService instance for interacting with transaction-related data.
*/
@Bean
public TransactionsService createTransactionServiceBean(BackendService backendService) {
return backendService.getTransactionsService();
}

/**
* Creates a bean for accessing the block service provided by the backend service.
*
* @param backendService The backend service instance.
* @return BlockService instance for interacting with block-related data.
*/
@Bean
public BlockService createBlockServiceBean(BackendService backendService) {
return backendService.getBlockService();
}
/**
* Creates a bean for accessing the block service provided by the backend service.
*
* @param backendService The backend service instance.
* @return BlockService instance for interacting with block-related data.
*/
@Bean
public BlockService createBlockServiceBean(BackendService backendService) {
return backendService.getBlockService();
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package org.cardanofoundation.ledgersync.verifier.data.app.config;

import java.util.Objects;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
Expand All @@ -11,78 +15,75 @@
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;
import java.util.Objects;

/**
* Configuration class for setting up the datasource, entity manager factory, and transaction manager
* for the LedgerSync application.
* Configuration class for setting up the datasource, entity manager factory, and transaction
* manager for the LedgerSync application.
*/
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "ledgerSyncEntityManagerFactory",
transactionManagerRef = "ledgerSyncTransactionManager",
basePackages = {"org.cardanofoundation.ledgersync.verifier.data.app.repository.ledgersync"})
entityManagerFactoryRef = "ledgerSyncEntityManagerFactory",
transactionManagerRef = "ledgerSyncTransactionManager",
basePackages = {"org.cardanofoundation.ledgersync.verifier.data.app.repository.ledgersync"})
public class LedgerSyncDatasourceConfig {

private final MultiDataSourceProperties multiDataSourceProperties;
private final MultiDataSourceProperties multiDataSourceProperties;

/**
* Constructor for LedgerSyncDatasourceConfig.
*
* @param multiDataSourceProperties The properties for configuring multiple datasources.
*/
public LedgerSyncDatasourceConfig(MultiDataSourceProperties multiDataSourceProperties) {
this.multiDataSourceProperties = multiDataSourceProperties;
}
/**
* Constructor for LedgerSyncDatasourceConfig.
*
* @param multiDataSourceProperties The properties for configuring multiple datasources.
*/
public LedgerSyncDatasourceConfig(MultiDataSourceProperties multiDataSourceProperties) {
this.multiDataSourceProperties = multiDataSourceProperties;
}

/**
* Creates the primary datasource bean for the LedgerSync application.
*
* @return The primary datasource for LedgerSync.
*/
@Primary
@Bean(name = "ledgerSyncDataSource")
public DataSource ledgerSyncDataSource() {
return multiDataSourceProperties.buildDataSource(
multiDataSourceProperties.getDatasourceLedgerSync());
}
/**
* Creates the primary datasource bean for the LedgerSync application.
*
* @return The primary datasource for LedgerSync.
*/
@Primary
@Bean(name = "ledgerSyncDataSource")
public DataSource ledgerSyncDataSource() {
return multiDataSourceProperties.buildDataSource(
multiDataSourceProperties.getDatasourceLedgerSync());
}

/**
* Creates the entity manager factory bean for the LedgerSync application.
*
* @param builder The EntityManagerFactoryBuilder.
* @param dataSource The primary datasource for LedgerSync.
* @return The LocalContainerEntityManagerFactoryBean for LedgerSync.
*/
@Primary
@Bean(name = "ledgerSyncEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(
EntityManagerFactoryBuilder builder,
@Qualifier("ledgerSyncDataSource") DataSource dataSource) {
return builder
.dataSource(dataSource)
.packages(
"org.cardanofoundation.ledgersync.consumercommon.entity",
"org.cardanofoundation.ledgersync.verifier.data.app.entity.ledgersync",
"org.cardanofoundation.ledgersync.consumercommon.enumeration",
"org.cardanofoundation.ledgersync.consumercommon.validation")
.build();
}
/**
* Creates the entity manager factory bean for the LedgerSync application.
*
* @param builder The EntityManagerFactoryBuilder.
* @param dataSource The primary datasource for LedgerSync.
* @return The LocalContainerEntityManagerFactoryBean for LedgerSync.
*/
@Primary
@Bean(name = "ledgerSyncEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(
EntityManagerFactoryBuilder builder,
@Qualifier("ledgerSyncDataSource") DataSource dataSource) {
return builder
.dataSource(dataSource)
.packages(
"org.cardanofoundation.ledgersync.consumercommon.entity",
"org.cardanofoundation.ledgersync.verifier.data.app.entity.ledgersync",
"org.cardanofoundation.ledgersync.consumercommon.enumeration",
"org.cardanofoundation.ledgersync.consumercommon.validation")
.build();
}

/**
* Creates the transaction manager bean for the LedgerSync application.
*
* @param ledgerSyncEntityManagerFactory The entity manager factory for LedgerSync.
* @return The transaction manager for LedgerSync.
*/
@Primary
@Bean(name = "ledgerSyncTransactionManager")
public PlatformTransactionManager ledgerSyncTransactionManager(
@Qualifier("ledgerSyncEntityManagerFactory")
LocalContainerEntityManagerFactoryBean ledgerSyncEntityManagerFactory) {
return new JpaTransactionManager(
Objects.requireNonNull(ledgerSyncEntityManagerFactory.getObject()));
}
/**
* Creates the transaction manager bean for the LedgerSync application.
*
* @param ledgerSyncEntityManagerFactory The entity manager factory for LedgerSync.
* @return The transaction manager for LedgerSync.
*/
@Primary
@Bean(name = "ledgerSyncTransactionManager")
public PlatformTransactionManager ledgerSyncTransactionManager(
@Qualifier("ledgerSyncEntityManagerFactory")
LocalContainerEntityManagerFactoryBean ledgerSyncEntityManagerFactory) {
return new JpaTransactionManager(
Objects.requireNonNull(ledgerSyncEntityManagerFactory.getObject()));
}
}

0 comments on commit bb254bb

Please sign in to comment.