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/03/06 07:37:14 UTC

[causeway] branch master updated: CAUSEWAY-3314: [Demo] Collection Annotation - adds VM stubs

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/causeway.git


The following commit(s) were added to refs/heads/master by this push:
     new 68093114d9 CAUSEWAY-3314: [Demo] Collection Annotation - adds VM stubs
68093114d9 is described below

commit 68093114d941fd8e0a9a0648b9c7303ae04c3325
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Mar 6 08:37:07 2023 +0100

    CAUSEWAY-3314: [Demo] Collection Annotation - adds VM stubs
---
 .../collections/Collection/CollectionMenu.java     | 23 +++-----
 .../hidden/CollectionHiddenVm-description.adoc     |  6 ++
 .../Collection/hidden/CollectionHiddenVm.java      | 67 ++++++++++++++++++++++
 .../hidden/CollectionHiddenVm.layout.xml           | 58 +++++++++++++++++++
 .../typeOf/CollectionTypeOfVm-description.adoc     |  7 +++
 .../Collection/typeOf/CollectionTypeOfVm.java      | 66 +++++++++++++++++++++
 .../typeOf/CollectionTypeOfVm.layout.xml           | 58 +++++++++++++++++++
 7 files changed, 270 insertions(+), 15 deletions(-)

diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/CollectionMenu.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/CollectionMenu.java
index 4b5a4d09d0..e1c853dd1e 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/CollectionMenu.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/CollectionMenu.java
@@ -24,7 +24,6 @@ import javax.inject.Named;
 import org.apache.causeway.applib.annotation.Action;
 import org.apache.causeway.applib.annotation.ActionLayout;
 import org.apache.causeway.applib.annotation.DomainService;
-import org.apache.causeway.applib.annotation.MemberSupport;
 import org.apache.causeway.applib.annotation.NatureOfService;
 import org.apache.causeway.applib.annotation.PriorityPrecedence;
 import org.apache.causeway.applib.annotation.SemanticsOf;
@@ -32,6 +31,8 @@ import org.apache.causeway.applib.services.factory.FactoryService;
 
 import demoapp.dom.domain.collections.Collection.domainEvent.CollectionDomainEventVm;
 import demoapp.dom.domain.collections.Collection.domainEvent.CollectionDomainEventVm_addChild;
+import demoapp.dom.domain.collections.Collection.hidden.CollectionHiddenVm;
+import demoapp.dom.domain.collections.Collection.typeOf.CollectionTypeOfVm;
 import lombok.RequiredArgsConstructor;
 import lombok.val;
 
@@ -58,28 +59,20 @@ public class CollectionMenu {
         return collectionDomainEventVm;
     }
 
-
-
     @Action(semantics = SemanticsOf.SAFE)
     @ActionLayout(cssClassFa="fa-glasses", describedAs = "Visibility of collections")
