From 4e498998614b0133af7999e2d01c04dd78d14df2 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 27 Dec 2023 15:09:19 -0500 Subject: [PATCH] 2023.12.1 --- bootstrap/pom.xml | 2 +- ecore/pom.xml | 2 +- emf/pom.xml | 2 +- html/pom.xml | 2 +- jstree/pom.xml | 2 +- model/app.drawio/.classpath | 40 -- model/app.drawio/.gitignore | 3 - model/app.drawio/.project | 23 - .../org.eclipse.core.resources.prefs | 5 - .../.settings/org.eclipse.jdt.core.prefs | 11 - .../.settings/org.eclipse.m2e.core.prefs | 4 - model/app.drawio/actions.yml | 16 - model/app.drawio/pom.xml | 51 -- model/app.drawio/readme.md | 117 ---- .../app.drawio/src/main/java/module-info.java | 12 - .../model/app/drawio/ConnectionProcessor.java | 165 ----- .../model/app/drawio/DocumentProcessor.java | 99 --- .../model/app/drawio/ElementProcessor.java | 44 -- .../html/model/app/drawio/LayerProcessor.java | 54 -- .../app/drawio/ModelElementProcessor.java | 655 ------------------ .../html/model/app/drawio/ModelProcessor.java | 18 - .../html/model/app/drawio/NodeProcessor.java | 274 -------- .../html/model/app/drawio/PageProcessor.java | 32 - .../model/app/drawio/ProcessorFactory.java | 40 -- .../model/app/drawio/ResourceFactory.java | 475 ------------- .../html/model/app/drawio/RoleRecord.java | 8 - .../html/model/app/drawio/RootProcessor.java | 68 -- .../html/model/app/tests/TestBase.java | 171 ----- .../html/model/app/tests/TestPage.java | 30 - .../nasdanika/html/model/app/tests/page.yml | 34 - model/app.gen.maven.archetype/pom.xml | 2 +- .../resources/archetype-resources/pom.xml | 4 +- model/app.gen.maven/pom.xml | 6 +- .../src/main/java/module-info.java | 1 + .../gen/maven/ActionSiteGeneratorMojo.java | 29 + model/app.gen/pom.xml | 11 +- model/app.graph/pom.xml | 2 +- model/app/pom.xml | 2 +- model/bootstrap.gen/pom.xml | 2 +- model/bootstrap/pom.xml | 2 +- model/html.gen/pom.xml | 2 +- model/html/pom.xml | 2 +- pom.xml | 26 +- 43 files changed, 64 insertions(+), 2486 deletions(-) delete mode 100644 model/app.drawio/.classpath delete mode 100644 model/app.drawio/.gitignore delete mode 100644 model/app.drawio/.project delete mode 100644 model/app.drawio/.settings/org.eclipse.core.resources.prefs delete mode 100644 model/app.drawio/.settings/org.eclipse.jdt.core.prefs delete mode 100644 model/app.drawio/.settings/org.eclipse.m2e.core.prefs delete mode 100644 model/app.drawio/actions.yml delete mode 100644 model/app.drawio/pom.xml delete mode 100644 model/app.drawio/readme.md delete mode 100644 model/app.drawio/src/main/java/module-info.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ConnectionProcessor.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/DocumentProcessor.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ElementProcessor.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/LayerProcessor.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ModelElementProcessor.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ModelProcessor.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/NodeProcessor.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/PageProcessor.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ProcessorFactory.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ResourceFactory.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/RoleRecord.java delete mode 100644 model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/RootProcessor.java delete mode 100644 model/app.drawio/src/test/java/org/nasdanika/html/model/app/tests/TestBase.java delete mode 100644 model/app.drawio/src/test/java/org/nasdanika/html/model/app/tests/TestPage.java delete mode 100644 model/app.drawio/src/test/resources/org/nasdanika/html/model/app/tests/page.yml diff --git a/bootstrap/pom.xml b/bootstrap/pom.xml index 952e5075..a0c6efbf 100644 --- a/bootstrap/pom.xml +++ b/bootstrap/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 .. bootstrap diff --git a/ecore/pom.xml b/ecore/pom.xml index d88b5033..13cdfc92 100644 --- a/ecore/pom.xml +++ b/ecore/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 .. ecore diff --git a/emf/pom.xml b/emf/pom.xml index 38d906da..2e46ec21 100644 --- a/emf/pom.xml +++ b/emf/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 .. emf diff --git a/html/pom.xml b/html/pom.xml index 35ff6b65..90953e9e 100644 --- a/html/pom.xml +++ b/html/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 .. html diff --git a/jstree/pom.xml b/jstree/pom.xml index 535fb78d..f2f6ad1d 100644 --- a/jstree/pom.xml +++ b/jstree/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 .. jstree diff --git a/model/app.drawio/.classpath b/model/app.drawio/.classpath deleted file mode 100644 index d207ce7a..00000000 --- a/model/app.drawio/.classpath +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/model/app.drawio/.gitignore b/model/app.drawio/.gitignore deleted file mode 100644 index 042a4ebb..00000000 --- a/model/app.drawio/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/bin/ -/target/ -/.polyglot..META-INF_MANIFEST.MF diff --git a/model/app.drawio/.project b/model/app.drawio/.project deleted file mode 100644 index 9d66e65a..00000000 --- a/model/app.drawio/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - org.nasdanika.html.model.app.drawio - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - - diff --git a/model/app.drawio/.settings/org.eclipse.core.resources.prefs b/model/app.drawio/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 8bc0e1c8..00000000 --- a/model/app.drawio/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 -encoding/=UTF-8 diff --git a/model/app.drawio/.settings/org.eclipse.jdt.core.prefs b/model/app.drawio/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 15592371..00000000 --- a/model/app.drawio/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 -org.eclipse.jdt.core.compiler.compliance=17 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=17 diff --git a/model/app.drawio/.settings/org.eclipse.m2e.core.prefs b/model/app.drawio/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index 14b697b7..00000000 --- a/model/app.drawio/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/model/app.drawio/actions.yml b/model/app.drawio/actions.yml deleted file mode 100644 index 374ce877..00000000 --- a/model/app.drawio/actions.yml +++ /dev/null @@ -1,16 +0,0 @@ -app-action: - text: Drawio - location: app/drawio/index.html - uris: drawio - content: - content-markdown: - source: - content-resource: - location: readme.md - interpolate: true - navigation: - - app-link: - text: Javadoc - uris: javadoc - icon: fab fa-java - location: ../../maven-site/apidocs/org.nasdanika.html.model.app.drawio/module-summary.html diff --git a/model/app.drawio/pom.xml b/model/app.drawio/pom.xml deleted file mode 100644 index 626b4bb5..00000000 --- a/model/app.drawio/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - 4.0.0 - - parent - org.nasdanika.html - 2023.12.0 - ../.. - - app-model-drawio - jar - Resource factory for loading drawio diagrams as application models - https://docs.nasdanika.org/modules/html/modules/models/modules/app/modules/drawio/index.html - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - package - - jar - - - model - - model/** - - ${project.basedir} - - - - - - - - - - org.nasdanika.html - app-model - ${project.version} - - - org.nasdanika.core - drawio - ${core.version} - - - \ No newline at end of file diff --git a/model/app.drawio/readme.md b/model/app.drawio/readme.md deleted file mode 100644 index 25719067..00000000 --- a/model/app.drawio/readme.md +++ /dev/null @@ -1,117 +0,0 @@ -** On hold, excluded from the parent, needs refactoring to the new graph processor API ** - - -With ${javadoc/org.nasdanika.html.model.app.drawio.ResourceFactory} [action models](../model/index.html) can be loaded from [Drawio](https://www.diagrams.net/) diagrams. -In other words, a structure of a web site/application can be defined as a diagram. - -The below table contains a list of available demos which can be used as starting points for "diagram-as-a-web-application" efforts. - -Description | Site | Sources ------------ | ---- | ------- -Documentation generated from a component diagram | https://docs.nasdanika.org/demo-drawio-actions/index.html | https://github.com/Nasdanika/demo-drawio-actions -Process documentation generated from a flow diagram | https://docs.nasdanika.org/demo-drawio-flow-actions/index.html | https://github.com/Nasdanika/demo-drawio-flow-actions -A web site generated from a mind map diagram | https://docs.nasdanika.org/demo-drawio-map/index.html | https://github.com/Nasdanika/demo-drawio-map - -Loading can be customized at two levels: - -* Adding properties to diagram elements -* Sub-classing ``org.nasdanika.html.model.app.drawio.ResourceFactory`` - -The following section explains configuration properties. For sub-classing consult ``org.nasdanika.html.model.app.drawio.ResourceFactory`` javadoc and source code. - -#### Configuration - -##### default-connection-role - -Node property. -Value is used for ``role`` connection property (see below). -Default connection role is inherited from semantic parents to semantic children. - -##### default-connection-target-role - -Node property. Value is used for ``role`` of targets of outgoing connections. -Default connection target role is inherited from semantic parents to semantic children. -See ``target-role`` below for more details. - -##### documentation - -Location of [Markdown](/modules/core/modules/exec/modules/model/content/Markdown.html) documentation. -The location is resolved relative to the documentation location of the semantic parent (recursively) or relative to the Drawio document (file) location if there is no semantic parent or there is no documentation for the semantic parent. - -For pages and page elements documentation may contain ``${{diagram}}`` and ``${{toc}}`` tokens to insert the page diagram and a table of contents respectively. - -The page diagram is processed to link model element to action pages. -Additional processing can be added by overriding on of ``createXXXProcessor`` methods in the resource factory and then overriding ``processEmbeddedDiagramElement`` method in the processor. -For example, shapes can be styled based on information extracted from external systems: - -* Roadmap diagram elements can be styled based on status extracted from the issue tracking system. -* Component diagram elements can be styled: - * Based on construction status extracted from the issue tracking system for a system being built. - * Based on information extracted from monitoring tools - load, availablity - for already built systems. - -##### icon - -Optional icon for an action loaded from a model element. Treated as a URL if contains a slash (``/``) or as a CSS class otherwise, e.g. ``fas fa-project-diagram`` a [Font Awesome 5](https://fontawesome.com/v5/search) project diagram icon. - -##### page-element - -Set it to ``true`` for the root element on the page, specifically for linked pages. - -For example, on the [Living Beings](https://docs.nasdanika.org/demo-drawio-map/) diagram [Cat](https://docs.nasdanika.org/demo-drawio-map/children/1350/children/1369/index.html) is linked to the ``Cat`` page with the ``Cat`` element being the page element. -As such, semantic children of the Cat element on the Cat page (Havana Brown, Maine Coon, and Savannah) are "mounted" to the Cat element on the main diagram. - -Please note that with page linking documentation shall be provided on the linking element, e.g. the Cat element on the main diagram. - -##### path - -``path`` property is used to form action location (URL). By default diagram element ID is used as path. You can specify path explicitly to have [clean URL's](https://en.wikipedia.org/wiki/Clean_URL). - -##### role - -Defines diagram element action type (role). -If present, one of: - -* ``anonymous`` - Connection target action is added to the anonymous actions of the source action. Anonymous actions are generated, but not auto-linked - they should be explicitly linked from the action content. -* ``child`` - Connection target action is added to the child actions of the source action. Child actions are shown in the left navigation panel. -* ``navigation`` - Connection target action is added to the navigation actions of the source action. Navigation actions are shown in: - * The footer for the root action, - * The navigation bar for the principal action, - * The section navigation for sections, - * Active action navigation for other actions. -* ``none`` - Clears role inherited from the semantic parent, if any. -* ``section`` - Connection target action is added to the section actions of the source action. Section actions are rendered as part of the parent action content. - -See [Action Types](../model/index.html#action-types) for additional details. - -##### root-page - -If a diagram file has multiple pages with some pages linked from others annotate linked pages with ``root-page`` set to ``false``. -In this case these pages of their page elements do not appear in the root of resource. -An alternative is to subclass the resource factory and explicitly select root resource elements from which to generate a web site. - -##### selector - -Use ``selector`` property to link a diagram element to an element on another diagram (page). -``selector`` value shall be a [Spring boolean expression](https://docs.spring.io/spring-framework/docs/5.3.24/reference/html/core.html#expressions). -The expression is evaluated in the context of a diagram element. - -Selectors allow to "reuse" the same element in multiple diagrams. - -For example, on the [Sample Integration](https://docs.nasdanika.org/demo-drawio-actions/children/218O8zdIhuJC0JnV0giS-1/children/218O8zdIhuJC0JnV0giS-2/index.html) diagram ``S3 Reference`` shape references [S3](https://docs.nasdanika.org/demo-drawio-actions/children/UEzPUAAOIrF-is8g5C7q-175/children/s3/index.html) node with ``getProperty('alias') == 's3'`` selector. - -##### sort - -Specifies how children shall be sorted. -Property value shall be in the form of ``[:config]`` where a type is one of: - -* ``clockwise`` or ``counterclockwise`` - sorts nodes clockwise and counterclockwise respectively relative to their semantic parent. Can be used in mind maps. May take base angle in degrees as optional configuration. Base angle defaults to 90 degrees (12 o'clock) if the semantic parent node does not have a semantic parent and to the angle between the parent and its parent otherwise. [Living beings](https://docs.nasdanika.org/demo-drawio-map/) mind map uses clockwise sort. -* ``label`` - sorts by label value. This is the default sort type. Optional ``descending`` configuration. -* ``property`` - sorts by property value (string). Optional ``descending`` configuration. - -##### target-role - -If this property is set for a connection and is not ``none`` or if ``default-target-role`` is not null or ``none`` then the connection establishes a semantic parent/child role between its source and target target role specifies the child's role. -See ``role`` for a list of supported values. - -The Living beings mind map uses ``default-target-role`` to establish semantic parent/child connections between nodes. - diff --git a/model/app.drawio/src/main/java/module-info.java b/model/app.drawio/src/main/java/module-info.java deleted file mode 100644 index 780f7f95..00000000 --- a/model/app.drawio/src/main/java/module-info.java +++ /dev/null @@ -1,12 +0,0 @@ -module org.nasdanika.html.model.app.drawio { - - requires transitive org.nasdanika.html.model.app; - requires transitive org.nasdanika.drawio; - requires org.jsoup; - requires org.nasdanika.exec; - requires org.eclipse.emf.common; - requires spring.expression; - requires org.nasdanika.html.model.bootstrap; - - exports org.nasdanika.html.model.app.drawio; -} diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ConnectionProcessor.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ConnectionProcessor.java deleted file mode 100644 index 20847917..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ConnectionProcessor.java +++ /dev/null @@ -1,165 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.function.Predicate; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.nasdanika.common.Util; -import org.nasdanika.drawio.Connection; -import org.nasdanika.drawio.Node; -import org.nasdanika.graph.processor.ProcessorConfig; -import org.nasdanika.html.model.app.Action; -import org.nasdanika.html.model.bootstrap.BootstrapFactory; -import org.nasdanika.html.model.bootstrap.Table; -import org.nasdanika.html.model.bootstrap.TableCell; -import org.nasdanika.html.model.bootstrap.TableRow; - -public class ConnectionProcessor extends ModelElementProcessor { - - @Override - public Connection getElement() { - return (Connection) super.getElement(); - } - - public ConnectionProcessor(ResourceFactory resourceFactory, URI uri, ProcessorConfig config, URI baseURI) { - super(resourceFactory, uri, config, baseURI); - } - - @Override - public String getText() { - String text = (getElement()).getLabel(); - if (Util.isBlank(text) && hasDocumentation()) { - Node source = getElement().getSource(); - String sourceText = source == null ? null : ((NodeProcessor) registry.infoMap().get(source).getProcessor()).getText(); - - Node target = getElement().getTarget(); - String targetText = target == null ? null : ((NodeProcessor) registry.infoMap().get(target).getProcessor()).getText(); - - if (Util.isBlank(sourceText) && Util.isBlank(targetText)) { - return null; - } - - StringBuilder textBuilder = new StringBuilder(); - if (!Util.isBlank(sourceText)) { - textBuilder.append(sourceText).append(" "); - } - textBuilder.append("->"); - if (!Util.isBlank(targetText)) { - textBuilder.append(" ").append(targetText); - } - return textBuilder.toString(); - } - return text; - } - - @Override - public void build() { - EObject se = getSemanticElement(); - if (se instanceof Action) { - Node source = getElement().getSource(); - Node target = getElement().getTarget(); - if (source != null || target != null) { - Action action = (Action) se; - // Source and target - Table table = BootstrapFactory.eINSTANCE.createTable(); - table.getAttributes().put("style", createText("width:auto")); - - if (source != null) { - TableRow sourceRow = BootstrapFactory.eINSTANCE.createTableRow(); - table.getRows().add(sourceRow); - - TableCell sourceHeader = BootstrapFactory.eINSTANCE.createTableCell(); - sourceHeader.setHeader(true); - sourceRow.getCells().add(sourceHeader); - sourceHeader.getContent().add(createText("Source")); - - TableCell sourceCell = BootstrapFactory.eINSTANCE.createTableCell(); - sourceRow.getCells().add(sourceCell); - - NodeProcessor sourceProcessor = (NodeProcessor) registry.infoMap().get(source).getProcessor(); - String sourceLabel = sourceProcessor.getText(); - if (Util.isBlank(sourceLabel)) { - sourceLabel = "(unlabeled)"; - } - String sourceLink = getModelElementLink(source); - if (sourceLink == null) { - sourceCell.getContent().add(createText(sourceLabel)); - } else { - sourceCell.getContent().add(createText("" + sourceLabel + "")); - } - } - - if (target != null) { - TableRow targetRow = BootstrapFactory.eINSTANCE.createTableRow(); - table.getRows().add(targetRow); - - TableCell targetHeader = BootstrapFactory.eINSTANCE.createTableCell(); - targetHeader.setHeader(true); - targetRow.getCells().add(targetHeader); - targetHeader.getContent().add(createText("Target")); - - TableCell targetCell = BootstrapFactory.eINSTANCE.createTableCell(); - targetRow.getCells().add(targetCell); - - NodeProcessor targetProcessor = (NodeProcessor) registry.infoMap().get(target).getProcessor(); - String targetLabel = targetProcessor.getText(); - if (Util.isBlank(targetLabel)) { - targetLabel = "(unlabeled)"; - } - String targetLink = getModelElementLink(target); - if (targetLink == null) { - targetCell.getContent().add(createText(targetLabel)); - } else { - targetCell.getContent().add(createText("" + targetLabel + "")); - } - } - - action.getContent().add(table); - } - } - super.build(); - } - - private String defaultConnectionTargetRoleName; - - public void setDefaultTargetRole(Registry registry, String defaultConnectionTargetRoleName, Predicate traversed) { - if (traversed.test(getElement())) { - this.defaultConnectionTargetRoleName = defaultConnectionTargetRoleName; - Node target = getElement().getTarget(); - if (target != null) { - NodeProcessor targetProcessor = (NodeProcessor) registry.infoMap().get(target).getProcessor(); - targetProcessor.setDefaultTargetConnectionRole(registry, defaultConnectionTargetRoleName, traversed); - } - } - } - - public EReference getTargetRole() { - String targetRoleProperty = resourceFactory.getTargetRoleProperty(); - if (!Util.isBlank(targetRoleProperty)) { - String targetRolePropertyName = getElement().getProperty(targetRoleProperty); - if (!Util.isBlank(targetRolePropertyName)) { - return resourceFactory.resolveRole(targetRolePropertyName); - } - } - return Util.isBlank(defaultConnectionTargetRoleName) ? null : resourceFactory.resolveRole(defaultConnectionTargetRoleName); - } - - @Override - public Map, EReference> setSemanticParentInfo(ProcessorInfo semanticParentInfo) { - Node target = getElement().getTarget(); - if (target == null) { - return super.setSemanticParentInfo(semanticParentInfo); - } - EReference targetRole = getTargetRole(); - if (targetRole == null) { - return super.setSemanticParentInfo(semanticParentInfo); - } - Map, EReference> ret = new LinkedHashMap<>(); - ((ModelElementProcessor) registry.infoMap().get(target).getProcessor()).setSemanticParentInfo(semanticParentInfo).entrySet().forEach(e -> ret.put(e.getKey(), targetRole)); - return ret; - } - -} diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/DocumentProcessor.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/DocumentProcessor.java deleted file mode 100644 index 229fe11b..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/DocumentProcessor.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.stream.Stream; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.nasdanika.drawio.Document; -import org.nasdanika.drawio.ModelElement; -import org.nasdanika.drawio.Page; -import org.nasdanika.graph.processor.ProcessorConfig; -import org.nasdanika.graph.processor.ProcessorInfo; -import org.nasdanika.graph.processor.emf.SemanticProcessor; -import org.nasdanika.html.model.app.Action; - -public class DocumentProcessor extends ElementProcessor implements SemanticProcessor { - - private Action documentAction; - - public DocumentProcessor(ResourceFactory resourceFactory, URI uri, ProcessorConfig config, URI baseURI) { - super(resourceFactory, uri, config, baseURI); - } - - @Override - public Document getElement() { - return (Document) super.getElement(); - } - - /** - * @return Semantic element for this processor. Can be created in advance or on access. - */ - @Override - public Collection getSemanticElements() { - return Collections.singleton(documentAction); - } - - /** - * Builds semantic element so it is ready for use. - */ - public Stream build() { - Action documentAction = resourceFactory.createDocumentAction(getElement()); - - List pages = new ArrayList<>(getElement().getPages()); - Comparator pageComparator = resourceFactory.getPageComparator(getElement()); - if (pageComparator != null) { - pages.sort(pageComparator); - } - - // Setting semantic hierarchy - Map, EReference> semanticChildrenInfo = new LinkedHashMap<>(); - for (Page page: pages) { - PageProcessor pageProcessor = (PageProcessor) registry.infoMap().get(page).getProcessor(); - if (pageProcessor.isRootPage()) { - ModelElement pageElement = pageProcessor.getPageElement(); - - ProcessorInfo semanticParentInfo = documentAction == null ? null : ProcessorInfo.of(config, this); - ModelElementProcessor pageElementProcessor = (ModelElementProcessor) registry.infoMap().get(pageElement).getProcessor(); - Map, EReference> pageElementSemanticInfo = pageElementProcessor.setSemanticParentInfo(semanticParentInfo); - semanticChildrenInfo.putAll(pageElementSemanticInfo); - } - } - - // Build semantic children recursively. - for (Entry, EReference> entry: semanticChildrenInfo.entrySet()) { - ModelElementProcessor processor = (ModelElementProcessor) entry.getKey().getProcessor(); - if (documentAction != null) { - EReference role = entry.getValue(); - if (role != null) { - @SuppressWarnings("unchecked") - Collection roleElements = (Collection) documentAction.eGet(role); - List semanticElements = processor.getSemanticElements(); - roleElements.addAll(semanticElements); - } - } - processor.build(); - } - - if (documentAction == null) { - return semanticChildrenInfo - .keySet() - .stream() - .map(ProcessorInfo::getProcessor) - .map(ModelElementProcessor.class::cast) - .map(ModelElementProcessor::getSemanticElements) - .flatMap(Collection::stream); - } - return Stream.of(documentAction); - } - -} - \ No newline at end of file diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ElementProcessor.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ElementProcessor.java deleted file mode 100644 index 6618ec48..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ElementProcessor.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import java.util.Map; - -import org.eclipse.emf.common.util.URI; -import org.nasdanika.graph.Element; -import org.nasdanika.graph.processor.ProcessorConfig; -import org.nasdanika.graph.processor.ProcessorInfo; - -/** - * Base class for processors. - * @author Pavel - * - */ -public class ElementProcessor { - - protected ResourceFactory resourceFactory; - protected ProcessorConfig config; - protected Map configs; // Processor records? - protected URI resourceURI; - protected URI baseURI; - - public ElementProcessor(ResourceFactory resourceFactory, URI resourceURI, ProcessorConfig config, URI baseURI) { - this.resourceFactory = resourceFactory; - this.resourceURI = resourceURI; - this.config = config; - this.baseURI = baseURI; - } - - public Element getElement() { - return config.getElement(); - } - - /** - * Does nothing. Override if parent info is needed. - * @param parentInfo - */ - public void setParentInfo(ProcessorInfo parentInfo) { } - - public void setRegistry(Map configs) { - this.configs = configs; // Processor records? - } - -} diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/LayerProcessor.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/LayerProcessor.java deleted file mode 100644 index 3ef80b00..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/LayerProcessor.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.stream.Stream; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EReference; -import org.nasdanika.drawio.Connection; -import org.nasdanika.drawio.Layer; -import org.nasdanika.graph.Element; -import org.nasdanika.graph.processor.ProcessorConfig; -import org.nasdanika.graph.processor.ProcessorInfo; - -public class LayerProcessor extends ModelElementProcessor { - - public LayerProcessor(ResourceFactory resourceFactory, URI uri, ProcessorConfig config, URI baseURI) { - super(resourceFactory, uri, config, baseURI); - } - - @Override - public Layer getElement() { - return (Layer) super.getElement(); - } - - @Override - public Map, EReference> collectSemanticChildrenInfo(ProcessorInfo semanticParentInfo) { - Stream, EReference>> superStream = super.collectSemanticChildrenInfo(semanticParentInfo).entrySet().stream(); - Stream, EReference>> childStream = config.getChildProcessorsInfo() - .values() - .stream() - .filter(ep -> { - // Connections with sources "belong" to source nodes. - Element e = ep.getConfig().getElement(); - return !(e instanceof Connection) || ((Connection) e).getSource() == null; - }) - .map(ProcessorInfo::getProcessor) - .map(ModelElementProcessor.class::cast) - .flatMap(p -> p.setSemanticParentInfo(semanticParentInfo).entrySet().stream()); - - Stream, EReference>> stream = Stream.concat(superStream, childStream); - - Comparator> semanticChildrenComparator = getSemanticChildrenComparator(); - if (semanticChildrenComparator != null) { - stream = stream.sorted((a, b) -> semanticChildrenComparator.compare(a.getKey(), b.getKey())); - } - - Map, EReference> ret = new LinkedHashMap<>(); - stream.forEach(e -> ret.put(e.getKey(), e.getValue())); - return ret; - } - -} diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ModelElementProcessor.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ModelElementProcessor.java deleted file mode 100644 index 20374953..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ModelElementProcessor.java +++ /dev/null @@ -1,655 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import javax.xml.parsers.ParserConfigurationException; - -import org.eclipse.emf.common.util.EMap; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.jsoup.Jsoup; -import org.nasdanika.common.Context; -import org.nasdanika.common.Util; -import org.nasdanika.drawio.Document; -import org.nasdanika.drawio.ModelElement; -import org.nasdanika.drawio.Page; -import org.nasdanika.drawio.Root; -import org.nasdanika.exec.Configurator; -import org.nasdanika.exec.ExecFactory; -import org.nasdanika.exec.content.ContentFactory; -import org.nasdanika.exec.content.Interpolator; -import org.nasdanika.exec.content.Markdown; -import org.nasdanika.exec.content.Text; -import org.nasdanika.graph.Element; -import org.nasdanika.graph.processor.ProcessorConfig; -import org.nasdanika.graph.processor.ProcessorInfo; -import org.nasdanika.graph.processor.emf.SemanticProcessor; -import org.nasdanika.html.model.app.Action; -import org.nasdanika.html.model.app.AppFactory; - -public class ModelElementProcessor extends ElementProcessor implements SemanticProcessor { - - protected List semanticChildren; - protected ProcessorInfo semanticParentInfo; - protected EObject semanticElement; - - protected ModelElementProcessor(ResourceFactory resourceFactory, URI uri, ProcessorConfig config, URI baseURI) { - super(resourceFactory, uri, config, baseURI); - } - - @Override - public ModelElement getElement() { - return (ModelElement) super.getElement(); - } - - /** - * @return true if this element creates one or more semantic elements and as such shall be passed as a semantic parent to setSemanticParentInfo(). - */ - protected boolean isSemantic() { - return !Util.isBlank(getText()) && resourceFactory.shallCreateAction(getElement()); - } - - public String getText() { - String label = (getElement()).getLabel(); - if (Util.isBlank(label) && hasDocumentation()) { - return "(unlabeled)"; - } - return Util.isBlank(label) ? null : Jsoup.parse(label).text(); - } - - /** - * @param semanticParentInfo - * @return Linked map of info to child role. - */ - public List setSemanticParentInfo(ProcessorInfo semanticParentInfo) { - if (isSemantic()) { - if (semanticParentInfo != null) { - ElementProcessor spp = semanticParentInfo.getProcessor(); - if (spp instanceof ModelElementProcessor && ((ModelElementProcessor) spp).isSemanticDescendant(getElement(), new HashSet<>()::add)) { - return Collections.emptyList(); - } - } - - this.semanticParentInfo = semanticParentInfo; - ProcessorInfo info = config.toInfo(this); - semanticChildren = collectSemanticChildrenInfo(info); - return Collections.singletonMap(info, getRole()); - } - - return collectSemanticChildrenInfo(semanticParentInfo); - } - - public List collectSemanticChildrenInfo(ProcessorInfo semanticParentInfo) { - Page linkedPage = getElement().getLinkedPage(); - if (linkedPage == null) { - return Collections.emptyList(); - } - PageProcessor pageProcessor = (PageProcessor) registry.infoMap().get(linkedPage).getProcessor(); - ModelElement pageElement = pageProcessor.getPageElement(); - ModelElementProcessor pageElementProcessor = (ModelElementProcessor) registry.infoMap().get(pageElement).getProcessor(); - return pageElementProcessor.collectSemanticChildrenInfo(semanticParentInfo); - } - - public void build() { - EObject semanticElement = getSemanticElement(); - if (semanticElement instanceof Action) { - Action action = (Action) semanticElement; - - EObject doc = getDocumentation(); - if (doc == null) { - String tooltip = getElement().getTooltip(); - if (!Util.isBlank(tooltip)) { - addContent(action, tooltip); - } - String embeddedDiagram = getEmbeddedDiagram(); - if (!Util.isBlank(embeddedDiagram)) { - addContent(action, embeddedDiagram); - } - String toc = getSemanticChildrenListOfContents(this); - if (!Util.isBlank(toc)) { - addContent(action, toc); - } - } else { - action.getContent().add(doc); - } - - // Adding children to roles and building - if (semanticChildrenInfo != null) { - for (Entry, EReference> childEntry: semanticChildrenInfo.entrySet()) { - ModelElementProcessor processor = (ModelElementProcessor) childEntry.getKey().getProcessor(); - EReference childRole = childEntry.getValue(); - if (childRole != null) { - @SuppressWarnings("unchecked") - Collection roleElements = (Collection) action.eGet(childRole); - roleElements.addAll(processor.getSemanticElements()); - } - processor.build(); - } - } - } - } - - protected String getSemanticID() { - return getElement().getId(); - } - - protected Document getEmbeddedDiagramDocument() throws ParserConfigurationException { - Page page = getElement().getModel().getPage(); - ModelElement pageElement = resourceFactory.getPageElement(page); - if (getElement().equals(pageElement)) { - Document toEmbed = Document.create(true, null); - toEmbed.getPages().add(page); - return toEmbed; - } - - Page linkedPage = getElement().getLinkedPage(); - if (linkedPage == null) { - return null; - } - PageProcessor linkedPageProcessor = (PageProcessor) registry.infoMap().get(linkedPage).getProcessor(); - ModelElement linkedPageElement = linkedPageProcessor.getPageElement(); - return ((ModelElementProcessor) registry.infoMap().get(linkedPageElement).getProcessor()).getEmbeddedDiagramDocument(); - } - - protected Comparator> getSemanticChildrenComparator() { - String sortProperty = resourceFactory.getSortProperty(); - String sort = null; - if (!org.nasdanika.common.Util.isBlank(sortProperty)) { - sort = (getElement()).getProperty(sortProperty); - } - if (org.nasdanika.common.Util.isBlank(sort)) { - // Inherit from semantic parent here? - sort = resourceFactory.getDefaultSort(); - } - - if (org.nasdanika.common.Util.isBlank(sort) || "none".equals(sort)) { - return null; - } - - String config = null; - int colonIdx = sort.indexOf(":"); - if (colonIdx != -1) { - config = sort.substring(colonIdx + 1); - sort = sort.substring(0, colonIdx); - } - - Comparator elementComparator = resourceFactory.createComparator(this.config.getElement(), sort, config); - if (elementComparator == null) { - return null; - } - - return (a,b) -> elementComparator.compare(a.getConfig().getElement(), b.getConfig().getElement()); - } - - public EReference getRole() { - return resourceFactory.getRole(getElement()); - } - - protected String getIcon() { - String iconProperty = resourceFactory.getIconProperty(); - ModelElement modelElement = getElement(); - return Util.isBlank(iconProperty) ? null : modelElement.getProperty(iconProperty); - } - - @Override - public List getSemanticElements() { - EObject semanticElement = getSemanticElement(); - if (semanticElement == null) { - return semanticChildrenInfo - .keySet() - .stream() - .map(ProcessorInfo::getProcessor) - .map(ModelElementProcessor.class::cast) - .map(ModelElementProcessor::getSemanticElements) - .flatMap(Collection::stream) - .collect(Collectors.toList()); - } - return Collections.singletonList(semanticElement); - } - - public EObject getSemanticElement() { - if (semanticElement == null) { - Action action; - Page linkedPage = getElement().getLinkedPage(); - if (linkedPage == null) { - String actionProperty = getElement().getProperty("action"); - if (Util.isBlank(actionProperty)) { - action = AppFactory.eINSTANCE.createAction(); - } else { - URI actionURI = URI.createURI(actionProperty); - actionURI = actionURI.resolve(resourceURI); - action = EcoreUtil.copy((Action) resourceFactory.getResourceSet().getEObject(actionURI, true)); - action.setId(UUID.randomUUID().toString()); - } - } else { - // TODO - handle content and diagram roles - by the page processor? - - ProcessorInfo pageInfo = registry.infoMap().get(linkedPage); - PageProcessor pageProcessor = (PageProcessor) pageInfo.getProcessor(); - ModelElement pageElement = pageProcessor.getPageElement(); - ModelElementProcessor pageElementProcessor = (ModelElementProcessor) registry.infoMap().get(pageElement).getProcessor(); - EObject pageSemanticElement = pageElementProcessor.getSemanticElement(); - if (pageSemanticElement instanceof Action) { - action = (Action) pageSemanticElement; - } else { - action = AppFactory.eINSTANCE.createAction(); - } - } - action.setId(getSemanticID()); - action.setText(getText()); - action.setDescription(getElement().getTooltip()); - String icon = getIcon(); - if (!Util.isBlank(icon)) { - action.setIcon(icon); - } - - EReference role = getRole(); - String path = getPath(); - if (!Util.isBlank(path) && path.startsWith("./")) { // A trick to avoid prepending location with role. - role = null; - path = path.substring(2); - } - StringBuilder locationBuilder = new StringBuilder(); - if (role != null) { - locationBuilder.append(role.getName()); - } - if (!Util.isBlank(path)) { - if (locationBuilder.length() > 0 && locationBuilder.charAt(locationBuilder.length() - 1) != '/') { - locationBuilder.append("/"); - } - locationBuilder.append(path); - } - if (locationBuilder.length() > 0 && locationBuilder.charAt(locationBuilder.length() - 1) != '/') { - locationBuilder.append("/"); - } - locationBuilder.append("index.html"); - action.setLocation(locationBuilder.toString()); - - semanticElement = action; - } - - return semanticElement; - } - - /** - * - * @return Absolute URI resolved relative to the semantic parent and eventually the baseURI. - */ - public URI getURI() { - EObject se = getSemanticElement(); - if (se instanceof Action) { - Action action = (Action) se; - String location = action.getLocation(); - if (!Util.isBlank(location)) { - URI actionURI = URI.createURI(Context.singleton(Context.BASE_URI_PROPERTY, baseURI).interpolateToString(location)); - if (semanticParentInfo != null) { - ElementProcessor sp = semanticParentInfo.getProcessor(); - if (sp instanceof ModelElementProcessor) { - URI spURI = ((ModelElementProcessor) sp).getURI(); - return actionURI.resolve(spURI); - } - } - return actionURI.resolve(baseURI); - } - } - - if (semanticParentInfo != null) { - ElementProcessor sp = semanticParentInfo.getProcessor(); - if (sp instanceof ModelElementProcessor) { - return ((ModelElementProcessor) sp).getURI(); - } - } - return null; - } - - protected String getPath() { - ModelElement modelElement = getElement(); - String pathProperty = resourceFactory.getPathProperty(); - if (!Util.isBlank(pathProperty)) { - String path = modelElement.getProperty(pathProperty); - if (!Util.isBlank(path)) { - return path; - } - } - if (modelElement instanceof Root) { - return ((Root) modelElement).getModel().getPage().getId(); - } - return modelElement.getId(); - } - - /** - * Returns semantic URI of this processor relative to the base processor's semantic URI. - * @param base - * @return - */ - public String relativeURI(ElementProcessor base) { - URI uri = getURI(); - if (uri == null) { - return null; - } - if (!(base instanceof ModelElementProcessor)) { - return uri.toString(); - } - - URI baseURI = ((ModelElementProcessor) base).getURI(); - if (baseURI == null) { - return uri.toString(); - } - - return uri.deresolve(baseURI, true, true, true).toString(); - } - - /** - * Returns documentation URI for this element or for its ancestor. - */ - protected URI resolveDocumentationBaseURI() { - ElementProcessor semanticParentProcessor = semanticParentInfo == null ? null : semanticParentInfo.getProcessor(); - URI base = semanticParentProcessor instanceof ModelElementProcessor ? ((ModelElementProcessor) semanticParentProcessor).resolveDocumentationBaseURI() : resourceURI; - - String documentationProperty = resourceFactory.getDocumentationProperty(); - if (Util.isBlank(documentationProperty)) { - return base; - } - - String docProp = (getElement()).getProperty(documentationProperty); - if (Util.isBlank(docProp)) { - return base; - } - - URI docURI = URI.createURI(docProp); - return base == null ? docURI : docURI.resolve(base); - } - - /** - * @param modelElement - * @return true if this element is the main element on the page which "represents" the page. - */ - protected boolean isPageElement(ModelElement modelElement) { - String pageElementFlagProperty = resourceFactory.getPageElementFlagProperty(); - if (Util.isBlank(pageElementFlagProperty)) { - return false; - } - String pageElementProp = modelElement.getProperty(pageElementFlagProperty); - return "true".equals(pageElementProp); - } - - /** - * @return - */ - protected String getSemanticChildrenListOfContents(ModelElementProcessor base) { - String listOpenTag = resourceFactory.getListOpenTag(getElement()); - String listCloseTag = resourceFactory.getListCloseTag(getElement()); - - if (semanticChildrenInfo == null - || semanticChildrenInfo.isEmpty() - || Util.isBlank(listOpenTag) - || Util.isBlank(listOpenTag)) { - return ""; - } - - StringBuilder tocBuilder = new StringBuilder(System.lineSeparator()).append(listOpenTag); - - for (ProcessorInfo sci: semanticChildrenInfo.keySet()) { - ElementProcessor childProcessor = sci.getProcessor(); - if (childProcessor instanceof ModelElementProcessor) { - tocBuilder.append(((ModelElementProcessor) childProcessor).getTableOfContentsElement(base)); - } - } - - tocBuilder.append(listCloseTag).append(System.lineSeparator()); - return tocBuilder.toString(); - } - - /** - * Creates a table of contents in the context of the base processor - * @return - */ - protected String getTableOfContentsElement(ModelElementProcessor base) { - String text = getText(); - if (Util.isBlank(text)) { - return ""; - } - - StringBuilder sb = new StringBuilder("
  • "); - String link = base == null || this == base ? null : base.getModelElementLink(getElement()); - if (Util.isBlank(link)) { - sb.append(text); - } else { - sb.append("").append(text).append(""); - } - String tooltip = getElement().getTooltip(); - if (!Util.isBlank(tooltip)) { - sb.append(" - ").append(tooltip).append(System.lineSeparator()); - } - - sb.append(getSemanticChildrenListOfContents(base)); - sb.append("
  • "); - sb.append(System.lineSeparator()); - - return sb.toString(); - } - - protected String getEmbeddedDiagram() { - try { - Document embeddedDiagramDocument = getEmbeddedDiagramDocument(); - if (embeddedDiagramDocument == null) { - return ""; - } - embeddedDiagramDocument.accept(this::processEmbeddedDiagramElement, resourceFactory.getConnectionBase()); - return embeddedDiagramDocument.toHtml(null, resourceFactory.getDiagramViewer()); - } catch (Exception e) { - return "Error embedding diagram: " + e; - } - } - - /** - * Processes an element of the embedded diagram. - * This implementation adds a link. Override for additional behavior, e.g. change background color based on external information. - * @param element - * @param action - * @param resolver - */ - protected void processEmbeddedDiagramElement(Element element) { - if (element instanceof ModelElement) { - ModelElement modelElement = (ModelElement) element; - if (getElement().equals(modelElement) || modelElement.isPageLink()) { - modelElement.setLink(null); - } - - if (Util.isBlank(modelElement.getLink())) { - String link = getModelElementLink(modelElement); - if (!Util.isBlank(link)) { - modelElement.setLink(link); - } - } - } - } - - public boolean hasDocumentation() { - String documentationProperty = resourceFactory.getDocumentationProperty(); - if (Util.isBlank(documentationProperty)) { - return false; - } - - String docProp = getElement().getProperty(documentationProperty); - if (Util.isBlank(docProp)) { - return false; - } - - return true; - } - - - protected EObject getDocumentation() { - if (!hasDocumentation()) { - return null; - } - - URI docURI = resolveDocumentationBaseURI(); - - Markdown markdown = ContentFactory.eINSTANCE.createMarkdown(); - org.nasdanika.exec.content.Resource docResource = ContentFactory.eINSTANCE.createResource(); - docResource.setLocation(docURI.toString()); - markdown.setSource(docResource); - markdown.setStyle(true); - - Interpolator interpolator = ContentFactory.eINSTANCE.createInterpolator(); - interpolator.setSource(markdown); - - String embeddedDiagram = getEmbeddedDiagram(); - - String tableOfContents = getSemanticChildrenListOfContents(this); - if (Util.isBlank(embeddedDiagram) && Util.isBlank(tableOfContents)) { - return interpolator; - } - - Configurator configurator = ExecFactory.eINSTANCE.createConfigurator(); - configurator.setTarget(interpolator); - - EMap properties = configurator.getProperties(); - if (!Util.isBlank(embeddedDiagram)) { - Text diagramText = ContentFactory.eINSTANCE.createText(); - diagramText.setContent(embeddedDiagram); - properties.put("diagram", diagramText); - } - - if (!Util.isBlank(tableOfContents)) { - Text tocText = ContentFactory.eINSTANCE.createText(); - tocText.setContent(tableOfContents); - properties.put("toc", tocText); - } - - return configurator; - } - - /** - * Resolves link to the model element from this action. - * @param modelElement Model element - * @param action Source action - * @param resolver Resolver - * @return - */ - protected String getModelElementLink(ModelElement modelElement) { - // Do not link to self or linked page's page element. - if (getElement().getId().equals(modelElement.getId())) { - return null; - } - Page linkedPage = getElement().getLinkedPage(); - if (linkedPage != null) { - PageProcessor linkedPageProcessor = (PageProcessor) registry.infoMap().get(linkedPage).getProcessor(); - ModelElement linkedPageElement = linkedPageProcessor.getPageElement(); - if (modelElement.getId().equals(linkedPageElement.getId())) { - return null; - } - } - - if (resourceFactory.shallCreateLink(modelElement)) { - // External reference - String externalReference = resourceFactory.getExternalReference(ProcessorInfo.of(config, this), modelElement); - if (externalReference != null) { - return externalReference; - } - // Link by cross-reference - String selectorProperty = resourceFactory.getSelectorProperty(); - if (!Util.isBlank(selectorProperty)) { - String selectorPropertyValue = modelElement.getProperty(selectorProperty); - if (!Util.isBlank(selectorPropertyValue)) { - Optional processorOptional = registry - .infoMap() - .entrySet() - .stream() - .filter(e -> resourceFactory.match(e.getKey(), selectorPropertyValue)) - .map(e -> e.getValue().getProcessor()) - .filter(ModelElementProcessor.class::isInstance) - .map(ModelElementProcessor.class::cast) - .filter(ModelElementProcessor::isSemantic) - .findFirst(); - - if (processorOptional.isPresent()) { - return processorOptional.get().relativeURI(this); - } - } - } - - // Link by ID equality - Optional processorOptional = registry - .infoMap() - .entrySet() - .stream() - .filter(e -> e.getKey() instanceof ModelElement && Objects.equals(modelElement.getId(), ((ModelElement) e.getKey()).getId())) - .map(e -> e.getValue().getProcessor()) - .filter(ModelElementProcessor.class::isInstance) - .map(ModelElementProcessor.class::cast) - .filter(ModelElementProcessor::isSemantic) - .findFirst(); - - if (processorOptional.isPresent()) { - return processorOptional.get().relativeURI(this); - } - } - return null; - } - - - /** - * Adds textual content. Helper method. - * @param content - */ - public static void addContent(Action action, String content) { - if (!Util.isBlank(content)) { - Text text = createText(content); - action.getContent().add(text); - } - } - - /** - * Convenience method to create Text and set content in one shot. - * @param content - * @return - */ - public static Text createText(String content) { - Text text = ContentFactory.eINSTANCE.createText(); - text.setContent(content); - return text; - } - - public ProcessorInfo getSemanticParentInfo() { - return semanticParentInfo; - } - - /** - * - * @param semanticAncestor - * @param traversed - * @return True if this processor's element is the same as the argument semanticAncestor or direct or transitive semantic child for the semantic ancestor. - */ - public boolean isSemanticDescendant(ModelElement semanticAncestor, Predicate traversed) { - if (getElement().equals(semanticAncestor)) { - return true; - } - if (semanticParentInfo != null && traversed.test(getElement())) { - if (semanticParentInfo.getConfig().getElement().equals(semanticAncestor)) { - return true; - } - ElementProcessor spp = getSemanticParentInfo().getProcessor(); - if (spp instanceof ModelElementProcessor) { - return ((ModelElementProcessor) spp).isSemanticDescendant(semanticAncestor, traversed); - } - return false; - } - return false; - } - -} diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ModelProcessor.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ModelProcessor.java deleted file mode 100644 index 8b6cc188..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ModelProcessor.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import org.eclipse.emf.common.util.URI; -import org.nasdanika.drawio.Model; -import org.nasdanika.graph.processor.ProcessorConfig; - -public class ModelProcessor extends ElementProcessor { - - public ModelProcessor(ResourceFactory resourceFactory, URI uri, ProcessorConfig config, URI baseURI) { - super(resourceFactory, uri, config, baseURI); - } - - @Override - public Model getElement() { - return (Model) super.getElement(); - } - -} diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/NodeProcessor.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/NodeProcessor.java deleted file mode 100644 index 500e0a78..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/NodeProcessor.java +++ /dev/null @@ -1,274 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import java.util.Collection; -import java.util.Comparator; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EReference; -import org.nasdanika.common.Util; -import org.nasdanika.drawio.Connection; -import org.nasdanika.drawio.Node; -import org.nasdanika.graph.processor.ProcessorConfig; -import org.nasdanika.graph.processor.ProcessorInfo; -import org.nasdanika.html.model.app.Action; -import org.nasdanika.html.model.app.AppFactory; -import org.nasdanika.html.model.app.AppPackage; -import org.nasdanika.html.model.bootstrap.BootstrapFactory; -import org.nasdanika.html.model.bootstrap.Table; -import org.nasdanika.html.model.bootstrap.TableCell; -import org.nasdanika.html.model.bootstrap.TableRow; - -public class NodeProcessor extends LayerProcessor { - - public NodeProcessor(ResourceFactory resourceFactory, URI uri, ProcessorConfig config, URI baseURI) { - super(resourceFactory, uri, config, baseURI); - } - - @Override - public Node getElement() { - return (Node) super.getElement(); - } - - @Override - public Map, EReference> collectSemanticChildrenInfo(ProcessorInfo semanticParentInfo) { - Stream, EReference>> superStream = super.collectSemanticChildrenInfo(semanticParentInfo).entrySet().stream(); - Stream, EReference>> outgoingConnectionsStream = getElement() - .getOutgoingConnections() - .stream() - .map(registry.infoMap()::get) - .map(ProcessorInfo::getProcessor) - .map(ModelElementProcessor.class::cast) - .flatMap(p -> p.setSemanticParentInfo(semanticParentInfo).entrySet().stream()); - - Stream, EReference>> stream = Stream.concat(superStream, outgoingConnectionsStream); - - Comparator> semanticChildrenComparator = getSemanticChildrenComparator(); - if (semanticChildrenComparator != null) { - stream = stream.sorted((a,b) -> semanticChildrenComparator.compare(a.getKey(), b.getKey())); - } - - Map, EReference> ret = new LinkedHashMap<>(); - stream.forEach(e -> ret.put(e.getKey(), e.getValue())); - return ret; - } - - @SuppressWarnings("unchecked") - @Override - public void build() { - super.build(); - EReference connectionsActionContainmentReference = resourceFactory.getConnectionsActionContainmentReference(getElement()); - if (connectionsActionContainmentReference != null) { - List incomingConnections = getElement().getIncomingConnections() - .stream() - .filter(c -> ((ConnectionProcessor) registry.infoMap().get(c).getProcessor()).getTargetRole() == null) - .collect(Collectors.toList()); - if (!incomingConnections.isEmpty()) { - Table table = BootstrapFactory.eINSTANCE.createTable(); - table.setBordered(true); - table.getAttributes().put("style", createText("width:auto")); - - TableRow headerRow = BootstrapFactory.eINSTANCE.createTableRow(); - table.getRows().add(headerRow); - - TableCell labelHeader = BootstrapFactory.eINSTANCE.createTableCell(); - labelHeader.setHeader(true); - headerRow.getCells().add(labelHeader); - labelHeader.getContent().add(createText("Label")); - - TableCell sourceHeader = BootstrapFactory.eINSTANCE.createTableCell(); - sourceHeader.setHeader(true); - headerRow.getCells().add(sourceHeader); - sourceHeader.getContent().add(createText("Source")); - - TableCell tooltipHeader = BootstrapFactory.eINSTANCE.createTableCell(); - tooltipHeader.setHeader(true); - headerRow.getCells().add(tooltipHeader); - tooltipHeader.getContent().add(createText("Tooltip")); - - for (Connection incomingConnection: incomingConnections) { // TODO - sorting - ProcessorInfo incomingConnectionInfo = registry.infoMap().get(incomingConnection); - ModelElementProcessor incomingConnectionProcessor = (ModelElementProcessor) incomingConnectionInfo.getProcessor(); - - TableRow connectionRow = BootstrapFactory.eINSTANCE.createTableRow(); - table.getRows().add(connectionRow); - - TableCell labelCell = BootstrapFactory.eINSTANCE.createTableCell(); - connectionRow.getCells().add(labelCell); - String connectionLabel = incomingConnectionProcessor.getText(); - if (Util.isBlank(connectionLabel) && incomingConnectionProcessor.hasDocumentation()) { - connectionLabel = "(unlabeled)"; - } - if (!Util.isBlank(connectionLabel)) { - String connectionLink = getModelElementLink(incomingConnection); - if (connectionLink == null) { - labelCell.getContent().add(createText(connectionLabel)); - } else { - labelCell.getContent().add(createText("" + connectionLabel + "")); - } - } - - TableCell sourceCell = BootstrapFactory.eINSTANCE.createTableCell(); - connectionRow.getCells().add(sourceCell); - - Node source = incomingConnection.getSource(); - if (source != null) { - ModelElementProcessor sourceProcessor = (ModelElementProcessor) registry.infoMap().get(source).getProcessor(); - String sourceLabel = sourceProcessor.getText(); - if (Util.isBlank(sourceLabel)) { - sourceLabel = "(unlabeled)"; - } - String sourceLink = getModelElementLink(source); - if (sourceLink == null) { - sourceCell.getContent().add(createText(sourceLabel)); - } else { - sourceCell.getContent().add(createText("" + sourceLabel + "")); - } - } - - TableCell tooltipCell = BootstrapFactory.eINSTANCE.createTableCell(); - connectionRow.getCells().add(tooltipCell); - String connectionTooltip = incomingConnection.getTooltip(); - if (!Util.isBlank(connectionTooltip)) { - tooltipCell.getContent().add(createText(connectionTooltip)); - } - } - - Action incomingConnectionsAction = AppFactory.eINSTANCE.createAction(); - incomingConnectionsAction.setText("Incoming connections"); - if (connectionsActionContainmentReference == AppPackage.Literals.ACTION__SECTIONS) { - incomingConnectionsAction.setName("incoming-connections"); - } else { - incomingConnectionsAction.setLocation("incoming-connections.html"); - } - incomingConnectionsAction.getContent().add(table); - ((Collection) getSemanticElement().eGet(connectionsActionContainmentReference)).add(incomingConnectionsAction); - } - - List outgoingConnections = getElement().getOutgoingConnections() - .stream() - .filter(c -> ((ConnectionProcessor) registry.infoMap().get(c).getProcessor()).getTargetRole() == null) - .collect(Collectors.toList()); - if (!outgoingConnections.isEmpty()) { - Table table = BootstrapFactory.eINSTANCE.createTable(); - table.setBordered(true); - table.getAttributes().put("style", createText("width:auto")); - - TableRow headerRow = BootstrapFactory.eINSTANCE.createTableRow(); - table.getRows().add(headerRow); - - TableCell labelHeader = BootstrapFactory.eINSTANCE.createTableCell(); - labelHeader.setHeader(true); - headerRow.getCells().add(labelHeader); - labelHeader.getContent().add(createText("Label")); - - TableCell targetHeader = BootstrapFactory.eINSTANCE.createTableCell(); - targetHeader.setHeader(true); - headerRow.getCells().add(targetHeader); - targetHeader.getContent().add(createText("Target")); - - TableCell tooltipHeader = BootstrapFactory.eINSTANCE.createTableCell(); - tooltipHeader.setHeader(true); - headerRow.getCells().add(tooltipHeader); - tooltipHeader.getContent().add(createText("Tooltip")); - - for (Connection outgoingConnection: outgoingConnections) { // TODO - sorting - ProcessorInfo outgoingConnectionInfo = registry.infoMap().get(outgoingConnection); - ModelElementProcessor outgoingConnectionProcessor = (ModelElementProcessor) outgoingConnectionInfo.getProcessor(); - - TableRow connectionRow = BootstrapFactory.eINSTANCE.createTableRow(); - table.getRows().add(connectionRow); - - TableCell labelCell = BootstrapFactory.eINSTANCE.createTableCell(); - connectionRow.getCells().add(labelCell); - String connectionLabel = outgoingConnectionProcessor.getText(); - if (Util.isBlank(connectionLabel) && outgoingConnectionProcessor.hasDocumentation()) { - connectionLabel = "(unlabeled)"; - } - if (!Util.isBlank(connectionLabel)) { - String connectionLink = getModelElementLink(outgoingConnection); - if (connectionLink == null) { - labelCell.getContent().add(createText(connectionLabel)); - } else { - labelCell.getContent().add(createText("" + connectionLabel + "")); - } - } - - TableCell targetCell = BootstrapFactory.eINSTANCE.createTableCell(); - connectionRow.getCells().add(targetCell); - - Node target = outgoingConnection.getTarget(); - if (target != null) { - ModelElementProcessor targetProcessor = (ModelElementProcessor) registry.infoMap().get(target).getProcessor(); - String targetLabel = targetProcessor.getText(); - if (Util.isBlank(targetLabel)) { - targetLabel = "(unlabeled)"; - } - String targetLink = getModelElementLink(target); - if (targetLink == null) { - targetCell.getContent().add(createText(targetLabel)); - } else { - targetCell.getContent().add(createText("" + targetLabel + "")); - } - } - - TableCell tooltipCell = BootstrapFactory.eINSTANCE.createTableCell(); - connectionRow.getCells().add(tooltipCell); - String connectionTooltip = outgoingConnection.getTooltip(); - if (!Util.isBlank(connectionTooltip)) { - tooltipCell.getContent().add(createText(connectionTooltip)); - } - } - - Action outboundConnectionsAction = AppFactory.eINSTANCE.createAction(); - outboundConnectionsAction.setText("Outgoing connections"); - if (connectionsActionContainmentReference == AppPackage.Literals.ACTION__SECTIONS) { - outboundConnectionsAction.setName("outgoing-connections"); - } else { - outboundConnectionsAction.setLocation("outgoing-connections.html"); - } - outboundConnectionsAction.getContent().add(table); - ((Collection) getSemanticElement().eGet(connectionsActionContainmentReference)).add(outboundConnectionsAction); - } - } - } - - protected String getDefaultTargetConnectionRoleName() { - String defaultConnectionTargetRoleProperty = resourceFactory.getDefaultConnectionTargetRoleProperty(); - if (Util.isBlank(defaultConnectionTargetRoleProperty)) { - return null; - } - - return getElement().getProperty(defaultConnectionTargetRoleProperty); - } - - @Override - public void setRegistry(Registry registry) { - super.setRegistry(registry); - - String defaultConnectionTargetRoleName = getDefaultTargetConnectionRoleName(); - if (!Util.isBlank(defaultConnectionTargetRoleName)) { - Set traversed = new HashSet<>(); - for (Connection ogc: getElement().getOutgoingConnections()) { - ((ConnectionProcessor) registry.infoMap().get(ogc).getProcessor()).setDefaultTargetRole(registry, defaultConnectionTargetRoleName, traversed::add); - } - } - } - - public void setDefaultTargetConnectionRole(Registry registry, String roleName, Predicate traversed) { - String defaultConnectionTargetRoleName = getDefaultTargetConnectionRoleName(); - if (Util.isBlank(defaultConnectionTargetRoleName)) { - for (Connection ogc: getElement().getOutgoingConnections()) { - ((ConnectionProcessor) registry.infoMap().get(ogc).getProcessor()).setDefaultTargetRole(registry, roleName, traversed); - } - } - } - -} diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/PageProcessor.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/PageProcessor.java deleted file mode 100644 index 5b0fff4d..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/PageProcessor.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import org.eclipse.emf.common.util.URI; -import org.nasdanika.drawio.ModelElement; -import org.nasdanika.drawio.Page; -import org.nasdanika.graph.processor.ProcessorConfig; - -/** - * Always pass-through to the page element. - * @author Pavel - * - */ -public class PageProcessor extends ElementProcessor { - - public PageProcessor(ResourceFactory resourceFactory, URI uri, ProcessorConfig config, URI baseURI) { - super(resourceFactory, uri, config, baseURI); - } - - public ModelElement getPageElement() { - return resourceFactory.getPageElement(getElement()); - } - - @Override - public Page getElement() { - return (Page) super.getElement(); - } - - public boolean isRootPage() { - return resourceFactory.isRootPage(getElement()); - } - -} diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ProcessorFactory.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ProcessorFactory.java deleted file mode 100644 index 4f4e2900..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ProcessorFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import java.util.Map; -import java.util.concurrent.CompletionStage; -import java.util.function.Consumer; - -import org.eclipse.emf.common.util.URI; -import org.nasdanika.common.ProgressMonitor; -import org.nasdanika.graph.Connection; -import org.nasdanika.graph.Element; -import org.nasdanika.graph.processor.NopEndpointProcessorConfigFactory; -import org.nasdanika.graph.processor.ProcessorConfig; -import org.nasdanika.graph.processor.ProcessorInfo; - -class ProcessorFactory implements NopEndpointProcessorConfigFactory { - - private ResourceFactory resourceFactory; - private URI uri; - - public ProcessorFactory(URI uri, ResourceFactory resourceFactory) { - this.uri = uri; - this.resourceFactory = resourceFactory; - } - - @Override - public ElementProcessor createProcessor(ProcessorConfig config, boolean parallel, Consumer> stageCollector, ProgressMonitor progressMonitor) { - return resourceFactory.createProcessor(uri, config, progressMonitor); - } - - @Override - public boolean isPassThrough(Connection connection) { - return false; - } - - @Override - public Registry createRegistry(Map> registry) { - return new Registry(registry); - } - -}; diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ResourceFactory.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ResourceFactory.java deleted file mode 100644 index cfb70c51..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/ResourceFactory.java +++ /dev/null @@ -1,475 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Comparator; -import java.util.UUID; -import java.util.stream.Stream; - -import javax.xml.parsers.ParserConfigurationException; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.Resource.Factory; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.nasdanika.common.NasdanikaException; -import org.nasdanika.common.ProgressMonitor; -import org.nasdanika.common.Util; -import org.nasdanika.drawio.Connection; -import org.nasdanika.drawio.ConnectionBase; -import org.nasdanika.drawio.Document; -import org.nasdanika.drawio.Layer; -import org.nasdanika.drawio.Model; -import org.nasdanika.drawio.ModelElement; -import org.nasdanika.drawio.Node; -import org.nasdanika.drawio.Page; -import org.nasdanika.drawio.Root; -import org.nasdanika.drawio.comparators.AngularNodeComparator; -import org.nasdanika.drawio.comparators.LabelModelElementComparator; -import org.nasdanika.drawio.comparators.PropertyModelElementComparator; -import org.nasdanika.drawio.emf.DrawioResource; -import org.nasdanika.graph.Element; -import org.nasdanika.graph.processor.ProcessorConfig; -import org.nasdanika.graph.processor.ProcessorInfo; -import org.nasdanika.html.model.app.Action; -import org.nasdanika.html.model.app.AppPackage; -import org.springframework.expression.EvaluationContext; -import org.springframework.expression.EvaluationException; -import org.springframework.expression.Expression; -import org.springframework.expression.ExpressionParser; -import org.springframework.expression.ParseException; -import org.springframework.expression.spel.standard.SpelExpressionParser; -import org.xml.sax.SAXException; - -public abstract class ResourceFactory implements Factory { - - private ResourceSet resourceSet; - private ConnectionBase connectionBase; - private boolean parallel; - - public ResourceFactory(ConnectionBase connectionBase, ResourceSet resourceSet, boolean parallel) { - this.connectionBase = connectionBase; - this.resourceSet = resourceSet; - this.parallel = parallel; - } - - - @Override - public Resource createResource(URI uri) { - ProcessorFactory processorFactory = new ProcessorFactory(uri, this); - return new DrawioResource(uri, parallel) { - - protected Document loadDocument(InputStream inputStream) throws IOException, ParserConfigurationException, SAXException { - return ResourceFactory.this.loadDocument(inputStream, getURI()); - } - - @Override - protected ProgressMonitor getProgressMonitor() { - return ResourceFactory.this.getProgressMonitor(uri); - } - - @Override - protected org.nasdanika.graph.processor.ProcessorFactory getProcessorFactory() { - return processorFactory; - } - - @Override - protected ProcessorInfo getProcessorInfo(org.nasdanika.html.model.app.drawio.Registry registry, Element element) { - return registry.infoMap().get(element); - } - - @Override - protected Stream getRegistrySemanticElements(org.nasdanika.html.model.app.drawio.Registry registry) { - return ResourceFactory.this.getSemanticElements(registry); - } - - }; - } - - protected abstract ProgressMonitor getProgressMonitor(URI uri); - - protected Document loadDocument(InputStream inputStream, URI uri) throws IOException, ParserConfigurationException, SAXException { - return Document.load(inputStream, uri); - } - - protected Stream getSemanticElements(org.nasdanika.html.model.app.drawio.Registry registry) { - return registry - .infoMap() - .values() - .stream() - .map(ProcessorInfo::getProcessor) - .filter(DocumentProcessor.class::isInstance) - .map(DocumentProcessor.class::cast) - .flatMap(DocumentProcessor::build); - } - - /** - * Base URI for resolving action relative references. This implementation returns a random absolute UR. - * @return - */ - protected URI getBaseURI(URI resourceURI) { - return URI.createURI("temp://" + UUID.randomUUID() + "/" + UUID.randomUUID() + "/"); - } - - protected ElementProcessor createProcessor(URI uri, ProcessorConfig config, ProgressMonitor progressMonitor) { - - URI baseURI = getBaseURI(uri); - ElementProcessor processor; - if (config.getElement() instanceof Document) { - processor = createDocumentProcessor(uri, config, baseURI); - } else if (config.getElement() instanceof Page) { - processor = createPageProcessor(uri, config, baseURI); - } else if (config.getElement() instanceof Model) { - processor = createModelProcessor(uri, config, baseURI); - } else if (config.getElement() instanceof Root) { - processor = createRootProcessor(uri, config, baseURI); - } else if (config.getElement() instanceof Node) { - processor = createNodeProcessor(uri, config, baseURI); - } else if (config.getElement() instanceof org.nasdanika.drawio.Connection) { - processor = createConnectionProcessor(uri, config, baseURI); - } else if (config.getElement() instanceof Layer) { - processor = createLayerProcessor(uri, config, baseURI); - } else if (config.getElement() instanceof Model) { - processor = createModelProcessor(uri, config, baseURI); - } else { - processor = null; - } - - if (processor != null) { - config.getParentProcessorInfo().thenAccept(processor::setParentInfo); - config.getRegistry().thenAccept(processor::setRegistry); - } - - return processor; - } - - protected ElementProcessor createLayerProcessor(URI uri, ProcessorConfig config, URI baseURI) { - return new LayerProcessor(this, uri, config, baseURI); - } - - protected ElementProcessor createConnectionProcessor(URI uri, ProcessorConfig config, URI baseURI) { - return new ConnectionProcessor(this, uri, config, baseURI); - } - - protected ElementProcessor createDocumentProcessor(URI uri, ProcessorConfig config, URI baseURI) { - return new DocumentProcessor(this, uri, config, baseURI); - } - - protected ElementProcessor createNodeProcessor(URI uri, ProcessorConfig config, URI baseURI) { - return new NodeProcessor(this, uri, config, baseURI); - } - - protected ElementProcessor createRootProcessor(URI uri, ProcessorConfig config, URI baseURI) { - return new RootProcessor(this, uri, config, baseURI); - } - - protected ElementProcessor createModelProcessor(URI uri, ProcessorConfig config, URI baseURI) { - return new ModelProcessor(this, uri, config, baseURI); - } - - protected ElementProcessor createPageProcessor(URI uri, ProcessorConfig config, URI baseURI) { - return new PageProcessor(this, uri, config, baseURI); - } - - protected EReference resolveRole(String roleName) { - switch (roleName) { - case "none": - return null; - case "child": - return AppPackage.Literals.LABEL__CHILDREN; - case "anonymous": - return AppPackage.Literals.ACTION__ANONYMOUS; - case "navigation": - return AppPackage.Literals.ACTION__NAVIGATION; - case "section": - return AppPackage.Literals.ACTION__SECTIONS; - default: - throw new IllegalArgumentException("Unsupported connection role: " + roleName); - } - } - - protected String getPathProperty() { - return "path"; - } - - protected String getIconProperty() { - return "icon"; - } - - protected String getRoleProperty() { - return "role"; - } - - protected String getTargetRoleProperty() { - return "target-role"; - } - - protected String getDefaultConnectionTargetRoleProperty() { - return "default-connection-target-role"; - } - - protected String getDefaultConnectionRoleProperty() { - return "default-connection-role"; - } - - protected ConnectionBase getConnectionBase() { - return connectionBase; - } - - protected String getSelectorProperty() { - return "selector"; - } - - /** - * @return URL of the diagram viewer. If not null then a diagram initialization script is added to the page. Otherwise the diagram shall be initialized by some other means. - */ - protected String getDiagramViewer() { - return "https://cdn.jsdelivr.net/gh/Nasdanika/drawio@dev/src/main/webapp/js/viewer-static.min.js"; - } - - - protected EReference getConnectionsActionContainmentReference(Node node) { - return AppPackage.Literals.ACTION__SECTIONS; - } - - protected String getListOpenTag(Element element) { - return "
      "; - } - - protected String getListCloseTag(Element element) { - return "
    "; - } - - protected String getPageElementFlagProperty() { - return "page-element"; - } - - protected String getDefaultSort() { - return "label"; - } - - protected String getSortProperty() { - return "sort"; - } - - protected String getDocumentationProperty() { - return "documentation"; - } - - protected Action createDocumentAction(Document document) { - return null; - } - - protected Comparator getPageComparator(Document document) { - return null; - } - - protected String getRoleName(ModelElement modelElement) { - String roleProperty = getRoleProperty(); - if (Util.isBlank(roleProperty)) { - return null; - } - return modelElement.getProperty(roleProperty); - } - - protected EReference getRole(ModelElement modelElement) { - String roleName = getRoleName(modelElement); - if (Util.isBlank(roleName)) { - return modelElement instanceof Connection ? AppPackage.Literals.ACTION__ANONYMOUS : AppPackage.Literals.LABEL__CHILDREN; - } - return resolveRole(roleName); - } - - protected String getRoleName(Page page) { - return getRoleName(page.getModel().getRoot()); - } - - protected EReference getPageRole(Page page) { - String roleName = getRoleName(page); - return Util.isBlank(roleName) ? AppPackage.Literals.LABEL__CHILDREN : resolveRole(roleName); - } - - /** - * @param modelElement - * @return true if this element is the main element on the page which "represents" the page. - */ - protected boolean isPageElement(ModelElement modelElement) { - String pageElementFlagProperty = getPageElementFlagProperty(); - if (Util.isBlank(pageElementFlagProperty)) { - return false; - } - String pageElementProp = modelElement.getProperty(pageElementFlagProperty); - return "true".equals(pageElementProp); - } - - /** - * @param page - * @return Element with page-element property set to true or root if there is no such element. - */ - protected ModelElement getPageElement(Page page) { - Root root = page.getModel().getRoot(); - return root.stream() - .filter(ModelElement.class::isInstance) - .map(ModelElement.class::cast) - .filter(this::isPageElement) - .findFirst() - .orElse(root); - } - - /** - * Creates comparators from type and config. - * This implementation creates comparators from org.nasdanika.drawio.comparators package: - *
      - *
    • {@link AngularNodeComparator} - clockwise and counterclockwise types with the base angle in degrees as configuration with 90 as default value.
    • - *
    • {@link LabelModelElementComparator} - label with optional descending configuration - compares label HTML plain text ignoring markup.
    • - *
    • {@link PropertyModelElementComparator} - property with property name as required configuration. Compares using property values. - *
    - * - * Override to add support of additional sort types. - * @param parent Semantic parent of nodes to sort. - * @param sortType - * @param config - * @return - */ - protected Comparator createComparator(Element semanticParent, String sortType, String config) { - if (!Util.isBlank(sortType)) { - switch (sortType) { - case "clockwise": - case "counterclockwise": - if (semanticParent instanceof Node) { - AngularNodeComparator nodeComparator = new AngularNodeComparator((Node) semanticParent, "clockwise".equals(sortType), Util.isBlank(config) ? null : Double.parseDouble(config)); - return (a,b) -> { - if (a instanceof Node && b instanceof Node) { - return nodeComparator.compare((Node) a, (Node) b); - } - if (a == null) { - return b == null ? 0 : 1; - } - if (b == null) { - return a == null ? 0 : -11; - } - return a.hashCode() - b.hashCode(); - }; - } - return null; - case "label": - LabelModelElementComparator labelComparator = new LabelModelElementComparator("descending".equals(config)); - return (a,b) -> { - if (a instanceof ModelElement && b instanceof ModelElement) { - return labelComparator.compare((ModelElement) a, (ModelElement) b); - } - if (a == null) { - return b == null ? 0 : 1; - } - if (b == null) { - return a == null ? 0 : -11; - } - return a.hashCode() - b.hashCode(); - }; - case "property": - PropertyModelElementComparator propertyComparator = new PropertyModelElementComparator(config, "descending".equals(config)); - return (a,b) -> { - if (a instanceof Node && b instanceof ModelElement) { - return propertyComparator.compare((ModelElement) a, (ModelElement) b); - } - if (a == null) { - return b == null ? 0 : 1; - } - if (b == null) { - return a == null ? 0 : -11; - } - return a.hashCode() - b.hashCode(); - }; - } - } - return null; - } - - /** - * @param modelElement - * @return true if a link shall be created for a given model element. This implementation returns true for {@link Layers}s, {@link Node}s and {@link Connection}s without a cross-reference or a pre-existing link which is not a page link. - */ - protected boolean shallCreateLink(ModelElement modelElement) { - return (modelElement instanceof Layer || modelElement instanceof Connection) && (Util.isBlank(modelElement.getLink()) || modelElement.isPageLink()); - } - - /** - * For cross-reference resolution. - * @param element - * @param expression - * @return - */ - protected boolean match(Element element, String expression) { - if (Util.isBlank(expression)) { - return true; - } - - try { - ExpressionParser parser = new SpelExpressionParser(); - Expression exp = parser.parseExpression(expression); - EvaluationContext evaluationContext = getEvaluationContext(); - return evaluationContext == null ? exp.getValue(element, Boolean.class) : exp.getValue(evaluationContext, element, Boolean.class); - } catch (ParseException e) { - throw new NasdanikaException("Error parsing expression '" + expression + "' in " + element + ": " + e, e); - } catch (EvaluationException e) { - return false; - } - } - - protected EvaluationContext getEvaluationContext() { - return null; - } - - /** - * @param modelElement - * @return true if an action shall be created for a given model element. This implementation returns true for elements without external links and without cross-references. - * False is returned for undocumented connections. - */ - protected boolean shallCreateAction(ModelElement modelElement) { - return (Util.isBlank(modelElement.getLink()) || modelElement.isPageLink()) - && (Util.isBlank(getSelectorProperty()) || Util.isBlank(modelElement.getProperty(getSelectorProperty()))) - && !(modelElement instanceof Connection && !hasDocumentation(modelElement)); // No actions for undocumented connections - } - - /** - * Migrating old stuff, remove if not used. Otherwise make protected. - * @return - */ - private boolean hasDocumentation(ModelElement modelElement) { - String documentationProperty = getDocumentationProperty(); - if (Util.isBlank(documentationProperty)) { - return false; - } - - String docProp = modelElement.getProperty(documentationProperty); - return !Util.isBlank(docProp); - } - - protected ResourceSet getResourceSet() { - return resourceSet; - } - - public boolean isRootPage(Page page) { - String rootPageFlagProperty = getRootPageFlagProperty(); - if (Util.isBlank(rootPageFlagProperty)) { - return true; - } - return !"false".equals(page.getModel().getRoot().getProperty(rootPageFlagProperty)); - } - - protected String getRootPageFlagProperty() { - return "root-page"; - } - - /** - * @param sourceProcessor - * @param target - * @return Link to the target from the source. This implementation returns null. Override to resolve external references. - */ - protected String getExternalReference(ProcessorInfo sourceInfo, ModelElement target) { - return null; - } - -} diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/RoleRecord.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/RoleRecord.java deleted file mode 100644 index f060f291..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/RoleRecord.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import org.eclipse.emf.ecore.EReference; -import org.nasdanika.graph.processor.ProcessorConfig; - -public record RoleRecord(ProcessorConfig config, ElementProcessor processor, EReference role) { - -} diff --git a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/RootProcessor.java b/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/RootProcessor.java deleted file mode 100644 index 6bbd900a..00000000 --- a/model/app.drawio/src/main/java/org/nasdanika/html/model/app/drawio/RootProcessor.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.nasdanika.html.model.app.drawio; - -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EReference; -import org.nasdanika.drawio.Root; -import org.nasdanika.graph.Element; -import org.nasdanika.graph.processor.ProcessorConfig; -import org.nasdanika.graph.processor.ProcessorInfo; - -public class RootProcessor extends ModelElementProcessor { - - public RootProcessor(ResourceFactory resourceFactory, URI uri, ProcessorConfig config, URI baseURI) { - super(resourceFactory, uri, config, baseURI); - } - - @Override - public Root getElement() { - return (Root) super.getElement(); - } - - @Override - public String getText() { - return getElement().getModel().getPage().getName(); - } - - @Override - protected Comparator> getSemanticChildrenComparator() { - Comparator> semanticChildrenComparator = super.getSemanticChildrenComparator(); - if (semanticChildrenComparator != null) { - return semanticChildrenComparator; - } - Root root = getElement(); - return (a,b) -> { - Element be = b.getConfig().getElement(); - Element ae = a.getConfig().getElement(); - if (Objects.equals(ae, be)) { - return 0; - } - return root.getLayers().indexOf(be) - root.getLayers().indexOf(ae); // Reverse order - }; - } - - @Override - protected String getSemanticID() { - return getElement().getModel().getPage().getId(); - } - - @Override - public Map, EReference> collectSemanticChildrenInfo(ProcessorInfo semanticParentInfo) { - Map, EReference> ret = new LinkedHashMap<>(); - config.getChildProcessorsInfo() - .values() - .stream() - .sorted(getSemanticChildrenComparator()) - .map(ProcessorInfo::getProcessor) - .map(ModelElementProcessor.class::cast) - .flatMap(p -> p.setSemanticParentInfo(semanticParentInfo).entrySet().stream()) - .forEach(e -> ret.put(e.getKey(), e.getValue())); - - return ret; - } - -} diff --git a/model/app.drawio/src/test/java/org/nasdanika/html/model/app/tests/TestBase.java b/model/app.drawio/src/test/java/org/nasdanika/html/model/app/tests/TestBase.java deleted file mode 100644 index abdb8188..00000000 --- a/model/app.drawio/src/test/java/org/nasdanika/html/model/app/tests/TestBase.java +++ /dev/null @@ -1,171 +0,0 @@ -package org.nasdanika.html.model.app.tests; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStreamWriter; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.function.Consumer; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.URIHandlerImpl; -import org.nasdanika.common.Command; -import org.nasdanika.common.Context; -import org.nasdanika.common.DiagnosticException; -import org.nasdanika.common.PrintStreamProgressMonitor; -import org.nasdanika.common.ProgressMonitor; -import org.nasdanika.common.Status; -import org.nasdanika.common.Util; -import org.nasdanika.html.model.app.util.AppObjectLoaderExecutionParticipant; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.DumperOptions.FlowStyle; -import org.yaml.snakeyaml.Yaml; - -/** - * Common methods for testing - * @author Pavel - * - */ -public class TestBase { - - public static void dumpToYaml(EObject eObject) { - DumperOptions dumperOptions = new DumperOptions(); - dumperOptions.setDefaultFlowStyle(FlowStyle.BLOCK); dumperOptions.setIndent(4); - new Yaml(dumperOptions).dump(dump(eObject), new OutputStreamWriter(System.out)); - } - - /** - * Dumps {@link EObject} to {@link Map} for to further dump to YAML. - * Outputs class, path, URI, and name. - * @param eObject - * @return - */ - @SuppressWarnings("unchecked") - public static Map dump(EObject eObject) { - Map ret = new LinkedHashMap<>(); - ret.put("class", eObject.eClass().getName()); - for (EReference ref: eObject.eClass().getEAllReferences()) { - if (ref. isContainment()) { - if (ref.isMany()) { - Collection> elements = new ArrayList<>(); - for (EObject el: ((Collection) eObject.eGet(ref))) { - if (el != null) { - elements.add(dump(el)); - } - } - if (!elements.isEmpty()) { - ret.put(ref.getName(), elements); - } - } else { - EObject val = (EObject) eObject.eGet(ref); - if (val != null) { - ret.put(ref.getName(), dump(val)); - } - } - } - } - return ret; - } - - // TODO - supplier, consumer, command tests - chaining with then - /** - * Loads resource and passes its root to the consumer. - * @param resource Resource location relative to the test class. - * @param consumer Consumer of the resource root - typically with assertions. - * @param diagnosticConsumer Consumer of diagnostic to validate status. - * @throws Exception - */ - protected void load( - String resource, - Consumer consumer, - Consumer diagnosticConsumer) throws Exception { - - load(resource, Context.EMPTY_CONTEXT, consumer, diagnosticConsumer); - } - - /** - * Loads resource and passes its root to the consumer. - * @param resource Resource location relative to the test class. - * @param consumer Consumer of the resource root - typically with assertions. - * @param diagnosticConsumer Consumer of diagnostic to validate status. - * @throws Exception - */ - protected void load( - String resource, - Context context, - Consumer consumer, - Consumer diagnosticConsumer) throws Exception { - // Outputs to console, send to file if desired. - ProgressMonitor progressMonitor = new PrintStreamProgressMonitor(); - - class TestCommand extends AppObjectLoaderExecutionParticipant implements Command { - - public TestCommand(Context context) { - super(context, false); - } - - @Override - protected Collection getResources() { - return Collections.singleton(URI.createURI(TestBase.this.getClass().getResource(resource).toString())); - } - - @Override - protected ResourceSet createResourceSet(ProgressMonitor progressMonitor) { - ResourceSet rs = super.createResourceSet(progressMonitor); - rs.getURIConverter().getURIHandlers().add(new URIHandlerImpl() { - - @Override - public boolean canHandle(URI uri) { - return uri != null && "classpath".equals(uri.scheme()); - } - - @Override - public InputStream createInputStream(URI uri, Map options) throws IOException { - return getClass().getClassLoader().getResourceAsStream(uri.path()); - } - - }); - return rs; - } - - @Override - public void execute(ProgressMonitor progressMonitor) { - assertEquals(1, roots.size()); - if (consumer != null) { - consumer.accept(roots.iterator().next()); - } - } - - }; - - // Diagnosing loaded resources. - try { - org.nasdanika.common.Diagnostic diagnostic = Util.call(new TestCommand(context), progressMonitor); - if (diagnosticConsumer != null) { - diagnosticConsumer.accept(diagnostic); - } - if (diagnostic.getStatus() == Status.WARNING || diagnostic.getStatus() == Status.ERROR) { - System.err.println("***********************"); - System.err.println("* Diagnostic *"); - System.err.println("***********************"); - diagnostic.dump(System.err, 4, Status.ERROR, Status.WARNING); - } - } catch (DiagnosticException e) { - System.err.println("******************************"); - System.err.println("* Diagnostic failed *"); - System.err.println("******************************"); - e.getDiagnostic().dump(System.err, 4, Status.FAIL); - throw e; - } - - } - -} diff --git a/model/app.drawio/src/test/java/org/nasdanika/html/model/app/tests/TestPage.java b/model/app.drawio/src/test/java/org/nasdanika/html/model/app/tests/TestPage.java deleted file mode 100644 index d1da4fc5..00000000 --- a/model/app.drawio/src/test/java/org/nasdanika/html/model/app/tests/TestPage.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.nasdanika.html.model.app.tests; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; -import org.nasdanika.common.Status; - -/** - * Tests of descriptor view parts and wizards. - * @author Pavel - * - */ -public class TestPage extends TestBase { - - @Test - public void test() throws Exception { - load( - "page.yml", - obj -> { - org.nasdanika.html.model.bootstrap.Page page = (org.nasdanika.html.model.bootstrap.Page) obj; - assertThat(page.getBody()).hasSize(1); - org.nasdanika.html.model.app.Page appPage = (org.nasdanika.html.model.app.Page) page.getBody().get(0); - assertThat(appPage.getHeader()).isNotNull(); - }, - diagnostic -> { - assertThat(diagnostic.getStatus()).isEqualTo(Status.SUCCESS); - }); - } - -} diff --git a/model/app.drawio/src/test/resources/org/nasdanika/html/model/app/tests/page.yml b/model/app.drawio/src/test/resources/org/nasdanika/html/model/app/tests/page.yml deleted file mode 100644 index 66d82ebb..00000000 --- a/model/app.drawio/src/test/resources/org/nasdanika/html/model/app/tests/page.yml +++ /dev/null @@ -1,34 +0,0 @@ -bootstrap-page: - cdn: true - theme: Cerulean - name: Test - language: EN - stylesheets: https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css - scripts: - - https://code.jquery.com/jquery-3.5.1.slim.min.js - - https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js - body: - app-page: - header: - content: - content-text: Header - navigation-bar: - content: - content-text: Navigation bar - navigation-panel: - content: - content-text: Navigation panel - content-panel: - content: - - content-text: Content panel - - html-tag: - name: h1 - content: - content-text: Hello - attributes: - class: - content-text: row - footer: - content: - content-text: Footer - diff --git a/model/app.gen.maven.archetype/pom.xml b/model/app.gen.maven.archetype/pom.xml index 81e01368..ff539d77 100644 --- a/model/app.gen.maven.archetype/pom.xml +++ b/model/app.gen.maven.archetype/pom.xml @@ -5,7 +5,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 ../.. site-generator-archetype-maven-plugin diff --git a/model/app.gen.maven.archetype/src/main/resources/archetype-resources/pom.xml b/model/app.gen.maven.archetype/src/main/resources/archetype-resources/pom.xml index 3b298302..e8992047 100644 --- a/model/app.gen.maven.archetype/src/main/resources/archetype-resources/pom.xml +++ b/model/app.gen.maven.archetype/src/main/resources/archetype-resources/pom.xml @@ -10,7 +10,7 @@ maven-site-plugin - 4.0.0-M9 + 4.0.0-M13 true true @@ -19,7 +19,7 @@ org.nasdanika.html site-generator-maven-plugin - 2023.12.0 + 2023.12.1 diff --git a/model/app.gen.maven/pom.xml b/model/app.gen.maven/pom.xml index 75f66424..abcecc9b 100644 --- a/model/app.gen.maven/pom.xml +++ b/model/app.gen.maven/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 ../.. @@ -40,13 +40,13 @@ org.apache.maven maven-plugin-api - 3.9.4 + 3.9.6 provided org.apache.maven.plugin-tools maven-plugin-annotations - 3.9.0 + 3.10.2 provided diff --git a/model/app.gen.maven/src/main/java/module-info.java b/model/app.gen.maven/src/main/java/module-info.java index 2dd96d0c..1009b5d2 100644 --- a/model/app.gen.maven/src/main/java/module-info.java +++ b/model/app.gen.maven/src/main/java/module-info.java @@ -1,6 +1,7 @@ module org.nasdanika.html.model.app.gen.maven { requires transitive org.nasdanika.maven; requires transitive org.nasdanika.html.model.app.gen; + requires ant.style.path.matcher; exports org.nasdanika.html.model.app.gen.maven; diff --git a/model/app.gen.maven/src/main/java/org/nasdanika/html/model/app/gen/maven/ActionSiteGeneratorMojo.java b/model/app.gen.maven/src/main/java/org/nasdanika/html/model/app/gen/maven/ActionSiteGeneratorMojo.java index b65393b3..97c7c99b 100644 --- a/model/app.gen.maven/src/main/java/org/nasdanika/html/model/app/gen/maven/ActionSiteGeneratorMojo.java +++ b/model/app.gen.maven/src/main/java/org/nasdanika/html/model/app/gen/maven/ActionSiteGeneratorMojo.java @@ -5,6 +5,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -36,6 +37,9 @@ import org.nasdanika.ncore.util.SemanticInfo; import org.nasdanika.ncore.util.SemanticRegistry; +import io.github.azagniotov.matcher.AntPathMatcher; +import io.github.azagniotov.matcher.AntPathMatcher.Builder; + /** * Generates action site. */ @@ -110,6 +114,12 @@ public class ActionSiteGeneratorMojo extends AbstractCommandMojo { */ @Parameter private List contributors; + + /** + * Files to keep in the output directory. + */ + @Parameter + private List outputCleanExcludes; /** * URL's of JSON resources with information about external semantic elements. Such JSON resources are created as part of site generation. @@ -164,6 +174,20 @@ protected void execute(Context context, ProgressMonitor progressMonitor) { throw new NasdanikaException(ex); } } + + protected boolean isDeleteOutputPath(String path) { + if (outputCleanExcludes != null) { + Builder builder = new AntPathMatcher.Builder(); + AntPathMatcher matcher = builder.build(); + for (String exclude: outputCleanExcludes) { + if (matcher.isMatch(exclude, path)) { + return false; + } + } + } + + return true; + } protected ActionSiteGenerator createActionSiteGenerator(Context context, ProgressMonitor progressMonitor) { File baseDir = project.getBasedir(); @@ -184,6 +208,11 @@ protected ActionSiteGenerator createActionSiteGenerator(Context context, Progres return new ActionSiteGenerator() { + @Override + protected boolean isDeleteOutputPath(String path) { + return ActionSiteGeneratorMojo.this.isDeleteOutputPath(path); + } + { this.parallel = ActionSiteGeneratorMojo.this.parallel; } diff --git a/model/app.gen/pom.xml b/model/app.gen/pom.xml index aa4fd2ce..f3cdb4cb 100644 --- a/model/app.gen/pom.xml +++ b/model/app.gen/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 ../.. app-model-gen @@ -67,14 +67,5 @@ sitemapgen4j 1.1.2 - -
    \ No newline at end of file diff --git a/model/app.graph/pom.xml b/model/app.graph/pom.xml index e9a884d6..835f6056 100644 --- a/model/app.graph/pom.xml +++ b/model/app.graph/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 ../.. app-model-graph diff --git a/model/app/pom.xml b/model/app/pom.xml index d76d0e4c..9b1f284e 100644 --- a/model/app/pom.xml +++ b/model/app/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 ../.. app-model diff --git a/model/bootstrap.gen/pom.xml b/model/bootstrap.gen/pom.xml index 5a3b3be9..ede35b64 100644 --- a/model/bootstrap.gen/pom.xml +++ b/model/bootstrap.gen/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 ../.. bootstrap-model-gen diff --git a/model/bootstrap/pom.xml b/model/bootstrap/pom.xml index 29bb8c59..ed2fd0b4 100644 --- a/model/bootstrap/pom.xml +++ b/model/bootstrap/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 ../.. bootstrap-model diff --git a/model/html.gen/pom.xml b/model/html.gen/pom.xml index 243f4538..22c9ff3b 100644 --- a/model/html.gen/pom.xml +++ b/model/html.gen/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 ../.. html-model-gen diff --git a/model/html/pom.xml b/model/html/pom.xml index 9f51202a..56315b3d 100644 --- a/model/html/pom.xml +++ b/model/html/pom.xml @@ -4,7 +4,7 @@ parent org.nasdanika.html - 2023.12.0 + 2023.12.1 ../.. html-model diff --git a/pom.xml b/pom.xml index cdff9eba..3436855b 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.nasdanika.html - 2023.12.0 + 2023.12.1 parent pom Nasdanika HTML Parent @@ -11,8 +11,8 @@ https://docs.nasdanika.org/modules/html/index.html - 2023.12.0 - 0.8.10 + 2023.12.1 + 0.8.11 UTF-8 false @@ -42,24 +42,24 @@ org.apache.maven.plugins maven-surefire-plugin - 3.1.2 + 3.2.3 org.junit.jupiter junit-jupiter-engine - 5.10.0 + 5.10.1 org.apache.maven.plugins maven-site-plugin - 4.0.0-M9 + 4.0.0-M13 org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 17 17 @@ -81,7 +81,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.5.0 + 3.6.3 @@ -128,7 +128,14 @@ org.junit.jupiter junit-jupiter-api - 5.10.0 + 5.10.1 + test + + + + org.junit.jupiter + junit-jupiter-engine + 5.10.1 test @@ -170,7 +177,6 @@ model/app model/app.gen model/app.graph - model/app.gen.maven model/app.gen.maven.archetype