Checkpoint - unstisfied dependency error ater adding gropus
This commit is contained in:
parent
368b4066c0
commit
2f63d05c6c
@ -3,11 +3,13 @@ package com.plannaplan.configutils;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import com.plannaplan.entities.Course;
|
import com.plannaplan.entities.Course;
|
||||||
|
import com.plannaplan.entities.Groups;
|
||||||
import com.plannaplan.entities.Lecturer;
|
import com.plannaplan.entities.Lecturer;
|
||||||
import com.plannaplan.models.FileData;
|
import com.plannaplan.models.FileData;
|
||||||
import com.plannaplan.services.CourseService;
|
import com.plannaplan.services.CourseService;
|
||||||
import com.plannaplan.services.GroupService;
|
import com.plannaplan.services.GroupService;
|
||||||
import com.plannaplan.services.LecturerService;
|
import com.plannaplan.services.LecturerService;
|
||||||
|
import com.plannaplan.types.WeekDay;
|
||||||
|
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
@ -20,6 +22,11 @@ public class FileToDatabaseMigrator {
|
|||||||
public static String COURSE_SYMBOL_STRING = "sym";
|
public static String COURSE_SYMBOL_STRING = "sym";
|
||||||
public static String COURSE_NAME_STRING = "nazwa";
|
public static String COURSE_NAME_STRING = "nazwa";
|
||||||
|
|
||||||
|
public static String GROUP_DAY_STRING = "dzien";
|
||||||
|
public static String GROUP_TIME_STRING = "godz_od";
|
||||||
|
public static String ROOM_STRING = "sala";
|
||||||
|
public static String CAPACITY_STRING = "Mc";
|
||||||
|
|
||||||
LecturerService lecturerService;
|
LecturerService lecturerService;
|
||||||
CourseService courseService;
|
CourseService courseService;
|
||||||
GroupService groupService;
|
GroupService groupService;
|
||||||
@ -41,6 +48,11 @@ public class FileToDatabaseMigrator {
|
|||||||
int surname_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_SURNAME_STRING);
|
int surname_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_SURNAME_STRING);
|
||||||
int name_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_NAME_STRING);
|
int name_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_NAME_STRING);
|
||||||
|
|
||||||
|
int day_index = data.getIndexOf(FileToDatabaseMigrator.GROUP_DAY_STRING);
|
||||||
|
int time_index = data.getIndexOf(FileToDatabaseMigrator.GROUP_TIME_STRING);
|
||||||
|
int room_index = data.getIndexOf(FileToDatabaseMigrator.ROOM_STRING);
|
||||||
|
int capacity_index = data.getIndexOf(FileToDatabaseMigrator.CAPACITY_STRING);
|
||||||
|
|
||||||
while (rows.hasNext()) {
|
while (rows.hasNext()) {
|
||||||
Row row = rows.next();
|
Row row = rows.next();
|
||||||
|
|
||||||
@ -51,6 +63,11 @@ public class FileToDatabaseMigrator {
|
|||||||
Cell name_cell = row.getCell(name_index);
|
Cell name_cell = row.getCell(name_index);
|
||||||
Cell surname_cell = row.getCell(surname_index);
|
Cell surname_cell = row.getCell(surname_index);
|
||||||
|
|
||||||
|
Cell day_cell = row.getCell(day_index);
|
||||||
|
Cell time_cell = row.getCell(time_index);
|
||||||
|
Cell room_cell = row.getCell(room_index);
|
||||||
|
Cell capacity_cell = row.getCell(capacity_index);
|
||||||
|
|
||||||
String lecturer_title = "";
|
String lecturer_title = "";
|
||||||
String lecturer_surname = "";
|
String lecturer_surname = "";
|
||||||
String lecturer_name = "";
|
String lecturer_name = "";
|
||||||
@ -58,6 +75,23 @@ public class FileToDatabaseMigrator {
|
|||||||
String course_name = course_name_cell.toString();
|
String course_name = course_name_cell.toString();
|
||||||
String sym_str = sym.toString();
|
String sym_str = sym.toString();
|
||||||
|
|
||||||
|
int day = (int) Double.parseDouble(day_cell.toString());
|
||||||
|
WeekDay group_day = WeekDay.getDay(day);
|
||||||
|
String room = room_cell.toString();
|
||||||
|
int time = 480;
|
||||||
|
int capacity = (int) Double.parseDouble(capacity_cell.toString());
|
||||||
|
|
||||||
|
Groups group = groupService.find(time, capacity, room);
|
||||||
|
|
||||||
|
if (group == null) {
|
||||||
|
group = new Groups();
|
||||||
|
group.setCapacity(capacity);
|
||||||
|
group.setTime(time);
|
||||||
|
group.setRoom(room);
|
||||||
|
}
|
||||||
|
|
||||||
|
groupService.save(group);
|
||||||
|
|
||||||
Course course = this.courseService.getCourseByName(course_name);
|
Course course = this.courseService.getCourseByName(course_name);
|
||||||
|
|
||||||
if (course == null) {
|
if (course == null) {
|
||||||
|
@ -3,9 +3,12 @@ package com.plannaplan.repositories;
|
|||||||
import com.plannaplan.entities.Groups;
|
import com.plannaplan.entities.Groups;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface GroupRepository extends JpaRepository<Groups, Long> {
|
public interface GroupRepository extends JpaRepository<Groups, Long> {
|
||||||
|
@Query(value = "SELECT * FROM groups WHERE name = :name AND surname = :surname AND title = :title ", nativeQuery = true)
|
||||||
|
Groups find(@Param("time") int time, @Param("room") String room, @Param("capacity") int capacity);
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.plannaplan.services;
|
package com.plannaplan.services;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Groups;
|
||||||
import com.plannaplan.repositories.GroupRepository;
|
import com.plannaplan.repositories.GroupRepository;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -9,4 +10,12 @@ import org.springframework.stereotype.Service;
|
|||||||
public class GroupService {
|
public class GroupService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GroupRepository repo;
|
private GroupRepository repo;
|
||||||
|
|
||||||
|
public Groups find(int time, int capacity, String room) {
|
||||||
|
return this.repo.find(time, room, capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save(Groups group) {
|
||||||
|
this.repo.save(group);
|
||||||
|
}
|
||||||
}
|
}
|
@ -8,4 +8,13 @@ public enum WeekDay {
|
|||||||
private WeekDay(int label) {
|
private WeekDay(int label) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static WeekDay getDay(int index) {
|
||||||
|
for (WeekDay d : values()) {
|
||||||
|
if (d.label == index) {
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user