<commit_before>package de.fh_bielefeld.newsboard.dao;

import de.fh_bielefeld.newsboard.model.AuthenticationToken;
import de.fh_bielefeld.newsboard.model.ExternModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 * Created by felixmeyer on 11.12.16.
 */
public class AuthenticationTokenDaoImpl implements AuthenticationTokenDao {
    private static final String GET_TOKEN_WITH_ID =
            "SELECT id, module_id, token FROM token WHERE id = ?";
    private static final String GET_ALL_TOKEN_FOR_MODULE =
            "SELECT id, module_id, token FROM token WHERE module_id = ?";
    private static final String UPDATE_TOKEN =
            "UPDATE authentication_token SET id = ?, token = ?, module_id = ? WHERE id = ?";
    private static final String INSERT_TOKEN =
            "INSERT INTO authentication_token (token, moduleId) VALUES (?, ?)";

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public AuthenticationToken getTokenWithId(int id) {
        return jdbcTemplate.queryForObject(GET_TOKEN_WITH_ID, new TokenRowMapper(), id);
    }

    @Override
    public List<AuthenticationToken> getAllTokenForModule(ExternModule externModule) {
        return jdbcTemplate.query(GET_ALL_TOKEN_FOR_MODULE, new TokenRowMapper(), externModule.getId());
    }

    @Override
    public int updateAuthenticationToken(AuthenticationToken authToken) {
        Object[] values = {
                authToken.getId(), authToken.getToken(), authToken.getModuleId()
        };
        return jdbcTemplate.update(UPDATE_TOKEN, values);
    }

    @Override
    public int insertAuthenticationToken(AuthenticationToken authToken) {<commit_msg>Changing field injection to constructor injection for daos.<commit_after>package de.fh_bielefeld.newsboard.dao;

import de.fh_bielefeld.newsboard.model.AuthenticationToken;
import de.fh_bielefeld.newsboard.model.ExternModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 * Created by felixmeyer on 11.12.16.
 */
public class AuthenticationTokenDaoImpl implements AuthenticationTokenDao {
    private static final String GET_TOKEN_WITH_ID =
            "SELECT id, module_id, token FROM token WHERE id = ?";
    private static final String GET_ALL_TOKEN_FOR_MODULE =
            "SELECT id, module_id, token FROM token WHERE module_id = ?";
    private static final String UPDATE_TOKEN =
            "UPDATE authentication_token SET id = ?, token = ?, module_id = ? WHERE id = ?";
    private static final String INSERT_TOKEN =
            "INSERT INTO authentication_token (token, moduleId) VALUES (?, ?)";

    private JdbcTemplate jdbcTemplate;

    @Autowired
    public AuthenticationTokenDaoImpl(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public AuthenticationToken getTokenWithId(int id) {
        return jdbcTemplate.queryForObject(GET_TOKEN_WITH_ID, new TokenRowMapper(), id);
    }

    @Override
    public List<AuthenticationToken> getAllTokenForModule(ExternModule externModule) {
        return jdbcTemplate.query(GET_ALL_TOKEN_FOR_MODULE, new TokenRowMapper(), externModule.getId());
    }

    @Override
    public int updateAuthenticationToken(AuthenticationToken authToken) {
        Object[] values = {
                authToken.getId(), authToken.getToken(), authToken.getModuleId()
        };
        return jdbcTemplate.update(UPDATE_TOKEN, values);
    }

    @Override
    public int insertAuthenticationToken(AuthenticationToken authToken) {
{'fraction_non_alphanumeric': 0.08346213292117466, 'fraction_numerical': 0.0030911901081916537, 'mean_word_length': 3.946496815286624, 'pattern_counts': {'":': 0, '<': 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': '2772076', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1071, 'n_words': 252}