backend/restservice/src/main/java/com/plannaplan/responses/models/AssignmentResponse.java
2020-12-29 16:36:12 +01:00

59 lines
2.0 KiB
Java
Executable File

package com.plannaplan.responses.models;
import java.util.HashMap;
import com.plannaplan.entities.Course;
import com.plannaplan.entities.Groups;
import com.plannaplan.types.GroupType;
import io.swagger.annotations.ApiModel;
@ApiModel(description = "Response shows information about given assigment to course.", value = "AssignmentResponse")
public class AssignmentResponse {
private Long id;
private String name;
private GroupWithCapacityResponse classes;
private GroupWithCapacityResponse lecture;
public AssignmentResponse(Course course, Groups lecture, Groups classes) {
this.id = course.getId();
this.name = course.getName();
this.lecture = lecture == null ? null : new GroupWithCapacityResponse(lecture);
this.classes = classes == null ? null : new GroupWithCapacityResponse(classes);
}
public AssignmentResponse(Course course, Groups lecture, Groups classes, HashMap<Long, Integer> ammounts) {
this.id = course.getId();
this.name = course.getName();
this.lecture = lecture == null ? null : new GroupWithCapacityResponse(lecture, ammounts.get(lecture.getId()));
this.classes = classes == null ? null : new GroupWithCapacityResponse(classes, ammounts.get(classes.getId()));
}
public AssignmentResponse(Course course, Groups group) {
this(course, group.getType() == GroupType.LECTURE ? group : null,
group.getType() == GroupType.CLASS ? group : null);
}
public AssignmentResponse(Course course, Groups group, HashMap<Long, Integer> ammounts) {
this(course, group.getType() == GroupType.LECTURE ? group : null,
group.getType() == GroupType.CLASS ? group : null, ammounts);
}
public GroupWithCapacityResponse getLecture() {
return this.lecture;
}
public GroupWithCapacityResponse getClasses() {
return this.classes;
}
public String getName() {
return this.name;
}
public Long getId() {
return this.id;
}
}