You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2023/05/30 06:24:26 UTC
[causeway] branch CAUSEWAY-2485 updated (13f9166b1e -> 95b3e0a073)
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a change to branch CAUSEWAY-2485
in repository https://gitbox.apache.org/repos/asf/causeway.git
from 13f9166b1e CAUSEWAY-2485: reworks @ActionLayout#redirectPolicy and @PropertyLayout#repainting
add 426eea0ef3 CAUSEWAY-2485: extends demo for @Percentage
add 9a23caf3c6 CAUSEWAY-3467: convenience: implement toString for ObjectActionParameter
add 4d35291f9b CAUSEWAY-3467: prepare checks for PARAMETER_HAS_NO_CHOICES_NOR_AUTOCOMPLETE
add 5defeaf8c0 CAUSEWAY-3467: fixes demo case and adds missing auto complete facet to param
add 73cd87f9f8 CAUSEWAY-3467: test approval
add 3d72dd7a7b CAUSEWAY-3467: test domain fixes
add 28a86b0f5b Merge remote-tracking branch 'origin/master' into issue_CAUSEWAY-3467-DomainObje
add c15a09559e CAUSEWAY-3467: fixes service loader issues (JDO bean )
add 689b13e497 CAUSEWAY-3467: wrapper guard flipped logic?
add a6e8d06338 Merge remote-tracking branch 'origin/master' into issue_CAUSEWAY-3467-DomainObje
add be4c62b624 CAUSEWAY-3467: demo fixes, showcase DomainObject#autoCompleteRepository
add 67f96b03b3 CAUSEWAY-3467: simplify demo showcase DomainObject#autoCompleteRepository
add 86a063e1cb CAUSEWAY-3467: proxies: just renaming vars
add f85ae7d742 CAUSEWAY-3467: fixes proxy creator
add db27d456a9 CAUSEWAY-3467: improve collection proxy code
add 8a7050f6c2 Merge pull request #1684 from apache/3467-domain.object.autocomplete
add ba35e43aad Bump camel.version from 3.14.7 to 3.14.8
add 9ee75c898f Merge pull request #1692 from apache/dependabot/maven/master/camel.version-3.14.8
add 950819d950 Bump maven-project-info-reports-plugin from 3.4.3 to 3.4.4
add ec4a255c28 Merge pull request #1689 from apache/dependabot/maven/master/org.apache.maven.plugins-maven-project-info-reports-plugin-3.4.4
add c0d18f146e CAUSEWAY-3467: demo adoc: remove warning (no longer an issue)
add 41b1150338 CAUSEWAY-3467: removing outdated comment
new 31cb24edad CAUSEWAY-2485: polishes demo app
new 4f8627c414 CAUSEWAY-2485: polishes demo app
new 95b3e0a073 CAUSEWAY-2485: polishes demo app descriptions
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
bom/pom.xml | 4 +-
.../proxy/_ProxyFactoryServiceAbstract.java | 18 +-
.../config/beans/CausewayBeanTypeClassifier.java | 10 +-
.../progmodel/ProgrammingModelConstants.java | 46 +-
.../MetaModelVisitor.java} | 61 +-
.../ActionParameterAutoCompleteFacetAbstract.java | 6 +-
...nParameterAutoCompleteFacetFromElementType.java | 75 +++
... => ActionParameterChoicesFacetFromAction.java} | 20 +-
...ctionParameterChoicesFacetFromElementType.java} | 17 +-
.../postprocessors/MetaModelPostProcessor.java | 9 +-
.../MetaModelPostProcessorAbstract.java | 13 +
.../param/ChoicesAndDefaultsPostProcessor.java | 87 ++-
.../core/metamodel/spec/ObjectSpecification.java | 10 +
.../specloader/postprocessor/PostProcessor.java | 5 +
.../specimpl/ObjectActionParameterAbstract.java | 7 +
.../specloader/validator/MetaModelValidator.java | 42 +-
.../handlers/CollectionInvocationHandler.java | 16 +-
.../DelegatingInvocationHandlerDefault.java | 5 +-
.../handlers/DomainObjectInvocationHandler.java | 11 +-
.../wrapper/handlers/MapInvocationHandler.java | 12 +-
.../NonScalarInvocationHandlerAbstract.java | 4 +-
.../wrapper/handlers/ProxyContextHandler.java | 20 +-
.../wrapper/proxy/ProxyCreator.java | 18 +-
.../proxy/ProxyCreatorTestUsingCodegenPlugin.java | 6 +-
.../DomainObjectAutoCompleteEntity.java | 14 +-
.../DomainObjectAutoCompleteEntityRepository.java | 23 +-
.../DomainObjectAutoCompletePage-description.adoc | 3 -
.../DomainObjectAutoCompletePage_find.java | 18 +
.../DomainObjectAutoCompletePage_objects.java | 21 +-
.../jdo/DomainObjectAutoCompleteEntityImpl.java | 10 +-
...mainObjectAutoCompleteEntityImplRepository.java | 13 +-
.../jpa/DomainObjectAutoCompleteEntityImpl.java | 10 +-
...mainObjectAutoCompleteEntityImplRepository.java | 13 +-
.../DomainObjectEditingPage-description.adoc | 43 +-
...jectEntityChangePublishingPage-description.adoc | 41 +-
.../DomainObjectIntrospectionPage-description.adoc | 75 ++-
...omainObjectIntrospectionAnnotOptEntityImpl.java | 6 +-
...nObjectIntrospectionEncapsulatedEntityImpl.java | 12 +-
...inObjectMixinMethodEntity_initialCharacter.java | 4 +-
.../DomainObjectMixinMethodEntity_updateName.java | 4 +-
...inObjectMixinMethodPage#objects.columnOrder.txt | 2 +
.../DomainObjectMixinMethodPage-description.adoc | 31 +-
.../DomainObjectMixinMethodPage_objects.java | 4 +-
.../nature/DomainObjectNaturePage-description.adoc | 49 +-
.../nature/DomainObjectNaturePage_entities.java | 11 +-
.../nature/DomainObjectNaturePage_viewModels.java | 1 -
.../DomainObjectNatureViewModel-description.adoc | 1 -
.../viewmodel/DomainObjectNatureViewModel.java | 6 +
.../ValueSemantics/ValueSemanticsMenu.java | 2 +-
.../ValueSemantics/percentage/Percentage.java | 8 +-
.../ValueSemanticsProviderForPercentage.java | 18 +-
...emanticsProviderPercentagePage-description.adoc | 42 +-
.../ValueSemanticsProviderPercentagePage.java | 4 +-
.../jpa/SpinUpDemoJpaTest.verify.approved.yaml | 723 ++++++++++++---------
...ay.core.config.beans.CausewayBeanTypeClassifier | 1 -
.../src/main/resources/META-INF/spring.factories | 1 +
.../DomainModelTest_usingGoodDomain.java | 4 +-
.../MetaModelRegressionTest.verify.approved.xml | 20 +-
.../testdomain/wrapper/jdo/JdoWrapperSyncTest.java | 2 +-
.../testdomain/jdo/JdoInventoryManager.java | 14 +-
.../testdomain/jpa/JpaInventoryManager.java | 13 +-
starters/pom.xml | 2 +-
supplemental-model/pom.xml | 2 +-
63 files changed, 1119 insertions(+), 674 deletions(-)
copy core/metamodel/src/main/java/org/apache/causeway/core/metamodel/{specloader/validator/MetaModelValidator.java => commons/MetaModelVisitor.java} (50%)
create mode 100644 core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/param/autocomplete/ActionParameterAutoCompleteFacetFromElementType.java
rename core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/param/choices/{ActionParameterChoicesFacetFromChoicesFromFacet.java => ActionParameterChoicesFacetFromAction.java} (79%)
rename core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/param/choices/{ActionParameterChoicesFacetFromChoicesFacet.java => ActionParameterChoicesFacetFromElementType.java} (80%)
create mode 100644 examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage#objects.columnOrder.txt
delete mode 100644 persistence/jdo/metamodel/src/main/resources/META-INF/services/org.apache.causeway.core.config.beans.CausewayBeanTypeClassifier
create mode 100644 persistence/jdo/metamodel/src/main/resources/META-INF/spring.factories
[causeway] 01/03: CAUSEWAY-2485: polishes demo app
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch CAUSEWAY-2485
in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 31cb24edad58ff593582e18e2e3abad5223fa9f3
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue May 30 06:48:31 2023 +0100
CAUSEWAY-2485: polishes demo app
---
.../DomainObjectEditingPage-description.adoc | 43 ++++++-------
...jectEntityChangePublishingPage-description.adoc | 41 ++++++------
.../DomainObjectIntrospectionPage-description.adoc | 75 ++++++++++++++++------
...omainObjectIntrospectionAnnotOptEntityImpl.java | 6 +-
...nObjectIntrospectionEncapsulatedEntityImpl.java | 12 ++--
5 files changed, 109 insertions(+), 68 deletions(-)
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/editing/DomainObjectEditingPage-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/editing/DomainObjectEditingPage-description.adoc
index ed7a1de9d5..19ee8ddb17 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/editing/DomainObjectEditingPage-description.adoc
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/editing/DomainObjectEditingPage-description.adoc
@@ -1,24 +1,20 @@
: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 state of the application can be changed either by invoking actions on domain objects, or by directly editing their properties.
-
-If the application has complicated business logic, then it's usually preferable to make all changes using actions, with editing globally disabled using a configuration property:
-
-[source,yaml]
-.application.yml
-----
-causeway:
- applib:
- annotation:
- domain-object:
- editing: false # false | true
-----
-
+If the application has complicated business logic, then it's usually preferable to make all changes using actions, with editing globally disabled using a configuration property (see section below for details).
This demo application is configured in this recommended way, with property editing disabled by default.
-The link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObject.html#editing[@DomainObject#editing] annotation can be used to override the default for a specific object, so that all of its properties can be edited.
+The link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObject.html#editing[@DomainObject#editing] annotation can be used to override the default for a specific object, so that all of its properties can be edited.
In addition, the link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObject.html#editingDisabledReason[@DomainObject#editingDisabledReason] can be used to specify the reason why a property cannot be edited.
+It's also possible to override the class-level default on a per-property basis, using the link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Property.html#editing[@Property#editing] attribute.
+A reason can also be specified at the property level using link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Property.html#editingDisabledReason[@Property#editingDisabledReason].
+There are therefore three levels at which property editing can be defined:
+
+ global configuration < @DomainObject < @Property
+
+This works in the opposite direction also: if the global config property is to _allow_ properties to be edited, then the `@DomainObject#editing` (or `@Property#editing`) could be used to disable editing.
+Such a setup is likely to be much less common, though.
== How this demo works
@@ -45,15 +41,18 @@ See section below for further discussion.
-== See also
-
-It's also possible to override the class-level default on a per-property basis, using the link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Property.html#editing[@Property#editing] attribute.
-A reason can also be specified at the property level using link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Property.html#editingDisabledReason[@Property#editingDisabledReason].
+== Configuration property
-There are therefore three levels at which property editing can be defined:
+To disable/enable editing globally, use:
- @Property > @DomainObject > global configuration property
+[source,yaml]
+.application.yml
+----
+causeway:
+ applib:
+ annotation:
+ domain-object:
+ editing: false # false | true
+----
-Alternatively, this works in the opposite direction also: if the global config property is to _allow_ properties to be edited, then the `@DomainObject#editing` (or `@Property#editing`) could be used to disable editing.
-This would be much less common, though.
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/entityChangePublishing/DomainObjectEntityChangePublishingPage-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/entityChangePublishing/DomainObjectEntityChangePublishingPage-description.adoc
index 52d064b9ae..71e1e43735 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/entityChangePublishing/DomainObjectEntityChangePublishingPage-description.adoc
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/entityChangePublishing/DomainObjectEntityChangePublishingPage-description.adoc
@@ -7,23 +7,12 @@ This callback is done only at the end of the interaction.
Common use cases are to replicate data to another system, or for gathering metrics ("which objects change the most?").
A typical SPI implementation could publish the event over the network, or perhaps store in a database.
-NOTE: Publishing of domain objects is only supported for domain entities, not view models.
-
-Entity change publishing can be enabled or disabled globally using a configuration property:
-
-[source,yaml]
-.application.yml
-----
-causeway:
- applib:
- annotation:
- domain-object:
- entity-change-publishing: 'none' # 'none' | 'all'
-----
-
-This demo app has entity change publishing disabled by default, but can be re-enabled on a case by case basis using the link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObject.html#entitychangepublishing[@DomainObject#entitychangepublishing] attribute.
+Entity change publishing can be enabled or disabled globally using a configuration property (see section below).
+This demo app has entity change publishing disabled by default, but can be re-enabled on a case by case basis using the link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObject.html#entitychangepublishing[@DomainObject#entityChangePublishing] attribute.
This page references a domain object that uses this attribute.
+NOTE: Publishing of domain objects is only supported for domain entities, not view models.
+
== How this demo works
@@ -31,7 +20,7 @@ This page references a domain object that uses this attribute.
The collection on the left shows a set of entity instances, which have `@DomainObject#entityChangePublishing` to enable the publishing of any changes to their state.
Below it is a collection that simply lists all of the changes that have been received.
This uses an implementation of `EntityChangesSubscriber` that captures changes and simply holds them in-memory.
-(There will always be some listed from the fixture scripts run when the application first bootstraps.)
+(There will always be some listed from the fixture scripts that are run when the application bootstraps.)
Using the "modify" action, you can (in one go) create new instances of the entity class, update existing instances, or delete instances.
This will cause new events to be logged.
@@ -46,14 +35,14 @@ In terms of code:
include::jpa/DomainObjectEntityChangePublishingEntityImpl.java[tags=class]
----
-* the modify action:
+* the modify action can be used to create new instances, update existing instances and/or delete existing instances:
+
[source,java,indent=0]
----
include::DomainObjectEntityChangePublishingPage_modify.java[tags=act]
----
-* the subscriber:
+* the subscriber listens to the events and simply adds them to the list:
+
[source,java,indent=0]
.EntityChangesSubscriberToCaptureChangesInMemory.java
@@ -62,7 +51,7 @@ include::../../../_changes/EntityChangesSubscriberToCaptureChangesInMemory.java[
----
<.> describes the set of changes
-* NB: this page shows the list of recent changes by virtue of also implementing a `ExposeCapturedChanges` marker interface (part of the demo app, not the framework).
+* the list of recent changes is shown because this page implementing an `ExposeCapturedChanges` marker interface (part of the demo app, not the framework).
A mixin then contributes the "recentChanges" collection:
+
[source,java,indent=0]
@@ -71,3 +60,17 @@ A mixin then contributes the "recentChanges" collection:
include::../../../_changes/ExposeCapturedChanges_recentChanges.java[tags=class]
----
+== Configuration property
+
+To enable/disable entity change publishing, use this configuration property:
+
+[source,yaml]
+.application.yml
+----
+causeway:
+ applib:
+ annotation:
+ domain-object:
+ entity-change-publishing: 'none' # 'none' | 'all'
+----
+
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/DomainObjectIntrospectionPage-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/DomainObjectIntrospectionPage-description.adoc
index 770f77e066..cb47948edc 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/DomainObjectIntrospectionPage-description.adoc
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/DomainObjectIntrospectionPage-description.adoc
@@ -5,26 +5,73 @@ Introspection is the process by which the framework builds up its internal metam
The framework supports three different introspection policies, depending on your taste of whether the metamodel should be explicitly called out (but that means more 'boilerplate'), or should be inferred so far as possible.
These introspection policies are:
-* "annotation optional"
-+
-Introspect public methods only, recognising getters as either properties or collections, and other public methods as actions.
+* *annotation optional* - introspect public methods only, recognising getters as either properties or collections, and other public methods as actions.
+
Supporting methods for either domain members (`hide`, `disable`, `validate`, `choices`, `autoComplete`) or for the object (`title`, `iconName`, `layout`, `cssClass`) do not need to be annotated either.
-* "annotation required"
-+
-Requires that getter methods representing properties or collections, and public methods representing actions are all explicitly annotated (with link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Property.html[@Property], link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Collection.html[@Collection] and link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Action.html[@Action])
+* *annotation required* - requires that getter methods representing properties or collections, and public methods representing actions are all explicitly annotated (with link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Property.html[@Property], link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Collection.html[@Collection] and link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Action.html[@Action])
+
However supporting methods for domain members (`hide`, `disable`, `validate`, `choices`, `autoComplete`) and for the object (`title`, `iconName`, `layout`, `cssClass`) do not need to be annotated.
-* "encapsulation enabled"
-+
-Requires that both the methods representing properties, collections an actions are annotated (with `@Property,` `@Collection` and `@Action`), and _also_ that the supporting methods are annotated (with link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/MemberSupport.html[@MemberSupport] for methods relating to domain members, and link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/ObjectSupport.html[@ObjectSupport] for the object-level supp [...]
+* *encapsulation enabled* - requires that both the methods representing properties, collections an actions are annotated (with `@Property,` `@Collection` and `@Action`), and _also_ that the supporting methods are annotated (with link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/MemberSupport.html[@MemberSupport] for methods relating to domain members, and link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/ObjectSupport.html[@ObjectSuppor [...]
+
However, the methods can have _any_ visibility, including `private` visibility.
This reduces the programmatic API of the domain object can so can help eliminate bugs.
++
+[NOTE]
+====
+entities using this type do not render correctly in collections - properties are not shown as columns.
+Tracking with https://issues.apache.org/jira/browse/CAUSEWAY-3471[CAUSEWAY-3471]
+====
+
+The default policy is set using a configuration property (see section below).
+Normally there would be little reason to override this - just adopt the convention that best fits your style, and leave it at that.
+However, it the need arises then it can be overridden on a class by class basis using the link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObject.html#introspection[@DomainObject#introspection] attribute.
+
+== How this demo works
+
+The collections on the left show three variants of the same entity, each with a property and an action, but each configured to use a different introspection policy.
+
+Navigate through to the entity to inspect the differences in their source code.
+
+In terms of code:
+
+* annotation optional:
++
+[source,java]
+----
+include::annotOpt/jpa/DomainObjectIntrospectionAnnotOptEntityImpl.java[tags=class]
+----
+<.> no need to annotate with `@Property`.
+It would also be ok to remove the methods but then annotate the field with `@lombok.Getter` and `@lombok.Setter`
+<.> no need to annotate with `@Action`
+<.> no need to annotate with `@MemberSupport`
-The default policy is set using a configuration property:
+* annotation required:
++
+[source,java]
+----
+include::annotReqd/jpa/DomainObjectIntrospectionAnnotReqdEntityImpl.java[tags=class]
+----
+<.> must annotate as `@Property`.
+It would also be ok to remove the methods but then annotate the field with `@Property` and also with `@lombok.Getter` and `@lombok.Setter`
+<.> must annotate as `@Action`
+<.> no need to annotate with `@MemberSupport`
+
+* encapsulated:
++
+[source,java]
+----
+include::encapsulated/jpa/DomainObjectIntrospectionEncapsulatedEntityImpl.java[tags=class]
+----
+<.> must annotate as `@Property`, but can have any visibility
+<.> must annotate as `@Action`, but can have any visibility
+<.> must annotate as @`MemberSupport` or `@Domain.Include`, but can have any visibility
+
+
+== Configuration property
+
+The default introspection policy is set using a configuration property:
[source,yaml]
.application.yaml
@@ -37,11 +84,3 @@ causeway:
----
<.> `annotation_optional` | `annotation_required` | `encapsulation_enabled`
-Normally there would be little reason to override this - just adopt the convention that best fits your style, and leave it at that.
-However, it the need arises then it can be overridden on a class by class basis using the link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObject.html#introspection[@DomainObject#introspection] attribute.
-
-== How this demo works
-
-The collections on the left show three variants of the same entity, each with a property and an action, but each configured to use a different introspection policy.
-
-Navigate through to the entity to inspect the differences in their source code.
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/annotOpt/jpa/DomainObjectIntrospectionAnnotOptEntityImpl.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/annotOpt/jpa/DomainObjectIntrospectionAnnotOptEntityImpl.java
index 1893ecdb56..fa71c43a11 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/annotOpt/jpa/DomainObjectIntrospectionAnnotOptEntityImpl.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/annotOpt/jpa/DomainObjectIntrospectionAnnotOptEntityImpl.java
@@ -63,7 +63,7 @@ public class DomainObjectIntrospectionAnnotOptEntityImpl
private Long id;
//tag::class[]
- private String name; // <.>
+ private String name; // <.>
public String getName() {
return name;
}
@@ -71,11 +71,11 @@ public class DomainObjectIntrospectionAnnotOptEntityImpl
this.name = name;
}
- public DomainObjectIntrospectionAnnotOptEntityImpl updateName(final String name) { // <.>
+ public DomainObjectIntrospectionAnnotOptEntityImpl updateName(final String name) { // <.>
setName(name);
return this;
}
- public String default0UpdateName() { // <.>
+ public String default0UpdateName() { // <.>
return getName();
}
}
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/encapsulated/jpa/DomainObjectIntrospectionEncapsulatedEntityImpl.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/encapsulated/jpa/DomainObjectIntrospectionEncapsulatedEntityImpl.java
index 7ea5c9ac6c..20a261c4b0 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/encapsulated/jpa/DomainObjectIntrospectionEncapsulatedEntityImpl.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/introspection/encapsulated/jpa/DomainObjectIntrospectionEncapsulatedEntityImpl.java
@@ -73,21 +73,21 @@ public class DomainObjectIntrospectionEncapsulatedEntityImpl
//tag::class[]
private String name;
- @Property // <.>
- private String getName() { // <1>
+ @Property // <.>
+ private String getName() { // <1>
return name;
}
private void setName(String name) {
this.name = name;
}
- @Action(semantics = SemanticsOf.IDEMPOTENT) // <.>
- private DomainObjectIntrospectionEncapsulatedEntity updateName(final String name) { // <2>
+ @Action(semantics = SemanticsOf.IDEMPOTENT) // <.>
+ private DomainObjectIntrospectionEncapsulatedEntity updateName(final String name) { // <2>
setName(name);
return this;
}
- @MemberSupport // <.>
- private String default0UpdateName() { // <3>
+ @MemberSupport // <.>
+ private String default0UpdateName() { // <3>
return getName();
}
}
[causeway] 02/03: CAUSEWAY-2485: polishes demo app
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch CAUSEWAY-2485
in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 4f8627c4148adb59262ed6754e39f467bd1be037
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue May 30 07:10:48 2023 +0100
CAUSEWAY-2485: polishes demo app
---
...inObjectMixinMethodEntity_initialCharacter.java | 4 +--
.../DomainObjectMixinMethodEntity_updateName.java | 4 +--
...inObjectMixinMethodPage#objects.columnOrder.txt | 2 ++
.../DomainObjectMixinMethodPage-description.adoc | 31 ++++++++++++++++------
.../DomainObjectMixinMethodPage_objects.java | 4 +--
5 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodEntity_initialCharacter.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodEntity_initialCharacter.java
index ae63240059..eb35493cf4 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodEntity_initialCharacter.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodEntity_initialCharacter.java
@@ -8,7 +8,7 @@ import lombok.RequiredArgsConstructor;
import lombok.val;
//tag::class[]
-@DomainObject(mixinMethod = "property") // <.>
+@DomainObject(mixinMethod = "property") // <.>
@Property()
@RequiredArgsConstructor
public class DomainObjectMixinMethodEntity_initialCharacter {
@@ -16,7 +16,7 @@ public class DomainObjectMixinMethodEntity_initialCharacter {
private final DomainObjectMixinMethodEntity mixee;
@MemberSupport
- public Character property() { // <.>
+ public Character property() { // <.>
val charArray = mixee.getName().toCharArray();
return charArray.length == 0 ? null : charArray[0];
}
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodEntity_updateName.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodEntity_updateName.java
index 5fd975ae44..ca4e499ff3 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodEntity_updateName.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodEntity_updateName.java
@@ -7,7 +7,7 @@ import org.apache.causeway.applib.annotation.MemberSupport;
import lombok.RequiredArgsConstructor;
//tag::class[]
-@DomainObject(mixinMethod = "action") // <.>
+@DomainObject(mixinMethod = "action") // <.>
@Action()
@RequiredArgsConstructor
public class DomainObjectMixinMethodEntity_updateName {
@@ -15,7 +15,7 @@ public class DomainObjectMixinMethodEntity_updateName {
private final DomainObjectMixinMethodEntity mixee;
@MemberSupport
- public DomainObjectMixinMethodEntity action(final String newName) { // <.>
+ public DomainObjectMixinMethodEntity action(final String newName) { // <.>
mixee.setName(newName);
return mixee;
}
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage#objects.columnOrder.txt b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage#objects.columnOrder.txt
new file mode 100644
index 0000000000..74bfc008f9
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage#objects.columnOrder.txt
@@ -0,0 +1,2 @@
+name
+initialCharacter
\ No newline at end of file
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage-description.adoc
index 7d437d3472..2115d60bc8 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage-description.adoc
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage-description.adoc
@@ -2,12 +2,14 @@
Mixins are a mechanism for decoupling behaviour from state, so that the behaviour of the mixin seemingly belongs to an underlying domain object, but in fact is implemented in a different class.
This is a particularly powerful capability for large "modular monoliths", because the mixin can reside in one module and the mixee (or contributee) can reside in another.
-This is made even more powerful by the fact that the contributee can be an interface type rather than a concrete class.
+This is made even more powerful by the fact that the mixin can contribute by way of an interface implemented by the contributee, rather than the contributee's concrete class.
+
+TIP: learn more about mixins at `Prog Model > Mixins`.
The idiomatic way of writing mixins is as class that is annotated with link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Property.html[@Property], link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Collection.html[@Collection] or link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/Action.html[@Action].
These require that the mixin class has a single primary method representing the domain member being contributed.
By default the name of this method is "prop" for properties, "coll" for collections, and "act" for actions.
-This default is defined through the link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObject.html#mixinmethod[@DomainObject#mixinmethod]; if you look into their definition you will see that the `@Property,` `@Collection` and `@Action` are all meta-annotated with `@DomainObject#mixinMethod`.
+This default is defined through the link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/annotation/DomainObject.html#mixinmethod[@DomainObject#mixinMethod]; if you look into their definition you will see that the `@Property,` `@Collection` and `@Action` are all meta-annotated with `@DomainObject#mixinMethod`.
In most circumstances there will be little need to use `@DomainObject#mixinMethod` directly.
However, if you prefer some other method names other than the defaults then you can annotate your mixins with this annotation; or define your own annotation (eg `@MyAction`) and meta-annotate it with both `@Action` and `@DomainObject#mixinMethod` as appropriate.
@@ -15,8 +17,14 @@ However, if you prefer some other method names other than the defaults then you
== How this demo works
-The collection on the left is a mixin to this view model, but (for demonstration purposes) uses `@DomainObject#mixinMethod` to change the default method name from "coll" to "collection":
+The collection on the left is a mixin to this view model, the "updateName" is a mixin action allows the name of any object to be updated, and the "initialCharacter" is a mixin property.
+These each uses `@DomainObject#mixinMethod` to change the default method name.
+
+In terms of code:
+* the mixin collection changes the default method name from "coll" to "collection".
+It is defined as:
++
[source,java,indent=0]
.DomainObjectMixinMethodPage_objects.java
----
@@ -25,9 +33,8 @@ include::DomainObjectMixinMethodPage_objects.java[tags=class]
<.> overrides the default mixin method
<.> method representing the contributed domain collection, using the overridden method name
-Similarly, the "updateName" action shown on the collection panel is also a mixin, allowing the name of any object to be updated.
-This also overrrides the default name:
-
+* the "updateName" mixin action (shown on the collection panel) overrrides the default name from "act" to "action":
++
[source,java,indent=0]
.DomainObjectMixinMethodPage_updateName.java
----
@@ -36,5 +43,13 @@ include::DomainObjectMixinMethodPage_updateName.java[tags=class]
<.> overrides the default mixin method
<.> method representing the contributed domain collection, using the overridden method name
-The 'initialCharacter' column in the table is also a mixin, this time of the domain class in the collection.
-Navigate through to the entity to inspect that mixin's source code.
+* the entity's 'initialCharacter' property mixin (shown as a column in the table is also a mixin) overrides the default name from "prop" to "property":
++
+[source,java,indent=0]
+.DomainObjectMixinMethodEntity_initialCharacter.java
+----
+include::DomainObjectMixinMethodEntity_initialCharacter.java[tags=class]
+----
+<.> overrides the default mixin method
+<.> method representing the contributed domain collection, using the overridden method name
+
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage_objects.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage_objects.java
index 94081d2fbc..bae56f1401 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage_objects.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/mixinMethod/DomainObjectMixinMethodPage_objects.java
@@ -13,7 +13,7 @@ import lombok.RequiredArgsConstructor;
import demoapp.dom._infra.values.ValueHolderRepository;
//tag::class[]
-@DomainObject(mixinMethod = "collection") // <.>
+@DomainObject(mixinMethod = "collection") // <.>
@Collection()
@CollectionLayout()
@RequiredArgsConstructor
@@ -24,7 +24,7 @@ public class DomainObjectMixinMethodPage_objects {
private final DomainObjectMixinMethodPage page;
//tag::class[]
- public List<? extends DomainObjectMixinMethodEntity> collection() { // <.>
+ public List<? extends DomainObjectMixinMethodEntity> collection() { // <.>
// ...
//end::class[]
return objectRepository.all();
[causeway] 03/03: CAUSEWAY-2485: polishes demo app descriptions
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch CAUSEWAY-2485
in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 95b3e0a07397de13e17fca3d632352eeba3217e7
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue May 30 07:23:56 2023 +0100
CAUSEWAY-2485: polishes demo app descriptions
---
.../nature/DomainObjectNaturePage-description.adoc | 49 ++++++++++++++++------
.../nature/DomainObjectNaturePage_entities.java | 11 ++++-
.../nature/DomainObjectNaturePage_viewModels.java | 1 -
.../DomainObjectNatureViewModel-description.adoc | 1 -
.../viewmodel/DomainObjectNatureViewModel.java | 6 +++
5 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage-description.adoc
index 3811bfca8f..c0f99f3046 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage-description.adoc
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage-description.adoc
@@ -6,27 +6,40 @@ Domain classes fall into three broad categories:
* domain entities, representing shared persistence state (eg `Customer`, `Order`, `Product` and so on)
* link:https://causeway.apache.org/userguide/${CAUSEWAY_VERSION}/fun/overview.html#view-models[view models], which hold session-specific (temporary) state.
View models can be used for a variety of use cases, such as a "manager" class to handle a complicated workflow (part of an "application layer"), or as an object to render as a simplified representation of an entity (part of the "presentation layer").
+The object you are looking at right now is a view model.
Strictly speaking mixins are domain objects (with a `nature` of "MIXIN"), though they manifest as contributed domain members (properties, collections or actions) rather than as individual object instances in their own right.
-The object you are looking at right now is a view model.
-Its source code is:
+
+== How this demo works
+
+There are two collections on the left hand side, one of domain entities and the other of view models.
+The entities are obtained by querying a repository, while the view models are created on the fly, each wrapping a corresponding entity.
+
+In terms of code:
+
+* collection of entities:
++
[source,java]
-.DomainObjectNaturePage.java
+.DomainObjectNaturePage_entities.java
----
-include::DomainObjectNaturePage.java[tags=class]
+include::DomainObjectNaturePage_entities.java[tags=class]
----
-<.> Specifies this is a JAXB element.
-This is actually enough for the framework to infer that this domain object is a view model.
++
+where `DomainObjectNatureEntity` (JPA version) is defined as:
++
+[source,java]
+.DomainObjectNaturePage_entities.java
+----
+include::entity/jpa/DomainObjectNatureEntityImpl.java[tags=class]
+----
+<.> The framework can infer the nature of the domain class from these annotations
<.> Nevertheless, it's generally good practice to specify the nature explicitly.
-== How this demo works
-
-There are two collections on the left hand side, one of domain entities and the other of view models.
-The entities are obtained by querying a repository, while the view models are created on the fly, each wrapping a corresponding entity:
-
+* collection of view models:
++
[source,java]
.DomainObjectNaturePage_viewModels.java
----
@@ -34,5 +47,17 @@ include::DomainObjectNaturePage_viewModels.java[tags=class]
----
<.> creates view model on the fly.
-Navigate through to these domain objects to inspect their source code; both the entity and view model explicitly indicates its `nature`.
++
+where `DomainObjectNatureEntity` is defined as:
++
+[source,java]
+.DomainObjectNaturePage_entities.java
+----
+include::viewmodel/DomainObjectNatureViewModel.java[tags=class]
+----
+<.> Specifies this is a JAXB element.
+This is actually enough for the framework to infer that this domain object is a view model.
+<.> Nevertheless, it's generally good practice to specify the nature explicitly.
+<.> Required to reference a persistent entity (or the entity class itself can be so annotated).
+
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage_entities.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage_entities.java
index c504bb7fd6..81d3f7f173 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage_entities.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage_entities.java
@@ -11,16 +11,23 @@ import lombok.RequiredArgsConstructor;
import demoapp.dom._infra.values.ValueHolderRepository;
import demoapp.dom.domain.objects.DomainObject.nature.entity.DomainObjectNatureEntity;
+//tag::class[]
@Collection()
@RequiredArgsConstructor
public class DomainObjectNaturePage_entities {
+ // ...
+//end::class[]
@SuppressWarnings("unused")
private final DomainObjectNaturePage page;
+//tag::class[]
public List<? extends DomainObjectNatureEntity> coll() {
- return objectRepository.all();
+ return entities.all();
}
+//end::class[]
- @Inject ValueHolderRepository<String, ? extends DomainObjectNatureEntity> objectRepository;
+ @Inject ValueHolderRepository<String, ? extends DomainObjectNatureEntity> entities;
+//tag::class[]
}
+//end::class[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage_viewModels.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage_viewModels.java
index 72ad49162d..2ddaf3b5d1 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage_viewModels.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/DomainObjectNaturePage_viewModels.java
@@ -31,7 +31,6 @@ public class DomainObjectNaturePage_viewModels {
//end::class[]
@Inject ValueHolderRepository<String, ? extends DomainObjectNatureEntity> entities;
-
//tag::class[]
}
//end::class[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/viewmodel/DomainObjectNatureViewModel-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/viewmodel/DomainObjectNatureViewModel-description.adoc
index 186cdc01cf..0a8b355573 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/viewmodel/DomainObjectNatureViewModel-description.adoc
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/viewmodel/DomainObjectNatureViewModel-description.adoc
@@ -10,7 +10,6 @@ include::DomainObjectNatureViewModel.java[tags=class]
<.> Specifies this is a JAXB element.
This is actually enough for the framework to infer that this domain object is a view model.
<.> Nevertheless, it's generally good practice to specify the nature explicitly.
-<.> Presentation logic that build on the behaviour of the underlying entity.
<.> Required to reference a persistent entity (or the entity class itself can be so annotated).
In many cases the framework is able to infer the nature of the domain object from annotations such as `@Entity` or `@PersistenceCapable` (for JPA or JDO entities), or from `@XmlElement` for JAXB-style view models.
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/viewmodel/DomainObjectNatureViewModel.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/viewmodel/DomainObjectNatureViewModel.java
index d212051d6e..da40f4994e 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/viewmodel/DomainObjectNatureViewModel.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObject/nature/viewmodel/DomainObjectNatureViewModel.java
@@ -56,6 +56,9 @@ public class DomainObjectNatureViewModel
this.message = underlying.getName();
this.underlying = underlying;
}
+ // ...
+
+//end::class[]
@ObjectSupport public String title() { // <.>
return message != null ? message : titleService.titleOf(underlying);
@@ -66,12 +69,15 @@ public class DomainObjectNatureViewModel
@XmlElement(required = false)
private String message;
+//tag::class[]
@Property
@Getter @Setter
@XmlElement
@XmlJavaTypeAdapter(PersistentEntityAdapter.class) // <.>
private DomainObjectNatureEntity underlying;
+//end::class[]
@Inject @XmlTransient TitleService titleService;
+//tag::class[]
}
//end::class[]