Search in sources :

Example 6 with MeetingRepository

use of de.lightbolt.meeting.systems.meeting.dao.MeetingRepository in project LightboltMeeting by LightboltMeeting.

the class MeetingStartJob method execute.

@Override
public void execute(JobExecutionContext context) {
    String[] jobDetail = context.getJobDetail().getKey().getName().split("-");
    DbHelper.doDaoAction(MeetingRepository::new, dao -> {
        Optional<Meeting> meetingOptional = dao.getById(Integer.parseInt(jobDetail[0]));
        if (meetingOptional.isEmpty()) {
            log.warn("Meeting doesn't exist, cannot execute start job.");
            return;
        }
        Meeting meeting = meetingOptional.get();
        if (meeting.getStatus() != MeetingStatus.ONGOING) {
            var manager = new MeetingManager(Bot.jda, meeting);
            manager.startMeeting();
        }
    });
}
Also used : MeetingManager(de.lightbolt.meeting.systems.meeting.MeetingManager) Meeting(de.lightbolt.meeting.systems.meeting.model.Meeting) MeetingRepository(de.lightbolt.meeting.systems.meeting.dao.MeetingRepository)

Aggregations

MeetingRepository (de.lightbolt.meeting.systems.meeting.dao.MeetingRepository)6 Meeting (de.lightbolt.meeting.systems.meeting.model.Meeting)5 MeetingManager (de.lightbolt.meeting.systems.meeting.MeetingManager)4 SystemsConfig (de.lightbolt.meeting.data.config.SystemsConfig)3 LocaleConfig (de.lightbolt.meeting.utils.localization.LocaleConfig)3 SQLException (java.sql.SQLException)3 Arrays (java.util.Arrays)3 Responses (de.lightbolt.meeting.command.Responses)2 MeetingSubcommand (de.lightbolt.meeting.systems.meeting.MeetingSubcommand)2 Optional (java.util.Optional)2 SlashCommandInteractionEvent (net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent)2 ReplyCallbackAction (net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction)2 Bot (de.lightbolt.meeting.Bot)1 DbHelper (de.lightbolt.meeting.data.h2db.DbHelper)1 LocalizationUtils (de.lightbolt.meeting.utils.localization.LocalizationUtils)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 Slf4j (lombok.extern.slf4j.Slf4j)1