<commit_before>package edu.kit.ipd.crowdcontrol.objectservice;

import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.PlatformManager;
import edu.kit.ipd.crowdcontrol.objectservice.database.DatabaseManager;
import edu.kit.ipd.crowdcontrol.objectservice.database.operations.NotificationRestOperations;
import edu.kit.ipd.crowdcontrol.objectservice.database.operations.PlatformOperations;
import edu.kit.ipd.crowdcontrol.objectservice.database.operations.TemplateOperations;
import edu.kit.ipd.crowdcontrol.objectservice.database.operations.WorkerOperations;
import edu.kit.ipd.crowdcontrol.objectservice.rest.Router;
import edu.kit.ipd.crowdcontrol.objectservice.rest.resources.NotificationResource;
import edu.kit.ipd.crowdcontrol.objectservice.rest.resources.PlatformResource;
import edu.kit.ipd.crowdcontrol.objectservice.rest.resources.TemplateResource;
import edu.kit.ipd.crowdcontrol.objectservice.rest.resources.WorkerResource;
import org.jooq.SQLDialect;

import javax.naming.NamingException;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.Properties;
import java.util.function.Function;

/**
 * @author <NAME>
 */
public class Main {
    public static void main(String[] args) throws IOException {
        Properties properties = new Properties();

        try (InputStream in = Main.class.getResourceAsStream("/config.properties")) {
            properties.load(in);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        Function<String, String> trimIfNotNull = s -> {
            if (s != null)
                return s.trim();
            else
                return s;
        };
        String url = trimIfNotNull.apply(properties.getProperty("database.url"));
        String username = trimIfNotNull.apply(properties.getProperty("database.username"));
        String password = trimIfNotNull.apply(properties.getProperty("database.password"));
        String databasePool = trimIfNotNull.apply(properties.getProperty("database.poolName"));

        SQLDialect dialect = SQLDialect.valueOf(properties.getProperty("database.dialect").trim());
        DatabaseManager databaseManager = null;
        try {
            databaseManager = new DatabaseManager(username, password, url, databasePool, dialect);
            databaseManager.initDatabase();
            boot(databaseManager);
        } catch (NamingException | SQLException e) {
            System.err.println("unable to establish database connection");
            e.printStackTrace();
            System.exit(-1);
        }
    }

    private static void boot(DatabaseManager databaseManager) {

        TemplateOperations templateOperations = new TemplateOperations(databaseManager.getContext());
        NotificationRestOperations notificationRestOperations = new NotificationRestOperations(databaseManager.getContext());
        PlatformOperations platformOperations = new PlatformOperations(databaseManager.getContext());
        WorkerOperations workerOperations = new WorkerOperations(context);

        new Router(
                new TemplateResource(templateOperations),
                new NotificationResource(notificationRestOperations),
                new PlatformResource(platformOperations),
                new WorkerResource(workerOperations, platformManager)
        ).init();
    }
}
<commit_msg>main: merge with database changes, also fixed wrong initialization<commit_after>package edu.kit.ipd.crowdcontrol.objectservice;

import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.PlatformManager;
import edu.kit.ipd.crowdcontrol.objectservice.database.DatabaseManager;
import edu.kit.ipd.crowdcontrol.objectservice.database.operations.NotificationRestOperations;
import edu.kit.ipd.crowdcontrol.objectservice.database.operations.PlatformOperations;
import edu.kit.ipd.crowdcontrol.objectservice.database.operations.TemplateOperations;
import edu.kit.ipd.crowdcontrol.objectservice.database.operations.WorkerOperations;
import edu.kit.ipd.crowdcontrol.objectservice.rest.Router;
import edu.kit.ipd.crowdcontrol.objectservice.rest.resources.NotificationResource;
import edu.kit.ipd.crowdcontrol.objectservice.rest.resources.PlatformResource;
import edu.kit.ipd.crowdcontrol.objectservice.rest.resources.TemplateResource;
import edu.kit.ipd.crowdcontrol.objectservice.rest.resources.WorkerResource;
import org.jooq.SQLDialect;

import javax.naming.NamingException;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.Properties;
import java.util.function.Function;

/**
 * @author <NAME>
 */
public class Main {
    public static void main(String[] args) throws IOException {
        Properties properties = new Properties();

        try (InputStream in = Main.class.getResourceAsStream("/config.properties")) {
            properties.load(in);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        Function<String, String> trimIfNotNull = s -> {
            if (s != null)
                return s.trim();
            else
                return s;
        };
        String url = trimIfNotNull.apply(properties.getProperty("database.url"));
        String username = trimIfNotNull.apply(properties.getProperty("database.username"));
        String password = trimIfNotNull.apply(properties.getProperty("database.password"));
        String databasePool = trimIfNotNull.apply(properties.getProperty("database.poolName"));

        SQLDialect dialect = SQLDialect.valueOf(properties.getProperty("database.dialect").trim());
        DatabaseManager databaseManager = null;
        try {
            databaseManager = new DatabaseManager(username, password, url, databasePool, dialect);
            databaseManager.initDatabase();
            boot(databaseManager);
        } catch (NamingException | SQLException e) {
            System.err.println("unable to establish database connection");
            e.printStackTrace();
            System.exit(-1);
        }
    }

    private static void boot(DatabaseManager databaseManager) {
        TemplateOperations templateOperations = new TemplateOperations(databaseManager.getContext());
        NotificationRestOperations notificationRestOperations = new NotificationRestOperations(databaseManager.getContext());
        TemplateOperations templateOperations = new TemplateOperations(databaseManager.getContext());
        NotificationRestOperations notificationRestOperations = new NotificationRestOperations(databaseManager.getContext());
        PlatformOperations platformOperations = new PlatformOperations(databaseManager.getContext());
        WorkerOperations workerOperations = new WorkerOperations(databaseManager.getContext());

        new Router(
                new TemplateResource(templateOperations),
                new NotificationResource(notificationRestOperations),
                new PlatformResource(platformOperations),
                new WorkerResource(workerOperations, platformManager)
        ).init();
    }
}

{'fraction_non_alphanumeric': 0.0948433328649712, 'fraction_numerical': 0.0005620345651257552, 'mean_word_length': 3.7107875579086698, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '7659160', 'n_tokens_mistral': 1760, 'n_tokens_neox': 1763, 'n_words': 312}