Search in sources :

Example 1 with ConfigurationSetup

use of org.openmrs.module.pihcore.setup.ConfigurationSetup in project openmrs-module-pihcore by PIH.

the class PihCoreActivator method configureSystem.

public void configureSystem() {
    try {
        log.info("Initiating pihcore configuration");
        final ConfigurationSetup configurationSetup = Context.getRegisteredComponents(ConfigurationSetup.class).get(0);
        configurationSetup.setupBase();
        configurationSetup.configureNonConceptDependencies();
        AdministrationService as = Context.getAdministrationService();
        String runInSeparateThread = as.getGlobalProperty(PihCoreConstants.GP_RUN_CONCEPT_SETUP_TASK_IN_SEPARATE_THREAD);
        if ("true".equalsIgnoreCase(runInSeparateThread)) {
            // see https://pihemr.atlassian.net/browse/UHM-4459
            log.info("Setting up configuration in a separate thread. Please monitor logs to check status.");
            Daemon.runInDaemonThread(() -> {
                try {
                    configurationSetup.configureConceptDependencies();
                } catch (Exception e) {
                    log.error("Configuration Setup Failed", e);
                    throw new RuntimeException(e);
                }
            }, daemonToken);
        } else {
            configurationSetup.configureConceptDependencies();
        }
        log.info("Distribution startup complete.");
    } catch (Exception e) {
        Module mod = ModuleFactory.getModuleById("pihcore");
        ModuleFactory.stopModule(mod, true, true);
        throw new RuntimeException("An error occurred while starting the pihcore module", e);
    }
}
Also used : AdministrationService(org.openmrs.api.AdministrationService) ConfigurationSetup(org.openmrs.module.pihcore.setup.ConfigurationSetup) Module(org.openmrs.module.Module)

Aggregations

AdministrationService (org.openmrs.api.AdministrationService)1 Module (org.openmrs.module.Module)1 ConfigurationSetup (org.openmrs.module.pihcore.setup.ConfigurationSetup)1