Checkpoint - group controller needs to be fixed
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
package com.plannaplan.responses.mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.responses.models.DefaultGroupResponse;
|
||||
import com.plannaplan.responses.models.WithCapacityGroupResponse;
|
||||
|
||||
public class GroupsMappers {
|
||||
public static List<DefaultGroupResponse> mapToDefaultResponse(List<Groups> groups) {
|
||||
return groups.stream().filter(Objects::nonNull).map(DefaultGroupResponse::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<WithCapacityGroupResponse> mapToCapacityResponse(List<Groups> groups) {
|
||||
return groups.stream().filter(Objects::nonNull).map(WithCapacityGroupResponse::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
@ -11,7 +11,6 @@ public class DefaultGroupResponse {
|
||||
private String time;
|
||||
private String lecturer;
|
||||
private String room;
|
||||
private int capacity;
|
||||
private GroupType type;
|
||||
|
||||
public DefaultGroupResponse(Groups group) {
|
||||
@ -20,7 +19,6 @@ public class DefaultGroupResponse {
|
||||
this.time = group.getTimeString() != null ? group.getTimeString() : "";
|
||||
this.lecturer = group.getLecturer() != null ? group.getLecturer().toString() : "";
|
||||
this.room = group.getRoom() != null ? group.getRoom() : "";
|
||||
this.capacity = group.getCapacity();
|
||||
this.type = group.getType() != null ? group.getType() : null;
|
||||
}
|
||||
|
||||
@ -32,10 +30,6 @@ public class DefaultGroupResponse {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
public String getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.plannaplan.responses.models;
|
||||
|
||||
import com.plannaplan.entities.Assignment;
|
||||
|
||||
public class GetCurrentAssignmentsResponse extends DefaultGroupResponse {
|
||||
public class GetCurrentAssignmentsResponse extends WithCapacityGroupResponse {
|
||||
|
||||
public GetCurrentAssignmentsResponse(Assignment assignment) {
|
||||
super(assignment);
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.plannaplan.responses.models;
|
||||
|
||||
import com.plannaplan.entities.Assignment;
|
||||
import com.plannaplan.entities.Groups;
|
||||
|
||||
public class WithCapacityGroupResponse extends DefaultGroupResponse {
|
||||
|
||||
private int capacity;
|
||||
|
||||
public WithCapacityGroupResponse(Groups group) {
|
||||
super(group);
|
||||
this.capacity = group.getCapacity();
|
||||
}
|
||||
|
||||
public WithCapacityGroupResponse(Assignment assignment) {
|
||||
this(assignment.getGroup());
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user