Search in sources :

Example 1 with ParameterValueVo

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;
}
Also used : ParameterValueResource(org.ligoj.app.resource.node.ParameterValueResource) NodeStatus(org.ligoj.app.api.NodeStatus) SubscriptionVo(org.ligoj.app.resource.subscription.SubscriptionVo) HashMap(java.util.HashMap) EventVo(org.ligoj.app.resource.node.EventVo) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) ParameterValueVo(org.ligoj.app.resource.node.ParameterValueVo) List(java.util.List) NodeResource(org.ligoj.app.resource.node.NodeResource) TreeMap(java.util.TreeMap) Map(java.util.Map) UserOrg(org.ligoj.app.iam.UserOrg) Subscription(org.ligoj.app.model.Subscription) Comparator(java.util.Comparator) ParameterValue(org.ligoj.app.model.ParameterValue) Project(org.ligoj.app.model.Project) DescribedBean(org.ligoj.bootstrap.core.DescribedBean) ParameterValueVo(org.ligoj.app.resource.node.ParameterValueVo) ParameterValue(org.ligoj.app.model.ParameterValue) TreeMap(java.util.TreeMap) SubscriptionVo(org.ligoj.app.resource.subscription.SubscriptionVo)

Aggregations

Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 NodeStatus (org.ligoj.app.api.NodeStatus)1 UserOrg (org.ligoj.app.iam.UserOrg)1 ParameterValue (org.ligoj.app.model.ParameterValue)1 Project (org.ligoj.app.model.Project)1 Subscription (org.ligoj.app.model.Subscription)1 EventVo (org.ligoj.app.resource.node.EventVo)1 NodeResource (org.ligoj.app.resource.node.NodeResource)1 ParameterValueResource (org.ligoj.app.resource.node.ParameterValueResource)1 ParameterValueVo (org.ligoj.app.resource.node.ParameterValueVo)1 SubscriptionVo (org.ligoj.app.resource.subscription.SubscriptionVo)1 DescribedBean (org.ligoj.bootstrap.core.DescribedBean)1