package com.plannaplan.responses.models; import java.util.HashMap; import com.plannaplan.entities.Assignment; import com.plannaplan.entities.Course; import com.plannaplan.entities.Groups; import com.plannaplan.types.GroupType; import io.swagger.annotations.ApiModel; /** * Assignment entity api response */ @ApiModel(description = "Response shows information about given assigment to course.", value = "AssignmentResponse") public class AssignmentResponse { private Long id; private String name; private String symbol; private GroupWithCapacityResponse classes; private GroupWithCapacityResponse lecture; /** * @param course course entity * @param lecture lecture Groups entity * @param classes class Groups entity */ public AssignmentResponse(Course course, Groups lecture, Groups classes) { this.id = course.getId(); this.name = course.getName(); this.symbol = course.getSymbol(); this.lecture = lecture == null ? null : new GroupWithCapacityResponse(lecture); this.classes = classes == null ? null : new GroupWithCapacityResponse(classes); } /** * @return returns symbol of assigned course */ public String getSymbol() { return symbol; } /** * @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, Groups lecture, Groups classes, HashMap ammounts) { this.id = course.getId(); this.name = course.getName(); this.symbol = course.getSymbol(); this.lecture = lecture == null ? null : new GroupWithCapacityResponse(lecture, ammounts.get(lecture.getId())); this.classes = classes == null ? null : new GroupWithCapacityResponse(classes, ammounts.get(classes.getId())); } /** * * @param course course entity * @param group class/lecture entity */ public AssignmentResponse(Course course, Groups group) { this(course, GroupType.isLectureOrClass(group.getType()) == GroupType.LECTURE ? group : null, GroupType.isLectureOrClass(group.getType()) == GroupType.CLASS ? group : null); } /** * @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, Groups group, HashMap ammounts) { this(course, GroupType.isLectureOrClass(group.getType()) == GroupType.LECTURE ? group : null, GroupType.isLectureOrClass(group.getType()) == GroupType.CLASS ? group : null, ammounts); } /** * @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 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 ammounts) { this.id = course.getId(); this.name = course.getName(); this.symbol = course.getSymbol(); 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; } /** * @param course course entity * @param lecture lecture Groups entity * @param classes class Groups entity */ public AssignmentResponse(Course course, Assignment lecture, Assignment classes) { this.id = course.getId(); this.name = course.getName(); this.symbol = course.getSymbol(); this.classes = classes != null ? new GroupWithCapacityResponse(classes) : null; this.lecture = lecture != null ? new GroupWithCapacityResponse(lecture) : null; } /** * @return Lecture in api response forms */ public GroupWithCapacityResponse getLecture() { return this.lecture; } /** * @return Class in api response forms */ public GroupWithCapacityResponse getClasses() { return this.classes; } /** * @return String course name */ public String getName() { return this.name; } /** * @return db assignment id */ public Long getId() { return this.id; } }