Skip to content

Commit

Permalink
Removed deprecated "addImplicitRelationships()" method.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed Feb 23, 2022
1 parent ae1da0f commit f85ed23
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 442 deletions.
100 changes: 0 additions & 100 deletions structurizr-core/src/com/structurizr/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -683,106 +683,6 @@ public CustomElement getCustomElementWithName(@Nonnull String name) {
return null;
}

/**
* <p>Propagates all relationships from children to their parents. For example, if you have two components (AAA and BBB)
* in different software systems that have a relationship, calling this method will add the following
* additional implied relationships to the model: AAA-&gt;BB AAA--&gt;B AA-&gt;BBB AA-&gt;BB AA-&gt;B A-&gt;BBB A-&gt;BB A-&gt;B.</p>
*
* @return a set of all implicit relationships that were added to the model
* @deprecated use {@link #setImpliedRelationshipsStrategy(ImpliedRelationshipsStrategy)} ()} instead to set a strategy, before creating relationships
*/
@Nonnull
@Deprecated
public Set<Relationship> addImplicitRelationships() {
Set<Relationship> implicitRelationships = new HashSet<>();

String descriptionKey = "D";
String technologyKey = "T";
String interactionStyleKey = "I";
Map<Element, Map<Element, Map<String, HashSet<String>>>> candidateRelationships = new HashMap<>();

for (Relationship relationship : getRelationships()) {
Element source = relationship.getSource();
Element destination = relationship.getDestination();

while (source != null) {
while (destination != null) {
if (!source.hasEfferentRelationshipWith(destination)) {
if (propagatedRelationshipIsAllowed(source, destination)) {

if (!candidateRelationships.containsKey(source)) {
candidateRelationships.put(source, new HashMap<>());
}

if (!candidateRelationships.get(source).containsKey(destination)) {
candidateRelationships.get(source).put(destination, new HashMap<>());
candidateRelationships.get(source).get(destination).put(descriptionKey, new HashSet<>());
candidateRelationships.get(source).get(destination).put(technologyKey, new HashSet<>());
candidateRelationships.get(source).get(destination).put(interactionStyleKey, new HashSet<>());
}

if (relationship.getDescription() != null) {
candidateRelationships.get(source).get(destination).get(descriptionKey).add(relationship.getDescription());
}

if (relationship.getTechnology() != null) {
candidateRelationships.get(source).get(destination).get(technologyKey).add(relationship.getTechnology());
}

if (relationship.getInteractionStyle() != null) {
candidateRelationships.get(source).get(destination).get(interactionStyleKey).add(relationship.getInteractionStyle().toString());
}
}
}

destination = destination.getParent();
}

destination = relationship.getDestination();
source = source.getParent();
}
}

for (Element source : candidateRelationships.keySet()) {
for (Element destination : candidateRelationships.get(source).keySet()) {
Set<String> possibleDescriptions = candidateRelationships.get(source).get(destination).get(descriptionKey);
Set<String> possibleTechnologies = candidateRelationships.get(source).get(destination).get(technologyKey);
Set<String> possibleInteractionStyles = candidateRelationships.get(source).get(destination).get(interactionStyleKey);

String description = "";
if (possibleDescriptions.size() == 1) {
description = possibleDescriptions.iterator().next();
}

String technology = "";
if (possibleTechnologies.size() == 1) {
technology = possibleTechnologies.iterator().next();
}

InteractionStyle interactionStyle = InteractionStyle.Synchronous;
// If any async relationships are present, mark the relationship as asynchronous
if (possibleInteractionStyles.contains(InteractionStyle.Asynchronous.toString())) {
interactionStyle = InteractionStyle.Asynchronous;
}

Relationship implicitRelationship = addRelationship(source, destination, description, technology, interactionStyle);
if (implicitRelationship != null) {
implicitRelationships.add(implicitRelationship);
}
}
}

return implicitRelationships;
}

private boolean propagatedRelationshipIsAllowed(Element source, Element destination) {
if (source.equals(destination)) {
return false;
}

return !(isChildOf(source, destination) || isChildOf(destination, source));
}

/**
* Determines whether this model is empty.
*
Expand Down
Loading

0 comments on commit f85ed23

Please sign in to comment.