package ulcrs.scheduler;

import ulcrs.models.schedule.Schedule;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

public class Scheduler {
    private static List<Schedule> generatedSchedules;
    private static boolean isScheduling = false;
    private static LocalDateTime schedulingStart;

    public static boolean generateSchedule() {
        // TODO implement
        // This is where the algorithm's entry point will be. This will call the scheduling algorithm with the
        // specified tutors, courses, and shifts from DataStore, and return the list of schedules generated from
        // those constraints

        // TODO we want to spin off a thread here to do our scheduling likely.
        // The scheduling should not be done on the same thread as the thread handling the HTTP request, as we need
        // to return data for the request to avoid a timeout

        isScheduling = true;
        schedulingStart = LocalDateTime.now();

        // Start scheduling algorithm

        isScheduling = false;
        generatedSchedules = new ArrayList<>();
        return true;
    }

    public static List<Schedule> fetchGeneratedSchedules() {
        if (!isComplete()) {
            return null;
        }

        return generatedSchedules;
    }

    private static boolean isComplete() {
        return schedulingStart != null && !isScheduling;
    }

    public static boolean verifySchedule(Schedule schedule) {
        // TODO implement
        return false;
    }

}

@@ -32,38 +32,231 @@
 ort 
-ulcrs.models.schedule.Schedule
+org.slf4j.Logger;%0D%0Aimport org.slf4j.LoggerFactory;%0D%0Aimport ulcrs.data.DataStore;%0D%0Aimport ulcrs.models.course.Course;%0D%0Aimport ulcrs.models.schedule.Schedule;%0D%0Aimport ulcrs.models.shift.Shift;%0D%0Aimport ulcrs.models.tutor.Tutor
 ;%0D%0A%0D
@@ -366,24 +366,101 @@
 cheduler %7B%0D%0A
+    private static Logger log = LoggerFactory.getLogger(Scheduler.class);%0D%0A%0D%0A
     private 
@@ -950,259 +950,541 @@
     
-// TODO we want to spin off a thread here to do our scheduling likely.%0D%0A        // The scheduling should not be done on the same thread as the thread handling the HTTP request, as we need%0D%0A        // to return data for the request to avoid a timeout%0D%0A
+List%3CTutor%3E tutors = DataStore.getTutors();%0D%0A        List%3CCourse%3E courses = DataStore.getCourses();%0D%0A        List%3CShift%3E shifts = DataStore.getShifts();%0D%0A%0D%0A        // Start new thread to handle scheduling so thread handling the HTTP request can return%0D%0A        Thread scheduleThread = new Thread(() -%3E %7B%0D%0A            schedule(tutors, courses, shifts);%0D%0A        %7D);%0D%0A        scheduleThread.start();%0D%0A%0D%0A        return true;%0D%0A    %7D%0D%0A%0D%0A%0D%0A    private static boolean schedule(List%3CTutor%3E tutors, List%3CCourse%3E courses, List%3CShift%3E shifts) %7B
 %0D%0A  
@@ -1598,24 +1598,105 @@
 lgorithm%0D%0A%0D%0A
+        // Run scheduling algorithm%0D%0A%0D%0A        // Finish scheduling algorithm%0D%0A%0D%0A
         isSc

Add new scheduler thread