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); diff --git a/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java b/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java index 95521c6..2a12410 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java +++ b/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java @@ -96,6 +96,26 @@ public class Groups { this.type = capacity >= 50 ? GroupType.LECTURE : GroupType.CLASS; } + /** + * Groups + * + * @param capacity capacity given to the groups + * @param room room given to the groups + * @param course course given to the groups + * @param time time given to the groups + * @param endTime end time of class in minutes + * @param day day given to the groups + * @param lecturer lecturer given to the groups + * @param zajCykId number of class in the term + * @param grNr Number of class/course + * @param type type of class/cource + */ + public Groups(int capacity, String room, Course course, int time, int endTime, WeekDay day, Lecturer lecturer, + Integer zajCykId, Integer grNr, GroupType type) { + this(capacity, room, course, time, endTime, day, lecturer, zajCykId, grNr); + this.type = type; + } + /** * Groups * @@ -159,9 +179,10 @@ public class Groups { * @param endTime end time of class in minutes * @param day day given to the groups * @param lecturer lecturer given to the groups + * @param type type given to the groups */ public void update(Integer capacity, String room, Course course, Integer time, Integer endTime, WeekDay day, - Lecturer lecturer) { + Lecturer lecturer, GroupType type) { if (capacity != null) { this.capacity = capacity; } @@ -189,6 +210,10 @@ public class Groups { if (lecturer != null) { this.lecturer = lecturer; } + + if (type != null) { + this.type = type; + } } /** diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/ConfiguratorService.java b/buisnesslogic/src/main/java/com/plannaplan/services/ConfiguratorService.java index 6d045c8..f2e7bc3 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/ConfiguratorService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/ConfiguratorService.java @@ -126,6 +126,7 @@ public class ConfiguratorService { @Override public void run() { + System.out.println("Performing event"); if (localDate.getYear() == LocalDate.now().getYear()) { assignmentService.callAcceptAlgorythm(); } diff --git a/buisnesslogic/src/main/java/com/plannaplan/types/GroupType.java b/buisnesslogic/src/main/java/com/plannaplan/types/GroupType.java index 67fe6d3..3b57aa8 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/types/GroupType.java +++ b/buisnesslogic/src/main/java/com/plannaplan/types/GroupType.java @@ -1,9 +1,23 @@ package com.plannaplan.types; /** - * GroupType contains types: LECTURE, CLASS + * GroupType contains types: LECTURE, CLASS, LAB, SEMINAR, CONSERVATORY, PRATICE */ public enum GroupType { - LECTURE, CLASS + LECTURE("Wykład"), CLASS("Ćwiczenia"), LAB("Laboratorium"), SEMINAR("Seminarium"),CONSERVATORY("Konwersatorium"), PRATICE("Praktyka"); + + public final String type; + private GroupType(String type) { + this.type = type; + } + + public final static GroupType getType(String type) { + for (GroupType d : values()) { + if (d.type.equals(type)) { + return d; + } + } + return null; + } } \ No newline at end of file diff --git a/buisnesslogic/src/test/java/com/plannaplan/configutils/FileReaderTest.java b/buisnesslogic/src/test/java/com/plannaplan/configutils/FileReaderTest.java index 4a01923..bfe683f 100755 --- a/buisnesslogic/src/test/java/com/plannaplan/configutils/FileReaderTest.java +++ b/buisnesslogic/src/test/java/com/plannaplan/configutils/FileReaderTest.java @@ -10,12 +10,11 @@ import org.junit.Test; public class FileReaderTest { @Test - public void shoulReturnNull() { + public void shouldNotReturnNull() { final InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx"); final FileReader r = new FileReader(inputStream); final FileData d = r.read(); - assertTrue(d.getRows().next().getCell(0).toString().equals("1.0")); - assertTrue(d.getKeys().size() == 24); + assertTrue(d.getKeys().size() == 12); assertTrue(d != null); } } \ No newline at end of file diff --git a/buisnesslogic/src/test/resources/Zajecia.xlsx b/buisnesslogic/src/test/resources/Zajecia.xlsx index 71e0ba7..9621d33 100755 Binary files a/buisnesslogic/src/test/resources/Zajecia.xlsx and b/buisnesslogic/src/test/resources/Zajecia.xlsx differ diff --git a/buisnesslogic/src/test/resources/ZajeciaAfterUpdate.xlsx b/buisnesslogic/src/test/resources/ZajeciaAfterUpdate.xlsx index bb3d360..fb8d83f 100755 Binary files a/buisnesslogic/src/test/resources/ZajeciaAfterUpdate.xlsx and b/buisnesslogic/src/test/resources/ZajeciaAfterUpdate.xlsx differ diff --git a/buisnesslogic/src/test/resources/ZajeciaBeforeUpdate.xlsx b/buisnesslogic/src/test/resources/ZajeciaBeforeUpdate.xlsx index 15b7367..bf55ef3 100755 Binary files a/buisnesslogic/src/test/resources/ZajeciaBeforeUpdate.xlsx and b/buisnesslogic/src/test/resources/ZajeciaBeforeUpdate.xlsx differ diff --git a/restservice/src/main/resources/Zajecia.xlsx b/restservice/src/main/resources/Zajecia.xlsx index 71e0ba7..9621d33 100755 Binary files a/restservice/src/main/resources/Zajecia.xlsx and b/restservice/src/main/resources/Zajecia.xlsx differ diff --git a/restservice/src/test/resources/Zajecia.xlsx b/restservice/src/test/resources/Zajecia.xlsx index 71e0ba7..9621d33 100755 Binary files a/restservice/src/test/resources/Zajecia.xlsx and b/restservice/src/test/resources/Zajecia.xlsx differ