46 lines
1.4 KiB
Java
Executable File
46 lines
1.4 KiB
Java
Executable File
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;
|
|
|
|
/**
|
|
* Commision With Groups api Response. It extends CommisionResponse repsone
|
|
*/
|
|
@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;
|
|
|
|
/**
|
|
* @param commision commision to map to api response
|
|
*/
|
|
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());
|
|
}
|
|
|
|
/**
|
|
* @return lsit of fetured groups ids
|
|
*/
|
|
public List<Long> getGroups() {
|
|
return groups;
|
|
}
|
|
|
|
}
|