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;
|
|
|
|
|
2020-11-08 16:55:56 +01:00
|
|
|
import io.swagger.annotations.ApiModel;
|
|
|
|
|
2020-11-08 17:20:00 +01:00
|
|
|
@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-11-08 17:20:00 +01:00
|
|
|
private List<GroupDefaultResponse> lectures = new ArrayList<>();
|
|
|
|
private List<GroupDefaultResponse> classes = new ArrayList<>();
|
2020-10-13 17:07:04 +02:00
|
|
|
|
2020-11-08 17:20:00 +01: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-11-08 17:20:00 +01:00
|
|
|
this.classes.add(new GroupDefaultResponse(group));
|
2020-10-13 17:07:04 +02:00
|
|
|
} else {
|
2020-11-08 17:20:00 +01:00
|
|
|
this.lectures.add(new GroupDefaultResponse(group));
|
2020-10-13 17:07:04 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-08 17:20:00 +01:00
|
|
|
public List<GroupDefaultResponse> getClasses() {
|
2020-10-13 17:07:04 +02:00
|
|
|
return this.classes;
|
|
|
|
}
|
|
|
|
|
2020-11-08 17:20:00 +01:00
|
|
|
public List<GroupDefaultResponse> getLectures() {
|
2020-10-13 17:07:04 +02:00
|
|
|
return this.lectures;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|