You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.1 KiB
60 lines
2.1 KiB
package de.superx.spring.config; |
|
|
|
import static org.quartz.SimpleScheduleBuilder.simpleSchedule; |
|
|
|
import java.util.List; |
|
|
|
import javax.sql.DataSource; |
|
|
|
import org.apache.log4j.Logger; |
|
import org.quartz.JobDataMap; |
|
import org.quartz.JobKey; |
|
import org.quartz.ScheduleBuilder; |
|
import org.quartz.Scheduler; |
|
import org.quartz.SchedulerException; |
|
import org.springframework.batch.core.configuration.JobLocator; |
|
import org.springframework.batch.core.launch.JobLauncher; |
|
import org.springframework.beans.factory.annotation.Autowired; |
|
import org.springframework.context.ApplicationContext; |
|
import org.springframework.context.event.ContextRefreshedEvent; |
|
import org.springframework.context.event.EventListener; |
|
|
|
import de.superx.rest.EtlJobApi; |
|
import de.superx.rest.model.job.Component; |
|
import de.superx.servlet.SuperXManager; |
|
import de.superx.spring.batch.job.BiQuartzBatchJob; |
|
|
|
@org.springframework.stereotype.Component |
|
public class BiApplicationContextInit { |
|
|
|
Logger logger = Logger.getLogger(BiApplicationContextInit.class); |
|
|
|
|
|
|
|
private boolean dbFunctionsLoaded = false; |
|
|
|
@EventListener |
|
void contextRefreshedEvent(ContextRefreshedEvent cre) { |
|
ApplicationContext ctx = cre.getApplicationContext(); |
|
DataSource ds = ctx.getBean(DataSource.class); |
|
if (SuperXManager.checkDatabaseEmpty(ds)) { |
|
logger.warn("eduetl db empty. Not installing module functions."); |
|
return; |
|
} |
|
logger.info("Installing module functions:"); |
|
if (SuperXManager.isHis1 && !dbFunctionsLoaded) { |
|
EtlJobApi jobApi = ctx.getBean(EtlJobApi.class); |
|
List<Component> components = jobApi.getAllComponentAndConnectorDetails(); |
|
for (Component component : components) { |
|
if (component.isInstalled()) { |
|
logger.info("Installing module funtions for " + component.getName()); |
|
jobApi.installModuleFunctions(component.getAbbreviation()); |
|
} |
|
} |
|
logger.info("Installing module funtions finished."); |
|
dbFunctionsLoaded = true; |
|
} |
|
} |
|
|
|
|
|
}
|
|
|