private static boolean isPartOf(Element element, Element other) { if (element.getId().equals(other.getId())) { return true; } else if (element.getParent() != null) { return isPartOf(element.getParent(), other); } return false; }
/** * <p>Adds all {@link com.structurizr.model.Container}s of the given {@link ContainerView} as well as all external influencers, that is all * persons and all other software systems with incoming or outgoing dependencies.</p> * <p>Additionally, all relationships of external dependencies are omitted to keep the diagram clean</p> */ public final void addAllInfluencers() { // add all software systems with incoming or outgoing dependencies getModel().getSoftwareSystems() .stream() .filter(softwareSystem -> softwareSystem.hasEfferentRelationshipWith(getSoftwareSystem()) || getSoftwareSystem().hasEfferentRelationshipWith(softwareSystem)) .forEach(this::add); // then add all people with incoming or outgoing dependencies getModel().getPeople() .stream() .filter(person -> person.hasEfferentRelationshipWith(getSoftwareSystem()) || getSoftwareSystem().hasEfferentRelationshipWith(person)) .forEach(this::add); // then remove all relationships of external elements to keep the container view clean getRelationships() .stream() .map(view -> view.getRelationship()) .filter(relationship -> !isPartOf(relationship.getDestination(), getSoftwareSystem()) && !isPartOf(relationship.getSource(), getSoftwareSystem())) .forEach(this::remove); }