-
Notifications
You must be signed in to change notification settings - Fork 41
Fix/add db iemr config #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SauravBizbRolly
wants to merge
12
commits into
add_db_iemr
Choose a base branch
from
fix/add_db_iemr_config
base: add_db_iemr
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
219ae88
add db identity table
SauravBizbRolly 4aef146
add db identity table
SauravBizbRolly 65993f2
Merge branch 'add_db_iemr' of https://github.com/PSMRI/Identity-API iβ¦
SauravBizbRolly f7bdc5c
add db identity table
SauravBizbRolly 382e785
add db identity table
SauravBizbRolly 06b98fa
add db identity table
SauravBizbRolly 85a6faf
add db identity table
SauravBizbRolly ef13eb4
add db identity table
SauravBizbRolly 20f51ff
add db identity table
SauravBizbRolly 5b903bc
add db identity table
SauravBizbRolly f05498a
add db identity table
SauravBizbRolly 4719d0f
add db identity table
SauravBizbRolly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/main/java/com/iemr/common/identity/config/PrimaryDBConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /* | ||
| * AMRIT β Accessible Medical Records via Integrated Technology | ||
| * Integrated EHR (Electronic Health Records) Solution | ||
| * | ||
| * Copyright (C) "Piramal Swasthya Management and Research Institute" | ||
| * | ||
| * This file is part of AMRIT. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see https://www.gnu.org/licenses/. | ||
| */ | ||
| package com.iemr.common.identity.config; | ||
|
|
||
| import com.iemr.common.identity.utils.config.ConfigProperties; | ||
| import jakarta.persistence.EntityManagerFactory; | ||
| import org.apache.tomcat.jdbc.pool.DataSource; | ||
| import org.apache.tomcat.jdbc.pool.PoolConfiguration; | ||
| import org.apache.tomcat.jdbc.pool.PoolProperties; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.beans.factory.annotation.Qualifier; | ||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.context.annotation.Primary; | ||
| import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | ||
| import org.springframework.orm.jpa.JpaTransactionManager; | ||
| import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; | ||
| import org.springframework.transaction.PlatformTransactionManager; | ||
| import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
|
||
| @Configuration | ||
| @EnableTransactionManagement | ||
| @EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", basePackages = {"com.iemr.common.identity.domain.identity", | ||
| "com.iemr.common.identity.repo","com.iemr.common.identity.data.rmnch",}) | ||
| public class PrimaryDBConfig { | ||
|
|
||
| Logger logger = LoggerFactory.getLogger(this.getClass().getName()); | ||
|
|
||
| @Primary | ||
| @Bean(name = "dataSource") | ||
| @ConfigurationProperties(prefix = "spring.datasource") | ||
| public DataSource dataSource() { | ||
| PoolConfiguration p = new PoolProperties(); | ||
| p.setMaxActive(30); | ||
| p.setMaxIdle(15); | ||
| p.setMinIdle(5); | ||
| p.setInitialSize(5); | ||
| p.setMaxWait(10000); | ||
| p.setMinEvictableIdleTimeMillis(15000); | ||
| p.setRemoveAbandoned(true); | ||
| p.setLogAbandoned(true); | ||
| p.setRemoveAbandonedTimeout(600); | ||
| p.setTestOnBorrow(true); | ||
| p.setValidationQuery("SELECT 1"); | ||
| org.apache.tomcat.jdbc.pool.DataSource datasource = new org.apache.tomcat.jdbc.pool.DataSource(); | ||
| datasource.setPoolProperties(p); | ||
|
|
||
| datasource.setUsername(ConfigProperties.getPropertyByName("spring.datasource.username")); | ||
| datasource.setPassword(ConfigProperties.getPropertyByName("spring.datasource.password")); | ||
|
|
||
| return datasource; | ||
| } | ||
|
|
||
| @Primary | ||
| @Bean(name = "entityManagerFactory") | ||
| public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder, | ||
| @Qualifier("dataSource") DataSource dataSource) { | ||
| return builder.dataSource(dataSource).packages("com.iemr.common.identity.domain.identity","com.iemr.common.identity.data.rmnch").persistenceUnit("db_identity").build(); | ||
| } | ||
|
|
||
| @Primary | ||
| @Bean(name = "transactionManager") | ||
| public PlatformTransactionManager transactionManager( | ||
| @Qualifier("entityManagerFactory") EntityManagerFactory entityManagerFactory) { | ||
| return new JpaTransactionManager(entityManagerFactory); | ||
| } | ||
| } |
86 changes: 86 additions & 0 deletions
86
src/main/java/com/iemr/common/identity/config/SecondaryDBConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /* | ||
| * AMRIT β Accessible Medical Records via Integrated Technology | ||
| * Integrated EHR (Electronic Health Records) Solution | ||
| * | ||
| * Copyright (C) "Piramal Swasthya Management and Research Institute" | ||
| * | ||
| * This file is part of AMRIT. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see https://www.gnu.org/licenses/. | ||
| */ | ||
| package com.iemr.common.identity.config; | ||
|
|
||
| import com.iemr.common.identity.utils.config.ConfigProperties; | ||
| import jakarta.persistence.EntityManagerFactory; | ||
| import org.apache.tomcat.jdbc.pool.DataSource; | ||
| import org.apache.tomcat.jdbc.pool.PoolConfiguration; | ||
| import org.apache.tomcat.jdbc.pool.PoolProperties; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.beans.factory.annotation.Qualifier; | ||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | ||
| import org.springframework.orm.jpa.JpaTransactionManager; | ||
| import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; | ||
| import org.springframework.transaction.PlatformTransactionManager; | ||
| import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
|
||
| @Configuration | ||
| @EnableTransactionManagement | ||
| @EnableJpaRepositories(entityManagerFactoryRef = "secondaryEntityManagerFactory", | ||
| transactionManagerRef = "secondaryTransactionManager", basePackages = {"com.iemr.common.identity.domain.iemr"}) | ||
| public class SecondaryDBConfig { | ||
|
|
||
| Logger logger = LoggerFactory.getLogger(this.getClass().getName()); | ||
|
|
||
| @Bean(name = "secondaryDataSource") | ||
| @ConfigurationProperties(prefix = "secondary.datasource") | ||
| public DataSource dataSource() { | ||
| PoolConfiguration p = new PoolProperties(); | ||
| p.setMaxActive(30); | ||
| p.setMaxIdle(15); | ||
| p.setMinIdle(5); | ||
| p.setInitialSize(5); | ||
| p.setMaxWait(10000); | ||
| p.setMinEvictableIdleTimeMillis(15000); | ||
| p.setRemoveAbandoned(true); | ||
| p.setLogAbandoned(true); | ||
| p.setRemoveAbandonedTimeout(600); | ||
| p.setTestOnBorrow(true); | ||
| p.setValidationQuery("SELECT 1"); | ||
| org.apache.tomcat.jdbc.pool.DataSource datasource = new org.apache.tomcat.jdbc.pool.DataSource(); | ||
| datasource.setPoolProperties(p); | ||
|
|
||
| datasource.setUsername(ConfigProperties.getPropertyByName("secondary.datasource.username")); | ||
| datasource.setPassword(ConfigProperties.getPropertyByName("secondary.datasource.password")); | ||
|
|
||
|
|
||
| return datasource; | ||
| } | ||
|
|
||
| @Bean(name = "secondaryEntityManagerFactory") | ||
| public LocalContainerEntityManagerFactoryBean barEntityManagerFactory(EntityManagerFactoryBuilder builder, | ||
| @Qualifier("secondaryDataSource") DataSource dataSource) { | ||
| return builder.dataSource(dataSource).packages("com.iemr.common.identity.domain.iemr").persistenceUnit("db_iemr").build(); | ||
| } | ||
|
|
||
| @Bean(name = "secondaryTransactionManager") | ||
| public PlatformTransactionManager barTransactionManager( | ||
| @Qualifier("secondaryEntityManagerFactory") EntityManagerFactory secondaryEntityManagerFactory) { | ||
| return new JpaTransactionManager(secondaryEntityManagerFactory); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / SonarCloud
Database passwords should not be disclosed High