/** * {@link Parameter} JPA to {@link ParameterVo} transformer. * * @param entity * The source JPA entity to convert. * @return The VO with all attributes : full node reference, and definition. */ public static ParameterVo toVo(final Parameter entity) { final ParameterVo vo = new ParameterVo(); // Copy basic data vo.setId(entity.getId()); vo.setType(entity.getType()); vo.setMandatory(entity.isMandatory()); vo.setSecured(entity.isSecured()); vo.setOwner(NodeResource.toVo(entity.getOwner())); vo.setDefaultValue(entity.getDefaultValue()); vo.setDepends(entity.getDepends().stream().map(Persistable::getId).collect(Collectors.toSet())); // Map constraint data if (entity.getType().isArray()) { vo.setValues(toConfiguration(entity.getData(), LIST_STRING_TYPE)); } else if (entity.getType() == ParameterType.INTEGER) { final Map<String, Integer> minMax = toConfiguration(entity.getData(), MAP_STRING_TYPE); vo.setMax(minMax.get("max")); vo.setMin(minMax.get("min")); } return vo; }