schedule accepted

This commit is contained in:
Filip Izydorczyk
2021-01-20 15:38:42 +01:00
parent cf875889b9
commit 20f52746b5
4 changed files with 77 additions and 9 deletions

View File

@ -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
*/

View File

@ -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)
*/

View File

@ -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);
}
/**