This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes some clashing issues with automatic key generation for views.
- Loading branch information
1 parent
d24d70f
commit 17026e7
Showing
23 changed files
with
121 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.structurizr.dsl; | ||
|
||
import com.structurizr.Workspace; | ||
import com.structurizr.view.FilteredView; | ||
import com.structurizr.view.SystemLandscapeView; | ||
import com.structurizr.view.View; | ||
|
||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
abstract class AbstractViewParser extends AbstractParser { | ||
|
||
protected String generateViewKey(Workspace workspace, String prefix) { | ||
int counter = 1; | ||
String key = prefix + "-" + counter; | ||
|
||
while (hasViewWithKey(workspace, key)) { | ||
counter++; | ||
key = prefix + "-" + counter; | ||
} | ||
|
||
return key; | ||
} | ||
|
||
protected boolean hasViewWithKey(Workspace workspace, String key) { | ||
Set<View> views = new HashSet<>(); | ||
views.addAll(workspace.getViews().getCustomViews()); | ||
views.addAll(workspace.getViews().getSystemLandscapeViews()); | ||
views.addAll(workspace.getViews().getSystemContextViews()); | ||
views.addAll(workspace.getViews().getContainerViews()); | ||
views.addAll(workspace.getViews().getComponentViews()); | ||
views.addAll(workspace.getViews().getDynamicViews()); | ||
views.addAll(workspace.getViews().getDeploymentViews()); | ||
|
||
Collection<FilteredView> filteredViews = workspace.getViews().getFilteredViews(); | ||
|
||
return | ||
views.stream().anyMatch(view -> view.getKey().equals(key)) || | ||
filteredViews.stream().anyMatch(view -> view.getKey().equals(key)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
workspace { | ||
|
||
model { | ||
person "User" | ||
} | ||
|
||
views { | ||
systemLandscape { | ||
} | ||
|
||
systemLandscape { | ||
} | ||
|
||
systemLandscape { | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.