Major refactor of reading from excel to db

This commit is contained in:
Maciek Głowacki
2020-09-21 17:45:52 +02:00
parent e91965e9b5
commit c449bc22e1
16 changed files with 158 additions and 167 deletions

View File

@ -17,12 +17,17 @@ public class Course {
private Long id;
private String name;
private String symbol;
@OneToMany(mappedBy = "courseId", fetch = FetchType.EAGER)
@OneToMany(mappedBy = "course", fetch = FetchType.EAGER)
private List<Groups> groups = new ArrayList<>();
public Course() {
}
public Course(String name, String symbol) {
this.name = name;
this.symbol = symbol;
}
public Long getId() {
return this.id;
}
@ -43,8 +48,8 @@ public class Course {
this.name = name;
}
public List<Groups> getGroups(){
public List<Groups> getGroups() {
return this.groups;
}
}
}

View File

@ -10,6 +10,8 @@ import javax.persistence.ManyToOne;
import com.plannaplan.types.GroupType;
import com.plannaplan.types.WeekDay;
@Entity
public class Groups {
@Id
@ -17,7 +19,7 @@ public class Groups {
private Long id;
@ManyToOne
@JoinColumn(name = "course_id")
private Course courseId;
private Course course;
private int time;
private String room;
private int capacity;
@ -30,6 +32,16 @@ public class Groups {
public Groups() {
}
public Groups(int capacity, String room, Course course, int time, WeekDay day, Lecturer lecturer) {
this.capacity = capacity;
this.room = room;
this.course = course;
this.time = time;
this.day = day;
this.lecturer = lecturer;
this.type = capacity >= 50 ? GroupType.LECTURE : GroupType.CLASS;
}
public Long getId() {
return this.id;
}
@ -83,11 +95,11 @@ public class Groups {
}
public Course getCourseId() {
return courseId;
return course;
}
public void setCourseId(Course courseId) {
this.courseId = courseId;
this.course = courseId;
}
public String getTimeString() {
@ -99,4 +111,4 @@ public class Groups {
}
return String.format("%s.%s", hoursString, minutesString);
}
}
}

View File

@ -8,7 +8,7 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import com.plannaplan.types.UserRoles;
//should setter be public?
@Entity
public class User {
@Id
@ -68,4 +68,5 @@ public class User {
public void setName(String name) {
this.name = name;
}
}