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

45 lines
1.4 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;
@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
public CoursesWithGroupsResponse(Course course) {
2020-10-13 17:07:04 +02:00
super(course);
course.getGroups().stream().forEach(group -> {
if (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
}
});
}
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;
}
2020-12-29 15:32:09 +01:00
public List<GroupWithCapacityResponse> getClasses() {
2020-10-13 17:07:04 +02:00
return this.classes;
}
2020-12-29 15:32:09 +01:00
public List<GroupWithCapacityResponse> getLectures() {
2020-10-13 17:07:04 +02:00
return this.lectures;
}
}