<commit_before>package org.motechproject.openmrs;


import org.apache.log4j.Logger;
import org.openmrs.api.*;
import org.openmrs.module.ModuleFactory;
import org.openmrs.util.DatabaseUpdateException;
import org.openmrs.util.InputRequiredException;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Properties;

import static java.lang.String.format;
import static org.openmrs.api.context.Context.startup;
import static org.openmrs.util.OpenmrsConstants.APPLICATION_DATA_DIRECTORY_RUNTIME_PROPERTY;
import static org.openmrs.util.OpenmrsConstants.AUTO_UPDATE_DATABASE_RUNTIME_PROPERTY;

public class Context {
    Logger logger = Logger.getLogger(Context.class);
    private String url;
    private String user;
    private String password;
    private String openmrsUser;
    private String openmrsPassword;

    public Context(String url, String user, String password, String openmrsUser, String openmrsPassword) {
        this.url = url;
        this.user = user;
        this.password = password;
        this.openmrsUser = openmrsUser;
        this.openmrsPassword = <PASSWORD>;
    }

    public void initialize() throws InputRequiredException, DatabaseUpdateException, IOException, URISyntaxException {
        logger.warn(format("connecting to openmrs instance at %s", url));
        Properties properties = new Properties();
        properties.setProperty(AUTO_UPDATE_DATABASE_RUNTIME_PROPERTY, String.valueOf(true));
        String path = getClass().getClassLoader().getResource("openmrs-data").toURI().getPath();
        logger.warn(format("openmrs data folder is  set to %s", path));
        properties.setProperty(APPLICATION_DATA_DIRECTORY_RUNTIME_PROPERTY, path);
        startup(url, user, password, properties);
        logger.warn(format("loaded %d modules", ModuleFactory.getLoadedModules().size()));
    }

    public PatientService getPatientService() {
        return org.openmrs.api.context.Context.getPatientService();
    }

    public PersonService getPersonService() {
        return org.openmrs.api.context.Context.getPersonService();
    }

    public UserService getUserService() {
        return org.openmrs.api.context.Context.getUserService();
    }

    public AdministrationService getAdministrationService() {
        return org.openmrs.api.context.Context.getAdministrationService();
    }
<commit_msg>Deepan | #1019 | Disabling second level caching in openmrs using runtime properties<commit_after>package org.motechproject.openmrs;


import org.apache.log4j.Logger;
import org.openmrs.api.*;
import org.openmrs.module.ModuleFactory;
import org.openmrs.util.DatabaseUpdateException;
import org.openmrs.util.InputRequiredException;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Properties;

import static java.lang.String.format;
import static org.openmrs.api.context.Context.startup;
import static org.openmrs.util.OpenmrsConstants.APPLICATION_DATA_DIRECTORY_RUNTIME_PROPERTY;
import static org.openmrs.util.OpenmrsConstants.AUTO_UPDATE_DATABASE_RUNTIME_PROPERTY;

public class Context {
    Logger logger = Logger.getLogger(Context.class);
    private String url;
    private String user;
    private String password;
    private String openmrsUser;
    private String openmrsPassword;
    private static final String ENABLE_HIBERNATE_SECOND_LEVEL_CACHE = "hibernate.cache.use_second_level_cache";

    public Context(String url, String user, String password, String openmrsUser, String openmrsPassword) {
        this.url = url;
        this.user = user;
        this.password = password;
        this.openmrsUser = openmrsUser;
        this.openmrsPassword = openmrsPassword;
    }

    public void initialize() throws InputRequiredException, DatabaseUpdateException, IOException, URISyntaxException {
        logger.warn(format("connecting to openmrs instance at %s", url));
        Properties properties = new Properties();
        properties.setProperty(AUTO_UPDATE_DATABASE_RUNTIME_PROPERTY, String.valueOf(true));
        String path = getClass().getClassLoader().getResource("openmrs-data").toURI().getPath();
        logger.warn(format("openmrs data folder is  set to %s", path));
        properties.setProperty(APPLICATION_DATA_DIRECTORY_RUNTIME_PROPERTY, path);
        properties.setProperty(ENABLE_HIBERNATE_SECOND_LEVEL_CACHE, String.valueOf(false));
        startup(url, user, password, properties);
        logger.warn(format("loaded %d modules", ModuleFactory.getLoadedModules().size()));
    }

    public PatientService getPatientService() {
        return org.openmrs.api.context.Context.getPatientService();
    }

    public PersonService getPersonService() {
        return org.openmrs.api.context.Context.getPersonService();
    }

    public UserService getUserService() {
        return org.openmrs.api.context.Context.getUserService();
    }

    public AdministrationService getAdministrationService() {
        return org.openmrs.api.context.Context.getAdministrationService();
    }

{'fraction_non_alphanumeric': 0.09304642359035664, 'fraction_numerical': 0.001195457262402869, 'mean_word_length': 4.306553911205074, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7152068', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1407, 'n_words': 286}