Part 2 has been ended. The Part 3: chanaged test
This commit is contained in:
parent
a30c3af09c
commit
035de011f2
@ -16,7 +16,7 @@ import com.plannaplan.entities.Assignment;
|
|||||||
import com.plannaplan.entities.Commision;
|
import com.plannaplan.entities.Commision;
|
||||||
import com.plannaplan.entities.User;
|
import com.plannaplan.entities.User;
|
||||||
import com.plannaplan.responses.mappers.AssignmentResponseMappers;
|
import com.plannaplan.responses.mappers.AssignmentResponseMappers;
|
||||||
import com.plannaplan.responses.models.GetCurrentAssignmentsResponse;
|
import com.plannaplan.responses.models.AssignmentResponse;
|
||||||
import com.plannaplan.services.AssignmentService;
|
import com.plannaplan.services.AssignmentService;
|
||||||
import com.plannaplan.services.CommisionService;
|
import com.plannaplan.services.CommisionService;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ public class AssignmentsController extends TokenBasedController {
|
|||||||
|
|
||||||
@GetMapping("/user")
|
@GetMapping("/user")
|
||||||
@ApiOperation(value = "Return user current assignemts (from newest commision). STUDENT Token needs to be provided.")
|
@ApiOperation(value = "Return user current assignemts (from newest commision). STUDENT Token needs to be provided.")
|
||||||
public ResponseEntity<List<GetCurrentAssignmentsResponse>> getCurrentAssignments() throws Exception {
|
public ResponseEntity<List<AssignmentResponse>> getCurrentAssignments() throws Exception {
|
||||||
User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException("User not found"));
|
User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException("User not found"));
|
||||||
Optional<Commision> com = this.commisionService.getNewestCommision(user);
|
Optional<Commision> com = this.commisionService.getNewestCommision(user);
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||||||
import com.plannaplan.App;
|
import com.plannaplan.App;
|
||||||
import com.plannaplan.entities.Course;
|
import com.plannaplan.entities.Course;
|
||||||
import com.plannaplan.responses.mappers.CoursesResponseMappers;
|
import com.plannaplan.responses.mappers.CoursesResponseMappers;
|
||||||
import com.plannaplan.responses.models.GetCoursesResponse;
|
import com.plannaplan.responses.models.CoursesDefaultResponse;
|
||||||
import com.plannaplan.responses.models.GetCoursesWithGroupsResponse;
|
import com.plannaplan.responses.models.CoursesWithGroupsResponse;
|
||||||
import com.plannaplan.services.CourseService;
|
import com.plannaplan.services.CourseService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -39,11 +39,11 @@ public class CoursesController {
|
|||||||
@RequestParam(name = "groups", defaultValue = "false") @ApiParam(value = "Boolean if you want to have resopnse with associated groups or without") Boolean groups) {
|
@RequestParam(name = "groups", defaultValue = "false") @ApiParam(value = "Boolean if you want to have resopnse with associated groups or without") Boolean groups) {
|
||||||
List<Course> courses = this.courseService.getAllCourses();
|
List<Course> courses = this.courseService.getAllCourses();
|
||||||
if (groups) {
|
if (groups) {
|
||||||
final List<GetCoursesWithGroupsResponse> response = CoursesResponseMappers
|
final List<CoursesWithGroupsResponse> response = CoursesResponseMappers
|
||||||
.mapToGetCoursesWithGroupsResponse(courses);
|
.mapToGetCoursesWithGroupsResponse(courses);
|
||||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
final List<GetCoursesResponse> response = CoursesResponseMappers.mapToGetCoursesResponse(courses);
|
final List<CoursesDefaultResponse> response = CoursesResponseMappers.mapToGetCoursesResponse(courses);
|
||||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||||||
import com.plannaplan.App;
|
import com.plannaplan.App;
|
||||||
import com.plannaplan.entities.Groups;
|
import com.plannaplan.entities.Groups;
|
||||||
import com.plannaplan.responses.mappers.GroupsMappers;
|
import com.plannaplan.responses.mappers.GroupsMappers;
|
||||||
import com.plannaplan.responses.models.DefaultGroupResponse;
|
import com.plannaplan.responses.models.GroupDefaultResponse;
|
||||||
import com.plannaplan.responses.models.GetCourseGroupsResponse;
|
import com.plannaplan.responses.models.CourseWithGroupsResponse;
|
||||||
import com.plannaplan.services.GroupService;
|
import com.plannaplan.services.GroupService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -35,7 +35,7 @@ public class GroupController {
|
|||||||
|
|
||||||
@GetMapping("/course/{id}")
|
@GetMapping("/course/{id}")
|
||||||
@ApiOperation(value = "Return list of lectures and classes (if present) given course")
|
@ApiOperation(value = "Return list of lectures and classes (if present) given course")
|
||||||
public ResponseEntity<GetCourseGroupsResponse<? extends DefaultGroupResponse>> getCourses(
|
public ResponseEntity<CourseWithGroupsResponse<? extends GroupDefaultResponse>> getCourses(
|
||||||
@PathVariable(name = "id") Long id,
|
@PathVariable(name = "id") Long id,
|
||||||
@RequestParam(name = "capacity", defaultValue = "true") @ApiParam(value = "Boolean if we want to have capacity field in response") Boolean capacity) {
|
@RequestParam(name = "capacity", defaultValue = "true") @ApiParam(value = "Boolean if we want to have capacity field in response") Boolean capacity) {
|
||||||
List<Groups> groups = this.groupService.getGroupsByCourse(id);
|
List<Groups> groups = this.groupService.getGroupsByCourse(id);
|
||||||
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
import com.plannaplan.App;
|
import com.plannaplan.App;
|
||||||
import com.plannaplan.entities.User;
|
import com.plannaplan.entities.User;
|
||||||
import com.plannaplan.responses.mappers.UserResponseMappers;
|
import com.plannaplan.responses.mappers.UserResponseMappers;
|
||||||
import com.plannaplan.responses.models.SearchForStudentsResponse;
|
import com.plannaplan.responses.models.UserResponse;
|
||||||
import com.plannaplan.services.UserService;
|
import com.plannaplan.services.UserService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -36,10 +36,10 @@ public class UsersController {
|
|||||||
@GetMapping("/student/search")
|
@GetMapping("/student/search")
|
||||||
@PreAuthorize("hasRole('ROLE_DEANERY')")
|
@PreAuthorize("hasRole('ROLE_DEANERY')")
|
||||||
@ApiOperation(value = "Serch for user by providing query. If query is empty it will return all students. You need token with DEANERY role to call this")
|
@ApiOperation(value = "Serch for user by providing query. If query is empty it will return all students. You need token with DEANERY role to call this")
|
||||||
public ResponseEntity<List<SearchForStudentsResponse>> configApp(
|
public ResponseEntity<List<UserResponse>> configApp(
|
||||||
@RequestParam("query") @ApiParam(value = "Query to filter all students. If empty will match everyone") String query) {
|
@RequestParam("query") @ApiParam(value = "Query to filter all students. If empty will match everyone") String query) {
|
||||||
final List<User> searches = this.userService.searchForStudents(query);
|
final List<User> searches = this.userService.searchForStudents(query);
|
||||||
final List<SearchForStudentsResponse> response = UserResponseMappers.mapToDefaultResponse(searches);
|
final List<UserResponse> response = UserResponseMappers.mapToDefaultResponse(searches);
|
||||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,13 @@ import java.util.Map;
|
|||||||
import com.plannaplan.entities.Assignment;
|
import com.plannaplan.entities.Assignment;
|
||||||
import com.plannaplan.entities.Course;
|
import com.plannaplan.entities.Course;
|
||||||
import com.plannaplan.entities.Groups;
|
import com.plannaplan.entities.Groups;
|
||||||
import com.plannaplan.responses.models.GetCurrentAssignmentsResponse;
|
import com.plannaplan.responses.models.AssignmentResponse;
|
||||||
import com.plannaplan.types.GroupType;
|
import com.plannaplan.types.GroupType;
|
||||||
|
|
||||||
public class AssignmentResponseMappers {
|
public class AssignmentResponseMappers {
|
||||||
|
|
||||||
public static final List<GetCurrentAssignmentsResponse> mapToResponse(List<Assignment> assignments) {
|
public static final List<AssignmentResponse> mapToResponse(List<Assignment> assignments) {
|
||||||
List<GetCurrentAssignmentsResponse> response = new ArrayList<>();
|
List<AssignmentResponse> response = new ArrayList<>();
|
||||||
HashMap<Course, List<Groups>> courses = new HashMap<>();
|
HashMap<Course, List<Groups>> courses = new HashMap<>();
|
||||||
assignments.stream().forEach((Assignment assignment) -> {
|
assignments.stream().forEach((Assignment assignment) -> {
|
||||||
final Groups group = assignment.getGroup();
|
final Groups group = assignment.getGroup();
|
||||||
@ -29,14 +29,14 @@ public class AssignmentResponseMappers {
|
|||||||
final Course course = entry.getKey();
|
final Course course = entry.getKey();
|
||||||
final List<Groups> courseGroups = entry.getValue();
|
final List<Groups> courseGroups = entry.getValue();
|
||||||
if (courseGroups.size() == 1) {
|
if (courseGroups.size() == 1) {
|
||||||
response.add(new GetCurrentAssignmentsResponse(course, courseGroups.get(0)));
|
response.add(new AssignmentResponse(course, courseGroups.get(0)));
|
||||||
}
|
}
|
||||||
if (courseGroups.size() == 2) {
|
if (courseGroups.size() == 2) {
|
||||||
final Groups lecture = courseGroups.stream().filter(o -> o.getType() == GroupType.LECTURE).findFirst()
|
final Groups lecture = courseGroups.stream().filter(o -> o.getType() == GroupType.LECTURE).findFirst()
|
||||||
.get();
|
.get();
|
||||||
final Groups classes = courseGroups.stream().filter(o -> o.getType() == GroupType.CLASS).findFirst()
|
final Groups classes = courseGroups.stream().filter(o -> o.getType() == GroupType.CLASS).findFirst()
|
||||||
.get();
|
.get();
|
||||||
response.add(new GetCurrentAssignmentsResponse(course, lecture, classes));
|
response.add(new AssignmentResponse(course, lecture, classes));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,16 @@ import java.util.Objects;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.plannaplan.entities.Course;
|
import com.plannaplan.entities.Course;
|
||||||
import com.plannaplan.responses.models.GetCoursesResponse;
|
import com.plannaplan.responses.models.CoursesDefaultResponse;
|
||||||
import com.plannaplan.responses.models.GetCoursesWithGroupsResponse;
|
import com.plannaplan.responses.models.CoursesWithGroupsResponse;
|
||||||
|
|
||||||
public class CoursesResponseMappers {
|
public class CoursesResponseMappers {
|
||||||
public static final List<GetCoursesResponse> mapToGetCoursesResponse(List<Course> courses) {
|
public static final List<CoursesDefaultResponse> mapToGetCoursesResponse(List<Course> courses) {
|
||||||
return courses.stream().filter(Objects::nonNull).map(GetCoursesResponse::new).collect(Collectors.toList());
|
return courses.stream().filter(Objects::nonNull).map(CoursesDefaultResponse::new).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final List<GetCoursesWithGroupsResponse> mapToGetCoursesWithGroupsResponse(List<Course> courses) {
|
public static final List<CoursesWithGroupsResponse> mapToGetCoursesWithGroupsResponse(List<Course> courses) {
|
||||||
return courses.stream().filter(Objects::nonNull).map(GetCoursesWithGroupsResponse::new)
|
return courses.stream().filter(Objects::nonNull).map(CoursesWithGroupsResponse::new)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,53 +6,53 @@ import java.util.Objects;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.plannaplan.entities.Groups;
|
import com.plannaplan.entities.Groups;
|
||||||
import com.plannaplan.responses.models.DefaultGroupResponse;
|
import com.plannaplan.responses.models.GroupDefaultResponse;
|
||||||
import com.plannaplan.responses.models.GetCourseGroupsResponse;
|
import com.plannaplan.responses.models.CourseWithGroupsResponse;
|
||||||
import com.plannaplan.responses.models.WithCapacityGroupResponse;
|
import com.plannaplan.responses.models.GroupWithCapacityResponse;
|
||||||
import com.plannaplan.types.GroupType;
|
import com.plannaplan.types.GroupType;
|
||||||
|
|
||||||
public class GroupsMappers {
|
public class GroupsMappers {
|
||||||
public static List<DefaultGroupResponse> mapToDefaultResponse(List<Groups> groups) {
|
public static List<GroupDefaultResponse> mapToDefaultResponse(List<Groups> groups) {
|
||||||
return groups.stream().filter(Objects::nonNull).map(DefaultGroupResponse::new).collect(Collectors.toList());
|
return groups.stream().filter(Objects::nonNull).map(GroupDefaultResponse::new).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<WithCapacityGroupResponse> mapToCapacityResponse(List<Groups> groups) {
|
public static List<GroupWithCapacityResponse> mapToCapacityResponse(List<Groups> groups) {
|
||||||
return groups.stream().filter(Objects::nonNull).map(WithCapacityGroupResponse::new)
|
return groups.stream().filter(Objects::nonNull).map(GroupWithCapacityResponse::new)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GetCourseGroupsResponse<DefaultGroupResponse> mapToGetCourseGroupsDefaultResponse (List<Groups> groups){
|
public static CourseWithGroupsResponse<GroupDefaultResponse> mapToGetCourseGroupsDefaultResponse (List<Groups> groups){
|
||||||
|
|
||||||
List<DefaultGroupResponse> lectures = new ArrayList<>();
|
List<GroupDefaultResponse> lectures = new ArrayList<>();
|
||||||
List<DefaultGroupResponse> classes = new ArrayList<>();
|
List<GroupDefaultResponse> classes = new ArrayList<>();
|
||||||
|
|
||||||
groups.stream().forEach(group -> {
|
groups.stream().forEach(group -> {
|
||||||
if (group.getType() == GroupType.CLASS) {
|
if (group.getType() == GroupType.CLASS) {
|
||||||
classes.add(new DefaultGroupResponse(group));
|
classes.add(new GroupDefaultResponse(group));
|
||||||
} else {
|
} else {
|
||||||
lectures.add(new DefaultGroupResponse(group));
|
lectures.add(new GroupDefaultResponse(group));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return new GetCourseGroupsResponse<>(classes, lectures);
|
return new CourseWithGroupsResponse<>(classes, lectures);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GetCourseGroupsResponse<WithCapacityGroupResponse> mapToGetCourseGroupsWithCapacityResponse (List<Groups> groups){
|
public static CourseWithGroupsResponse<GroupWithCapacityResponse> mapToGetCourseGroupsWithCapacityResponse (List<Groups> groups){
|
||||||
|
|
||||||
List<WithCapacityGroupResponse> lectures = new ArrayList<>();
|
List<GroupWithCapacityResponse> lectures = new ArrayList<>();
|
||||||
List<WithCapacityGroupResponse> classes = new ArrayList<>();
|
List<GroupWithCapacityResponse> classes = new ArrayList<>();
|
||||||
|
|
||||||
groups.stream().forEach(group -> {
|
groups.stream().forEach(group -> {
|
||||||
if (group.getType() == GroupType.CLASS) {
|
if (group.getType() == GroupType.CLASS) {
|
||||||
classes.add(new WithCapacityGroupResponse(group));
|
classes.add(new GroupWithCapacityResponse(group));
|
||||||
} else {
|
} else {
|
||||||
lectures.add(new WithCapacityGroupResponse(group));
|
lectures.add(new GroupWithCapacityResponse(group));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return new GetCourseGroupsResponse<>(classes, lectures);
|
return new CourseWithGroupsResponse<>(classes, lectures);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import java.util.Objects;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.plannaplan.entities.User;
|
import com.plannaplan.entities.User;
|
||||||
import com.plannaplan.responses.models.SearchForStudentsResponse;
|
import com.plannaplan.responses.models.UserResponse;
|
||||||
|
|
||||||
public class UserResponseMappers {
|
public class UserResponseMappers {
|
||||||
public static List<SearchForStudentsResponse> mapToDefaultResponse(List<User> groups) {
|
public static List<UserResponse> mapToDefaultResponse(List<User> groups) {
|
||||||
return groups.stream().filter(Objects::nonNull).map(SearchForStudentsResponse::new)
|
return groups.stream().filter(Objects::nonNull).map(UserResponse::new)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,30 +6,30 @@ import com.plannaplan.types.GroupType;
|
|||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
|
||||||
@ApiModel(description = "Response shows information about given assigment to course.", value = "GetCurrentAssignmentsResponse")
|
@ApiModel(description = "Response shows information about given assigment to course.", value = "AssignmentResponse")
|
||||||
public class GetCurrentAssignmentsResponse {
|
public class AssignmentResponse {
|
||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
private WithCapacityGroupResponse classes;
|
private GroupWithCapacityResponse classes;
|
||||||
private WithCapacityGroupResponse lecture;
|
private GroupWithCapacityResponse lecture;
|
||||||
|
|
||||||
public GetCurrentAssignmentsResponse(Course course, Groups lecture, Groups classes) {
|
public AssignmentResponse(Course course, Groups lecture, Groups classes) {
|
||||||
this.id = course.getId();
|
this.id = course.getId();
|
||||||
this.name = course.getName();
|
this.name = course.getName();
|
||||||
this.lecture = lecture == null ? null : new WithCapacityGroupResponse(lecture);
|
this.lecture = lecture == null ? null : new GroupWithCapacityResponse(lecture);
|
||||||
this.classes = classes == null ? null : new WithCapacityGroupResponse(classes);
|
this.classes = classes == null ? null : new GroupWithCapacityResponse(classes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetCurrentAssignmentsResponse(Course course, Groups group) {
|
public AssignmentResponse(Course course, Groups group) {
|
||||||
this(course, group.getType() == GroupType.LECTURE ? group : null,
|
this(course, group.getType() == GroupType.LECTURE ? group : null,
|
||||||
group.getType() == GroupType.CLASS ? group : null);
|
group.getType() == GroupType.CLASS ? group : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WithCapacityGroupResponse getLecture() {
|
public GroupWithCapacityResponse getLecture() {
|
||||||
return this.lecture;
|
return this.lecture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WithCapacityGroupResponse getClasses() {
|
public GroupWithCapacityResponse getClasses() {
|
||||||
return this.classes;
|
return this.classes;
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@ import com.plannaplan.entities.Commision;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
@ApiModel(description = "Response shows information about commision", value = "CommisionResponse")
|
@ApiModel(description = "Response shows information about commision.", value = "CommisionResponse")
|
||||||
public class CommisionResponse {
|
public class CommisionResponse {
|
||||||
@ApiModelProperty(value = "ID created by database")
|
@ApiModelProperty(value = "ID created by database")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
@ -5,13 +5,13 @@ import java.util.List;
|
|||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
|
||||||
@ApiModel(description = "Response shows information about groups to given course.", value = "DefaultGroupResponse")
|
@ApiModel(description = "Response shows information about groups to given course.", value = "CourseWithGroupsResponse")
|
||||||
public class GetCourseGroupsResponse <T> {
|
public class CourseWithGroupsResponse <T> {
|
||||||
|
|
||||||
private List<T> lectures = new ArrayList<>();
|
private List<T> lectures = new ArrayList<>();
|
||||||
private List<T> classes = new ArrayList<>();
|
private List<T> classes = new ArrayList<>();
|
||||||
|
|
||||||
public GetCourseGroupsResponse(List<T> classes, List<T> lectures ){
|
public CourseWithGroupsResponse(List<T> classes, List<T> lectures ){
|
||||||
this.lectures = lectures;
|
this.lectures = lectures;
|
||||||
this.classes = classes;
|
this.classes = classes;
|
||||||
}
|
}
|
@ -5,10 +5,10 @@ import com.plannaplan.responses.models.abstracts.CoursesResponse;
|
|||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
|
||||||
@ApiModel(description = "Response shows information about course.", value = "DefaultGroupResponse")
|
@ApiModel(description = "Response shows information about course.", value = "CoursesDefaultResponse")
|
||||||
public class GetCoursesResponse extends CoursesResponse {
|
public class CoursesDefaultResponse extends CoursesResponse {
|
||||||
|
|
||||||
public GetCoursesResponse(Course course) {
|
public CoursesDefaultResponse(Course course) {
|
||||||
super(course);
|
super(course);
|
||||||
}
|
}
|
||||||
|
|
@ -9,28 +9,28 @@ import com.plannaplan.types.GroupType;
|
|||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
|
||||||
@ApiModel(description = "Response shows information about groups to given course.", value = "GetCoursesWithGroupsResponse")
|
@ApiModel(description = "Response shows information about groups to given course.", value = "CoursesWithGroupsResponse")
|
||||||
public class GetCoursesWithGroupsResponse extends CoursesResponse {
|
public class CoursesWithGroupsResponse extends CoursesResponse {
|
||||||
|
|
||||||
private List<DefaultGroupResponse> lectures = new ArrayList<>();
|
private List<GroupDefaultResponse> lectures = new ArrayList<>();
|
||||||
private List<DefaultGroupResponse> classes = new ArrayList<>();
|
private List<GroupDefaultResponse> classes = new ArrayList<>();
|
||||||
|
|
||||||
public GetCoursesWithGroupsResponse(Course course) {
|
public CoursesWithGroupsResponse(Course course) {
|
||||||
super(course);
|
super(course);
|
||||||
course.getGroups().stream().forEach(group -> {
|
course.getGroups().stream().forEach(group -> {
|
||||||
if (group.getType() == GroupType.CLASS) {
|
if (group.getType() == GroupType.CLASS) {
|
||||||
this.classes.add(new DefaultGroupResponse(group));
|
this.classes.add(new GroupDefaultResponse(group));
|
||||||
} else {
|
} else {
|
||||||
this.lectures.add(new DefaultGroupResponse(group));
|
this.lectures.add(new GroupDefaultResponse(group));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DefaultGroupResponse> getClasses() {
|
public List<GroupDefaultResponse> getClasses() {
|
||||||
return this.classes;
|
return this.classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DefaultGroupResponse> getLectures() {
|
public List<GroupDefaultResponse> getLectures() {
|
||||||
return this.lectures;
|
return this.lectures;
|
||||||
}
|
}
|
||||||
|
|
@ -7,8 +7,8 @@ import com.plannaplan.types.GroupType;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
@ApiModel(description = "Response shows information about given group", value = "DefaultGroupResponse")
|
@ApiModel(description = "Response shows information about given group.", value = "GroupDefaultResponse")
|
||||||
public class DefaultGroupResponse {
|
public class GroupDefaultResponse {
|
||||||
|
|
||||||
@ApiModelProperty(value = "ID created by database.")
|
@ApiModelProperty(value = "ID created by database.")
|
||||||
private Long id;
|
private Long id;
|
||||||
@ -28,7 +28,7 @@ public class DefaultGroupResponse {
|
|||||||
@ApiModelProperty(value = "Value shows kind of group. The types are LECTURE or CLASS.")
|
@ApiModelProperty(value = "Value shows kind of group. The types are LECTURE or CLASS.")
|
||||||
private GroupType type;
|
private GroupType type;
|
||||||
|
|
||||||
public DefaultGroupResponse(Groups group) {
|
public GroupDefaultResponse(Groups group) {
|
||||||
this.id = group.getId() != null ? group.getId() : null;
|
this.id = group.getId() != null ? group.getId() : null;
|
||||||
this.day = group.getDay() != null ? group.getDay().label : -1;
|
this.day = group.getDay() != null ? group.getDay().label : -1;
|
||||||
this.time = group.getTimeString() != null ? group.getTimeString() : "";
|
this.time = group.getTimeString() != null ? group.getTimeString() : "";
|
||||||
@ -37,7 +37,7 @@ public class DefaultGroupResponse {
|
|||||||
this.type = group.getType() != null ? group.getType() : null;
|
this.type = group.getType() != null ? group.getType() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultGroupResponse(Assignment assignment) {
|
public GroupDefaultResponse(Assignment assignment) {
|
||||||
this(assignment.getGroup());
|
this(assignment.getGroup());
|
||||||
}
|
}
|
||||||
|
|
@ -4,17 +4,17 @@ import com.plannaplan.entities.Assignment;
|
|||||||
import com.plannaplan.entities.Groups;
|
import com.plannaplan.entities.Groups;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
|
||||||
@ApiModel(description = "Response shows information about group with included capacity.", value = "WithCapacityGroupResponse")
|
@ApiModel(description = "Response shows information about group with included capacity.", value = "GroupWithCapacityResponse")
|
||||||
public class WithCapacityGroupResponse extends DefaultGroupResponse {
|
public class GroupWithCapacityResponse extends GroupDefaultResponse {
|
||||||
|
|
||||||
private int capacity;
|
private int capacity;
|
||||||
|
|
||||||
public WithCapacityGroupResponse(Groups group) {
|
public GroupWithCapacityResponse(Groups group) {
|
||||||
super(group);
|
super(group);
|
||||||
this.capacity = group.getCapacity();
|
this.capacity = group.getCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WithCapacityGroupResponse(Assignment assignment) {
|
public GroupWithCapacityResponse(Assignment assignment) {
|
||||||
this(assignment.getGroup());
|
this(assignment.getGroup());
|
||||||
}
|
}
|
||||||
|
|
@ -4,15 +4,15 @@ import com.plannaplan.entities.User;
|
|||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
|
||||||
@ApiModel(description = "Response shows information about user.", value = "SearchForStudentsResponse")
|
@ApiModel(description = "Response shows information about user.", value = "UserResponse")
|
||||||
public class SearchForStudentsResponse {
|
public class UserResponse {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
public SearchForStudentsResponse(User user) {
|
public UserResponse(User user) {
|
||||||
this.id = user.getId();
|
this.id = user.getId();
|
||||||
this.name = user.getName();
|
this.name = user.getName();
|
||||||
this.surname = user.getSurname();
|
this.surname = user.getSurname();
|
Loading…
Reference in New Issue
Block a user