Made Lecturer service to work

This commit is contained in:
Filip Izydorczyk
2020-08-04 17:30:03 +02:00
parent 821f1ffa75
commit 90cc284f7a
8 changed files with 82 additions and 31 deletions

View File

@ -13,7 +13,10 @@ public class FileToDatabaseMigrator {
public static String LECTURER_SURNAME_STRING = "nazwisko";
public static String LECTURER_TITLE_STRING = "tytul";
public FileToDatabaseMigrator() {
LecturerService lecturerService;
public FileToDatabaseMigrator(LecturerService lecturerService) {
this.lecturerService = lecturerService;
}
public void migrate(FileData data) {
@ -23,13 +26,13 @@ public class FileToDatabaseMigrator {
int surname_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_SURNAME_STRING);
int name_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_NAME_STRING);
LecturerService lecturerService = new LecturerService();
while (rows.hasNext()) {
Row row = rows.next();
Lecturer newLecturer = new Lecturer(row.getCell(title_index).toString(), row.getCell(name_index).toString(),
row.getCell(surname_index).toString());
System.out.println(newLecturer.getSurname());
System.out.println(newLecturer.getName());
System.out.println(newLecturer.getTitle());
lecturerService.save(newLecturer);
}