Skip to content

Commit

Permalink
remove capabilities from GraphBuilder
Browse files Browse the repository at this point in the history
(planned to add rectangle capabilities into application component)
(will be implemented separately)
  • Loading branch information
mauvaisetroupe committed Nov 16, 2023
1 parent 2adc66c commit d0c713c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,12 @@ public class Application {
private Long id;
private String name;
private String url;
private Set<String> capabilities;
private boolean actor;

public Set<String> getCapabilities() {
return capabilities;
}

public void setCapabilities(Set<String> capabilities) {
this.capabilities = capabilities;
}

public Application(Long id, String name, String url, Set<String> capabilities, boolean actor) {
public Application(Long id, String name, String url, boolean actor) {
this.id = id;
this.name = name;
this.url = url;
this.capabilities = capabilities;
this.actor = actor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import com.mauvaisetroupe.eadesignit.service.diagram.drawio.MXFileSerializer;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.stream.Collectors;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
Expand All @@ -31,17 +29,9 @@ public GraphDTO createGraph(LandscapeView landscape, boolean showLabels) {
for (FunctionalFlow flow : landscape.getFlows()) {
for (FunctionalFlowStep step : flow.getSteps()) {
FlowInterface interface1 = step.getFlowInterface();
Application source = getApplication(
interface1.getSource(),
interface1.getSourceComponent(),
getGapabilitiesForLandscape(interface1.getSource(), landscape)
);
Application source = getApplication(interface1.getSource(), interface1.getSourceComponent());
graph.addApplication(source);
Application target = getApplication(
interface1.getTarget(),
interface1.getTargetComponent(),
getGapabilitiesForLandscape(interface1.getTarget(), landscape)
);
Application target = getApplication(interface1.getTarget(), interface1.getTargetComponent());
graph.addApplication(target);
String id = flow.getId() + "-" + step.getStepOrder();
String url = "/functional-flow/" + flow.getId() + "/view";
Expand Down Expand Up @@ -70,22 +60,13 @@ public GraphDTO createGraph(LandscapeView landscape, boolean showLabels) {
return graph;
}

private Set<String> getGapabilitiesForLandscape(com.mauvaisetroupe.eadesignit.domain.Application application, LandscapeView landscape) {
return application
.getCapabilityApplicationMappings()
.stream()
.filter(c -> c.getLandscapes().contains(landscape))
.map(c -> c.getCapability().getName())
.collect(Collectors.toSet());
}

public GraphDTO createGraph(FunctionalFlow flow, boolean addStepOrder) {
GraphDTO graph = new GraphDTO();
for (FunctionalFlowStep step : flow.getSteps()) {
FlowInterface interface1 = step.getFlowInterface();
Application source = getApplication(interface1.getSource(), interface1.getSourceComponent(), null);
Application source = getApplication(interface1.getSource(), interface1.getSourceComponent());
graph.addApplication(source);
Application target = getApplication(interface1.getTarget(), interface1.getTargetComponent(), null);
Application target = getApplication(interface1.getTarget(), interface1.getTargetComponent());
graph.addApplication(target);
String id = flow.getId() + "-" + step.getStepOrder();
String _label = (addStepOrder ? step.getStepOrder() + ". " : "") + WordUtils.wrap(step.getDescription(), 50, "\\n", false);
Expand Down Expand Up @@ -121,9 +102,9 @@ private void addGroupInGraph(GraphDTO graph, FunctionalFlowStep step) {
public GraphDTO createGraph(SortedSet<IFlowInterface> interfaces, boolean showLabels) {
GraphDTO graph = new GraphDTO();
for (IFlowInterface interface1 : interfaces) {
Application source = getApplication(interface1.getSource(), interface1.getSourceComponent(), null);
Application source = getApplication(interface1.getSource(), interface1.getSourceComponent());
graph.addApplication(source);
Application target = getApplication(interface1.getTarget(), interface1.getTargetComponent(), null);
Application target = getApplication(interface1.getTarget(), interface1.getTargetComponent());
graph.addApplication(target);
Long id = interface1.getId();
String label = interface1.getAlias();
Expand Down Expand Up @@ -152,30 +133,24 @@ public GraphDTO createGraph(SortedSet<IFlowInterface> interfaces, boolean showLa
return graph;
}

private Application getApplication(
com.mauvaisetroupe.eadesignit.domain.Application application,
ApplicationComponent component,
Set<String> capabilities
) {
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",
capabilities,
application.getApplicationType() == ApplicationType.ACTOR
);
} else {
return getApplication(application, capabilities);
return getApplication(application);
}
}

private Application getApplication(com.mauvaisetroupe.eadesignit.domain.Application application, Set<String> capabilities) {
private Application getApplication(com.mauvaisetroupe.eadesignit.domain.Application application) {
return new Application(
application.getId(),
application.getName(),
"/application/" + application.getId() + "/view",
capabilities,
application.getApplicationType() == ApplicationType.ACTOR
);
}
Expand All @@ -190,7 +165,7 @@ private void addInApplicationsGroup(
) {
if (component != null && component.getDisplayInLandscape() != null && component.getDisplayInLandscape()) {
// Add in group the component
graph.addApplicationIngroup(groupName, getApplication(myApplication, getGapabilitiesForLandscape(myApplication, landscape)));
graph.addApplicationIngroup(groupName, getApplication(myApplication));
// Add in group the application itself
// Bug in smetana, cannont add link from/to package,
// so add the application itself in the package as a subcomponent
Expand All @@ -214,7 +189,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, null, null, false);
Application application = new Application(id, applicationName, null, false);
graph.addApplication(application);
aMap.put(application.getId(), application);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,28 +165,13 @@ private String getComponentByNameOrId(Application application, boolean useID, Di
return open + application.getName() + close;
}

public void createComponentWithId(
StringBuilder plantUMLSource,
Application application,
DiagramType diagramType,
boolean addCapabilities
) {
public void createComponentWithId(StringBuilder plantUMLSource, Application application, DiagramType diagramType) {
if (diagramType == DiagramType.SEQUENCE_DIAGRAM) {
String type = application.isActor() ? "actor" : "participant";
plantUMLSource.append(type + " \"" + application.getName() + "\" as C" + application.getId() + "\n");
} else {
String type = application.isActor() ? "actor" : "component";
if (!addCapabilities || application.getCapabilities() == null || application.getCapabilities().size() == 0) {
plantUMLSource.append(type + " \"" + application.getName() + "\" as C" + application.getId() + "\n");
} else {
plantUMLSource.append(type + " \"" + application.getName() + "\" as C" + application.getId() + "{\n");
application
.getCapabilities()
.forEach(c -> {
plantUMLSource.append(" rectangle \"" + application.getId() + "." + c + "\"\n");
});
plantUMLSource.append("}\n");
}
plantUMLSource.append(type + " \"" + application.getName() + "\" as C" + application.getId() + "\n");
}
plantUMLSource.append("url of C" + application.getId() + " is [[" + application.getUrl() + "]]\n");
}
Expand Down Expand Up @@ -244,17 +229,11 @@ public void getLegend(StringBuilder plantUMLSource, List<String[]> legend) {
plantUMLSource.append("End Legend\n");
}

public void getPlantumlPackage(
StringBuilder plantUMLSource,
String packageName,
List<Application> applications,
boolean useID,
boolean addCapabilities
) {
public void getPlantumlPackage(StringBuilder plantUMLSource, String packageName, List<Application> applications, boolean useID) {
plantUMLSource.append("package \"" + packageName + "\" {\n");
for (Application application : applications) {
if (useID) {
createComponentWithId(plantUMLSource, application, DiagramType.COMPONENT_DIAGRAM, addCapabilities);
createComponentWithId(plantUMLSource, application, DiagramType.COMPONENT_DIAGRAM);
} else {
plantUMLSource.append(getComponentByNameOrId(application, useID, DiagramType.COMPONENT_DIAGRAM));
plantUMLSource.append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private String createPlantUMLSource(
// itś not possible to add an URL for an Application or an ApplicationComponent inside a reliation [A] -> [B]
// so we need to create a component for each Application / ApplicationComponent
// and associate the URL to that componnet
plantUMLBuilder.createComponentWithId(plantUMLSource, application, diagramType, false);
plantUMLBuilder.createComponentWithId(plantUMLSource, application, diagramType);
useID = true;
}
} else {
Expand All @@ -93,7 +93,7 @@ private String createPlantUMLSource(
if (groupComponents) {
// crerate groups (packages)
for (Entry<String, List<Application>> groupEntry : graph.getApplicationGroups().entrySet()) {
plantUMLBuilder.getPlantumlPackage(plantUMLSource, groupEntry.getKey(), groupEntry.getValue(), useID, false);
plantUMLBuilder.getPlantumlPackage(plantUMLSource, groupEntry.getKey(), groupEntry.getValue(), useID);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,39 @@ public class PLantumlToDrawioPositionerTest {
@Test
void testGetPosition() throws ParserConfigurationException, SAXException, IOException, XPathExpressionException, URISyntaxException {
Collection<Application> applications = new ArrayList<>();
applications.add(new Application(1L, "Accounts Service", null, null, false));
applications.add(new Application(2L, "Apple pay", null, null, false));
applications.add(new Application(3L, "Apple push notification service", null, null, false));
applications.add(new Application(4L, "BILnet", null, null, false));
applications.add(new Application(6L, "Cards Service", null, null, false));
applications.add(new Application(7L, "Decibel", null, null, false));
applications.add(new Application(8L, "Financial instruments service", null, null, false));
applications.add(new Application(9L, "Google Analytics", null, null, false));
applications.add(new Application(10L, "Google Firebase", null, null, false));
applications.add(new Application(11L, "IBM Campaign", null, null, false));
applications.add(new Application(12L, "Identity manager", null, null, false));
applications.add(new Application(13L, "Instant Payments service", null, null, false));
applications.add(new Application(14L, "Investor profile service", null, null, false));
applications.add(new Application(15L, "Kondor+", null, null, false));
applications.add(new Application(16L, "Loans service", null, null, false));
applications.add(new Application(17L, "Luxtrust", null, null, false));
applications.add(new Application(18L, "Marketing Files, Forms, FactSet", null, null, false));
applications.add(new Application(19L, "Party Service", null, null, false));
applications.add(new Application(20L, "Payconiq", null, null, false));
applications.add(new Application(201L, "Payconiq service", null, null, false));
applications.add(new Application(21L, "Payments service", null, null, false));
applications.add(new Application(22L, "Portfolios Service", null, null, false));
applications.add(new Application(23L, "Product Mandates service", null, null, false));
applications.add(new Application(24L, "PSD2 Payments Service", null, null, false));
applications.add(new Application(25L, "Report Data Collector", null, null, false));
applications.add(new Application(26L, "RT notif Service", null, null, false));
applications.add(new Application(27L, "Secured message service", null, null, false));
applications.add(new Application(28L, "Sirius", null, null, false));
applications.add(new Application(29L, "Six Payments", null, null, false));
applications.add(new Application(30L, "T24", null, null, false));
applications.add(new Application(31L, "Trading service", null, null, false));
applications.add(new Application(32L, "Trust Service", null, null, false));
applications.add(new Application(33L, "User settings service", null, null, false));
applications.add(new Application(1L, "Accounts Service", null, false));
applications.add(new Application(2L, "Apple pay", null, false));
applications.add(new Application(3L, "Apple push notification service", null, false));
applications.add(new Application(4L, "BILnet", null, false));
applications.add(new Application(6L, "Cards Service", null, false));
applications.add(new Application(7L, "Decibel", null, false));
applications.add(new Application(8L, "Financial instruments service", null, false));
applications.add(new Application(9L, "Google Analytics", null, false));
applications.add(new Application(10L, "Google Firebase", null, false));
applications.add(new Application(11L, "IBM Campaign", null, false));
applications.add(new Application(12L, "Identity manager", null, false));
applications.add(new Application(13L, "Instant Payments service", null, false));
applications.add(new Application(14L, "Investor profile service", null, false));
applications.add(new Application(15L, "Kondor+", null, false));
applications.add(new Application(16L, "Loans service", null, false));
applications.add(new Application(17L, "Luxtrust", null, false));
applications.add(new Application(18L, "Marketing Files, Forms, FactSet", null, false));
applications.add(new Application(19L, "Party Service", null, false));
applications.add(new Application(20L, "Payconiq", null, false));
applications.add(new Application(201L, "Payconiq service", null, false));
applications.add(new Application(21L, "Payments service", null, false));
applications.add(new Application(22L, "Portfolios Service", null, false));
applications.add(new Application(23L, "Product Mandates service", null, false));
applications.add(new Application(24L, "PSD2 Payments Service", null, false));
applications.add(new Application(25L, "Report Data Collector", null, false));
applications.add(new Application(26L, "RT notif Service", null, false));
applications.add(new Application(27L, "Secured message service", null, false));
applications.add(new Application(28L, "Sirius", null, false));
applications.add(new Application(29L, "Six Payments", null, false));
applications.add(new Application(30L, "T24", null, false));
applications.add(new Application(31L, "Trading service", null, false));
applications.add(new Application(32L, "Trust Service", null, false));
applications.add(new Application(33L, "User settings service", null, false));

//InputStream stream = PLantumlToDrawioPositionerTest.class.getResourceAsStream("/com/mauvaisetroupe/eadesignit/service/diagram/drawio/svg.xml");
ResourceLoader resourceLoader = new DefaultResourceLoader();
Expand Down

0 comments on commit d0c713c

Please sign in to comment.