|
@@ -122,28 +122,28 @@ public class DiagramController {
|
|
|
private void buildLinesAndNodes(Diagram diagram, Map<String, Object> map) {
|
|
|
Optional.ofNullable(map.get("lines")).ifPresent(lines ->
|
|
|
diagram.setLines(Arrays.asList(parser.parseContent(parser.toJson(lines), Line[].class))));
|
|
|
- Optional.ofNullable(map.get("template")).ifPresent(template -> {
|
|
|
- List<DiagramNode> nodes = new ArrayList<>();
|
|
|
- Optional.ofNullable(parser.parseContent(parser.toJson(template), DiagramTemplate.class)).ifPresent(diagramTemplate -> {
|
|
|
- List<Container> containers = diagramTemplate.getContainers();
|
|
|
- if (CollectionUtil.isNotEmpty(containers)) {
|
|
|
- containers.forEach(container -> {
|
|
|
- if (container.isEquipmentBox()) {
|
|
|
- List<IComponent> children = container.getChildren();
|
|
|
- if (CollectionUtil.isNotEmpty(children)) {
|
|
|
- children.forEach(iComponent -> {
|
|
|
- if (StrUtil.equalsIgnoreCase(iComponent.getCompType(), EquipmentNode.TYPE)) {
|
|
|
- DiagramNode node = parser.parseContent(parser.toJson(iComponent), DiagramNode.class);
|
|
|
- nodes.add(node);
|
|
|
- }
|
|
|
- });
|
|
|
+ List<DiagramNode> nodes = new ArrayList<>();
|
|
|
+ Optional.ofNullable(map.get("template")).flatMap(template ->
|
|
|
+ Optional.ofNullable(parser.parseContent(parser.toJson(template), DiagramTemplate.class)))
|
|
|
+ .ifPresent(diagramTemplate -> {
|
|
|
+ List<Container> containers = diagramTemplate.getContainers();
|
|
|
+ if (CollectionUtil.isNotEmpty(containers)) {
|
|
|
+ containers.forEach(container -> {
|
|
|
+ if (container.isEquipmentBox()) {
|
|
|
+ List<IComponent> children = container.getChildren();
|
|
|
+ if (CollectionUtil.isNotEmpty(children)) {
|
|
|
+ children.forEach(iComponent -> {
|
|
|
+ if (StrUtil.equalsIgnoreCase(iComponent.getCompType(), EquipmentNode.TYPE)) {
|
|
|
+ DiagramNode node = parser.parseContent(parser.toJson(iComponent), DiagramNode.class);
|
|
|
+ nodes.add(node);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- diagram.setNodes(nodes);
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ diagram.setNodes(nodes);
|
|
|
}
|
|
|
|
|
|
/**
|