backend/buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java

191 lines
3.9 KiB
Java
Raw Normal View History

package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
2020-07-25 10:21:42 +02:00
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
2020-07-25 09:58:40 +02:00
import com.plannaplan.types.GroupType;
import com.plannaplan.types.WeekDay;
/**
* Entity of Groups grouping of state ssociated about course,time,room,capacity,type,day
*/
@Entity
public class Groups {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
2020-07-25 10:56:11 +02:00
@ManyToOne
@JoinColumn(name = "course_id")
private Course course;
private int time;
private String room;
private int capacity;
2020-07-25 09:58:40 +02:00
private GroupType type;
private WeekDay day;
2020-07-25 10:21:42 +02:00
@ManyToOne
@JoinColumn(name = "lecturer_id")
private Lecturer lecturer;
public Groups() {
}
/**
* Groups
*
* @param capacity capacity given to the groups
* @param room room given to the groups
* @param course course given to the groups
* @param time time given to the groups
* @param day day given to the groups
* @param lecturer lecturer given to the 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;
}
/**
* getId
* @return id
*/
2020-08-11 17:36:58 +02:00
public Long getId() {
return this.id;
}
/**
* getLecturer
* @return lecturer
*/
2020-07-25 10:21:42 +02:00
public Lecturer getLecturer() {
return lecturer;
}
/**
* setLecturer
* @param lecturer set lecturer into groups
*/
2020-07-25 10:21:42 +02:00
public void setLecturer(Lecturer lecturer) {
this.lecturer = lecturer;
}
/**
* WeekDay
* @return day
*/
2020-07-25 09:58:40 +02:00
public WeekDay getDay() {
return day;
}
/**
* setLecturer
* @param day set day into groups
*/
2020-07-25 09:58:40 +02:00
public void setDay(WeekDay day) {
this.day = day;
}
/**
* GroupType
* @return type
*/
2020-07-25 09:58:40 +02:00
public GroupType getType() {
return type;
}
/**
* setType
* @param type set type into groups
*/
2020-07-25 09:58:40 +02:00
public void setType(GroupType type) {
this.type = type;
}
/**
* getCapacity
* @return capacity
*/
public int getCapacity() {
return capacity;
}
/**
* setCapacity
* @param capacity set capacity into groups
*/
public void setCapacity(int capacity) {
this.capacity = capacity;
}
/**
* getRoom
* @return room
*/
public String getRoom() {
return room;
}
/**
* setRoom
* @param room set room into groups
*/
public void setRoom(String room) {
this.room = room;
}
/**
* getTime
* @return time
*/
public int getTime() {
return time;
}
/**
* setTime
* @param time set time into groups
*/
public void setTime(int time) {
this.time = time;
}
/**
* getCourseId
* @return course
*/
2020-07-25 10:56:11 +02:00
public Course getCourseId() {
return course;
}
/**
* setCourseId
* @param courseId set courseId into groups
*/
2020-07-25 10:56:11 +02:00
public void setCourseId(Course courseId) {
this.course = courseId;
}
2020-08-18 15:41:03 +02:00
/**
* getTimeString
* @return time as formated String
*/
2020-08-18 15:41:03 +02:00
public String getTimeString() {
int minutes = this.getTime() % 60;
2020-08-18 16:10:46 +02:00
String hoursString = Integer.toString(this.getTime() / 60);
2020-08-18 15:41:03 +02:00
String minutesString = Integer.toString(minutes);
if (minutes < 10) {
minutesString = "0" + minutesString;
}
2020-08-18 16:10:46 +02:00
return String.format("%s.%s", hoursString, minutesString);
2020-08-18 15:41:03 +02:00
}
}