Checkpoint
This commit is contained in:
@ -1,12 +1,37 @@
|
||||
package com.plannaplan.configutils;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.plannaplan.entities.Lecturer;
|
||||
import com.plannaplan.models.FileData;
|
||||
import com.plannaplan.services.LecturerService;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
|
||||
public class FileToDatabaseMigrator {
|
||||
public static String LECTURER_NAME_STRING = "imie";
|
||||
public static String LECTURER_SURNAME_STRING = "nazwisko";
|
||||
public static String LECTURER_TITLE_STRING = "tytul";
|
||||
|
||||
public FileToDatabaseMigrator() {
|
||||
}
|
||||
|
||||
public void migrate(FileData data) {
|
||||
Iterator<Row> rows = data.getRows();
|
||||
|
||||
int title_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_TITLE_STRING);
|
||||
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());
|
||||
|
||||
lecturerService.save(newLecturer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user