2020-10-13 17:07:04 +02:00
|
|
|
package com.plannaplan.responses.models;
|
|
|
|
|
2020-12-29 16:36:12 +01:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
2021-01-20 15:38:42 +01:00
|
|
|
import com.plannaplan.entities.Assignment;
|
2020-10-28 13:44:13 +01:00
|
|
|
import com.plannaplan.entities.Course;
|
|
|
|
import com.plannaplan.entities.Groups;
|
|
|
|
import com.plannaplan.types.GroupType;
|
2020-10-13 17:07:04 +02:00
|
|
|
|
2020-11-08 16:55:56 +01:00
|
|
|
import io.swagger.annotations.ApiModel;
|
|
|
|
|
2021-01-15 17:45:29 +01:00
|
|
|
/**
|
|
|
|
* Assignment entity api response
|
|
|
|
*/
|
2020-11-08 17:20:00 +01:00
|
|
|
@ApiModel(description = "Response shows information about given assigment to course.", value = "AssignmentResponse")
|
|
|
|
public class AssignmentResponse {
|
2020-10-28 13:44:13 +01:00
|
|
|
private Long id;
|
|
|
|
private String name;
|
2021-01-23 16:45:36 +01:00
|
|
|
private String symbol;
|
2020-11-08 17:20:00 +01:00
|
|
|
private GroupWithCapacityResponse classes;
|
|
|
|
private GroupWithCapacityResponse lecture;
|
2020-10-13 17:07:04 +02:00
|
|
|
|
2021-01-15 17:45:29 +01:00
|
|
|
/**
|
|
|
|
* @param course course entity
|
|
|
|
* @param lecture lecture Groups entity
|
|
|
|
* @param classes class Groups entity
|
|
|
|
*/
|
2020-11-08 17:20:00 +01:00
|
|
|
public AssignmentResponse(Course course, Groups lecture, Groups classes) {
|
2020-10-28 13:44:13 +01:00
|
|
|
this.id = course.getId();
|
|
|
|
this.name = course.getName();
|
2021-01-23 16:45:36 +01:00
|
|
|
this.symbol = course.getSymbol();
|
2020-11-08 17:20:00 +01:00
|
|
|
this.lecture = lecture == null ? null : new GroupWithCapacityResponse(lecture);
|
|
|
|
this.classes = classes == null ? null : new GroupWithCapacityResponse(classes);
|
2020-10-28 13:44:13 +01:00
|
|
|
}
|
|
|
|
|
2021-01-23 16:45:36 +01:00
|
|
|
/**
|
|
|
|
* @return returns symbol of assigned course
|
|
|
|
*/
|
|
|
|
public String getSymbol() {
|
|
|
|
return symbol;
|
|
|
|
}
|
|
|
|
|
2021-01-15 17:45:29 +01:00
|
|
|
/**
|
|
|
|
* @param course course entity
|
|
|
|
* @param lecture lecture Groups entity
|
|
|
|
* @param classes class Groups entity
|
|
|
|
* @param ammounts map with ammounts key - group id, value - ammounts of taken
|
|
|
|
* places
|
|
|
|
*/
|
2020-12-29 16:36:12 +01:00
|
|
|
public AssignmentResponse(Course course, Groups lecture, Groups classes, HashMap<Long, Integer> ammounts) {
|
|
|
|
this.id = course.getId();
|
|
|
|
this.name = course.getName();
|
2021-01-23 16:45:36 +01:00
|
|
|
this.symbol = course.getSymbol();
|
2020-12-29 16:36:12 +01:00
|
|
|
this.lecture = lecture == null ? null : new GroupWithCapacityResponse(lecture, ammounts.get(lecture.getId()));
|
|
|
|
this.classes = classes == null ? null : new GroupWithCapacityResponse(classes, ammounts.get(classes.getId()));
|
|
|
|
}
|
|
|
|
|
2021-01-15 17:45:29 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param course course entity
|
|
|
|
* @param group class/lecture entity
|
|
|
|
*/
|
2020-11-08 17:20:00 +01:00
|
|
|
public AssignmentResponse(Course course, Groups group) {
|
2021-01-19 10:44:35 +01:00
|
|
|
this(course, GroupType.isLectureOrClass(group.getType()) == GroupType.LECTURE ? group : null,
|
|
|
|
GroupType.isLectureOrClass(group.getType()) == GroupType.CLASS ? group : null);
|
2020-10-28 13:44:13 +01:00
|
|
|
}
|
|
|
|
|
2021-01-15 17:45:29 +01:00
|
|
|
/**
|
|
|
|
* @param course course entity
|
|
|
|
* @param group class/lecture entity
|
|
|
|
* @param ammounts map with ammounts key - group id, value - ammounts of taken
|
|
|
|
* places
|
|
|
|
*/
|
2020-12-29 16:36:12 +01:00
|
|
|
public AssignmentResponse(Course course, Groups group, HashMap<Long, Integer> ammounts) {
|
2021-01-19 10:44:35 +01:00
|
|
|
this(course, GroupType.isLectureOrClass(group.getType()) == GroupType.LECTURE ? group : null,
|
|
|
|
GroupType.isLectureOrClass(group.getType()) == GroupType.CLASS ? group : null, ammounts);
|
2020-12-29 16:36:12 +01:00
|
|
|
}
|
|
|
|
|
2021-01-20 15:38:42 +01:00
|
|
|
/**
|
|
|
|
* @param course course entity
|
|
|
|
* @param group class/lecture entity
|
|
|
|
* @param ammounts map with ammounts key - group id, value - ammounts of taken
|
|
|
|
* places
|
|
|
|
*/
|
|
|
|
public AssignmentResponse(Course course, Assignment group, HashMap<Long, Integer> ammounts) {
|
|
|
|
this(course, GroupType.isLectureOrClass(group.getGroup().getType()) == GroupType.LECTURE ? group : null,
|
|
|
|
GroupType.isLectureOrClass(group.getGroup().getType()) == GroupType.CLASS ? group : null, ammounts);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param course course entity
|
|
|
|
* @param group class/lecture entity
|
|
|
|
*/
|
|
|
|
public AssignmentResponse(Course course, Assignment group) {
|
|
|
|
this(course, GroupType.isLectureOrClass(group.getGroup().getType()) == GroupType.LECTURE ? group : null,
|
|
|
|
GroupType.isLectureOrClass(group.getGroup().getType()) == GroupType.CLASS ? group : null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param course course entity
|
|
|
|
* @param lecture lecture Groups entity
|
|
|
|
* @param classes class Groups entity
|
|
|
|
* @param ammounts map with ammounts key - group id, value - ammounts of taken
|
|
|
|
* places
|
|
|
|
*/
|
|
|
|
public AssignmentResponse(Course course, Assignment lecture, Assignment classes, HashMap<Long, Integer> ammounts) {
|
2021-01-22 16:46:53 +01:00
|
|
|
this.id = course.getId();
|
2021-01-20 15:38:42 +01:00
|
|
|
this.name = course.getName();
|
2021-01-23 16:45:36 +01:00
|
|
|
this.symbol = course.getSymbol();
|
2021-01-25 16:23:28 +01:00
|
|
|
this.classes = classes != null
|
|
|
|
? new GroupWithCapacityResponse(classes, ammounts.get(classes.getGroup().getId()))
|
|
|
|
: null;
|
|
|
|
this.lecture = lecture != null
|
|
|
|
? new GroupWithCapacityResponse(lecture, ammounts.get(lecture.getGroup().getId()))
|
|
|
|
: null;
|
2021-01-20 15:38:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param course course entity
|
|
|
|
* @param lecture lecture Groups entity
|
|
|
|
* @param classes class Groups entity
|
|
|
|
*/
|
|
|
|
public AssignmentResponse(Course course, Assignment lecture, Assignment classes) {
|
2021-01-22 16:46:53 +01:00
|
|
|
this.id = course.getId();
|
2021-01-20 15:38:42 +01:00
|
|
|
this.name = course.getName();
|
2021-01-23 16:45:36 +01:00
|
|
|
this.symbol = course.getSymbol();
|
2021-01-25 16:23:28 +01:00
|
|
|
this.classes = classes != null ? new GroupWithCapacityResponse(classes) : null;
|
|
|
|
this.lecture = lecture != null ? new GroupWithCapacityResponse(lecture) : null;
|
2021-01-20 15:38:42 +01:00
|
|
|
}
|
|
|
|
|
2021-01-15 17:45:29 +01:00
|
|
|
/**
|
|
|
|
* @return Lecture in api response forms
|
|
|
|
*/
|
2020-11-08 17:20:00 +01:00
|
|
|
public GroupWithCapacityResponse getLecture() {
|
2020-10-28 13:44:13 +01:00
|
|
|
return this.lecture;
|
|
|
|
}
|
|
|
|
|
2021-01-15 17:45:29 +01:00
|
|
|
/**
|
|
|
|
* @return Class in api response forms
|
|
|
|
*/
|
2020-11-08 17:20:00 +01:00
|
|
|
public GroupWithCapacityResponse getClasses() {
|
2020-10-28 13:44:13 +01:00
|
|
|
return this.classes;
|
|
|
|
}
|
|
|
|
|
2021-01-15 17:45:29 +01:00
|
|
|
/**
|
|
|
|
* @return String course name
|
|
|
|
*/
|
2020-10-28 13:44:13 +01:00
|
|
|
public String getName() {
|
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
|
2021-01-15 17:45:29 +01:00
|
|
|
/**
|
|
|
|
* @return db assignment id
|
|
|
|
*/
|
2020-10-28 13:44:13 +01:00
|
|
|
public Long getId() {
|
|
|
|
return this.id;
|
2020-10-13 17:07:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|