Solved problem with wrong insert into the db.
This commit is contained in:
parent
90cc284f7a
commit
4eabc194fc
@ -38,6 +38,7 @@ public class FileReader {
|
|||||||
while (cellIt.hasNext()) {
|
while (cellIt.hasNext()) {
|
||||||
Cell c = cellIt.next();
|
Cell c = cellIt.next();
|
||||||
keys.put(c.toString(), index);
|
keys.put(c.toString(), index);
|
||||||
|
index+=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rowIt.remove();
|
rowIt.remove();
|
||||||
|
@ -6,6 +6,7 @@ import com.plannaplan.entities.Lecturer;
|
|||||||
import com.plannaplan.models.FileData;
|
import com.plannaplan.models.FileData;
|
||||||
import com.plannaplan.services.LecturerService;
|
import com.plannaplan.services.LecturerService;
|
||||||
|
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
|
||||||
public class FileToDatabaseMigrator {
|
public class FileToDatabaseMigrator {
|
||||||
@ -28,12 +29,28 @@ public class FileToDatabaseMigrator {
|
|||||||
|
|
||||||
while (rows.hasNext()) {
|
while (rows.hasNext()) {
|
||||||
Row row = rows.next();
|
Row row = rows.next();
|
||||||
Lecturer newLecturer = new Lecturer(row.getCell(title_index).toString(), row.getCell(name_index).toString(),
|
|
||||||
row.getCell(surname_index).toString());
|
Cell title_cell = row.getCell(title_index);
|
||||||
System.out.println(newLecturer.getSurname());
|
Cell name_cell = row.getCell(name_index);
|
||||||
System.out.println(newLecturer.getName());
|
Cell surname_cell = row.getCell(surname_index);
|
||||||
System.out.println(newLecturer.getTitle());
|
|
||||||
|
String lecturer_title = "";
|
||||||
|
String lecturer_surname = "";
|
||||||
|
String lecturer_name = "";
|
||||||
|
|
||||||
|
if (title_cell != null) {
|
||||||
|
lecturer_title = title_cell.toString();
|
||||||
|
}
|
||||||
|
if (name_cell != null) {
|
||||||
|
lecturer_name = name_cell.toString();
|
||||||
|
}
|
||||||
|
if (surname_cell != null) {
|
||||||
|
lecturer_surname = surname_cell.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
Lecturer newLecturer = new Lecturer(lecturer_title, lecturer_name, lecturer_surname);
|
||||||
lecturerService.save(newLecturer);
|
lecturerService.save(newLecturer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user