<commit_before>package net.sf.sitemonitoring.service;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import javax.sql.DataSource;

import lombok.extern.slf4j.Slf4j;
import net.sf.sitemonitoring.entity.Configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class UpgradeService {

	@Autowired
	private DataSource dataSource;

	@Autowired
	private ConfigurationService configurationService;

	/**
	 * In this method will be upgrades to existing database
	 * 
	 * @throws SQLException
	 */
	public void upgradeDatabase(Configuration configuration) {
		if (configuration.getMonitoringVersion() == null || configuration.getMonitoringVersion().isEmpty()) {
			configuration.setMonitoringVersion("2.1");
			configurationService.saveExcludingPassword(configuration);
			update("update monit_check set condition_value = condition");
		}
		if (configuration.getMonitoringVersion().equals("2.1")) {
			configuration.setDefaultSpiderCheckInterval(60);
			configuration.setDefaultSendEmails(true);
			configuration.setMonitoringVersion("2.1.1");
			configurationService.saveExcludingPassword(configuration);
		}
		if (configuration.getMonitoringVersion().equals("2.1.1")) {
			configuration.setMonitoringVersion("2.1.2");
			configurationService.saveExcludingPassword(configuration);
		}
		if (configuration.getMonitoringVersion().equals("2.1.2")) {
			configuration.setInfoMessage("Please don't monitor my websites (like javavids.com and sitemonitoring.sourceforge.net). Lot's of people started doing it and effectively DDOSed them. If you monitor them anyway, your IP address will be blocked!");
			configuration.setUserAgent("sitemonitoring http://sitemonitoring.sourceforge.net");
			configuration.setMonitoringVersion("2.1.3");
			configurationService.saveExcludingPassword(configuration);
		}
		if (configuration.getMonitoringVersion().equals("2.1.3")) {
			configuration.setMonitoringVersion("2.1.4");
			configurationService.saveExcludingPassword(configuration);
		}
		if (configuration.getMonitoringVersion().equals("2.1.4")) {
			configuration.setMonitoringVersion("2.1.6");
			configuration.setDefaultSendEmails(true);
			configurationService.saveExcludingPassword(configuration);
		}
		if (configuration.getMonitoringVersion().equals("2.1.6")) {
			configuration.setMonitoringVersion("2.1.7");
			configuration.setEmailFrom(configuration.getAdminEmail());
			configurationService.saveExcludingPassword(configuration);
		}
		if (configuration.getMonitoringVersion().equals("2.1.7")) {
			configuration.setMonitoringVersion("2.1.8");
			configurationService.saveExcludingPassword(configuration);
		}
		if (configuration.getMonitoringVersion().equals("2.1.8")) {
			configuration.setMonitoringVersion("2.1.9");
			configurationService.saveExcludingPassword(configuration);
		}
	}

	private void update(String sql) {
		Connection connection = null;
		try {
			connection = dataSource.getConnection();
			Statement statement = connection.createStatement();
			statement.executeUpdate(sql);<commit_msg>fixed upgrade service<commit_after>package net.sf.sitemonitoring.service;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import javax.sql.DataSource;

import lombok.extern.slf4j.Slf4j;
import net.sf.sitemonitoring.entity.Configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class UpgradeService {

	@Autowired
	private DataSource dataSource;

	@Autowired
	private ConfigurationService configurationService;

	/**
	 * In this method will be upgrades to existing database
	 * 
	 * @throws SQLException
	 */
	public void upgradeDatabase(Configuration configuration) {
		if (configuration.getMonitoringVersion() == null || configuration.getMonitoringVersion().isEmpty()) {
			configuration.setMonitoringVersion("2.1");
			configurationService.saveExcludingPassword(configuration);
			update("update monit_check set condition_value = condition");
			configuration = configurationService.find();
		}
		if(configuration.getMonitoringVersion().equals("2.2")) {
			// this was error
			configuration.setMonitoringVersion("2.1");
			configurationService.saveExcludingPassword(configuration);
			configuration = configurationService.find();
		}
		if (configuration.getMonitoringVersion().equals("2.1")) {
			configuration.setDefaultSpiderCheckInterval(60);
			configuration.setDefaultSendEmails(true);
			configuration.setMonitoringVersion("2.1.1");
			configurationService.saveExcludingPassword(configuration);
			configuration = configurationService.find();
		}
		if (configuration.getMonitoringVersion().equals("2.1.1")) {
			configuration.setMonitoringVersion("2.1.2");
			configurationService.saveExcludingPassword(configuration);
			configuration = configurationService.find();
		}
		if (configuration.getMonitoringVersion().equals("2.1.2")) {
			configuration.setInfoMessage("Please don't monitor my websites (like javavids.com and sitemonitoring.sourceforge.net). Lot's of people started doing it and effectively DDOSed them. If you monitor them anyway, your IP address will be blocked!");
			configuration.setUserAgent("sitemonitoring http://sitemonitoring.sourceforge.net");
			configuration.setMonitoringVersion("2.1.3");
			configurationService.saveExcludingPassword(configuration);
			configuration = configurationService.find();
		}
		if (configuration.getMonitoringVersion().equals("2.1.3")) {
			configuration.setMonitoringVersion("2.1.4");
			configurationService.saveExcludingPassword(configuration);
			configuration = configurationService.find();
		}
		if (configuration.getMonitoringVersion().equals("2.1.4")) {
			configuration.setMonitoringVersion("2.1.6");
			configuration.setDefaultSendEmails(true);
			configurationService.saveExcludingPassword(configuration);
			configuration = configurationService.find();
		}
		if (configuration.getMonitoringVersion().equals("2.1.6")) {
			configuration.setMonitoringVersion("2.1.7");
			configuration.setEmailFrom(configuration.getAdminEmail());
			configurationService.saveExcludingPassword(configuration);
			configuration = configurationService.find();
		}
		if (configuration.getMonitoringVersion().equals("2.1.7")) {
			configuration.setMonitoringVersion("2.1.8");
			configurationService.saveExcludingPassword(configuration);
			configuration = configurationService.find();
		}
		if (configuration.getMonitoringVersion().equals("2.1.8")) {
			configuration.setMonitoringVersion("2.1.9");
			configurationService.saveExcludingPassword(configuration);
			configuration = configurationService.find();
		}
	}

	private void update(String sql) {
		Connection connection = null;
		try {
			connection = dataSource.getConnection();
			Statement statement = connection.createStatement();
			statement.executeUpdate(sql);
{'fraction_non_alphanumeric': 0.11642651296829971, 'fraction_numerical': 0.016138328530259365, 'mean_word_length': 6.089887640449438, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4332293', 'n_tokens_mistral': 2080, 'n_tokens_neox': 1844, 'n_words': 305}