package gdms;

import dao.DBManagement;
import error.GExcptInit;
import error.GExcptSQL;

import java.util.*;

public class GDMS {
    static Map<String, Date> schedules;
    static String schedulePath = "";
    public static void init() throws GExcptInit {
        initSchedule();
        Timer timer = new Timer(true);
        for(Map.Entry<String, Date> schedule:schedules.entrySet()){
            timer.schedule(getTimerTask(schedule.getKey()),schedule.getValue());
        }
    }


    private static TimerTask getTimerTask(String s) throws GExcptInit {
        switch (s){
            case "teacher_choose_student_start_date":
                return new TimerTask() {
                    @Override
                    public void run() {
                        List<String> fields = new ArrayList<>();
                        fields.add("teacher_choose_student_status");
                        try {
                            DBManagement.updateAll("graduation_design",fields,"1");
                        } catch (GExcptSQL gExcptSQL) {
                            gExcptSQL.printStackTrace();
                            System.exit(1);
                        }
                    }
                };
            case "student_choose_teacher_start_date":
                return new TimerTask() {
                    @Override
                    public void run() {
                        List<String> fields = new ArrayList<>();
                        fields.add("teacher_choose_student_status");
                        try {
                            DBManagement.updateAll("graduation_design",fields,"1");
                        } catch (GExcptSQL gExcptSQL) {
                            gExcptSQL.printStackTrace();
                            System.exit(1);
                        }
                    }
                };
            case "choose_end_date":
                return new TimerTask() {
                    @Override
                    public void run() {
                        ;
                    }
                };
            case "opening_report_opinion_deadline_date":
                return new TimerTask() {
                    @Override
                    public void run() {
                        ;
                    }
                };
            case "finished_product_deadline_date":
                return new TimerTask() {
                    @Override
                    public void run() {
                        ;
                    }
                };
            case "finished_product_review_deadline_date":
                return new TimerTask() {
                    @Override
                    public void run() {
                        ;
                    }
                };
            case "reply_opinion_deadline_date":
                return new TimerTask() {
                    @Override
                    public void run() {
                        ;
                    }
                };
        }

        throw new GExcptInit("GlobalTimePoint.json error");
    }

    private static void initSchedule() {

    }
}
