Search in sources :

Example 1 with DemoDataConfig

use of org.jboss.pnc.common.json.moduleconfig.DemoDataConfig in project pnc by project-ncl.

the class DemoDataInitializer method initialize.

@PostConstruct
public void initialize() {
    DemoDataConfig demoDataConfig = null;
    try {
        demoDataConfig = configuration.getModuleConfig(new PncConfigProvider<>(DemoDataConfig.class));
    } catch (ConfigurationParseException e) {
        logger.warn("Cannot read demo data config.", e);
    }
    if (demoDataConfig == null || !demoDataConfig.getImportDemoData()) {
        logger.info("Demo data import is not enabled.");
        return;
    }
    long numberOfProjectInDB = projectRepository.count();
    if (numberOfProjectInDB != 0) {
        logger.info("There are >0 ({}) projects in DB. Skipping initialization." + numberOfProjectInDB);
    } else {
        logger.info("Initializing DEMO data");
        dbDataInitializer.initiliazeProjectProductData();
        dbDataInitializer.initiliazeBuildRecordDemoData();
        dbDataInitializer.verifyData();
        logger.info("Finished initializing DEMO data");
    }
}
Also used : ConfigurationParseException(org.jboss.pnc.common.json.ConfigurationParseException) PncConfigProvider(org.jboss.pnc.common.json.moduleprovider.PncConfigProvider) DemoDataConfig(org.jboss.pnc.common.json.moduleconfig.DemoDataConfig) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)1 ConfigurationParseException (org.jboss.pnc.common.json.ConfigurationParseException)1 DemoDataConfig (org.jboss.pnc.common.json.moduleconfig.DemoDataConfig)1 PncConfigProvider (org.jboss.pnc.common.json.moduleprovider.PncConfigProvider)1