You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2023/01/26 18:18:44 UTC
[causeway] 01/01: Merge remote-tracking branch 'origin/master' into spring6
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch spring6
in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 48dd3ec7316d8e7a4158a502f6308cdb4052519e
Merge: 56a9d5d8d3 06829af8ff
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Jan 26 19:18:37 2023 +0100
Merge remote-tracking branch 'origin/master' into spring6
.../causeway/applib/graph/tree/TreePath.java | 51 ++++-
.../applib/graph/tree/TreePath_Default.java | 44 +++-
.../causeway/applib/graph/tree/TreePathTest.java | 33 ++-
.../core/config/CausewayConfiguration.java | 12 +-
.../demo/domain/src/main/resources/application.yml | 6 +
.../extensions/docgen/CausewayModuleExtDocgen.java | 36 ++-
.../extensions/docgen/applib/HelpNode.java | 245 +++++++++++++++++++++
.../HelpPage.java} | 18 +-
.../extensions/docgen/help/DefaultHelpVm.java | 63 ------
.../docgen/help/DefaultHelpVm.layout.xml | 37 ----
.../extensions/docgen/helptree/HelpNodeVm-PAGE.svg | 44 ++++
.../docgen/helptree/HelpNodeVm-TOPIC.svg | 44 ++++
.../extensions/docgen/helptree/HelpNodeVm.java | 127 +++++++++++
.../docgen/helptree/HelpNodeVm.layout.xml | 39 ++++
.../docgen/helptree/HelpTreeAdapter.java | 34 +--
.../extensions/docgen/menu/DocumentationMenu.java | 16 +-
.../topics/domainobjects/EntityDiagramPage.java | 78 +++++++
.../docgen/topics/domainobjects/_DiagramUtils.java | 63 ++++++
.../welcome/WelcomeHelpPage.java} | 44 ++--
valuetypes/asciidoc/applib/pom.xml | 4 +
.../asciidoc/applib/src/main/java/module-info.java | 3 +
.../applib/CausewayModuleValAsciidocApplib.java | 168 ++++++++++++++
.../valuetypes/asciidoc/applib/value/AsciiDoc.java | 13 +-
.../asciidoc/applib/value/Converter.java | 80 -------
24 files changed, 1045 insertions(+), 257 deletions(-)
diff --cc extensions/core/docgen/src/main/java/org/apache/causeway/extensions/docgen/helptree/HelpNodeVm.java
index 0000000000,0e1f428900..8e75f98e41
mode 000000,100644..100644
--- a/extensions/core/docgen/src/main/java/org/apache/causeway/extensions/docgen/helptree/HelpNodeVm.java
+++ b/extensions/core/docgen/src/main/java/org/apache/causeway/extensions/docgen/helptree/HelpNodeVm.java
@@@ -1,0 -1,127 +1,127 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.causeway.extensions.docgen.helptree;
+
+ import java.util.Optional;
+
-import javax.inject.Inject;
-import javax.inject.Named;
++import jakarta.inject.Inject;
++import jakarta.inject.Named;
+
+ import org.apache.causeway.applib.ViewModel;
+ import org.apache.causeway.applib.annotation.DomainObject;
+ import org.apache.causeway.applib.annotation.DomainObjectLayout;
+ import org.apache.causeway.applib.annotation.LabelPosition;
+ import org.apache.causeway.applib.annotation.Nature;
+ import org.apache.causeway.applib.annotation.Navigable;
+ import org.apache.causeway.applib.annotation.ObjectSupport;
+ import org.apache.causeway.applib.annotation.Programmatic;
+ import org.apache.causeway.applib.annotation.Property;
+ import org.apache.causeway.applib.annotation.PropertyLayout;
+ import org.apache.causeway.applib.annotation.Where;
+ import org.apache.causeway.applib.graph.tree.TreeNode;
+ import org.apache.causeway.applib.graph.tree.TreePath;
+ import org.apache.causeway.extensions.docgen.CausewayModuleExtDocgen;
+ import org.apache.causeway.extensions.docgen.applib.HelpNode;
+ import org.apache.causeway.extensions.docgen.applib.HelpNode.HelpTopic;
+ import org.apache.causeway.valuetypes.asciidoc.applib.value.AsciiDoc;
+
+ import lombok.Getter;
+ import lombok.val;
+ import lombok.extern.log4j.Log4j2;
+
+ @Named(CausewayModuleExtDocgen.NAMESPACE + ".HelpNodeVm")
+ @DomainObject(
+ nature=Nature.VIEW_MODEL)
+ @DomainObjectLayout(
+ named = "Application Help")
+ @Log4j2
+ public class HelpNodeVm implements ViewModel {
+
+ public final static String PATH_DELIMITER = "|"; // required to be URL-safe
+
+ public static HelpNodeVm forRootTopic(final HelpTopic rootTopic) {
+ return new HelpNodeVm(rootTopic, rootTopic);
+ }
+
+ @Getter @Programmatic
+ private final HelpTopic rootTopic;
+
+ @Getter @Programmatic
+ private final HelpNode helpNode;
+
+ @Inject
+ public HelpNodeVm(final HelpTopic rootTopic, final String rootPathMemento) {
+ this(rootTopic, TreePath.parse(rootPathMemento, PATH_DELIMITER));
+ }
+
+ HelpNodeVm(final HelpTopic rootTopic, final TreePath treePath) {
+ this(rootTopic, rootTopic
+ .lookup(treePath)
+ .orElseGet(()->{
+ log.warn("could not resolve help node {}", treePath);
+ return rootTopic;
+ }));
+ }
+
+ HelpNodeVm(final HelpTopic rootTopic, final HelpNode helpNode) {
+ this.rootTopic = rootTopic;
+ this.helpNode = helpNode;
+ }
+
+ @ObjectSupport public String title() {
+ return helpNode.getTitle();
+ }
+
+ @ObjectSupport public String iconName() {
+ val type = helpNode.getHelpNodeType();
+ return type!=null ? type.name() : "";
+ }
+
+ @Property
+ @PropertyLayout(labelPosition = LabelPosition.NONE, fieldSetId = "tree", sequence = "1")
+ public TreeNode<HelpNodeVm> getTree() {
+ final TreeNode<HelpNodeVm> tree = TreeNode.lazy(HelpNodeVm.forRootTopic(rootTopic), HelpTreeAdapter.class);
+
+ // expand the current node
+ helpNode.getPath().streamUpTheHierarchyStartingAtSelf()
+ .forEach(tree::expand);
+
+ return tree;
+ }
+
+ @Property
+ @PropertyLayout(navigable=Navigable.PARENT, hidden=Where.EVERYWHERE, fieldSetId = "detail", sequence = "1")
+ public HelpNodeVm getParent() {
+ return Optional.ofNullable(helpNode.getPath().getParentIfAny())
+ .map(parentPath->new HelpNodeVm(rootTopic, parentPath.toString()))
+ .orElse(null);
+ }
+
+ @Property
+ @PropertyLayout(labelPosition = LabelPosition.NONE, fieldSetId = "detail", sequence = "2")
+ @Getter(lazy = true)
+ private final AsciiDoc helpContent = helpNode.getContent();
+
+
+ @Override
+ public String viewModelMemento() {
+ return helpNode.getPath().stringify(PATH_DELIMITER);
+ }
+
+ }
diff --cc extensions/core/docgen/src/main/java/org/apache/causeway/extensions/docgen/topics/domainobjects/EntityDiagramPage.java
index 0000000000,8cbffe302c..c23cedd595
mode 000000,100644..100644
--- a/extensions/core/docgen/src/main/java/org/apache/causeway/extensions/docgen/topics/domainobjects/EntityDiagramPage.java
+++ b/extensions/core/docgen/src/main/java/org/apache/causeway/extensions/docgen/topics/domainobjects/EntityDiagramPage.java
@@@ -1,0 -1,78 +1,78 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.causeway.extensions.docgen.topics.domainobjects;
+
+ import java.util.Optional;
+ import java.util.stream.Collectors;
+ import java.util.stream.Stream;
+
-import javax.inject.Inject;
-import javax.inject.Named;
++import jakarta.inject.Inject;
++import jakarta.inject.Named;
+
+ import org.springframework.stereotype.Component;
+
+ import org.apache.causeway.core.config.beans.CausewayBeanTypeRegistry;
+ import org.apache.causeway.core.metamodel.spec.ObjectSpecification;
+ import org.apache.causeway.core.metamodel.specloader.SpecificationLoader;
+ import org.apache.causeway.extensions.docgen.CausewayModuleExtDocgen;
+ import org.apache.causeway.extensions.docgen.applib.HelpPage;
+ import org.apache.causeway.valuetypes.asciidoc.applib.value.AsciiDoc;
+
+ import lombok.RequiredArgsConstructor;
+
+ @Component
+ @Named(CausewayModuleExtDocgen.NAMESPACE + ".EntityDiagramPage")
+ @RequiredArgsConstructor(onConstructor_ = {@Inject})
+ public class EntityDiagramPage implements HelpPage {
+
+ private final SpecificationLoader specLoader;
+ private final CausewayBeanTypeRegistry beanTypeRegistry;
+
+ @Override
+ public String getTitle() {
+ return "Entity Diagram";
+ }
+
+ @Override
+ public AsciiDoc getContent() {
+ return AsciiDoc.valueOf(
+ "== Entities\n\n"
+ + _DiagramUtils.plantumlBlock(entityTypesAsDiagram()));
+ }
+
+ // -- HELPER
+
+ private String entityTypesAsDiagram() {
+ return streamEntityTypes()
+ .map(spec->_DiagramUtils.object(spec))
+ .collect(Collectors.joining("\n"));
+
+ //TODO add entity relations - that is, model the object graph
+ }
+
+ private Stream<ObjectSpecification> streamEntityTypes() {
+ return beanTypeRegistry.getEntityTypes().keySet()
+ .stream()
+ .map(specLoader::specForType)
+ .filter(Optional::isPresent)
+ .map(Optional::get);
+ }
+
+ }
+
diff --cc extensions/core/docgen/src/main/java/org/apache/causeway/extensions/docgen/topics/welcome/WelcomeHelpPage.java
index 1606800ccc,db9c52a8e6..79385b0e05
--- a/extensions/core/docgen/src/main/java/org/apache/causeway/extensions/docgen/topics/welcome/WelcomeHelpPage.java
+++ b/extensions/core/docgen/src/main/java/org/apache/causeway/extensions/docgen/topics/welcome/WelcomeHelpPage.java
@@@ -22,16 -22,12 +22,12 @@@ import java.util.HashMap
import java.util.Map;
import java.util.Optional;
- import jakarta.annotation.Priority;
-import javax.inject.Inject;
-import javax.inject.Named;
+import jakarta.inject.Inject;
+import jakarta.inject.Named;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.stereotype.Service;
+ import org.springframework.stereotype.Component;
- import org.apache.causeway.applib.ViewModel;
import org.apache.causeway.applib.annotation.DomainObject;
- import org.apache.causeway.applib.annotation.PriorityPrecedence;
import org.apache.causeway.applib.layout.component.ActionLayoutData;
import org.apache.causeway.applib.layout.component.CollectionLayoutData;
import org.apache.causeway.applib.layout.component.FieldSet;