<commit_before>package org.pi.litepost.databaseAccess;

import java.sql.ResultSet;
import java.util.HashMap;

public class DatabaseQueryManager {
	DatabaseConnector databaseConnector;
	HashMap<String, DatabaseQuery> databaseQueries;

	public DatabaseQueryManager(DatabaseConnector databaseConnector) {
		this.databaseConnector = databaseConnector;
		databaseQueries = new HashMap<String, DatabaseQuery>();

		// Comments:
		databaseQueries.put("deleteComment", new DatabaseQuery(false,
				"DELETE FROM Comments WHERE comment_id = ?"));
		databaseQueries.put("deleteCommentByUser", new DatabaseQuery(false,
				"DELETE FROM Comments WHERE comment_id = ?"));
		databaseQueries.put("getComment", new DatabaseQuery(true,
				"SELECT * FROM Comments WHERE comment_id = ?"));
		databaseQueries.put("getCommentsByPost", new DatabaseQuery(true,
				"SELECT * FROM Comments WHERE post_id = ?"));
		databaseQueries.put("insertComment", new DatabaseQuery(false,
				"INSERT INTO Comments(comment_id, user_id, content, date, parent_id, post_id) VALUES(?, ?, ?, ?, ?, ?)",
				"Comments"));
		databaseQueries.put("updateComment", new DatabaseQuery(false,
				"UPDATE Comments SET text = ? WHERE comment_id = ?"));
		databaseQueries.put("reportComment", new DatabaseQuery(false,
				"UPDATE comments SET reported = 1"));
		databaseQueries.put("getCommentsByParentId", new DatabaseQuery(true,
				"SELECT * FROM Comments WHERE parentId = ?"));
		databaseQueries.put("getReportedComments", new DatabaseQuery(true,
				"SELECT * FROM Comments WHERE reported = 1"));

		// Messages:
		databaseQueries.put("deleteMessage", new DatabaseQuery(false,
				"DELETE FROM Messages WHERE message_id = ?"));
		databaseQueries.put("deleteMessageByUser", new DatabaseQuery(false,
				"DELETE FROM Messages WHERE receiver = ? OR sender = ?"));
		databaseQueries.put("getMessagesByUser", new DatabaseQuery(true,
				"SELECT * FROM Messages WHERE userId = ?"));
		databaseQueries.put("insertMessage", new DatabaseQuery(false,
				"INSERT INTO Messages(message_id, date, sender, receiver, subject, content) VALUES(?, ?, ?, ?, ?, ?)",
				"Messages"));
		databaseQueries.put("getMessagesById", new DatabaseQuery(true,
				"SELECT * FROM Messages WHERE message_id = ?"));

		// Posts:
		databaseQueries.put("deletePost", new DatabaseQuery(false,
				"DELETE FROM Posts WHERE post_id = ?"));
		databaseQueries.put("deletePostByUser", new DatabaseQuery(false,
				"DELETE FROM Posts WHERE user_id = ?"));
		databaseQueries.put("getReportPost", new DatabaseQuery(true,
				"SELECT * FROM Posts WHERE reported = 1"));
		databaseQueries.put("insertPost", new DatabaseQuery(false,
				"INSERT INTO Posts(post_id, title, content, date, contact, user_id) VALUES(?, ?, ?, ?, ?, ?)",
				"Posts"));
		// TODO funktioniert das so?
		databaseQueries.put("deleteOldPosts", new DatabaseQuery(false,
				"DELETE FROM Posts WHERE date < ?"));
		databaseQueries.put("updatePost", new DatabaseQuery(false,<commit_msg>fixed getCommentsByPost and getCommentsByParentId<commit_after>package org.pi.litepost.databaseAccess;

import java.sql.ResultSet;
import java.util.HashMap;

public class DatabaseQueryManager {
	DatabaseConnector databaseConnector;
	HashMap<String, DatabaseQuery> databaseQueries;

	public DatabaseQueryManager(DatabaseConnector databaseConnector) {
		this.databaseConnector = databaseConnector;
		databaseQueries = new HashMap<String, DatabaseQuery>();

		// Comments:
		databaseQueries.put("deleteComment", new DatabaseQuery(false,
				"DELETE FROM Comments WHERE comment_id = ?"));
		databaseQueries.put("deleteCommentByUser", new DatabaseQuery(false,
				"DELETE FROM Comments WHERE comment_id = ?"));
		databaseQueries.put("getComment", new DatabaseQuery(true,
				"SELECT * FROM Comments WHERE comment_id = ?"));
		databaseQueries.put("getCommentsByPost", new DatabaseQuery(true,
				"SELECT * FROM Comments WHERE post_id = ? and parent_id = 0"));
		databaseQueries.put("insertComment", new DatabaseQuery(false,
				"INSERT INTO Comments(comment_id, user_id, content, date, parent_id, post_id) VALUES(?, ?, ?, ?, ?, ?)",
				"Comments"));
		databaseQueries.put("updateComment", new DatabaseQuery(false,
				"UPDATE Comments SET text = ? WHERE comment_id = ?"));
		databaseQueries.put("reportComment", new DatabaseQuery(false,
				"UPDATE comments SET reported = 1"));
		databaseQueries.put("getCommentsByParentId", new DatabaseQuery(true,
				"SELECT * FROM Comments WHERE parent_id = ?"));
		databaseQueries.put("getReportedComments", new DatabaseQuery(true,
				"SELECT * FROM Comments WHERE reported = 1"));

		// Messages:
		databaseQueries.put("deleteMessage", new DatabaseQuery(false,
				"DELETE FROM Messages WHERE message_id = ?"));
		databaseQueries.put("deleteMessageByUser", new DatabaseQuery(false,
				"DELETE FROM Messages WHERE receiver = ? OR sender = ?"));
		databaseQueries.put("getMessagesByUser", new DatabaseQuery(true,
				"SELECT * FROM Messages WHERE userId = ?"));
		databaseQueries.put("insertMessage", new DatabaseQuery(false,
				"INSERT INTO Messages(message_id, date, sender, receiver, subject, content) VALUES(?, ?, ?, ?, ?, ?)",
				"Messages"));
		databaseQueries.put("getMessagesById", new DatabaseQuery(true,
				"SELECT * FROM Messages WHERE message_id = ?"));

		// Posts:
		databaseQueries.put("deletePost", new DatabaseQuery(false,
				"DELETE FROM Posts WHERE post_id = ?"));
		databaseQueries.put("deletePostByUser", new DatabaseQuery(false,
				"DELETE FROM Posts WHERE user_id = ?"));
		databaseQueries.put("getReportPost", new DatabaseQuery(true,
				"SELECT * FROM Posts WHERE reported = 1"));
		databaseQueries.put("insertPost", new DatabaseQuery(false,
				"INSERT INTO Posts(post_id, title, content, date, contact, user_id) VALUES(?, ?, ?, ?, ?, ?)",
				"Posts"));
		// TODO funktioniert das so?
		databaseQueries.put("deleteOldPosts", new DatabaseQuery(false,
				"DELETE FROM Posts WHERE date < ?"));
		databaseQueries.put("updatePost", new DatabaseQuery(false,
{'fraction_non_alphanumeric': 0.1298679592177837, 'fraction_numerical': 0.001169981614574628, 'mean_word_length': 5.56140350877193, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '6270476', 'n_tokens_mistral': 1930, 'n_tokens_neox': 1687, 'n_words': 415}