Skip to content

Commit

Permalink
Adapt plantuml for applicationComponent
Browse files Browse the repository at this point in the history
close #68
  • Loading branch information
mauvaisetroupe committed Oct 19, 2022
1 parent 55d6ff1 commit f30180b
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FunctionalFlowStep implements Serializable, Comparable<FunctionalFl
@ManyToOne(optional = false)
@JoinColumn(name = "interfaces_id")
@NotNull
@JsonIgnoreProperties(value = { "sourceComponent", "targetComponent", "owner", "steps" }, allowSetters = true)
@JsonIgnoreProperties(value = { "owner", "steps" }, allowSetters = true)
private FlowInterface flowInterface;

@ManyToOne(optional = false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mauvaisetroupe.eadesignit.service.drawio;

import com.mauvaisetroupe.eadesignit.domain.ApplicationComponent;
import com.mauvaisetroupe.eadesignit.domain.FlowInterface;
import com.mauvaisetroupe.eadesignit.domain.FunctionalFlow;
import com.mauvaisetroupe.eadesignit.domain.FunctionalFlowStep;
Expand Down Expand Up @@ -30,17 +31,13 @@ public GraphDTO createGraph(LandscapeView landscape) {
for (FunctionalFlow flow : landscape.getFlows()) {
for (FunctionalFlowStep step : flow.getSteps()) {
FlowInterface interface1 = step.getFlowInterface();
graph.addApplication(new Application(interface1.getSource().getId(), interface1.getSource().getName()));
graph.addApplication(new Application(interface1.getTarget().getId(), interface1.getTarget().getName()));
Application source = getApplication(interface1.getSource(), interface1.getSourceComponent());
graph.addApplication(source);
Application target = getApplication(interface1.getTarget(), interface1.getTargetComponent());
graph.addApplication(target);
String id = flow.getId() + "-" + interface1.getId();
String url = "/functional-flow/" + flow.getId() + "/view";
Edge edge = new Edge(
id,
interface1.getSource().getId(),
interface1.getTarget().getId(),
new Label(flow.getAlias(), url),
false
);
Edge edge = new Edge(id, source.getId(), target.getId(), new Label(flow.getAlias(), url), false);
graph.addEdge(edge);
}
}
Expand All @@ -52,15 +49,17 @@ public GraphDTO createGraph(FunctionalFlow flow) {
GraphDTO graph = new GraphDTO();
for (FunctionalFlowStep step : flow.getSteps()) {
FlowInterface interface1 = step.getFlowInterface();
graph.addApplication(new Application(interface1.getSource().getId(), interface1.getSource().getName()));
graph.addApplication(new Application(interface1.getTarget().getId(), interface1.getTarget().getName()));
Application source = getApplication(interface1.getSource(), interface1.getSourceComponent());
graph.addApplication(source);
Application target = getApplication(interface1.getTarget(), interface1.getTargetComponent());
graph.addApplication(target);
String id = flow.getId() + "-" + interface1.getId();
String _label = step.getStepOrder() + ". " + WordUtils.wrap(step.getDescription(), 50, "\\n", false);
Label label = new Label(_label, null);
if (interface1.getProtocol() != null) {
label.addMetadata(KEY_PROTOCOL, interface1.getProtocol().getName());
}
Edge edge = new Edge(id, interface1.getSource().getId(), interface1.getTarget().getId(), label, false);
Edge edge = new Edge(id, source.getId(), target.getId(), label, false);
graph.addEdge(edge);
}
graph.consolidateEdges();
Expand All @@ -70,18 +69,32 @@ public GraphDTO createGraph(FunctionalFlow flow) {
public GraphDTO createGraph(SortedSet<FlowInterfaceLight> interfaces) {
GraphDTO graph = new GraphDTO();
for (FlowInterfaceLight interface1 : interfaces) {
graph.addApplication(new Application(interface1.getSource().getId(), interface1.getSource().getName()));
graph.addApplication(new Application(interface1.getTarget().getId(), interface1.getTarget().getName()));
Application source = getApplication(interface1.getSource(), interface1.getSourceComponent());
graph.addApplication(source);
Application target = getApplication(interface1.getTarget(), interface1.getTargetComponent());
graph.addApplication(target);
Long id = interface1.getId();
String label = interface1.getAlias();
String url = "/flow-interface/" + interface1.getId() + "/view";
Edge edge = new Edge("" + id, interface1.getSource().getId(), interface1.getTarget().getId(), new Label(label, url), false);
Edge edge = new Edge("" + id, source.getId(), target.getId(), new Label(label, url), false);
graph.addEdge(edge);
}
graph.consolidateEdges();
return graph;
}

private Application getApplication(com.mauvaisetroupe.eadesignit.domain.Application application, ApplicationComponent component) {
if (component != null && component.getDisplayInLandscape() != null && component.getDisplayInLandscape()) {
return new Application(
component.getId(),
application.getName() + " / " + component.getName(),
"/application-component/" + component.getId() + "/view"
);
} else {
return new Application(application.getId(), application.getName(), "/application/" + application.getId() + "/view");
}
}

public GraphDTO createGraph(Document doc) throws XPathExpressionException {
GraphDTO graph = new GraphDTO();
Map<Long, Application> aMap = new HashMap<>();
Expand All @@ -98,7 +111,7 @@ public GraphDTO createGraph(Document doc) throws XPathExpressionException {
String elementIdValue = ((Element) nodeList.item(i)).getAttribute("elementId");
Long id = Long.parseLong(elementIdValue.replace(MXFileSerializer.APP_ID_PREFIX, ""));
String applicationName = ((Element) nodeList.item(i)).getAttribute("value");
Application application = new Application(id, applicationName);
Application application = new Application(id, applicationName, null);
graph.addApplication(application);
aMap.put(application.getId(), application);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ public class Application {

private Long id;
private String name;
private String url;

public Application(Long id, String name) {
public Application(Long id, String name, String url) {
this.id = id;
this.name = name;
this.url = url;
}

// Getter and setters
Expand All @@ -27,4 +29,12 @@ public String getName() {
public void setName(String name) {
this.name = name;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void createComponent(StringBuilder plantUMLSource, Application applicatio
} else {
plantUMLSource.append("component [" + application.getName() + "] as C" + application.getId() + "\n");
}
plantUMLSource.append("url of C" + application.getId() + " is [[/application/" + application.getId() + "/view]]\n");
plantUMLSource.append("url of C" + application.getId() + " is [[" + application.getUrl() + "]]\n");
}

public void getPlantumlFooter(StringBuilder plantUMLSource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@
}}</router-link>
</div>
</dd>
<dt>
<span>Target</span>
</dt>
<dd>
<div v-if="flowInterface.target">
<router-link :to="{ name: 'ApplicationView', params: { applicationId: flowInterface.target.id } }">{{
flowInterface.target.name
}}</router-link>
</div>
</dd>
<dt>
<span>Source Component</span>
</dt>
Expand All @@ -84,6 +74,16 @@
>
</div>
</dd>
<dt>
<span>Target</span>
</dt>
<dd>
<div v-if="flowInterface.target">
<router-link :to="{ name: 'ApplicationView', params: { applicationId: flowInterface.target.id } }">{{
flowInterface.target.name
}}</router-link>
</div>
</dd>
<dt>
<span>Target Component</span>
</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@
>
{{ step.flowInterface.source.name }}
</router-link>
<span v-if="step.flowInterface.id && step.flowInterface.sourceComponent">
/
<router-link
:to="{ name: 'ApplicationComponentView', params: { applicationComponentId: step.flowInterface.sourceComponent.id } }"
>{{ step.flowInterface.sourceComponent.name }}</router-link
>
</span>
</td>
<td>
<router-link
Expand All @@ -203,6 +210,13 @@
>
{{ step.flowInterface.target.name }}
</router-link>
<span v-if="step.flowInterface.id && step.flowInterface.targetComponent">
/
<router-link
:to="{ name: 'ApplicationComponentView', params: { applicationComponentId: step.flowInterface.targetComponent.id } }"
>{{ step.flowInterface.targetComponent.name }}</router-link
>
</span>
</td>

<td>
Expand Down

0 comments on commit f30180b

Please sign in to comment.