-    public void hidden(){
+    public CollectionHiddenVm hidden(){
+        return new CollectionHiddenVm();
     }
-    @MemberSupport public String disableHidden(){
-        return "Visibility of collections" +
-                 " (not yet implemented in demo)";
-    }
-
-
 
     @Action(semantics = SemanticsOf.SAFE)
     @ActionLayout(cssClassFa="fa-shapes", describedAs = "Element type of collections")
-    public void typeOf(){
-    }
-    @MemberSupport public String disableTypeOf(){
-        return "Element type of collections" +
-                 " (not yet implemented in demo)";
+    public CollectionTypeOfVm typeOf(){
+        return new CollectionTypeOfVm();
     }
 
+    // -- HELPER
+
     private CollectionDomainEventVm_addChild addChild(final CollectionDomainEventVm collectionDomainEventVm) {
         return factoryService.mixin(CollectionDomainEventVm_addChild.class, collectionDomainEventVm);
     }
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/hidden/CollectionHiddenVm-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/hidden/CollectionHiddenVm-description.adoc
new file mode 100644
index 0000000000..74e984fb70
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/hidden/CollectionHiddenVm-description.adoc
@@ -0,0 +1,6 @@
+:Notice: 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 ag [...]
+
+The `hidden` attribute ...
+
+WARNING: TODO[CAUSEWAY-3311]
+Indicates when the collection is not visible to the user.
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/hidden/CollectionHiddenVm.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/hidden/CollectionHiddenVm.java
new file mode 100644
index 0000000000..555e7f2d37
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/hidden/CollectionHiddenVm.java
@@ -0,0 +1,67 @@
+/*
+ *  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 demoapp.dom.domain.collections.Collection.hidden;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Named;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.causeway.applib.annotation.Collection;
+import org.apache.causeway.applib.annotation.DomainObject;
+import org.apache.causeway.applib.annotation.Editing;
+import org.apache.causeway.applib.annotation.Nature;
+import org.apache.causeway.applib.annotation.ObjectSupport;
+import org.apache.causeway.applib.annotation.Where;
+
+import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
+import demoapp.dom.domain._entities.DemoEntity;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+//tag::class[]
+@DomainObject(
+        nature=Nature.VIEW_MODEL,
+        editing = Editing.ENABLED)
+@Named("demo.CollectionHiddenVm")
+@XmlRootElement(name = "root")
+@XmlType
+@XmlAccessorType(XmlAccessType.FIELD)
+@NoArgsConstructor
+public class CollectionHiddenVm implements HasAsciiDocDescription {
+
+    @ObjectSupport public String title() {
+        return "Collection#hidden";
+    }
+
+//tag::collection[]
+    @Collection(
+            hidden = Where.PARENTED_TABLES)
+    @XmlTransient
+    @Getter @Setter
+    private List<DemoEntity> collection = new ArrayList<>();
+//end::collection[]
+}
+//end::class[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/hidden/CollectionHiddenVm.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/hidden/CollectionHiddenVm.layout.xml
new file mode 100644
index 0000000000..c5315ddb7f
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/hidden/CollectionHiddenVm.layout.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- 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. -->
+<bs3:grid
+        xsi:schemaLocation="https://causeway.apache.org/applib/layout/component https://causeway.apache.org/applib/layout/component/component.xsd   https://causeway.apache.org/applib/layout/grid/bootstrap3 https://causeway.apache.org/applib/layout/grid/bootstrap3/bootstrap3.xsd"
+        xmlns:bs3="https://causeway.apache.org/applib/layout/grid/bootstrap3"
+        xmlns:cpt="https://causeway.apache.org/applib/layout/component"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+
+	<bs3:row>
+		<bs3:col span="10" unreferencedActions="true">
+			<cpt:domainObject />
+		</bs3:col>
+		<bs3:col span="2">
+			<cpt:fieldSet name="" id="sources" />
+		</bs3:col>
+	</bs3:row>
+
+	<bs3:row>
+		<bs3:col span="6">
+			<cpt:fieldSet name="Annotated" id="annotation"/>
+			<cpt:fieldSet name="Variants" id="variants"/>
+			<cpt:fieldSet name="Contributed" id="contributed"/>
+			<cpt:fieldSet name="Meta-annotated" id="meta-annotated"/>
+			<cpt:fieldSet name="Meta-annotated Overridden" id="meta-annotated-overridden"/>
+			<cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/>
+			<cpt:collection id="children">
+				<cpt:action id="returnsChildren"/>
+			</cpt:collection>
+		</bs3:col>
+		<bs3:col span="6">
+			<cpt:fieldSet name="Description" id="description" >
+				<cpt:action id="clearHints" position="PANEL" />
+				<cpt:action id="downloadLayoutXml"  position="PANEL_DROPDOWN"/>
+				<cpt:action id="rebuildMetamodel" position="PANEL"/>
+				<cpt:action id="downloadMetamodelXml"  position="PANEL_DROPDOWN"/>
+				<cpt:action id="inspectMetamodel"  position="PANEL_DROPDOWN"/>
+                <cpt:action id="recentCommands"  position="PANEL_DROPDOWN"/>
+				<cpt:action id="downloadJdoMetadata"  position="PANEL_DROPDOWN"/>
+				<cpt:action id="openRestApi" position="PANEL_DROPDOWN" />
+				<cpt:property id="description"/>
+			</cpt:fieldSet>
+		</bs3:col>
+	</bs3:row>
+	<bs3:row>
+		<bs3:col span="12" unreferencedCollections="true"/>
+	</bs3:row>
+
+</bs3:grid>
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/typeOf/CollectionTypeOfVm-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/typeOf/CollectionTypeOfVm-description.adoc
new file mode 100644
index 0000000000..9d4659634d
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/typeOf/CollectionTypeOfVm-description.adoc
@@ -0,0 +1,7 @@
+:Notice: 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 ag [...]
+
+The `typeOf` attribute ...
+
+WARNING: TODO[CAUSEWAY-3311]
+The type-of the elements held within the collection.
+This is only provided as a fallback; usually the framework can infer the element type of the collection from the collection method’s generic type.
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/typeOf/CollectionTypeOfVm.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/typeOf/CollectionTypeOfVm.java
new file mode 100644
index 0000000000..b8cbc02dce
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/typeOf/CollectionTypeOfVm.java
@@ -0,0 +1,66 @@
+/*
+ *  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 demoapp.dom.domain.collections.Collection.typeOf;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Named;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.causeway.applib.annotation.Collection;
+import org.apache.causeway.applib.annotation.DomainObject;
+import org.apache.causeway.applib.annotation.Editing;
+import org.apache.causeway.applib.annotation.Nature;
+import org.apache.causeway.applib.annotation.ObjectSupport;
+
+import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
+import demoapp.dom.domain._entities.DemoEntity;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+//tag::class[]
+@DomainObject(
+        nature=Nature.VIEW_MODEL,
+        editing = Editing.ENABLED)
+@Named("demo.CollectionTypeOfVm")
+@XmlRootElement(name = "root")
+@XmlType
+@XmlAccessorType(XmlAccessType.FIELD)
+@NoArgsConstructor
+public class CollectionTypeOfVm implements HasAsciiDocDescription {
+
+    @ObjectSupport public String title() {
+        return "Collection#typeOf";
+    }
+
+//tag::collection[]
+    @Collection(
+            typeOf = DemoEntity.class)
+    @XmlTransient
+    @Getter @Setter
+    private List<DemoEntity> collection = new ArrayList<>();
+//end::collection[]
+}
+//end::class[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/typeOf/CollectionTypeOfVm.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/typeOf/CollectionTypeOfVm.layout.xml
new file mode 100644
index 0000000000..c5315ddb7f
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/collections/Collection/typeOf/CollectionTypeOfVm.layout.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- 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. -->
+<bs3:grid
+        xsi:schemaLocation="https://causeway.apache.org/applib/layout/component https://causeway.apache.org/applib/layout/component/component.xsd   https://causeway.apache.org/applib/layout/grid/bootstrap3 https://causeway.apache.org/applib/layout/grid/bootstrap3/bootstrap3.xsd"
+        xmlns:bs3="https://causeway.apache.org/applib/layout/grid/bootstrap3"
+        xmlns:cpt="https://causeway.apache.org/applib/layout/component"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+
+	<bs3:row>
+		<bs3:col span="10" unreferencedActions="true">
+			<cpt:domainObject />
+		</bs3:col>
+		<bs3:col span="2">
+			<cpt:fieldSet name="" id="sources" />
+		</bs3:col>
+	</bs3:row>
+
+	<bs3:row>
+		<bs3:col span="6">
+			<cpt:fieldSet name="Annotated" id="annotation"/>
+			<cpt:fieldSet name="Variants" id="variants"/>
+			<cpt:fieldSet name="Contributed" id="contributed"/>
+			<cpt:fieldSet name="Meta-annotated" id="meta-annotated"/>
+			<cpt:fieldSet name="Meta-annotated Overridden" id="meta-annotated-overridden"/>
+			<cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/>
+			<cpt:collection id="children">
+				<cpt:action id="returnsChildren"/>
+			</cpt:collection>
+		</bs3:col>
+		<bs3:col span="6">
+			<cpt:fieldSet name="Description" id="description" >
+				<cpt:action id="clearHints" position="PANEL" />
+				<cpt:action id="downloadLayoutXml"  position="PANEL_DROPDOWN"/>
+				<cpt:action id="rebuildMetamodel" position="PANEL"/>
+				<cpt:action id="downloadMetamodelXml"  position="PANEL_DROPDOWN"/>
+				<cpt:action id="inspectMetamodel"  position="PANEL_DROPDOWN"/>
+                <cpt:action id="recentCommands"  position="PANEL_DROPDOWN"/>
+				<cpt:action id="downloadJdoMetadata"  position="PANEL_DROPDOWN"/>
+				<cpt:action id="openRestApi" position="PANEL_DROPDOWN" />
+				<cpt:property id="description"/>
+			</cpt:fieldSet>
+		</bs3:col>
+	</bs3:row>
+	<bs3:row>
+		<bs3:col span="12" unreferencedCollections="true"/>
+	</bs3:row>
+
+</bs3:grid>