Commit f837b1ae authored by Piotr Gawron's avatar Piotr Gawron
Browse files

StartupBean depends on the Populator

parent 1c9d80be
......@@ -2,6 +2,7 @@ package lcsb.mapviewer.web.bean.utils;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import javax.annotation.PostConstruct;
import javax.servlet.ServletContext;
......@@ -10,6 +11,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.init.ScriptException;
import org.springframework.stereotype.Component;
import lcsb.mapviewer.common.Configuration;
......@@ -20,6 +22,7 @@ import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.ProjectStatus;
import lcsb.mapviewer.model.map.layout.ReferenceGenome;
import lcsb.mapviewer.model.user.ConfigurationElementType;
import lcsb.mapviewer.persist.CustomDatabasePopulator;
import lcsb.mapviewer.persist.DbUtils;
import lcsb.mapviewer.services.interfaces.IConfigurationService;
import lcsb.mapviewer.services.interfaces.IProjectService;
......@@ -39,26 +42,31 @@ public class StartupBean {
private transient IReferenceGenomeService referenceGenomeService;
private transient DbUtils dbUtils;
private ServletContext servletContext;
private CustomDatabasePopulator flyway;
@Autowired
public StartupBean(final IProjectService projectService,
final IConfigurationService configurationService,
final IReferenceGenomeService referenceGenomeService,
final ServletContext servletContext,
final DbUtils dbUtils) {
final DbUtils dbUtils,
final CustomDatabasePopulator flyway) {
this.projectService = projectService;
this.configurationService = configurationService;
this.referenceGenomeService = referenceGenomeService;
this.servletContext = servletContext;
this.dbUtils = dbUtils;
this.flyway = flyway;
}
/**
* Method that process initial script of application.
*/
@PostConstruct
public void init() {
loadCustomLog4jProperties();
try {
flyway.populate(flyway.getDataSource().getConnection());
} catch (ScriptException | SQLException e) {
logger.error(e,e);
}
logger.debug("Application startup script starts");
Configuration.setWebAppDir(servletContext.getRealPath(".") + "/../");
setInterruptedProjectsStatuses();
......@@ -137,8 +145,8 @@ public class StartupBean {
}
/**
* Set {@link ProjectStatus#FAIL} statuses to projects that were uploading when
* application was shutdown.
* Set {@link ProjectStatus#FAIL} statuses to projects that were uploading
* when application was shutdown.
*/
private void setInterruptedProjectsStatuses() {
try {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment