<commit_before>package com.atlassian.jira.plugins.dvcs.scheduler;

import java.util.Date;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.atlassian.jira.plugins.dvcs.service.OrganizationService;
import com.atlassian.jira.plugins.dvcs.service.RepositoryService;
import com.atlassian.jira.plugins.dvcs.util.SystemUtils;
import com.atlassian.sal.api.lifecycle.LifecycleAware;
import com.atlassian.sal.api.scheduling.PluginScheduler;
import com.google.common.collect.Maps;

public class DvcsScheduler implements LifecycleAware
{
	private static final Logger log = LoggerFactory.getLogger(DvcsScheduler.class);
	private static final String JOB_NAME = DvcsScheduler.class.getName() + ":job";

	private final PluginScheduler pluginScheduler; // provided by SAL
	
	private static final String PROPERTY_KEY = "dvcs.connector.scheduler.interval";
	private static final long DEFAULT_INTERVAL = 1000L * 60 * 10; // default job interval (1 hour) TODO set to 1 hour
	private long interval = DEFAULT_INTERVAL;
	private final OrganizationService organizationService;
	private final RepositoryService repositoryService;

	public DvcsScheduler(PluginScheduler pluginScheduler, OrganizationService organizationService,
	        RepositoryService repositoryService)
	{
		this.pluginScheduler = pluginScheduler;
		this.organizationService = organizationService;
		this.repositoryService = repositoryService;
	}

	@Override
	public void onStart()
	{
		this.interval = SystemUtils.getSystemPropertyLong(PROPERTY_KEY, DEFAULT_INTERVAL);
		log.debug("Starting DVCSConnector Scheduler Job starting");
		reschedule();
	}

	public void reschedule()
	{
		Map<String, Object> data = Maps.newHashMap();
		data.put("organizationService",organizationService);
		data.put("repositoryService",repositoryService);

		pluginScheduler.scheduleJob(JOB_NAME, // unique name of the job
		        DvcsSchedulerJob.class, // class of the job
		        data, // data that needs to be passed to the job
		        new Date(), // the time the job is to start
		        interval); // interval between repeats, in milliseconds
	}

}<commit_msg>BBC-176: Trying to avoid exception with ActiveObjects about different copies of EntityManager<commit_after>package com.atlassian.jira.plugins.dvcs.scheduler;

import java.util.Date;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.jira.plugins.dvcs.activeobjects.v3.OrganizationMapping;
import com.atlassian.jira.plugins.dvcs.service.OrganizationService;
import com.atlassian.jira.plugins.dvcs.service.RepositoryService;
import com.atlassian.jira.plugins.dvcs.util.SystemUtils;
import com.atlassian.sal.api.lifecycle.LifecycleAware;
import com.atlassian.sal.api.scheduling.PluginScheduler;
import com.google.common.collect.Maps;

public class DvcsScheduler implements LifecycleAware
{
	private static final Logger log = LoggerFactory.getLogger(DvcsScheduler.class);
	private static final String JOB_NAME = DvcsScheduler.class.getName() + ":job";

	private final PluginScheduler pluginScheduler; // provided by SAL
	
	private static final String PROPERTY_KEY = "dvcs.connector.scheduler.interval";
	private static final long DEFAULT_INTERVAL = 1000L * 60 * 10; // default job interval (1 hour) TODO set to 1 hour
	private long interval = DEFAULT_INTERVAL;
	private final OrganizationService organizationService;
	private final RepositoryService repositoryService;
	private final ActiveObjects activeObjects;

	public DvcsScheduler(PluginScheduler pluginScheduler, OrganizationService organizationService,
	        RepositoryService repositoryService, ActiveObjects activeObjects)
	{
		this.pluginScheduler = pluginScheduler;
		this.organizationService = organizationService;
		this.repositoryService = repositoryService;
		this.activeObjects = activeObjects;
	}

    @Override
    public void onStart()
    {
        log.debug("onStart");
        // this is here only to trigger migration of AO
        activeObjects.find(OrganizationMapping.class);

        this.interval = SystemUtils.getSystemPropertyLong(PROPERTY_KEY, DEFAULT_INTERVAL);
        log.debug("Starting DVCSConnector Scheduler Job. interval=" + interval);
        reschedule();
    }
	
	public void reschedule()
	{
		Map<String, Object> data = Maps.newHashMap();
		data.put("organizationService",organizationService);
		data.put("repositoryService",repositoryService);

		pluginScheduler.scheduleJob(JOB_NAME, // unique name of the job
		        DvcsSchedulerJob.class, // class of the job
		        data, // data that needs to be passed to the job
		        new Date(), // the time the job is to start
		        interval); // interval between repeats, in milliseconds
	}


}
{'fraction_non_alphanumeric': 0.083889816360601, 'fraction_numerical': 0.005843071786310518, 'mean_word_length': 4.7608173076923075, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '1924630', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1329, 'n_words': 343}