From 7813f148eb87b2d00ed0da504e0d38698a16d15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Wed, 6 Jan 2021 11:39:42 +0100 Subject: [PATCH] Added new column type with reading it and write groupType into DB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../configutils/FileToDatabaseMigrator.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/buisnesslogic/src/main/java/com/plannaplan/configutils/FileToDatabaseMigrator.java b/buisnesslogic/src/main/java/com/plannaplan/configutils/FileToDatabaseMigrator.java index 44af1f6..744653a 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/configutils/FileToDatabaseMigrator.java +++ b/buisnesslogic/src/main/java/com/plannaplan/configutils/FileToDatabaseMigrator.java @@ -8,6 +8,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.Row; @@ -31,6 +32,7 @@ public class FileToDatabaseMigrator { private static final String GROUP_TIME_STRING = "godz_od"; private static final String ROOM_STRING = "sala"; private static final String CAPACITY_STRING = "Mc"; + private static final String TYPE_GROUP= "typ"; private static final String ZAJ_CYK_ID = "zaj_cyk_id"; private static final String GR_NR = "gr_nr"; @@ -58,6 +60,7 @@ public class FileToDatabaseMigrator { int timeIndex = data.getIndexOf(FileToDatabaseMigrator.GROUP_TIME_STRING); int roomIndex = data.getIndexOf(FileToDatabaseMigrator.ROOM_STRING); int capacityIndex = data.getIndexOf(FileToDatabaseMigrator.CAPACITY_STRING); + int typeGroupIndex = data.getIndexOf(FileToDatabaseMigrator.TYPE_GROUP); int zajCykIdIndex = data.getIndexOf(FileToDatabaseMigrator.ZAJ_CYK_ID); int grNrIndex = data.getIndexOf(FileToDatabaseMigrator.GR_NR); @@ -79,11 +82,12 @@ public class FileToDatabaseMigrator { Integer grNr = row.getCell(grNrIndex) != null ? (int) Double.parseDouble(row.getCell(grNrIndex).toString().trim()) : null; - int day = (int) Double.parseDouble(row.getCell(dayIndex).toString()); + int day = row.getCell(dayIndex) != null ? (int) Double.parseDouble(row.getCell(dayIndex).toString()) : 0; WeekDay groupDay = WeekDay.getDay(day - 1); int time = parseTimeToInt(row.getCell(timeIndex).toString()); String room = row.getCell(roomIndex).toString().trim(); int capacity = (int) Double.parseDouble(row.getCell(capacityIndex).toString()); + GroupType typeGroup = GroupType.getType(row.getCell(typeGroupIndex).toString()); Course course = this.courseService.getCourseByName(courseName) .orElseGet(() -> this.courseService.save(new Course(courseName, symbol))); @@ -93,9 +97,8 @@ public class FileToDatabaseMigrator { .save(new Lecturer(lecturerTitle, lecturerName, lecturerSurname))); Groups group = this.groupService.find(zajCykId, grNr).orElseGet( - () -> new Groups(capacity, room, course, time, groupDay, lecturer, zajCykId, grNr)); - - group.update(capacity, room, course, time, null, groupDay, lecturer); + () -> new Groups(capacity, room, course, time, capacity, groupDay, lecturer, zajCykId, grNr, typeGroup)); + group.update(capacity, room, course, time, null, groupDay, lecturer, typeGroup); this.groupService.save(group);