/** {@inheritDoc} */ @Override @Transactional(readOnly=true) public List<OnmsResource> findTopLevelResources() { // Retrieve all top-level resources by passing null as the parent final List<OnmsResource> resources = m_resourceTypes.values().stream() .distinct() .map(type -> type.getResourcesForParent(null)) .flatMap(List::stream) .filter(this::hasAnyChildResources) .collect(Collectors.toList()); return resources; }
@Override public List<OnmsResource> load() { Preconditions.checkNotNull(m_parent, "parent attribute"); // Gather the lists of children from all the available resource types and merge them // into a single list List<OnmsResource> children = getAvailableResourceTypes().stream() .map(t -> t.getResourcesForParent(m_parent)) .flatMap(List::stream) .collect(Collectors.toList()); // Set the parent field on all of the resources children.stream().forEach(c -> c.setParent(m_parent)); return children; }