/** * Return the tool instance if is an instance. * * @return The tool instance if is an instance. */ @JsonIgnore public Node getTool() { if (isService()) { return null; } return isInstance() ? getRefined() : this; } }
/** * Convert a {@link Node} to a {@link Path} inside the given parent directory. * * @param node * The related node. * @param fragments * The computed sibling path (updated). */ private void toFragments(final Node node, List<String> fragments) { if (node.isRefining()) { toFragments(node.getRefined(), fragments); } fragments.add(toFragmentId(node).replace(':', '-')); }
private Snapshotting getSnapshot(final Node node) { return Optional.ofNullable(locator.getResource(node.getId(), Snapshotting.class)) .orElseThrow(() -> new BusinessException("snapshot-no-supported", node.getRefined().getId())); }
/** * Return the last part of the node identifier, excluding the part of the parent. Built like that : * <ul> * <li>node = 'service:id:ldap:ad1', fragment = 'ad1'</li> * <li>node = 'service:id:ldap', fragment = 'ldap'</li> * <li>node = 'service:id', fragment = 'service:id'</li> * </ul> * * @param node * The node to convert to a simple fragment String. * @return The simple fragment. */ private String toFragmentId(final Node node) { return node.isRefining() ? node.getId().substring(node.getRefined().getId().length() + 1) : node.getId(); } }
/** * Return all events related to a visible node of given user. * * @param user * The principal user requesting these events. * @return Events related to a visible {@link Node}. */ public List<EventVo> findAll(final String user) { final List<Event> events = repository.findLastEvents(user); final Map<String, EventVo> services = new HashMap<>(); final Map<String, EventVo> tools = new HashMap<>(); for (final Event event : events) { final Node parent = event.getNode().getRefined(); fillParentEvents(tools, parent, EventResource.toVo(event), event.getValue()); fillParentEvents(services, parent.getRefined(), tools.get(parent.getId()), event.getValue()); } return new ArrayList<>(services.values()); }
private boolean equalsOrParentOf(final Node parent, final Node node) { return node.equals(parent) || node.isRefining() && equalsOrParentOf(parent, node.getRefined()); }
final NodeVo parent = nodes.get(entry.getValue().getRefined().getId()); node.setRefined(parent); node.getParameters().putAll(parent.getParameters());
/** * {@link Node} JPA to business object transformer. * * @param entity * Source entity. * @return The corresponding VO object with recursive redefined reference. */ public static NodeVo toVo(final Node entity) { final NodeVo vo = toVoLight(entity); if (entity.isRefining()) { vo.setRefined(toVo(entity.getRefined())); } return vo; }
/** * Check the desired mode is a subset of allowed modes. */ private SubscriptionMode checkMode(final NodeEditionVo vo, final Node entity) { if (entity.isRefining()) { // Check the mode inheritance return checkMode(entity.getRefined().getMode(), vo.getMode()); } return vo.getMode(); }