Added time to in group resonse
This commit is contained in:
parent
8dc94f84c0
commit
c62674b9d8
@ -11,11 +11,14 @@ import com.plannaplan.types.GroupType;
|
|||||||
import com.plannaplan.types.WeekDay;
|
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
|
@Entity
|
||||||
public class Groups {
|
public class Groups {
|
||||||
|
private static final int DEFAULT_CLASS_TIME = 90;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
@ -23,6 +26,7 @@ public class Groups {
|
|||||||
@JoinColumn(name = "course_id")
|
@JoinColumn(name = "course_id")
|
||||||
private Course course;
|
private Course course;
|
||||||
private int time;
|
private int time;
|
||||||
|
private int endTime;
|
||||||
private String room;
|
private String room;
|
||||||
private int capacity;
|
private int capacity;
|
||||||
private GroupType type;
|
private GroupType type;
|
||||||
@ -38,24 +42,50 @@ public class Groups {
|
|||||||
* Groups
|
* Groups
|
||||||
*
|
*
|
||||||
* @param capacity capacity given to the groups
|
* @param capacity capacity given to the groups
|
||||||
* @param room room given to the groups
|
* @param room room given to the groups
|
||||||
* @param course course given to the groups
|
* @param course course given to the groups
|
||||||
* @param time time given to the groups
|
* @param time time given to the groups
|
||||||
* @param day day 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
|
* @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.capacity = capacity;
|
||||||
this.room = room;
|
this.room = room;
|
||||||
this.course = course;
|
this.course = course;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
|
this.endTime = endTime;
|
||||||
this.day = day;
|
this.day = day;
|
||||||
this.lecturer = lecturer;
|
this.lecturer = lecturer;
|
||||||
this.type = capacity >= 50 ? GroupType.LECTURE : GroupType.CLASS;
|
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
|
* getId
|
||||||
|
*
|
||||||
* @return id
|
* @return id
|
||||||
*/
|
*/
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@ -64,6 +94,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* getLecturer
|
* getLecturer
|
||||||
|
*
|
||||||
* @return lecturer
|
* @return lecturer
|
||||||
*/
|
*/
|
||||||
public Lecturer getLecturer() {
|
public Lecturer getLecturer() {
|
||||||
@ -72,6 +103,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* setLecturer
|
* setLecturer
|
||||||
|
*
|
||||||
* @param lecturer set lecturer into groups
|
* @param lecturer set lecturer into groups
|
||||||
*/
|
*/
|
||||||
public void setLecturer(Lecturer lecturer) {
|
public void setLecturer(Lecturer lecturer) {
|
||||||
@ -80,6 +112,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* WeekDay
|
* WeekDay
|
||||||
|
*
|
||||||
* @return day
|
* @return day
|
||||||
*/
|
*/
|
||||||
public WeekDay getDay() {
|
public WeekDay getDay() {
|
||||||
@ -88,6 +121,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* setLecturer
|
* setLecturer
|
||||||
|
*
|
||||||
* @param day set day into groups
|
* @param day set day into groups
|
||||||
*/
|
*/
|
||||||
public void setDay(WeekDay day) {
|
public void setDay(WeekDay day) {
|
||||||
@ -96,6 +130,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* GroupType
|
* GroupType
|
||||||
|
*
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public GroupType getType() {
|
public GroupType getType() {
|
||||||
@ -104,6 +139,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* setType
|
* setType
|
||||||
|
*
|
||||||
* @param type set type into groups
|
* @param type set type into groups
|
||||||
*/
|
*/
|
||||||
public void setType(GroupType type) {
|
public void setType(GroupType type) {
|
||||||
@ -112,6 +148,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* getCapacity
|
* getCapacity
|
||||||
|
*
|
||||||
* @return capacity
|
* @return capacity
|
||||||
*/
|
*/
|
||||||
public int getCapacity() {
|
public int getCapacity() {
|
||||||
@ -120,6 +157,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* setCapacity
|
* setCapacity
|
||||||
|
*
|
||||||
* @param capacity set capacity into groups
|
* @param capacity set capacity into groups
|
||||||
*/
|
*/
|
||||||
public void setCapacity(int capacity) {
|
public void setCapacity(int capacity) {
|
||||||
@ -128,6 +166,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* getRoom
|
* getRoom
|
||||||
|
*
|
||||||
* @return room
|
* @return room
|
||||||
*/
|
*/
|
||||||
public String getRoom() {
|
public String getRoom() {
|
||||||
@ -136,6 +175,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* setRoom
|
* setRoom
|
||||||
|
*
|
||||||
* @param room set room into groups
|
* @param room set room into groups
|
||||||
*/
|
*/
|
||||||
public void setRoom(String room) {
|
public void setRoom(String room) {
|
||||||
@ -144,6 +184,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* getTime
|
* getTime
|
||||||
|
*
|
||||||
* @return time
|
* @return time
|
||||||
*/
|
*/
|
||||||
public int getTime() {
|
public int getTime() {
|
||||||
@ -152,6 +193,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* setTime
|
* setTime
|
||||||
|
*
|
||||||
* @param time set time into groups
|
* @param time set time into groups
|
||||||
*/
|
*/
|
||||||
public void setTime(int time) {
|
public void setTime(int time) {
|
||||||
@ -160,6 +202,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* getCourseId
|
* getCourseId
|
||||||
|
*
|
||||||
* @return course
|
* @return course
|
||||||
*/
|
*/
|
||||||
public Course getCourseId() {
|
public Course getCourseId() {
|
||||||
@ -168,6 +211,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* setCourseId
|
* setCourseId
|
||||||
|
*
|
||||||
* @param courseId set courseId into groups
|
* @param courseId set courseId into groups
|
||||||
*/
|
*/
|
||||||
public void setCourseId(Course courseId) {
|
public void setCourseId(Course courseId) {
|
||||||
@ -176,6 +220,7 @@ public class Groups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* getTimeString
|
* getTimeString
|
||||||
|
*
|
||||||
* @return time as formated String
|
* @return time as formated String
|
||||||
*/
|
*/
|
||||||
public String getTimeString() {
|
public String getTimeString() {
|
||||||
@ -187,4 +232,19 @@ public class Groups {
|
|||||||
}
|
}
|
||||||
return String.format("%s.%s", hoursString, minutesString);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,9 @@ public class GroupDefaultResponse {
|
|||||||
@ApiModelProperty(value = "Value shows time when the course takes.")
|
@ApiModelProperty(value = "Value shows time when the course takes.")
|
||||||
private String time;
|
private String time;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "Value shows time when the course ends.")
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "Value shows degree, name and surname.")
|
@ApiModelProperty(value = "Value shows degree, name and surname.")
|
||||||
private String lecturer;
|
private String lecturer;
|
||||||
|
|
||||||
@ -37,6 +40,7 @@ public class GroupDefaultResponse {
|
|||||||
this.id = group.getId() != null ? group.getId() : null;
|
this.id = group.getId() != null ? group.getId() : null;
|
||||||
this.day = group.getDay() != null ? group.getDay().label : -1;
|
this.day = group.getDay() != null ? group.getDay().label : -1;
|
||||||
this.time = group.getTimeString() != null ? group.getTimeString() : "";
|
this.time = group.getTimeString() != null ? group.getTimeString() : "";
|
||||||
|
this.endTime = group.getEndTimeString() != null ? group.getEndTimeString() : "";
|
||||||
this.lecturer = group.getLecturer() != null ? group.getLecturer().toString() : "";
|
this.lecturer = group.getLecturer() != null ? group.getLecturer().toString() : "";
|
||||||
this.room = group.getRoom() != null ? group.getRoom() : "";
|
this.room = group.getRoom() != null ? group.getRoom() : "";
|
||||||
this.type = group.getType() != null ? group.getType() : null;
|
this.type = group.getType() != null ? group.getType() : null;
|
||||||
@ -67,6 +71,10 @@ public class GroupDefaultResponse {
|
|||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
public int getDay() {
|
public int getDay() {
|
||||||
return day;
|
return day;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user