37 lines
1.1 KiB
Java
37 lines
1.1 KiB
Java
|
package com.plannaplan.responses.models;
|
||
|
|
||
|
import java.util.List;
|
||
|
import java.util.Objects;
|
||
|
import java.util.function.Function;
|
||
|
import java.util.stream.Collectors;
|
||
|
|
||
|
import com.plannaplan.entities.Assignment;
|
||
|
import com.plannaplan.entities.Commision;
|
||
|
|
||
|
import io.swagger.annotations.ApiModel;
|
||
|
import io.swagger.annotations.ApiModelProperty;
|
||
|
|
||
|
@ApiModel(description = "Response shows information about commision and its groups.", value = "CommisionWithGroupsResponse")
|
||
|
public class CommisionWithGroupsResponse extends CommisionResponse {
|
||
|
|
||
|
@ApiModelProperty(value = "List of groups ids in databse that belongs to commision")
|
||
|
private List<Long> groups;
|
||
|
|
||
|
public CommisionWithGroupsResponse(Commision commision) {
|
||
|
super(commision);
|
||
|
this.groups = commision.getAssignments().stream().filter(Objects::nonNull)
|
||
|
.map(new Function<Assignment, Long>() {
|
||
|
|
||
|
@Override
|
||
|
public Long apply(Assignment arg0) {
|
||
|
return arg0.getGroup().getId();
|
||
|
}
|
||
|
}).collect(Collectors.toList());
|
||
|
}
|
||
|
|
||
|
public List<Long> getGroups() {
|
||
|
return groups;
|
||
|
}
|
||
|
|
||
|
}
|