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,73 +32,250 @@
 ort 
-ulcrs.models.schedule.Schedule;%0D%0A%0D%0Aimport java.time.LocalDateTime
+com.google.gson.Gson;%0D%0Aimport com.google.gson.reflect.TypeToken;%0D%0Aimport com.google.gson.stream.JsonReader;%0D%0Aimport ulcrs.data.DataStore;%0D%0Aimport ulcrs.models.schedule.Schedule;%0D%0A%0D%0Aimport java.io.InputStream;%0D%0Aimport java.io.InputStreamReader
 ;%0D%0Ai
@@ -289,22 +289,26 @@
 ava.
-u
 ti
-l.ArrayList
+me.LocalDateTime
 ;%0D%0Ai
@@ -1227,32 +1227,34 @@
 lgorithm%0D%0A%0D%0A
+%0D%0A
         
 isScheduling
@@ -1245,77 +1245,362 @@
     
-isScheduling = false;%0D%0A        generatedSchedules = new ArrayList%3C%3E()
+// For now, return mock data%0D%0A        InputStream is = DataStore.class.getClassLoader().getResourceAsStream(%22mockSchedule_FrontendExpects.json%22);%0D%0A        JsonReader reader = new JsonReader(new InputStreamReader(is));%0D%0A        generatedSchedules = new Gson().fromJson(reader, new TypeToken%3CList%3CSchedule%3E%3E() %7B%7D.getType());%0D%0A%0D%0A        isScheduling = false
 ;%0D%0A 

Update Schedule endpoints to use mock data