133 lines
3.5 KiB
Java
Executable File
133 lines
3.5 KiB
Java
Executable File
package com.plannaplan.responses.models;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
import com.plannaplan.entities.Assignment;
|
|
import com.plannaplan.entities.Groups;
|
|
import com.plannaplan.types.GroupType;
|
|
|
|
import io.swagger.annotations.ApiModel;
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
|
/**
|
|
* Default api response for Groups entity
|
|
*/
|
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
@ApiModel(description = "Response shows information about given group.", value = "GroupDefaultResponse")
|
|
public class GroupDefaultResponse {
|
|
|
|
@ApiModelProperty(value = "ID created by database.")
|
|
private Long id;
|
|
|
|
@ApiModelProperty(value = "Value shows what day when the course is. Example 0 is Monday.")
|
|
private int day;
|
|
|
|
@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;
|
|
|
|
@ApiModelProperty(value = "Value shows room where the class takes.")
|
|
private String room;
|
|
|
|
@ApiModelProperty(value = "Value shows kind of group. The types are LECTURE or CLASS.")
|
|
private GroupType type;
|
|
|
|
@ApiModelProperty(value = "Value shows how many places is already taken by other students.")
|
|
private Integer takenPlaces;
|
|
|
|
/**
|
|
* creat new entity
|
|
*
|
|
* @param group entity to map to api response
|
|
*/
|
|
public GroupDefaultResponse(Groups group) {
|
|
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 ? GroupType.isLectureOrClass(group.getType()) : null;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param group entity to map to api response
|
|
* @param takenPlaces ammount of taken places for group by other users
|
|
*/
|
|
public GroupDefaultResponse(Groups group, int takenPlaces) {
|
|
this(group);
|
|
this.takenPlaces = takenPlaces;
|
|
}
|
|
|
|
/**
|
|
* creat new entity
|
|
*
|
|
* @param assignment entity to map to api response
|
|
*/
|
|
public GroupDefaultResponse(Assignment assignment) {
|
|
this(assignment.getGroup());
|
|
}
|
|
|
|
/**
|
|
* @return what typew of group is this (lecture or class)
|
|
*/
|
|
public GroupType getType() {
|
|
return type;
|
|
}
|
|
|
|
/**
|
|
* @return room where classes will take place
|
|
*/
|
|
public String getRoom() {
|
|
return room;
|
|
}
|
|
|
|
/**
|
|
* @return name of group lecturer
|
|
*/
|
|
public String getLecturer() {
|
|
return lecturer;
|
|
}
|
|
|
|
/**
|
|
* @return time when group is scheduled on
|
|
*/
|
|
public String getTime() {
|
|
return time;
|
|
}
|
|
|
|
/**
|
|
* @return time when class ends
|
|
*/
|
|
public String getEndTime() {
|
|
return endTime;
|
|
}
|
|
|
|
/**
|
|
* @return int what day is it. 0-6 (Monday - Sunday)
|
|
*/
|
|
public int getDay() {
|
|
return day;
|
|
}
|
|
|
|
/**
|
|
* @return db id
|
|
*/
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
/**
|
|
* @return ammount of taken places for group by other users
|
|
*/
|
|
public Integer getTakenPlaces() {
|
|
return this.takenPlaces;
|
|
}
|
|
|
|
}
|