diff --git a/avni-server-api/src/main/java/org/avni/server/domain/metabase/DatabaseDetails.java b/avni-server-api/src/main/java/org/avni/server/domain/metabase/DatabaseDetails.java index 519f002e6..222325b37 100644 --- a/avni-server-api/src/main/java/org/avni/server/domain/metabase/DatabaseDetails.java +++ b/avni-server-api/src/main/java/org/avni/server/domain/metabase/DatabaseDetails.java @@ -8,19 +8,21 @@ public class DatabaseDetails { private String port; private String db; private String user; + private String password; public DatabaseDetails() { } - public DatabaseDetails(String host, String port, String db, String user) { + public DatabaseDetails(String host, String port, String db, String user, String password) { this.host = host; this.port = port; this.db = db; this.user = user; + this.password = password; } - public DatabaseDetails(AvniDatabase avniDatabase, String dbUser) { - this(avniDatabase.getAvniDatabaseServer(), avniDatabase.getAvniDatabasePort(), avniDatabase.getAvniDatabaseName(), dbUser); + public DatabaseDetails(AvniDatabase avniDatabase, String dbUser, String dbUserPassword) { + this(avniDatabase.getAvniDatabaseServer(), avniDatabase.getAvniDatabasePort(), avniDatabase.getAvniDatabaseName(), dbUser, dbUserPassword); } public String getHost() { @@ -38,4 +40,8 @@ public String getDb() { public String getUser() { return user; } + + public String getPassword() { + return password; + } } diff --git a/avni-server-api/src/main/java/org/avni/server/service/metabase/MetabaseService.java b/avni-server-api/src/main/java/org/avni/server/service/metabase/MetabaseService.java index 8d2ad289e..7b6178701 100644 --- a/avni-server-api/src/main/java/org/avni/server/service/metabase/MetabaseService.java +++ b/avni-server-api/src/main/java/org/avni/server/service/metabase/MetabaseService.java @@ -13,6 +13,8 @@ @Service public class MetabaseService { + public static final String ORG_DB_USER_PASSWORD = "password"; + public static final String DB_ENGINE = "postgres"; private final OrganisationService organisationService; private final AvniDatabase avniDatabase; private final DatabaseRepository databaseRepository; @@ -44,7 +46,7 @@ public void setupMetabase() { globalDatabase = databaseRepository.getDatabaseByName(new Database(name)); if (globalDatabase == null) { - Database newDatabase = new Database(name, "postgres", new DatabaseDetails(avniDatabase, dbUser)); + Database newDatabase = new Database(name, DB_ENGINE, new DatabaseDetails(avniDatabase, dbUser, ORG_DB_USER_PASSWORD)); globalDatabase = databaseRepository.save(newDatabase); }