diff --git a/java/hello-world/src/main/java/org/acme/schooltimetabling/TimetableApp.java b/java/hello-world/src/main/java/org/acme/schooltimetabling/TimetableApp.java
index 4002711a..d62164ef 100644
--- a/java/hello-world/src/main/java/org/acme/schooltimetabling/TimetableApp.java
+++ b/java/hello-world/src/main/java/org/acme/schooltimetabling/TimetableApp.java
@@ -22,7 +22,7 @@
import java.util.*;
public class TimetableApp {
-
+//TODO andrea schuman name udpate in excel file, update in the db as well or at least check over this
private static final Logger LOGGER = LoggerFactory.getLogger(TimetableApp.class);
private static final String YAML_FILE_PATH = "constants/config.yaml";
private static final boolean PRINT_DETAILED_SUMMARY = true;
@@ -102,9 +102,9 @@ public static void main(String[] args) throws Exception{
});
}
-// storeResults(solution);
ResultSaver resultSaver = new ResultSaver(solution);
resultSaver.saveSolution();
+ resultSaver.teacherTimesToJson();
return;
}
diff --git a/java/hello-world/src/main/java/org/acme/schooltimetabling/apiCalls/surveyEndpoint/SurveyRecord.java b/java/hello-world/src/main/java/org/acme/schooltimetabling/apiCalls/surveyEndpoint/SurveyRecord.java
index 1cefde96..3d88bd0d 100644
--- a/java/hello-world/src/main/java/org/acme/schooltimetabling/apiCalls/surveyEndpoint/SurveyRecord.java
+++ b/java/hello-world/src/main/java/org/acme/schooltimetabling/apiCalls/surveyEndpoint/SurveyRecord.java
@@ -4,7 +4,9 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import org.acme.schooltimetabling.TimetableApp;
import org.acme.schooltimetabling.apiCalls.teacherEndpoint.TeacherRecord;
+import org.acme.schooltimetabling.constants.Constants;
import org.acme.schooltimetabling.constants.Days;
+import org.acme.schooltimetabling.constants.Preference;
import org.acme.schooltimetabling.domain.teacher.Faculty;
import org.acme.schooltimetabling.domain.teacher.Teacher;
import org.acme.schooltimetabling.helperClasses.BitSetHelper;
@@ -98,7 +100,8 @@ else if(val.equalsIgnoreCase("acceptable")){
conflict.or(bsRep);
}
}
- Teacher teacher = new Teacher(TeacherGenerator.getNextTeacherID(), nonCanonName, preferences, acceptable, conflict);
+ Teacher teacher = new Teacher(TeacherGenerator.getNextTeacherID(), Constants.TEACHER_NAME_TO_CANON.get(nonCanonName),
+ preferences, acceptable, conflict, Preference.parsePref((String) extraFields.get("gap")));
if(teacherRecord.isFaculty()) teacher = new Faculty(teacher);
return teacher;
}
diff --git a/java/hello-world/src/main/java/org/acme/schooltimetabling/constants/Constants.java b/java/hello-world/src/main/java/org/acme/schooltimetabling/constants/Constants.java
index 5a555336..8cfde997 100644
--- a/java/hello-world/src/main/java/org/acme/schooltimetabling/constants/Constants.java
+++ b/java/hello-world/src/main/java/org/acme/schooltimetabling/constants/Constants.java
@@ -14,6 +14,7 @@
import org.slf4j.LoggerFactory;
import java.io.InputStream;
+import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -23,6 +24,10 @@
* fit anywhere else, like a class.
*/
public class Constants {
+ /**
+ * Global time formatter
+ */
+ public static final DateTimeFormatter TIME_FMT = DateTimeFormatter.ofPattern("h:mma");
/**
* Set to True for testing. Helps by pass some checks
* */
diff --git a/java/hello-world/src/main/java/org/acme/schooltimetabling/constants/Preference.java b/java/hello-world/src/main/java/org/acme/schooltimetabling/constants/Preference.java
new file mode 100644
index 00000000..7663a45d
--- /dev/null
+++ b/java/hello-world/src/main/java/org/acme/schooltimetabling/constants/Preference.java
@@ -0,0 +1,27 @@
+package org.acme.schooltimetabling.constants;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public enum Preference {
+
+ AGREE, NEUTRAL, DISAGREE;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Process.class);
+
+ /**
+ *
case insensitive maps ["", "disagree"] -> {@link #DISAGREE}; ["agree"] -> {@link #AGREE};
+ * ["neutral"] -> {@link #NEUTRAL}
+ * if the string doesn't match any of these options. The program will exit until resolved
+ * @param pref String representation of preference
+ * @return enum representation or error/exits if no match is found
+ */
+ public static Preference parsePref(String pref){
+ if("".equals(pref) || "disagree".equalsIgnoreCase(pref)) return Preference.DISAGREE;
+ else if("agree".equalsIgnoreCase(pref)) return Preference.AGREE;
+ else if("neutral".equalsIgnoreCase(pref)) return Preference.NEUTRAL;
+ LOGGER.error("When reading a survey unknown preference was encountered '{}'.... EXITING", pref);
+ System.exit(1);
+ throw new IllegalStateException(String.format("Unknown preference '%s' encountered while reading survey", pref));
+ }
+}
diff --git a/java/hello-world/src/main/java/org/acme/schooltimetabling/domain/lesson/Lesson.java b/java/hello-world/src/main/java/org/acme/schooltimetabling/domain/lesson/Lesson.java
index 4fb5c63d..19334090 100644
--- a/java/hello-world/src/main/java/org/acme/schooltimetabling/domain/lesson/Lesson.java
+++ b/java/hello-world/src/main/java/org/acme/schooltimetabling/domain/lesson/Lesson.java
@@ -4,6 +4,7 @@
import ai.timefold.solver.core.api.domain.lookup.PlanningId;
import ai.timefold.solver.core.api.domain.variable.PlanningVariable;
import org.acme.schooltimetabling.constants.Constants;
+import org.acme.schooltimetabling.constants.Days;
import org.acme.schooltimetabling.domain.Room;
import org.acme.schooltimetabling.domain.Timeslot;
import org.acme.schooltimetabling.domain.teacher.Teacher;
@@ -12,7 +13,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
import java.util.BitSet;
+import java.util.List;
+import java.util.Map;
@PlanningEntity(difficultyComparatorClass = LessonComparator.class)
//@PlanningEntity(comparator = LessonComparator.class)
@@ -37,7 +43,6 @@ public class Lesson {
public boolean hasLecture, hasLabAct;
public int lecHours, labActHours;
public Teacher teacherObj;
- private Integer linker = null;
@PlanningVariable
@@ -55,38 +60,16 @@ private Lesson() {
* https://docs.timefold.ai/timefold-solver/latest/using-timefold-solver/modeling-planning-problems#planningId*/
/* Test factory methods */
-
- /**
- * No linker
- */
public static Lesson test_buildLesson(String Id, int lecSection, String courseName, String teacherName, String modifiers,
String courseConfig, int courseID, Teacher teacherObj, Timeslot timeslot, Room room){
return new Lesson(Id, lecSection, courseName, teacherName, modifiers, courseConfig, courseID, teacherObj
, timeslot, room);
}
- /**
- * with linker
- */
- public static Lesson test_buildLesson(String Id, int lecSection, String courseName, String teacherName, String modifiers,
- String courseConfig, int courseID, Teacher teacherObj, Timeslot timeslot, Room room,
- Integer linker){
- return new Lesson(Id, lecSection, courseName, teacherName, modifiers, courseConfig, courseID, teacherObj
- , timeslot, room, linker);
- }
/* Test constructor(s)*/
- private Lesson(String Id, int lecSection, String courseName, String teacherName, String modifiers,
- String courseConfig, int courseID, Teacher teacherObj, Timeslot timeslot, Room room, Integer linker){
- this(Id, lecSection, courseName, teacherName, modifiers, courseConfig, courseID, teacherObj
- , timeslot, room);
- this.linker = linker;
- }
-
private Lesson(String Id, int lecSection, String courseName, String teacherName, String modifiers,
String courseConfig, int courseID, Teacher teacherObj, Timeslot timeslot, Room room){
-// /*calling normal constructor used during setup*/
-// this(Id, lecSection, courseName, teacherName, modifiers, courseConfig, courseID, teacherObj, null);
/*the courseConfig stream is assumed to come in the format
* E-L-A where E is the number of lecture units, L is the number of
* lab units, and A is the number of activity units */
@@ -131,7 +114,7 @@ private Lesson(String Id, int lecSection, String courseName, String teacherName,
* @param teacherObj teacher object associated with the teacherName
*/
public Lesson(String Id, int lecSection, String courseName, String modifiers,
- String courseConfig, Teacher teacherObj, Integer linker){
+ String courseConfig, Teacher teacherObj){
/*the courseConfig stream is assumed to come in the format
* E-L-A where E is the number of lecture units, L is the number of
* lab units, and A is the number of activity units */
@@ -156,7 +139,6 @@ public Lesson(String Id, int lecSection, String courseName, String modifiers,
/*TODO check if we can delete this field*/
this.teacherName = teacherObj.getName();
this.modifiers = modifiers;
- this.linker = linker;
}
/**
@@ -250,10 +232,6 @@ public Teacher getTeacherObj() {
return teacherObj;
}
- public Integer getLinker(){
- return linker;
- }
-
public boolean isStudio(){
return Constants.STUDIO_STYLE_COURSES.contains(this.courseName);
}
@@ -313,4 +291,35 @@ public BitSet maskOutCmprs(){
copy.and(ScheduleConfig.getCompressOutMask());
return copy;
}
+
+ public List