Search in sources :

Example 11 with JamSubmission

use of net.javadiscord.javabot.systems.jam.model.JamSubmission in project JavaBot by Java-Discord.

the class JamSubmissionRepository method readSubmission.

private JamSubmission readSubmission(ResultSet rs, Jam jam) throws SQLException {
    JamSubmission submission = new JamSubmission();
    submission.setId(rs.getLong("id"));
    submission.setCreatedAt(rs.getTimestamp("created_at").toLocalDateTime());
    submission.setJam(jam);
    submission.setThemeName(rs.getString("theme_name"));
    submission.setUserId(rs.getLong("user_id"));
    submission.setSourceLink(rs.getString("source_link"));
    submission.setDescription(rs.getString("description"));
    return submission;
}
Also used : JamSubmission(net.javadiscord.javabot.systems.jam.model.JamSubmission)

Example 12 with JamSubmission

use of net.javadiscord.javabot.systems.jam.model.JamSubmission in project JavaBot by Java-Discord.

the class JamSubmissionRepository method getSubmission.

/**
 * Gets a single submission based on the given submission id.
 *
 * @param jam          The {@link Jam}.
 * @param submissionId The submission's id.
 * @return The {@link JamSubmission}.
 * @throws SQLException If an error occurs.
 */
public JamSubmission getSubmission(Jam jam, long submissionId) throws SQLException {
    PreparedStatement stmt = con.prepareStatement("SELECT * FROM jam_submission WHERE jam_id = ? AND id = ?");
    stmt.setLong(1, jam.getId());
    stmt.setLong(2, submissionId);
    ResultSet rs = stmt.executeQuery();
    JamSubmission submission = null;
    if (rs.next()) {
        submission = this.readSubmission(rs, jam);
    }
    stmt.close();
    return submission;
}
Also used : JamSubmission(net.javadiscord.javabot.systems.jam.model.JamSubmission) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Aggregations

JamSubmission (net.javadiscord.javabot.systems.jam.model.JamSubmission)12 PreparedStatement (java.sql.PreparedStatement)4 HashMap (java.util.HashMap)4 JamSubmissionRepository (net.javadiscord.javabot.systems.jam.dao.JamSubmissionRepository)4 ResultSet (java.sql.ResultSet)3 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)3 ArrayList (java.util.ArrayList)2 OptionMapping (net.dv8tion.jda.api.interactions.commands.OptionMapping)2 JamMessageRepository (net.javadiscord.javabot.systems.jam.dao.JamMessageRepository)2 JamRepository (net.javadiscord.javabot.systems.jam.dao.JamRepository)2 OffsetDateTime (java.time.OffsetDateTime)1 List (java.util.List)1 Map (java.util.Map)1 JDA (net.dv8tion.jda.api.JDA)1 net.dv8tion.jda.api.entities (net.dv8tion.jda.api.entities)1 User (net.dv8tion.jda.api.entities.User)1 SlashCommandInteractionEvent (net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent)1 JamConfig (net.javadiscord.javabot.data.config.guild.JamConfig)1 Jam (net.javadiscord.javabot.systems.jam.model.Jam)1 JamTheme (net.javadiscord.javabot.systems.jam.model.JamTheme)1