Added time to in group resonse

This commit is contained in:
Filip Izydorczyk 2020-12-20 12:14:12 +01:00
parent 8dc94f84c0
commit c62674b9d8
2 changed files with 74 additions and 6 deletions

View File

@ -11,11 +11,14 @@ 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 of Groups grouping of state ssociated about
* course,time,room,capacity,type,day
*/
@Entity
public class Groups {
private static final int DEFAULT_CLASS_TIME = 90;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ -23,6 +26,7 @@ public class Groups {
@JoinColumn(name = "course_id")
private Course course;
private int time;
private int endTime;
private String room;
private int capacity;
private GroupType type;
@ -38,24 +42,50 @@ public class 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 room room given to the groups
* @param course course given to the groups
* @param time time given to the groups
* @param endTime end time of class in minutes
* @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) {
public Groups(int capacity, String room, Course course, int time, int endTime, WeekDay day, Lecturer lecturer) {
this.capacity = capacity;
this.room = room;
this.course = course;
this.time = time;
this.endTime = endTime;
this.day = day;
this.lecturer = lecturer;
this.type = capacity >= 50 ? GroupType.LECTURE : GroupType.CLASS;
}
/**
* Create groups with default class duration
*
* @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, room, course, time, time + DEFAULT_CLASS_TIME, day, lecturer);
}
/**
* get time of class end
*
* @return hour of class finish time in minutes
*/
public int getEndTime() {
return endTime;
}
/**
* getId
*
* @return id
*/
public Long getId() {
@ -64,6 +94,7 @@ public class Groups {
/**
* getLecturer
*
* @return lecturer
*/
public Lecturer getLecturer() {
@ -72,6 +103,7 @@ public class Groups {
/**
* setLecturer
*
* @param lecturer set lecturer into groups
*/
public void setLecturer(Lecturer lecturer) {
@ -80,6 +112,7 @@ public class Groups {
/**
* WeekDay
*
* @return day
*/
public WeekDay getDay() {
@ -88,6 +121,7 @@ public class Groups {
/**
* setLecturer
*
* @param day set day into groups
*/
public void setDay(WeekDay day) {
@ -96,6 +130,7 @@ public class Groups {
/**
* GroupType
*
* @return type
*/
public GroupType getType() {
@ -104,6 +139,7 @@ public class Groups {
/**
* setType
*
* @param type set type into groups
*/
public void setType(GroupType type) {
@ -112,6 +148,7 @@ public class Groups {
/**
* getCapacity
*
* @return capacity
*/
public int getCapacity() {
@ -120,6 +157,7 @@ public class Groups {
/**
* setCapacity
*
* @param capacity set capacity into groups
*/
public void setCapacity(int capacity) {
@ -128,6 +166,7 @@ public class Groups {
/**
* getRoom
*
* @return room
*/
public String getRoom() {
@ -136,6 +175,7 @@ public class Groups {
/**
* setRoom
*
* @param room set room into groups
*/
public void setRoom(String room) {
@ -144,6 +184,7 @@ public class Groups {
/**
* getTime
*
* @return time
*/
public int getTime() {
@ -152,6 +193,7 @@ public class Groups {
/**
* setTime
*
* @param time set time into groups
*/
public void setTime(int time) {
@ -160,6 +202,7 @@ public class Groups {
/**
* getCourseId
*
* @return course
*/
public Course getCourseId() {
@ -168,6 +211,7 @@ public class Groups {
/**
* setCourseId
*
* @param courseId set courseId into groups
*/
public void setCourseId(Course courseId) {
@ -176,6 +220,7 @@ public class Groups {
/**
* getTimeString
*
* @return time as formated String
*/
public String getTimeString() {
@ -187,4 +232,19 @@ public class Groups {
}
return String.format("%s.%s", hoursString, minutesString);
}
/**
* gets end time formated strins
*
* @return end time as formated String
*/
public String getEndTimeString() {
int minutes = this.getEndTime() % 60;
String hoursString = Integer.toString(this.getEndTime() / 60);
String minutesString = Integer.toString(minutes);
if (minutes < 10) {
minutesString = "0" + minutesString;
}
return String.format("%s.%s", hoursString, minutesString);
}
}

View File

@ -21,6 +21,9 @@ public class GroupDefaultResponse {
@ApiModelProperty(value = "Value shows time when the course takes.")
private String time;
@ApiModelProperty(value = "Value shows time when the course ends.")
private String endTime;
@ApiModelProperty(value = "Value shows degree, name and surname.")
private String lecturer;
@ -37,6 +40,7 @@ public class GroupDefaultResponse {
this.id = group.getId() != null ? group.getId() : null;
this.day = group.getDay() != null ? group.getDay().label : -1;
this.time = group.getTimeString() != null ? group.getTimeString() : "";
this.endTime = group.getEndTimeString() != null ? group.getEndTimeString() : "";
this.lecturer = group.getLecturer() != null ? group.getLecturer().toString() : "";
this.room = group.getRoom() != null ? group.getRoom() : "";
this.type = group.getType() != null ? group.getType() : null;
@ -67,6 +71,10 @@ public class GroupDefaultResponse {
return time;
}
public String getEndTime() {
return endTime;
}
public int getDay() {
return day;
}