schedule accepted
This commit is contained in:
@ -2,6 +2,7 @@ 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;
|
||||
@ -65,6 +66,51 @@ public class AssignmentResponse {
|
||||
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<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) {
|
||||
this.name = course.getName();
|
||||
this.classes = new GroupWithCapacityResponse(classes, ammounts.get(classes.getGroup().getId()));
|
||||
this.lecture = new GroupWithCapacityResponse(lecture, ammounts.get(lecture.getGroup().getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param course course entity
|
||||
* @param lecture lecture Groups entity
|
||||
* @param classes class Groups entity
|
||||
*/
|
||||
public AssignmentResponse(Course course, Assignment lecture, Assignment classes) {
|
||||
this.name = course.getName();
|
||||
this.classes = new GroupWithCapacityResponse(classes);
|
||||
this.lecture = new GroupWithCapacityResponse(lecture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Lecture in api response forms
|
||||
*/
|
||||
|
@ -39,6 +39,9 @@ public class GroupDefaultResponse {
|
||||
@ApiModelProperty(value = "Value shows how many places is already taken by other students.")
|
||||
private Integer takenPlaces;
|
||||
|
||||
@ApiModelProperty(value = "Used only in resposnes realted to user assignments. For example in <code>/api/v1/users/schedule</code>.")
|
||||
private Boolean isAccepted;
|
||||
|
||||
/**
|
||||
* creat new entity
|
||||
*
|
||||
@ -54,6 +57,13 @@ public class GroupDefaultResponse {
|
||||
this.type = group.getType() != null ? GroupType.isLectureOrClass(group.getType()) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return is group accepted if its related to assignmetn
|
||||
*/
|
||||
public Boolean getIsAccepted() {
|
||||
return isAccepted;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param group entity to map to api response
|
||||
@ -73,6 +83,16 @@ public class GroupDefaultResponse {
|
||||
this(assignment.getGroup());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param assignment entity to map to api response
|
||||
* @param takenPlaces map with ammounts of taken places
|
||||
*/
|
||||
public GroupDefaultResponse(Assignment assignment, int takenPlaces) {
|
||||
this(assignment.getGroup(), takenPlaces);
|
||||
this.isAccepted = assignment.isAccepted();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return what typew of group is this (lecture or class)
|
||||
*/
|
||||
|
@ -49,7 +49,7 @@ public class GroupWithCapacityResponse extends GroupDefaultResponse {
|
||||
* @param takenPlaces group taken places
|
||||
*/
|
||||
public GroupWithCapacityResponse(Assignment assignment, int takenPlaces) {
|
||||
this(assignment.getGroup(), takenPlaces);
|
||||
super(assignment, takenPlaces);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user