backend/restservice/src/main/java/com/plannaplan/responses/models/CoursesWithGroupsResponse.java

69 lines
2.1 KiB
Java
Raw Normal View History

2020-10-13 17:07:04 +02:00
package com.plannaplan.responses.models;
import java.util.ArrayList;
import java.util.List;
import com.plannaplan.entities.Course;
2020-10-13 17:13:43 +02:00
import com.plannaplan.responses.models.abstracts.CoursesResponse;
2020-10-13 17:07:04 +02:00
import com.plannaplan.types.GroupType;
import io.swagger.annotations.ApiModel;
2021-01-15 17:45:29 +01:00
/**
* Courses With Groups Api Response . It extends abstract response -
* CoursesResponse. It was one of first repsones created in system. Later we
* resigned from asbstract and used settig
* <code>spring.jackson.default-property-inclusion = NON_NULL</code> in
* properties instead.
*/
@ApiModel(description = "Response shows information about groups to given course.", value = "CoursesWithGroupsResponse")
public class CoursesWithGroupsResponse extends CoursesResponse {
2020-10-13 17:07:04 +02:00
2020-12-29 15:32:09 +01:00
private List<GroupWithCapacityResponse> lectures = new ArrayList<>();
private List<GroupWithCapacityResponse> classes = new ArrayList<>();
2020-10-13 17:07:04 +02:00
2021-01-15 17:45:29 +01:00
/**
* create new instance
*
* @param course course to map to api response
*/
public CoursesWithGroupsResponse(Course course) {
2020-10-13 17:07:04 +02:00
super(course);
course.getGroups().stream().forEach(group -> {
2021-01-19 10:44:35 +01:00
if (GroupType.isLectureOrClass(group.getType()) == GroupType.CLASS) {
2020-12-29 15:32:09 +01:00
this.classes.add(new GroupWithCapacityResponse(group));
2020-10-13 17:07:04 +02:00
} else {
2020-12-29 15:32:09 +01:00
this.lectures.add(new GroupWithCapacityResponse(group));
2020-10-13 17:07:04 +02:00
}
});
}
2021-01-15 17:45:29 +01:00
/**
*
* @param course course to map to api response
* @param lectures list of api resposnes of lectures
* @param classes list of api resposnes of classes
*/
2020-12-29 15:32:09 +01:00
public CoursesWithGroupsResponse(Course course, List<GroupWithCapacityResponse> lectures,
List<GroupWithCapacityResponse> classes) {
super(course);
this.lectures = lectures;
this.classes = classes;
}
2021-01-15 17:45:29 +01:00
/**
* @return list of api resposnes of classes
*/
2020-12-29 15:32:09 +01:00
public List<GroupWithCapacityResponse> getClasses() {
2020-10-13 17:07:04 +02:00
return this.classes;
}
2021-01-15 17:45:29 +01:00
/**
* @return list of api resposnes of lectures
*/
2020-12-29 15:32:09 +01:00
public List<GroupWithCapacityResponse> getLectures() {
2020-10-13 17:07:04 +02:00
return this.lectures;
}
}