public class DatabaseService extends MigrationService
DatabaseConnection
s of a SiteApplication
.MigrationService.MigrationStatus
Modifier and Type | Field and Description |
---|---|
protected DatabaseConnectionRepository |
databaseConnectionRepository |
APP_NG_ROOT_DATABASE, DATABASE_MAX_CONNECTIONS, DATABASE_MIN_CONNECTIONS, DATABASE_NAME, DATABASE_NAME_PREFIX, DATABASE_REPAIR, DATABASE_TYPE, DATABASE_VALIDATION_PERIOD, DATABASE_VALIDATION_QUERY, HIBERNATE_CONNECTION_DRIVER_CLASS, HIBERNATE_CONNECTION_PASSWORD, HIBERNATE_CONNECTION_URL, HIBERNATE_CONNECTION_USERNAME
Constructor and Description |
---|
DatabaseService() |
Modifier and Type | Method and Description |
---|---|
protected void |
dropApplicationConnection(DatabaseConnection databaseConnection,
DataSource dataSource) |
DatabaseConnection |
getRootConnectionOfType(DatabaseConnection.DatabaseType type) |
protected String |
getUserName(Site site,
Application application) |
protected void |
initApplicationConnection(DatabaseConnection applicationConnection,
DataSource dataSource) |
DatabaseConnection |
initDatabase(Properties config,
boolean managed,
boolean setActive)
Configures and (optionally) migrates the appNG root
DatabaseConnection from the given
Properties . |
MigrationService.MigrationStatus |
manageApplicationConnection(SiteApplication siteApplication,
File sqlFolder,
String databasePrefix)
Migrates the database for the given
SiteApplication . |
void |
resetApplicationConnection(SiteApplication siteApplication,
String databasePrefix)
Resets the configuration for the
DatabaseConnection (if existing) of the given SiteApplication to
the default values. |
void |
save(DatabaseConnection databaseConnection)
Persists the given
DatabaseConnection . |
DatabaseConnection |
setActiveConnection(DatabaseConnection rootConnection,
boolean changeManagedState)
Configures the appNG root
DatabaseConnection s by either creating a new one or updating the existing
DatabaseConnection for each DatabaseConnection.DatabaseType . |
getDataSource, getDataSource, getFlyway, getPlatformConnection, initDatabase, initDatabase, migrate, status, status, statusComplete, statusComplete, statusComplete
@Autowired protected DatabaseConnectionRepository databaseConnectionRepository
protected void initApplicationConnection(DatabaseConnection applicationConnection, DataSource dataSource) throws IOException, URISyntaxException
IOException
URISyntaxException
public void resetApplicationConnection(SiteApplication siteApplication, String databasePrefix)
DatabaseConnection
(if existing) of the given SiteApplication
to
the default values.siteApplication
- a SiteApplication
protected String getUserName(Site site, Application application)
protected void dropApplicationConnection(DatabaseConnection databaseConnection, DataSource dataSource) throws IOException, URISyntaxException
IOException
URISyntaxException
@Transactional public DatabaseConnection initDatabase(Properties config, boolean managed, boolean setActive)
DatabaseConnection
from the given
Properties
.config
- the properties read from "/conf/appNG.properties"managed
- whether to make the connection managedsetActive
- if the connection should be set as he active root connection, creating a new
DatabaseConnection
if necessary. Only applied if MigrationService.status(DatabaseConnection)
returns a non-null value.DatabaseConnection
@Transactional public DatabaseConnection setActiveConnection(DatabaseConnection rootConnection, boolean changeManagedState)
DatabaseConnection
s by either creating a new one or updating the existing
DatabaseConnection
for each DatabaseConnection.DatabaseType
. Also checks if the connections are working and calls
DatabaseConnection#setActive(false)
if this is not the case.rootConnection
- the current root connectionchangeManagedState
- if set to true
, the managed state for an existing connection is set to
rootConnection#isManaged()
public DatabaseConnection getRootConnectionOfType(DatabaseConnection.DatabaseType type)
@Transactional public MigrationService.MigrationStatus manageApplicationConnection(SiteApplication siteApplication, File sqlFolder, String databasePrefix)
SiteApplication
.siteApplication
- the SiteApplication
to migrate the database forsqlFolder
- the root folder for the migration-scripts provided by the SiteApplication
databasePrefix
- the prefix for the database to createMigrationService.MigrationStatus
@Transactional public void save(DatabaseConnection databaseConnection)
DatabaseConnection
.databaseConnection
- the connection to persist.Copyright © 2011–2023 aiticon GmbH. All rights reserved.