Config worksgit add .git add .

This commit is contained in:
Filip Izydorczyk
2020-08-08 00:08:36 +02:00
parent 2f63d05c6c
commit ac0851ae29
3 changed files with 42 additions and 14 deletions
buisnesslogic/src/main/java/com/plannaplan

@ -9,6 +9,7 @@ import com.plannaplan.models.FileData;
import com.plannaplan.services.CourseService;
import com.plannaplan.services.GroupService;
import com.plannaplan.services.LecturerService;
import com.plannaplan.types.GroupType;
import com.plannaplan.types.WeekDay;
import org.apache.poi.ss.usermodel.Cell;
@ -78,20 +79,12 @@ public class FileToDatabaseMigrator {
int day = (int) Double.parseDouble(day_cell.toString());
WeekDay group_day = WeekDay.getDay(day);
String room = room_cell.toString();
int time = 480;
int time = this.parseTimeToInt(time_cell.toString());
int capacity = (int) Double.parseDouble(capacity_cell.toString());
Groups group = groupService.find(time, capacity, room);
if (group == null) {
group = new Groups();
group.setCapacity(capacity);
group.setTime(time);
group.setRoom(room);
}
groupService.save(group);
Course course = this.courseService.getCourseByName(course_name);
if (course == null) {
@ -112,12 +105,44 @@ public class FileToDatabaseMigrator {
lecturer_surname = surname_cell.toString();
}
if (lecturerService.getLecturer(lecturer_title, lecturer_name, lecturer_surname) == null) {
Lecturer newLecturer = new Lecturer(lecturer_title, lecturer_name, lecturer_surname);
lecturerService.save(newLecturer);
Lecturer lecturer = lecturerService.getLecturer(lecturer_title, lecturer_name, lecturer_surname);
if (lecturer == null) {
lecturer = new Lecturer(lecturer_title, lecturer_name, lecturer_surname);
lecturerService.save(lecturer);
}
if (group == null) {
group = new Groups();
group.setCapacity(capacity);
group.setRoom(room);
group.setCourseId(course);
group.setTime(time);
if (capacity >= 50) {
group.setType(GroupType.LECTURE);
} else {
group.setType(GroupType.CLASS);
}
group.setDay(group_day);
group.setLecturer(lecturer);
groupService.save(group);
}
}
}
private Integer parseTimeToInt(String time) {
String times[] = time.split("\\.");
if (times.length == 2) {
return Integer.parseInt(times[0]) * 60 + Integer.parseInt(times[1]);
}
times = time.split("\\:");
if (times.length == 2) {
return Integer.parseInt(times[0]) * 60 + Integer.parseInt(times[1]);
}
return 0;
}
}