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
The following commit(s) were added to refs/heads/CAUSEWAY-2485 by this push:
new f3ae4fdc38 CAUSEWAY-2485: fleshes out WrapperFactory
f3ae4fdc38 is described below
commit f3ae4fdc38bf9ef2d025ad319cee4e0e5aeb9059
Author: danhaywood <[email protected]>
AuthorDate: Sun May 21 15:54:11 2023 +0100
CAUSEWAY-2485: fleshes out WrapperFactory
---
.../src/main/java/demoapp/dom/DemoModuleJpa.java | 4 +-
.../demoapp/dom/services/core/ServicesMenu.java | 29 ++--
...ErrorReportingServiceDemoPage-description.adoc} | 0
...oVm.java => ErrorReportingServiceDemoPage.java} | 4 +-
...ml => ErrorReportingServiceDemoPage.layout.xml} | 0
...{WrapperFactoryEntity.java => PrimeNumber.java} | 27 ++--
...FactorySeeding.java => PrimeNumberFactory.java} | 19 +--
.../core/wrapperFactory/PrimeNumberGenerator.java | 70 ++++++++++
...JdoEntities.java => PrimeNumberRepository.java} | 26 ++--
.../WrapperFactoryDemoPage-description.adoc | 49 +++++++
.../WrapperFactoryDemoPage.java} | 31 ++---
.../WrapperFactoryDemoPage.layout.xml} | 6 +-
.../WrapperFactoryDemoPage_createPrimes.java | 44 ++++++
.../WrapperFactoryDemoPage_primeNumbers.java | 28 ++++
...pperFactoryEntity_mixinUpdatePropertyAsync.java | 63 ---------
...pperFactoryEntity_updatePropertyAsyncMixin.java | 54 --------
...iption.adoc => PrimeNumberJdo-description.adoc} | 5 +-
.../core/wrapperFactory/jdo/PrimeNumberJdo.java | 58 ++++++++
...ava => PrimeNumberJdoFactoryAndRepository.java} | 32 ++++-
.../core/wrapperFactory/jdo/WrapperFactoryJdo.java | 136 -------------------
...iption.adoc => PrimeNumberJpa-description.adoc} | 3 +-
.../core/wrapperFactory/jpa/PrimeNumberJpa.java | 68 ++++++++++
...ava => PrimeNumberJpaFactoryAndRepository.java} | 30 ++++-
.../core/wrapperFactory/jpa/WrapperFactoryJpa.java | 148 ---------------------
24 files changed, 425 insertions(+), 509 deletions(-)
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/DemoModuleJpa.java
b/examples/demo/domain/src/main/java/demoapp/dom/DemoModuleJpa.java
index 1e02db9178..50b6ec5486 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/DemoModuleJpa.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/DemoModuleJpa.java
@@ -59,7 +59,7 @@ import
demoapp.dom.domain.properties.Property.projecting.jpa.PropertyProjectingC
import demoapp.dom.domain.properties.Property.snapshot.jpa.PropertySnapshotJpa;
import
demoapp.dom.domain.properties.PropertyLayout.hidden.jpa.PropertyLayoutHiddenJpa;
import demoapp.dom.services.core.eventbusservice.EventLogEntryJpa;
-import demoapp.dom.services.core.wrapperFactory.jpa.WrapperFactoryJpa;
+import demoapp.dom.services.core.wrapperFactory.jpa.PrimeNumberJpa;
import demoapp.dom.services.extensions.secman.apptenancy.jpa.TenantedJpa;
import demoapp.dom.types.causeway.blobs.jpa.CausewayBlobJpa;
import demoapp.dom.types.causeway.clobs.jpa.CausewayClobJpa;
@@ -206,7 +206,7 @@ import
demoapp.dom.types.primitive.shorts.jpa.PrimitiveShortJpa;
WrapperByteJpa.class,
TenantedJpa.class,
- WrapperFactoryJpa.class,
+ PrimeNumberJpa.class,
NumberConstantJpa.class,
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java
index 2f26b5272c..fe54b768a2 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java
@@ -18,6 +18,7 @@
*/
package demoapp.dom.services.core;
+import javax.annotation.Priority;
import javax.inject.Inject;
import javax.inject.Named;
@@ -29,48 +30,44 @@ import
org.apache.causeway.applib.annotation.PriorityPrecedence;
import org.apache.causeway.applib.annotation.SemanticsOf;
import org.apache.causeway.applib.services.factory.FactoryService;
+import demoapp.dom.services.core.wrapperFactory.WrapperFactoryDemoPage;
+
import lombok.RequiredArgsConstructor;
-import demoapp.dom._infra.values.ValueHolderRepository;
-import
demoapp.dom.services.core.errorreportingservice.ErrorReportingServiceDemoVm;
+import
demoapp.dom.services.core.errorreportingservice.ErrorReportingServiceDemoPage;
import demoapp.dom.services.core.eventbusservice.EventBusServiceDemoPage;
import demoapp.dom.services.core.messageservice.MessageServiceDemoPage;
-import demoapp.dom.services.core.wrapperFactory.WrapperFactoryEntity;
@Named("demo.ServicesMenu")
-@DomainService(
- nature=NatureOfService.VIEW
-)
[email protected](PriorityPrecedence.EARLY)
+@DomainService(nature=NatureOfService.VIEW)
+@Priority(PriorityPrecedence.EARLY)
@RequiredArgsConstructor(onConstructor_ = {@Inject})
public class ServicesMenu {
- final ValueHolderRepository<String, ? extends WrapperFactoryEntity>
wrapperFactoryEntities;
- final FactoryService factoryService;
-
+ private final FactoryService factoryService;
@Action
@ActionLayout(cssClassFa="fa-bolt")
public EventBusServiceDemoPage eventBusService(){
- return factoryService.viewModel(new EventBusServiceDemoPage());
+ return new EventBusServiceDemoPage();
}
@Action
@ActionLayout(cssClassFa="fa-sticky-note")
public MessageServiceDemoPage messageService(){
- return factoryService.viewModel(new MessageServiceDemoPage());
+ return new MessageServiceDemoPage();
}
@Action
@ActionLayout(cssClassFa="fa-bomb")
- public ErrorReportingServiceDemoVm errorReportingService(){
- return factoryService.viewModel(new ErrorReportingServiceDemoVm());
+ public ErrorReportingServiceDemoPage errorReportingService(){
+ return new ErrorReportingServiceDemoPage();
}
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(cssClassFa="fa-gift", describedAs = "Formal object
interactions + async")
- public WrapperFactoryEntity wrapperFactory(){
- return wrapperFactoryEntities.first().orElse(null);
+ public WrapperFactoryDemoPage wrapperFactory(){
+ return factoryService.viewModel(WrapperFactoryDemoPage.class);
}
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoPage-description.adoc
similarity index 100%
rename from
examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm-description.adoc
rename to
examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoPage-description.adoc
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoPage.java
similarity index 94%
copy from
examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm.java
copy to
examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoPage.java
index 2789be054c..73c78ffa0e 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoPage.java
@@ -36,9 +36,9 @@ import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
@XmlRootElement(name = "Demo")
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
-@Named("demo.ErrorReportingServiceDemoVm")
+@Named("demo.ErrorReportingServiceDemoPage")
@DomainObject(nature=Nature.VIEW_MODEL, editing=Editing.ENABLED)
-public class ErrorReportingServiceDemoVm implements HasAsciiDocDescription {
+public class ErrorReportingServiceDemoPage implements HasAsciiDocDescription {
@ObjectSupport public String title() {
return "Error Reporting Service Demo";
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm.layout.xml
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoPage.layout.xml
similarity index 100%
copy from
examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm.layout.xml
copy to
examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoPage.layout.xml
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryEntity.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumber.java
similarity index 63%
rename from
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryEntity.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumber.java
index cb0022f74e..c0c05c3cc2 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryEntity.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumber.java
@@ -21,28 +21,23 @@ package demoapp.dom.services.core.wrapperFactory;
import javax.inject.Named;
import org.apache.causeway.applib.annotation.DomainObject;
+import org.apache.causeway.applib.annotation.DomainObjectLayout;
+import org.apache.causeway.applib.annotation.ObjectSupport;
import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
-import demoapp.dom._infra.values.ValueHolder;
-import demoapp.dom.domain._commands.ExposePersistedCommands;
-@Named("demo.WrapperFactoryEntity") // shared permissions with concrete sub
class
+@Named("demo.PrimeNumber") // shared permissions with concrete sub class
@DomainObject
-public abstract class WrapperFactoryEntity
+@DomainObjectLayout
+public abstract class PrimeNumber
implements
- HasAsciiDocDescription,
- ExposePersistedCommands,
- ValueHolder<String> {
+ HasAsciiDocDescription {
- public abstract String getPropertyAsync();
- public abstract void setPropertyAsync(String value);
-
- public abstract String getPropertyAsyncMixin();
- public abstract void setPropertyAsyncMixin(String value);
-
- @Override
- public String value() {
- return getPropertyAsync();
+ @ObjectSupport
+ public String title() {
+ return "PrimeNumber: " + getPrimeNumber();
}
+ public abstract Integer getPrimeNumber();
+
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactorySeeding.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumberFactory.java
similarity index 68%
rename from
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactorySeeding.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumberFactory.java
index 41bcb717bf..a6c00d50c1 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactorySeeding.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumberFactory.java
@@ -18,21 +18,6 @@
*/
package demoapp.dom.services.core.wrapperFactory;
-import javax.inject.Inject;
-
-import org.springframework.stereotype.Service;
-
-import demoapp.dom._infra.seed.SeedServiceAbstract;
-import demoapp.dom._infra.values.ValueHolderRepository;
-
-@Service
-public class WrapperFactorySeeding
-extends SeedServiceAbstract {
-
- @Inject
- public WrapperFactorySeeding(ValueHolderRepository<String, ? extends
WrapperFactoryEntity> entities) {
- super(entities);
- }
-
+public interface PrimeNumberFactory<T extends PrimeNumber> {
+ T newPrimeNumber(Integer value);
}
-
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumberGenerator.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumberGenerator.java
new file mode 100644
index 0000000000..1ff18684a5
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumberGenerator.java
@@ -0,0 +1,70 @@
+package demoapp.dom.services.core.wrapperFactory;
+
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+
+import javax.inject.Inject;
+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.NatureOfService;
+import org.apache.causeway.applib.annotation.Programmatic;
+import org.apache.causeway.applib.annotation.Where;
+import org.apache.causeway.applib.services.wrapper.WrapperFactory;
+import org.apache.causeway.applib.services.wrapper.control.AsyncControl;
+
+//tag::class[]
+@Named("demo.DemoEntityFactory")
+@DomainService(
+ nature = NatureOfService.VIEW // <.>
+)
+@RequiredArgsConstructor(onConstructor_ = {@Inject})
+public class PrimeNumberGenerator {
+
+ final PrimeNumberFactory<?> primeNumberFactory;
+ final WrapperFactory wrapperFactory;
+
+ @Action
+ @ActionLayout(hidden = Where.EVERYWHERE) // <.>
+ public void calculatePrimeNumbersAsync(int from, int upTo) {
+ int nextPrime = nextPrime(from);
+ if (nextPrime <= upTo) {
+ primeNumberFactory.newPrimeNumber(nextPrime);
+ wrapperFactory.asyncWrap(
+ this,
+ AsyncControl.returningVoid().withSkipRules()
+ ).calculatePrimeNumbersAsync(nextPrime, upTo); // <.>
+ }
+ }
+
+ @SneakyThrows
+ private static int nextPrime(int number) {
+ Thread.sleep(200); // <.>
+ number++;
+ while (!isPrime(number)) {
+ number++;
+ }
+ return number;
+ }
+
+ private static boolean isPrime(int number) {
+ //...
+//end::class[]
+ if (number <= 1) {
+ return false;
+ }
+
+ for (int i = 2; i <= Math.sqrt(number); i++) {
+ if (number % i == 0) {
+ return false;
+ }
+ }
+
+ return true;
+//tag::class[]
+ }
+}
+//end::class[]
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdoEntities.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumberRepository.java
similarity index 59%
copy from
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdoEntities.java
copy to
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumberRepository.java
index 36dd30cb31..33d7e8aea1 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdoEntities.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/PrimeNumberRepository.java
@@ -16,25 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
-package demoapp.dom.services.core.wrapperFactory.jdo;
+package demoapp.dom.services.core.wrapperFactory;
-import org.springframework.context.annotation.Profile;
-import org.springframework.stereotype.Service;
+import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
+import demoapp.dom.services.core.wrapperFactory.jpa.PrimeNumberJpa;
-import demoapp.dom._infra.values.ValueHolderRepository;
+import java.util.List;
-@Profile("demo-jdo")
-@Service
-public class WrapperFactoryJdoEntities
-extends ValueHolderRepository<String, WrapperFactoryJdo> {
+import javax.inject.Named;
- protected WrapperFactoryJdoEntities() {
- super(WrapperFactoryJdo.class);
- }
+import org.apache.causeway.applib.annotation.DomainObject;
+import org.apache.causeway.applib.annotation.ObjectSupport;
- @Override
- protected WrapperFactoryJdo newDetachedEntity(String value) {
- return new WrapperFactoryJdo(value);
- }
+public interface PrimeNumberRepository<T extends PrimeNumber> {
+
+ public List<T> all();
+ public void removeAll();
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage-description.adoc
new file mode 100644
index 0000000000..4f1dad2af0
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage-description.adoc
@@ -0,0 +1,49 @@
+: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
link:https://causeway.apache.org/refguide/2.0.0-RC1/applib/index/services/wrapper/WrapperFactory.html[WrapperFactory]
was originally developed for testing purposes, allowing an action to be
invoked on another object "as if" through the UI.
+This use case is still supported.
+If any validation rules fail, then a corresponding exception is thrown, which
the test code will catch and assert accordingly.
+
+The `WrapperFactory` also allows actions to be invoked with rules checking
disabled.
+A common use case here is to trigger publishing, for example to the
https://causeway.apache.org/userguide/2.0.0-RC1/executionoutbox/about.html[Execution
outbox] for integration with downstream systems.
+
+A further use case is to support the execution of long-running actions, to be
run asynchronously.
+This is the use case demonstrated on this page.
+
+== How this demo works
+
+On the left hand side of this page is an action, `calculatePrimeNumbers`.
+This can be used to calculate all prime numbers up to 10_000, the results of
which are shown in the associated collection.
+
+The demo uses calculating a prime number as an example of a function that
might take a long time to execute, though to emphasise this the function also
waits ^1^/~5~^th^ of a second each time it is called.
+
+The function executes recursively, but each time invoking the next
asynchronously, and therefore in a different interaction/transaction.
+This means that it is possible to refresh the page and see the numbers being
generated in real-time.
+
+In terms of code:
+
+* the action to create primes is:
++
+[source,java]
+.WrapperFactoryDemoPage_createPrimes.java
+----
+include::WrapperFactoryDemoPage_createPrimes.java[tags=class]
+----
+<.> uses the `WrapperFactory` to create a proxy around the target
+<.> the target object to delegate to, in this case the injected
`PrimeNumberGenerator` service.
+It is also possible to delegate to entities.
+<.> indicates that the action should be invoked asynchronously, and to ignore
any hide/disable/validate rules
+<.> instruct the proxy to invoke the action.
+
+* the action invoked is:
++
+[source,java,indent=0]
+.PrimeNumberGenerator.java
+----
+include::PrimeNumberGenerator.java[tags=class]
+----
+<.> the target object _must_ be part of the framework's metamodel ...
+<.> \... and the method called must be an action.
+However, it can be hidden (which is why "skipRules" is commonly used).
+<.> calls itself recursively to calculate the next prime number
+<.> for demo purposes only
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage.java
similarity index 58%
rename from
examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage.java
index 2789be054c..ea5ed2a4e4 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage.java
@@ -16,40 +16,29 @@
* specific language governing permissions and limitations
* under the License.
*/
-package demoapp.dom.services.core.errorreportingservice;
+package demoapp.dom.services.core.wrapperFactory;
+import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
+
+import javax.inject.Inject;
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.XmlType;
-import org.apache.causeway.applib.annotation.Action;
-import org.apache.causeway.applib.annotation.ActionLayout;
-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 org.apache.causeway.applib.annotation.*;
@XmlRootElement(name = "Demo")
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
-@Named("demo.ErrorReportingServiceDemoVm")
+@Named("demo.WrapperFactoryDemoPage")
@DomainObject(nature=Nature.VIEW_MODEL, editing=Editing.ENABLED)
-public class ErrorReportingServiceDemoVm implements HasAsciiDocDescription {
-
- @ObjectSupport public String title() {
- return "Error Reporting Service Demo";
- }
+public class WrapperFactoryDemoPage implements HasAsciiDocDescription {
- @Action
- @ActionLayout(
- cssClassFa="fa-skull-crossbones",
- describedAs = "Throws an unrecoverable error for demonstration
purposes.")
- public Object triggerAnError(){
- throw new IllegalArgumentException("Error for demonstration
purposes!");
+ @ObjectSupport
+ public String title() {
+ return "WrapperFactory Demo";
}
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm.layout.xml
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage.layout.xml
similarity index 92%
rename from
examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm.layout.xml
rename to
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage.layout.xml
index a47367f7dd..98f1b73aa9 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/errorreportingservice/ErrorReportingServiceDemoVm.layout.xml
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage.layout.xml
@@ -25,8 +25,10 @@
<bs3:row>
<bs3:col span="6">
- <cpt:action id="triggerAnError" cssClass="btn-danger"/>
- <cpt:fieldSet name="Other" id="other"
unreferencedProperties="true"/>
+ <cpt:fieldSet name="Other" id="other"
unreferencedProperties="true" />
+ <cpt:collection id="primeNumbers">
+ <cpt:action id="createPrimes"/>
+ </cpt:collection>
</bs3:col>
<bs3:col span="6">
<cpt:fieldSet name="Description" id="description" >
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage_createPrimes.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage_createPrimes.java
new file mode 100644
index 0000000000..44a46fb468
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage_createPrimes.java
@@ -0,0 +1,44 @@
+package demoapp.dom.services.core.wrapperFactory;
+
+import javax.inject.Inject;
+
+import org.apache.causeway.applib.annotation.Action;
+import org.apache.causeway.applib.annotation.MemberSupport;
+import org.apache.causeway.applib.services.wrapper.WrapperFactory;
+import org.apache.causeway.applib.services.wrapper.control.AsyncControl;
+
+import demoapp.dom.services.core.wrapperFactory.jdo.PrimeNumberJdo;
+
+import lombok.RequiredArgsConstructor;
+
+import lombok.val;
+
+@Action
+@RequiredArgsConstructor
+public class WrapperFactoryDemoPage_createPrimes {
+
+ private final WrapperFactoryDemoPage page;
+
+// tag::class[]
+ @Inject WrapperFactory wrapperFactory;
+ @Inject PrimeNumberGenerator primeNumberGenerator;
+
+ @MemberSupport
+ public WrapperFactoryDemoPage act(Integer upTo) {
+ primeNumberRepository.removeAll();
+ wrapperFactory.asyncWrap( // <.>
+ primeNumberGenerator, // <.>
+ AsyncControl.returningVoid().withSkipRules() // <.>
+ ).calculatePrimeNumbersAsync(1, upTo); // <.>
+ return page;
+ }
+// end::class[]
+ public String validateUpTo(Integer upTo) {
+ if (upTo < 1) return "cannot be less than 1";
+ if (upTo > 10000) return "can only calculate primes up to than 10000";
+ return null;
+ }
+
+ @Inject PrimeNumberRepository<?> primeNumberRepository;
+
+}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage_primeNumbers.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage_primeNumbers.java
new file mode 100644
index 0000000000..f0ca20cf25
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryDemoPage_primeNumbers.java
@@ -0,0 +1,28 @@
+package demoapp.dom.services.core.wrapperFactory;
+
+import lombok.RequiredArgsConstructor;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.causeway.applib.annotation.Collection;
+import org.apache.causeway.applib.annotation.CollectionLayout;
+import org.apache.causeway.applib.annotation.MemberSupport;
+
+@Collection
+@CollectionLayout(paged = 20)
+@RequiredArgsConstructor
+public class WrapperFactoryDemoPage_primeNumbers {
+
+ private final WrapperFactoryDemoPage page;
+
+ @MemberSupport
+ public List<? extends PrimeNumber> coll() {
+ return primeNumberRepository.all();
+ }
+
+ @Inject PrimeNumberRepository primeNumberRepository;
+
+}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryEntity_mixinUpdatePropertyAsync.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryEntity_mixinUpdatePropertyAsync.java
deleted file mode 100644
index 60bd28f245..0000000000
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryEntity_mixinUpdatePropertyAsync.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.services.core.wrapperFactory;
-
-import javax.inject.Inject;
-
-import org.apache.causeway.applib.annotation.Action;
-import org.apache.causeway.applib.annotation.ActionLayout;
-import org.apache.causeway.applib.annotation.MemberSupport;
-import org.apache.causeway.applib.annotation.SemanticsOf;
-import org.apache.causeway.applib.services.wrapper.WrapperFactory;
-import org.apache.causeway.applib.services.wrapper.control.AsyncControl;
-
-import lombok.RequiredArgsConstructor;
-import lombok.val;
-
-//tag::class[]
-@Action(
- semantics = SemanticsOf.IDEMPOTENT
-)
-@ActionLayout(
- named = "Mixin Update Property"
- , associateWith = "propertyAsync"
- , sequence = "2"
-)
-@RequiredArgsConstructor
-public class WrapperFactoryEntity_mixinUpdatePropertyAsync {
-
- @Inject WrapperFactory wrapperFactory;
-
- // ...
-//end::class[]
-
- private final WrapperFactoryEntity wrapperFactoryEntity;
-
-//tag::class[]
- @MemberSupport public WrapperFactoryEntity act(final String value) {
- val control = AsyncControl.returningVoid().withSkipRules();
- val wrapped = this.wrapperFactory.asyncWrap(this.wrapperFactoryEntity,
control);
- wrapped.setPropertyAsync(value);
- return this.wrapperFactoryEntity;
- }
- @MemberSupport public String default0Act() {
- return wrapperFactoryEntity.getPropertyAsync();
- }
-}
-//end::class[]
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryEntity_updatePropertyAsyncMixin.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryEntity_updatePropertyAsyncMixin.java
deleted file mode 100644
index 2fa07c3106..0000000000
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/WrapperFactoryEntity_updatePropertyAsyncMixin.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.services.core.wrapperFactory;
-
-import org.apache.causeway.applib.annotation.Action;
-import org.apache.causeway.applib.annotation.ActionLayout;
-import org.apache.causeway.applib.annotation.MemberSupport;
-import org.apache.causeway.applib.annotation.SemanticsOf;
-
-import lombok.RequiredArgsConstructor;
-
-//tag::class[]
-@Action(
- semantics = SemanticsOf.IDEMPOTENT
-)
-@ActionLayout(
- named = "Update Property Async"
- , describedAs = "Mixin that Updates 'property async mixin' directly"
- , associateWith = "propertyAsyncMixin"
- , sequence = "2"
-)
-@RequiredArgsConstructor
-public class WrapperFactoryEntity_updatePropertyAsyncMixin {
- // ...
-//end::class[]
-
- private final WrapperFactoryEntity wrapperFactoryEntity;
-
-//tag::class[]
- @MemberSupport public WrapperFactoryEntity act(final String value) {
- wrapperFactoryEntity.setPropertyAsyncMixin(value);
- return wrapperFactoryEntity;
- }
- @MemberSupport public String default0Act() {
- return wrapperFactoryEntity.getPropertyAsyncMixin();
- }
-}
-//end::class[]
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdo-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/PrimeNumberJdo-description.adoc
similarity index 92%
rename from
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdo-description.adoc
rename to
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/PrimeNumberJdo-description.adoc
index 32dc53a4ec..211914b282 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdo-description.adoc
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/PrimeNumberJdo-description.adoc
@@ -3,6 +3,7 @@
CAUTION: TODO - to document
[source,java]
+.PrimeNumberJdo.java
+----
+include::PrimeNumberJdo.java[tags=class]
----
-include::WrapperFactoryJdo.java[tags=class]
-----
\ No newline at end of file
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/PrimeNumberJdo.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/PrimeNumberJdo.java
new file mode 100644
index 0000000000..3155c5487b
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/PrimeNumberJdo.java
@@ -0,0 +1,58 @@
+/*
+ * 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.services.core.wrapperFactory.jdo;
+
+import javax.inject.Named;
+import javax.jdo.annotations.DatastoreIdentity;
+import javax.jdo.annotations.IdGeneratorStrategy;
+import javax.jdo.annotations.IdentityType;
+import javax.jdo.annotations.PersistenceCapable;
+
+import org.springframework.context.annotation.Profile;
+
+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.Property;
+
+import demoapp.dom.services.core.wrapperFactory.PrimeNumber;
+
+import lombok.Getter;
+
+@Profile("demo-jdo")
+//tag::class[]
+@PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "demo")
+@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "id")
+@Named("demo.PrimeNumber")
+@DomainObject(
+ nature=Nature.ENTITY
+ , editing = Editing.DISABLED
+)
+public class PrimeNumberJdo
+ extends PrimeNumber {
+
+ public PrimeNumberJdo(final Integer orimeNumber) {
+ this.primeNumber = orimeNumber;
+ }
+
+ @Property
+ @Getter
+ private Integer primeNumber;
+}
+//end::class[]
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdoEntities.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/PrimeNumberJdoFactoryAndRepository.java
similarity index 52%
rename from
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdoEntities.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/PrimeNumberJdoFactoryAndRepository.java
index 36dd30cb31..a316ef0b14 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdoEntities.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/PrimeNumberJdoFactoryAndRepository.java
@@ -18,23 +18,41 @@
*/
package demoapp.dom.services.core.wrapperFactory.jdo;
+import java.util.List;
+
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
-import demoapp.dom._infra.values.ValueHolderRepository;
+import org.apache.causeway.applib.services.repository.RepositoryService;
+
+import lombok.RequiredArgsConstructor;
+
+import demoapp.dom.services.core.wrapperFactory.PrimeNumberFactory;
+import demoapp.dom.services.core.wrapperFactory.PrimeNumberRepository;
+import demoapp.dom.services.core.wrapperFactory.jpa.PrimeNumberJpa;
@Profile("demo-jdo")
@Service
-public class WrapperFactoryJdoEntities
-extends ValueHolderRepository<String, WrapperFactoryJdo> {
+@RequiredArgsConstructor
+public class PrimeNumberJdoFactoryAndRepository
+ implements PrimeNumberRepository<PrimeNumberJdo>,
PrimeNumberFactory<PrimeNumberJdo> {
- protected WrapperFactoryJdoEntities() {
- super(WrapperFactoryJdo.class);
+ private final RepositoryService repositoryService;
+
+ @Override
+ public PrimeNumberJdo newPrimeNumber(Integer value) {
+ return repositoryService.persistAndFlush(new PrimeNumberJdo(value));
}
@Override
- protected WrapperFactoryJdo newDetachedEntity(String value) {
- return new WrapperFactoryJdo(value);
+ public List<PrimeNumberJdo> all() {
+ return repositoryService.allInstances(PrimeNumberJdo.class);
}
+ @Override
+ public void removeAll() {
+ all().forEach(repositoryService::remove);
+ }
+
+
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdo.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdo.java
deleted file mode 100644
index 5063a80727..0000000000
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jdo/WrapperFactoryJdo.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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.services.core.wrapperFactory.jdo;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.jdo.annotations.DatastoreIdentity;
-import javax.jdo.annotations.IdGeneratorStrategy;
-import javax.jdo.annotations.IdentityType;
-import javax.jdo.annotations.PersistenceCapable;
-
-import org.springframework.context.annotation.Profile;
-
-import org.apache.causeway.applib.annotation.Action;
-import org.apache.causeway.applib.annotation.ActionLayout;
-import org.apache.causeway.applib.annotation.DomainObject;
-import org.apache.causeway.applib.annotation.Editing;
-import org.apache.causeway.applib.annotation.MemberSupport;
-import org.apache.causeway.applib.annotation.Nature;
-import org.apache.causeway.applib.annotation.ObjectSupport;
-import org.apache.causeway.applib.annotation.Property;
-import org.apache.causeway.applib.annotation.PropertyLayout;
-import org.apache.causeway.applib.annotation.SemanticsOf;
-import org.apache.causeway.applib.services.factory.FactoryService;
-import org.apache.causeway.applib.services.wrapper.WrapperFactory;
-import org.apache.causeway.applib.services.wrapper.control.AsyncControl;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.val;
-
-import demoapp.dom.services.core.wrapperFactory.WrapperFactoryEntity;
-import
demoapp.dom.services.core.wrapperFactory.WrapperFactoryEntity_updatePropertyAsyncMixin;
-
-@Profile("demo-jdo")
-//tag::class[]
-@PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "demo")
-@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "id")
-@Named("demo.WrapperFactoryEntity")
-@DomainObject(
- nature=Nature.ENTITY
- , editing = Editing.DISABLED
-)
-public class WrapperFactoryJdo
- extends WrapperFactoryEntity {
-
- @Inject transient WrapperFactory wrapperFactory;
- @Inject transient FactoryService factoryService;
-
- // ...
-//end::class[]
-
- public WrapperFactoryJdo(final String initialValue) {
- this.propertyAsync = initialValue;
- this.propertyAsyncMixin = initialValue;
- }
-
- @ObjectSupport public String title() {
- return "WrapperFactory";
- }
-
-//tag::property[]
- @Property()
- @PropertyLayout(fieldSetId = "async", sequence = "1")
- @Getter @Setter
- private String propertyAsync;
-
- @Property()
- @PropertyLayout(fieldSetId = "async", sequence = "2")
- @Getter @Setter
- private String propertyAsyncMixin;
-//end::property[]
-
-//tag::async[]
- @Action(
- semantics = SemanticsOf.IDEMPOTENT
- )
- @ActionLayout(
- describedAs = "@Action()"
- , associateWith = "propertyAsync"
- , sequence = "1"
- )
- public WrapperFactoryJdo updatePropertyAsync(final String value) {
- val control = AsyncControl.returningVoid().withSkipRules();
- val wrapperFactoryJdo = this.wrapperFactory.asyncWrap(this, control);
- wrapperFactoryJdo.setPropertyAsync(value);
- return this;
- }
- @MemberSupport public String default0UpdatePropertyAsync() {
- return getPropertyAsync();
- }
-//end::async[]
-
-//end::class[]
- @SuppressWarnings("unused")
-//tag::class[]
-//tag::async[]
- @Action(
- semantics = SemanticsOf.IDEMPOTENT
- )
- @ActionLayout(
- describedAs = "Calls the 'updatePropertyAsync' (mixin) action
asynchronously"
- , associateWith = "propertyAsyncMixin"
- , sequence = "1"
- )
- public WrapperFactoryJdo updatePropertyUsingAsyncWrapMixin(final String
value) {
- val control =
AsyncControl.returning(WrapperFactoryJdo.class).withSkipRules();
- val mixin =
this.wrapperFactory.asyncWrapMixin(WrapperFactoryEntity_updatePropertyAsyncMixin.class,
this, control);
- WrapperFactoryJdo act = (WrapperFactoryJdo) mixin.act(value);
- return this;
- }
- @MemberSupport public String default0UpdatePropertyUsingAsyncWrapMixin() {
- return new
WrapperFactoryEntity_updatePropertyAsyncMixin(this).default0Act();
- }
-//end::async[]
-
-//tag::class[]
-
-}
-//end::class[]
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/WrapperFactoryJpa-description.adoc
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/PrimeNumberJpa-description.adoc
similarity index 92%
rename from
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/WrapperFactoryJpa-description.adoc
rename to
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/PrimeNumberJpa-description.adoc
index 66a65fd4e1..c414692c77 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/WrapperFactoryJpa-description.adoc
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/PrimeNumberJpa-description.adoc
@@ -3,7 +3,8 @@
CAUTION: TODO - to document
[source,java]
+.PrimeNumberJpa.java
----
-include::WrapperFactoryJpa.java[tags=class]
+include::PrimeNumberJpa.java[tags=class]
----
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/PrimeNumberJpa.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/PrimeNumberJpa.java
new file mode 100644
index 0000000000..c74fcfa553
--- /dev/null
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/PrimeNumberJpa.java
@@ -0,0 +1,68 @@
+/*
+ * 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.services.core.wrapperFactory.jpa;
+
+import javax.inject.Named;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EntityListeners;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.springframework.context.annotation.Profile;
+
+import org.apache.causeway.applib.annotation.DomainObject;
+import org.apache.causeway.applib.annotation.Property;
+import
org.apache.causeway.persistence.jpa.applib.integration.CausewayEntityListener;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+import demoapp.dom.services.core.wrapperFactory.PrimeNumber;
+
+@Profile("demo-jpa")
+//tag::class[]
+@Entity
+@Table(
+ schema = "demo",
+ name = "PrimeNumberJpa"
+)
+@EntityListeners(CausewayEntityListener.class)
+@Named("demo.PrimeNumber")
+@DomainObject
+@NoArgsConstructor
+public class PrimeNumberJpa
+ extends PrimeNumber {
+
+ public PrimeNumberJpa(final Integer primeNumber) {
+ this.primeNumber = primeNumber;
+ }
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ @Property
+ @Column(nullable = false)
// <.>
+ @Getter
+ private Integer primeNumber;
+
+}
+//end::class[]
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/WrapperFactoryJpaEntities.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/PrimeNumberJpaFactoryAndRepository.java
similarity index 54%
rename from
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/WrapperFactoryJpaEntities.java
rename to
examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/PrimeNumberJpaFactoryAndRepository.java
index 573a98a03a..f3ae0b8dc5 100644
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/WrapperFactoryJpaEntities.java
+++
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/PrimeNumberJpaFactoryAndRepository.java
@@ -18,23 +18,39 @@
*/
package demoapp.dom.services.core.wrapperFactory.jpa;
+import org.apache.causeway.applib.services.repository.RepositoryService;
+
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
-import demoapp.dom._infra.values.ValueHolderRepository;
+import demoapp.dom.services.core.wrapperFactory.PrimeNumberFactory;
+import demoapp.dom.services.core.wrapperFactory.PrimeNumberRepository;
+
+import lombok.RequiredArgsConstructor;
+
+import java.util.List;
@Profile("demo-jpa")
@Service
-public class WrapperFactoryJpaEntities
-extends ValueHolderRepository<String, WrapperFactoryJpa> {
+@RequiredArgsConstructor
+public class PrimeNumberJpaFactoryAndRepository
+ implements PrimeNumberRepository<PrimeNumberJpa>,
PrimeNumberFactory<PrimeNumberJpa> {
+
+ private final RepositoryService repositoryService;
- protected WrapperFactoryJpaEntities() {
- super(WrapperFactoryJpa.class);
+ @Override
+ public PrimeNumberJpa newPrimeNumber(Integer value) {
+ return repositoryService.persistAndFlush(new PrimeNumberJpa(value));
+ }
+
+ @Override
+ public List<PrimeNumberJpa> all() {
+ return repositoryService.allInstances(PrimeNumberJpa.class);
}
@Override
- protected WrapperFactoryJpa newDetachedEntity(String value) {
- return new WrapperFactoryJpa(value);
+ public void removeAll() {
+ all().forEach(repositoryService::remove);
}
}
diff --git
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/WrapperFactoryJpa.java
b/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/WrapperFactoryJpa.java
deleted file mode 100644
index eb94bdeefc..0000000000
---
a/examples/demo/domain/src/main/java/demoapp/dom/services/core/wrapperFactory/jpa/WrapperFactoryJpa.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.services.core.wrapperFactory.jpa;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.persistence.Entity;
-import javax.persistence.EntityListeners;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import org.springframework.context.annotation.Profile;
-
-import org.apache.causeway.applib.annotation.Action;
-import org.apache.causeway.applib.annotation.ActionLayout;
-import org.apache.causeway.applib.annotation.DomainObject;
-import org.apache.causeway.applib.annotation.Editing;
-import org.apache.causeway.applib.annotation.MemberSupport;
-import org.apache.causeway.applib.annotation.Nature;
-import org.apache.causeway.applib.annotation.ObjectSupport;
-import org.apache.causeway.applib.annotation.Property;
-import org.apache.causeway.applib.annotation.PropertyLayout;
-import org.apache.causeway.applib.annotation.SemanticsOf;
-import org.apache.causeway.applib.services.factory.FactoryService;
-import org.apache.causeway.applib.services.wrapper.WrapperFactory;
-import org.apache.causeway.applib.services.wrapper.control.AsyncControl;
-import
org.apache.causeway.persistence.jpa.applib.integration.CausewayEntityListener;
-
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import lombok.val;
-
-import demoapp.dom.services.core.wrapperFactory.WrapperFactoryEntity;
-import
demoapp.dom.services.core.wrapperFactory.WrapperFactoryEntity_updatePropertyAsyncMixin;
-
-@Profile("demo-jpa")
-//tag::class[]
-@Entity
-@Table(
- schema = "demo",
- name = "WrapperFactoryJpa"
-)
-@EntityListeners(CausewayEntityListener.class)
-@Named("demo.WrapperFactoryEntity")
-@DomainObject(
- nature=Nature.ENTITY
- , editing = Editing.DISABLED
-)
-@NoArgsConstructor
-public class WrapperFactoryJpa
- extends WrapperFactoryEntity {
-
- @Inject transient WrapperFactory wrapperFactory;
- @Inject transient FactoryService factoryService;
-
- // ...
-//end::class[]
-
- public WrapperFactoryJpa(final String initialValue) {
- this.propertyAsync = initialValue;
- this.propertyAsyncMixin = initialValue;
- }
-
- @ObjectSupport public String title() {
- return "WrapperFactory";
- }
-
- @Id
- @GeneratedValue
- private Long id;
-
-//tag::property[]
- @Property()
- @PropertyLayout(fieldSetId = "async", sequence = "1")
- @Getter @Setter
- private String propertyAsync;
-
- @Property()
- @PropertyLayout(fieldSetId = "async", sequence = "2")
- @Getter @Setter
- private String propertyAsyncMixin;
-//end::property[]
-
-//tag::async[]
- @Action(
- semantics = SemanticsOf.IDEMPOTENT
- )
- @ActionLayout(
- describedAs = "@Action()"
- , associateWith = "propertyAsync"
- , sequence = "1"
- )
- public WrapperFactoryJpa updatePropertyAsync(final String value) {
- val control = AsyncControl.returningVoid().withSkipRules();
- val wrapperFactoryJdo = this.wrapperFactory.asyncWrap(this, control);
- wrapperFactoryJdo.setPropertyAsync(value);
- return this;
- }
- @MemberSupport public String default0UpdatePropertyAsync() {
- return getPropertyAsync();
- }
-//end::async[]
-
-//end::class[]
- @SuppressWarnings("unused")
-//tag::class[]
-//tag::async[]
- @Action(
- semantics = SemanticsOf.IDEMPOTENT
- )
- @ActionLayout(
- describedAs = "Calls the 'updatePropertyAsync' (mixin) action
asynchronously"
- , associateWith = "propertyAsyncMixin"
- , sequence = "1"
- )
- public WrapperFactoryJpa updatePropertyUsingAsyncWrapMixin(final String
value) {
- val control =
AsyncControl.returning(WrapperFactoryJpa.class).withSkipRules();
- val mixin =
this.wrapperFactory.asyncWrapMixin(WrapperFactoryEntity_updatePropertyAsyncMixin.class,
this, control);
- WrapperFactoryJpa act = (WrapperFactoryJpa) mixin.act(value);
- return this;
- }
- @MemberSupport public String default0UpdatePropertyUsingAsyncWrapMixin() {
- return new
WrapperFactoryEntity_updatePropertyAsyncMixin(this).default0Act();
- }
-//end::async[]
-
-//tag::class[]
-
-}
-//end::class[]