use of org.ligoj.app.resource.node.ParameterValueVo in project ligoj-api by ligoj.
the class ToVoConverter method apply.
@Override
public ProjectVo apply(final Project entity) {
final ProjectVo vo = new ProjectVo();
vo.copyAuditData(entity, userConverter);
DescribedBean.copy(entity, vo);
vo.setPkey(entity.getPkey());
vo.setTeamLeader(userConverter.apply(entity.getTeamLeader()));
// Build the subscriptions
final Map<Integer, SubscriptionVo> subscriptions = new TreeMap<>();
for (final Object[] resultSet : this.subscriptionsAndParam) {
// Add subscription value
final ParameterValue parameterValue = (ParameterValue) resultSet[1];
addVo(subscriptions, (Subscription) resultSet[0]).getParameters().put(parameterValue.getParameter().getId(), ParameterValueResource.parseValue(parameterValue, new ParameterValueVo()));
}
// Merge with subscription without parameters
entity.getSubscriptions().forEach(s -> addVo(subscriptions, s));
// Return the subscription to order by the related node
vo.setSubscriptions(subscriptions.values().stream().sorted(Comparator.comparing(s -> s.getNode().getId(), String::compareTo)).collect(Collectors.toList()));
return vo;
}
Aggregations