Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add startVisit and endVisit methods to add handling of FileredView #285

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can use the archetype by running this maven-friendly 😅command.
Current version is ![GitHub version](https://badge.fury.io/gh/Riduidel%2Faadarchi.svg)

```sh
mvn archetype:generate -DarchetypeVersion=0.0.1 -Daadarchi-version=0.0.1 -DarchetypeGroupId=io.github.Riduidel.aadarchi -DarchetypeArtifactId=archetype
mvn archetype:generate -DarchetypeVersion=0.1.4 -Daadarchi-version=0.1.4 -DarchetypeGroupId=io.github.Riduidel.aadarchi -DarchetypeArtifactId=archetype
```

This will ask you a few questions and generate the project.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ workspace "aadarchi-documentation-system" {
model {
person_architect = person "Architect" "The architect as team scribe is the writer of this kind of documentation."
person_stakeholder = person "Stakeholder" "All project stakeholders are readers of this kind of documentation."
aadarchi = softwareSystem "Aadarchi" {
aadarchi = softwareSystem "Aadarchi" "auto-include" {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le tag auto-include ne se met qu'au niveau de la vue, pas du modèle

properties {
"aadarchi.tickets.project" "aadarchi-documentation-system"
"aadarchi.issue.manager" "https://github.com/Riduidel/aadarchi-documentation-system"
Expand All @@ -16,7 +16,7 @@ workspace "aadarchi-documentation-system" {
}
maven -> this "Invokes this plugin during build to generate data"
}
aadarchi_base = container "base" "" "Java, CDI" {
aadarchi_base = container "base" "" "Java, CDI" "auto-include" {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le tag auto-include ne se met qu'au niveau de la vue, pas du modèle

properties {
"aadarchi.sequence.generator.with" "true"
}
Expand Down Expand Up @@ -47,11 +47,13 @@ workspace "aadarchi-documentation-system" {
systemContext "aadarchi" "SystemContext" "Illustration of aadarchi-documentation usage" {
include *
}
container "aadarchi" "system_containers" "Agile architecture containers" {
container "aadarchi" "system_containers_source" "Agile architecture containers" {
include *
}
component "aadarchi_base" "base_components" "Agile architecture base components view" {
component "aadarchi_base" "base_components_source" "Agile architecture base components view" {
include *
}
filtered "system_containers_source" include "Element,Relationship,auto-include" "system_containers" "Agile architecture containers"
filtered "base_components_source" include "Element,Relationship,auto-include" "base_components" "Agile architecture base components view"
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
== base components

[plantuml, {plantumldir}base_components, svg, opts="inline"]
[plantuml, {plantumldir}base_components_source, svg, opts="inline"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faut utiliser la vue générée, et pas la vue source

----
include::{structurizrdir}/base_components.plantuml[]
include::{structurizrdir}/base_components_source.plantuml[]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faut utiliser la vue générée, et pas la vue source

----

== base interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
:chapter: Software%20Architecture
include::_notify-bug-admonition.adoc[]

[plantuml, {plantumldir}system_containers, svg, opts="inline"]
[plantuml, {plantumldir}system_containers_source, svg, opts="inline"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faut utiliser la vue générée, et pas la vue source

----
include::{structurizrdir}/system_containers.plantuml[]
include::{structurizrdir}/system_containers_source.plantuml[]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faut utiliser la vue générée, et pas la vue source

----

**TODO**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import javax.enterprise.inject.Instance;
import javax.inject.Inject;

import com.structurizr.view.FilteredView;
import org.apache.commons.lang3.time.StopWatch;
import org.apache.deltaspike.core.api.config.ConfigProperty;
import org.ndx.aadarchi.base.enhancers.ModelElementKeys;
import org.ndx.aadarchi.base.enhancers.ModelElementKeys.ConfigProperties.EnhancementsDir;
import org.ndx.aadarchi.base.utils.SimpleOutputBuilder;

Expand Down Expand Up @@ -125,6 +125,13 @@ private void enhancerVisitViews(ViewEnhancer enhancer, ViewSet viewset) {
views.filter(s -> withClassLoader(() -> enhancer.startVisit(s)))
.forEach(s -> withClassLoader(() -> enhancer.endVisit(s, outputBuilder)));
enhancer.endVisit(viewset, outputBuilder);

Stream<FilteredView> filteredViews = viewset.getFilteredViews().stream();
if (enhancer.isParallel())
filteredViews = filteredViews.parallel();
filteredViews.filter(s -> withClassLoader(() -> enhancer.startVisit(s)))
.forEach(s -> withClassLoader(() -> enhancer.endVisit(s, outputBuilder)));
enhancer.endVisit(viewset, outputBuilder);
}
}

Expand Down
5 changes: 5 additions & 0 deletions base/src/main/java/org/ndx/aadarchi/base/ViewEnhancer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ndx.aadarchi.base;

import com.structurizr.view.FilteredView;
import com.structurizr.view.View;
import com.structurizr.view.ViewSet;

Expand All @@ -8,7 +9,11 @@ public interface ViewEnhancer extends Enhancer {

boolean startVisit(View s);

boolean startVisit(FilteredView filteredView);

void endVisit(View s, OutputBuilder builder);

void endVisit(ViewSet viewset, OutputBuilder builder);

void endVisit(FilteredView filteredView, OutputBuilder builder);
}
17 changes: 11 additions & 6 deletions base/src/main/java/org/ndx/aadarchi/base/enhancers/ToDsl.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import javax.inject.Inject;

import com.structurizr.view.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -29,12 +30,6 @@
import com.structurizr.model.Person;
import com.structurizr.model.Relationship;
import com.structurizr.model.SoftwareSystem;
import com.structurizr.view.ComponentView;
import com.structurizr.view.ContainerView;
import com.structurizr.view.SystemContextView;
import com.structurizr.view.SystemLandscapeView;
import com.structurizr.view.View;
import com.structurizr.view.ViewSet;

/**
* Enhancer that generate a structurizr dsl file The dsl file is used to
Expand Down Expand Up @@ -243,6 +238,11 @@ public boolean startVisit(View s) {
return true;
}

@Override
public boolean startVisit(FilteredView filteredView) {
return true;
}

@Override
public void endVisit(View s, OutputBuilder builder) {
String PLACEHOLDER = "\t\t\tWARNING: Include and autolayout can't be infered from static view content, so you'll have to set that yourself\n\t\t}\n";
Expand Down Expand Up @@ -278,4 +278,9 @@ public void endVisit(View s, OutputBuilder builder) {
public void endVisit(ViewSet viewset, OutputBuilder builder) {
architecture += "\n";
}

@Override
public void endVisit(FilteredView filteredView, OutputBuilder builder) {
architecture += "\n";
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
package org.ndx.aadarchi.base.enhancers;

import com.structurizr.view.*;
import org.ndx.aadarchi.base.OutputBuilder;
import org.ndx.aadarchi.base.ViewEnhancer;

import com.structurizr.Workspace;
import com.structurizr.view.ComponentView;
import com.structurizr.view.ContainerView;
import com.structurizr.view.CustomView;
import com.structurizr.view.DeploymentView;
import com.structurizr.view.DynamicView;
import com.structurizr.view.SystemContextView;
import com.structurizr.view.SystemLandscapeView;
import com.structurizr.view.View;
import com.structurizr.view.ViewSet;

/**
* The view enhancer adapter allow visiting all view, and provides detailed informations about the view type.
Expand Down Expand Up @@ -85,6 +77,15 @@ protected boolean startVisit(CustomView c) {
return false;
}

@Override
public boolean startVisit(FilteredView filteredView) {
return true;
}

@Override
public void endVisit(FilteredView filteredView, OutputBuilder builder) {
}

@Override
public void endVisit(View s, OutputBuilder builder) {
if (s instanceof CustomView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

import com.structurizr.view.*;
import org.apache.deltaspike.core.api.config.ConfigProperty;
import org.ndx.aadarchi.base.OutputBuilder;
import org.ndx.aadarchi.base.ViewEnhancer;
Expand All @@ -20,10 +21,6 @@
import com.structurizr.Workspace;
import com.structurizr.annotation.Component;
import com.structurizr.export.plantuml.C4PlantUMLExporter;
import com.structurizr.view.ComponentView;
import com.structurizr.view.ContainerView;
import com.structurizr.view.View;
import com.structurizr.view.ViewSet;

/**
* Generates all graph and output them in the {@link #destination} folder
Expand Down Expand Up @@ -63,6 +60,9 @@ public int priority() {
@Override
public boolean startVisit(View s) { return true; }

@Override
public boolean startVisit(FilteredView filteredView) { return true; }

/**
* At view end visit, we selectively remove the layout information if it is layout with legend
*/
Expand All @@ -78,6 +78,11 @@ public void endVisit(ViewSet viewset, OutputBuilder builder) {
logger.info(String.format("All views should have been output to %s", destination.getAbsolutePath()));
}

@Override
public void endVisit(FilteredView filteredView, OutputBuilder builder) {
logger.info(String.format("All views should have been output to %s", destination.getAbsolutePath()));
}

@Override
public boolean startVisit(Workspace workspace, OutputBuilder builder) {
writeAllViews(workspace);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.ndx.aadarchi.base.enhancers.graph;

import java.util.logging.Logger;

import javax.inject.Inject;

import org.ndx.aadarchi.base.OutputBuilder;
import org.ndx.aadarchi.base.enhancers.ViewEnhancerAdapter;

import com.structurizr.view.ComponentView;
import com.structurizr.view.ContainerView;
import com.structurizr.view.FilteredView;
import com.structurizr.view.View;
import com.structurizr.view.ViewSet;


public class ViewUpdater extends ViewEnhancerAdapter {
private static final String INCLUDE_TAG = "auto-include";
@Inject Logger logger;
@Override
public boolean isParallel() {
// TODO Auto-generated method stub
return false;
}

@Override
public int priority() {
return TOP_PRIORITY_FOR_INTERNAL_ENHANCERS+1;
}

@Override
public boolean startVisit(FilteredView filteredView) {
return true;
}

@Override
public void endVisit(FilteredView filteredView, OutputBuilder builder) {
if(filteredView.getTags().contains(INCLUDE_TAG)) {
View source = filteredView.getView();
if(source instanceof ComponentView) {
((ComponentView) source).addAllComponents();
} else if(source instanceof ContainerView) {
((ContainerView) source).addAllContainersAndInfluencers();
}
}
super.endVisit(filteredView, builder);
}

public void endVisit(ViewSet v, OutputBuilder b) {
if(v.getFilteredViews().isEmpty()) {
logger.warning("There are no filtered views in viewset, so we don't add any discovered container/component");
}
}
}