You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2022/01/29 09:14:07 UTC
[isis] branch master updated: ISIS-2950: [Demo] fixes provisioning for eventbus showcase (JPA)
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 740e9e6 ISIS-2950: [Demo] fixes provisioning for eventbus showcase (JPA)
740e9e6 is described below
commit 740e9e65bbc1dae3d4b5725b389aae4547b9aa8b
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat Jan 29 10:13:57 2022 +0100
ISIS-2950: [Demo] fixes provisioning for eventbus showcase (JPA)
---
.../src/main/java/demoapp/dom/DemoModuleJpa.java | 2 ++
.../eventbusservice/EventBusServiceDemoVm.java | 8 +++---
...tLogEntryRepository.java => EventLogEntry.java} | 27 ++++++++++++--------
.../core/eventbusservice/EventLogEntryJdo.java | 25 ++++++-------------
.../EventLogEntryJdoRepository.java | 4 +--
.../core/eventbusservice/EventLogEntryJpa.java | 29 +++++++++-------------
.../eventbusservice/EventLogEntryRepository.java | 4 +--
.../EventSubscriberDemoImplementation.java | 6 ++---
8 files changed, 49 insertions(+), 56 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 f97568d..957210a 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/DemoModuleJpa.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/DemoModuleJpa.java
@@ -37,6 +37,7 @@ import demoapp.dom.domain.objects.other.embedded.jpa.NumberConstantJpa;
import demoapp.dom.domain.properties.Property.commandPublishing.jpa.PropertyCommandPublishingJpa;
import demoapp.dom.domain.properties.Property.executionPublishing.jpa.PropertyExecutionPublishingJpa;
import demoapp.dom.domain.properties.Property.projecting.jpa.PropertyProjectingChildJpa;
+import demoapp.dom.services.core.eventbusservice.EventLogEntryJpa;
import demoapp.dom.services.core.wrapperFactory.jpa.WrapperFactoryJpa;
import demoapp.dom.services.extensions.secman.apptenancy.jpa.TenantedJpa;
import demoapp.dom.types.isis.blobs.jpa.IsisBlobJpa;
@@ -96,6 +97,7 @@ import demoapp.dom.types.primitive.shorts.jpa.PrimitiveShortJpa;
IsisAsciiDocJpa.class,
IsisMarkdownJpa.class,
IsisCalendarEventJpa.class,
+ EventLogEntryJpa.class,
JavaAwtBufferedImageJpa.class,
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventBusServiceDemoVm.java b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventBusServiceDemoVm.java
index b20f2a9..3080994 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventBusServiceDemoVm.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventBusServiceDemoVm.java
@@ -24,11 +24,11 @@ import javax.inject.Inject;
import org.apache.isis.applib.annotation.Action;
import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.ActionLayout.Position;
import org.apache.isis.applib.annotation.Collection;
import org.apache.isis.applib.annotation.DomainObject;
import org.apache.isis.applib.annotation.Nature;
import org.apache.isis.applib.annotation.ObjectSupport;
-import org.apache.isis.applib.annotation.ActionLayout.Position;
import org.apache.isis.applib.services.eventbus.EventBusService;
import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
@@ -36,7 +36,7 @@ import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
@DomainObject(nature=Nature.VIEW_MODEL, logicalTypeName = "demo.EventBusServiceDemoVm")
public class EventBusServiceDemoVm implements HasAsciiDocDescription {
- @Inject private EventLogEntryJdoRepository repository;
+ @Inject private EventLogEntryRepository<? extends EventLogEntry> eventLogEntryRepository;
@Inject private EventBusService eventBusService;
@ObjectSupport public String title() {
@@ -44,8 +44,8 @@ public class EventBusServiceDemoVm implements HasAsciiDocDescription {
}
@Collection
- public List<EventLogEntryJdo> getAllEvents(){
- return repository.listAll();
+ public List<? extends EventLogEntry> getAllEvents(){
+ return eventLogEntryRepository.listAll();
}
public static class UiButtonEvent {}
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryRepository.java b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntry.java
similarity index 57%
copy from examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryRepository.java
copy to examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntry.java
index 864d7df..257222b 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryRepository.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntry.java
@@ -18,23 +18,30 @@
*/
package demoapp.dom.services.core.eventbusservice;
-import java.util.List;
+import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.ObjectSupport;
-import lombok.val;
+@DomainObject(logicalTypeName = "demo.EventLogEntry")
+public abstract class EventLogEntry {
-import demoapp.dom.services.core.eventbusservice.EventBusServiceDemoVm.UiButtonEvent;
+ @ObjectSupport public String title() {
+ return getEvent();
+ }
-public interface EventLogEntryRepository<T> {
+ public abstract String getEvent();
+ public abstract void setEvent(String event);
- List<T> listAll();
+ public abstract Acknowledge getAcknowledge();
+ public abstract void setAcknowledge(Acknowledge acknowledge);
- void add(T entry);
- T newEntityFor(UiButtonEvent event);
+ // demonstrating 2 methods of changing a property ...
+ // - inline edit
+ // - via action
- default void storeEvent(UiButtonEvent event) {
- val entry = newEntityFor(event);
- add(entry);
+ public static enum Acknowledge {
+ IGNORE,
+ CRITICAL
}
}
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJdo.java b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJdo.java
index a6be88a..da87c12 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJdo.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJdo.java
@@ -32,7 +32,6 @@ import org.apache.isis.applib.annotation.Action;
import org.apache.isis.applib.annotation.ActionLayout;
import org.apache.isis.applib.annotation.DomainObject;
import org.apache.isis.applib.annotation.Editing;
-import org.apache.isis.applib.annotation.ObjectSupport;
import org.apache.isis.applib.annotation.Property;
import lombok.Getter;
@@ -44,8 +43,11 @@ import demoapp.dom.services.core.eventbusservice.EventBusServiceDemoVm.UiButtonE
@Profile("demo-jdo")
@PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "demo" )
@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "id")
-@DomainObject
-public class EventLogEntryJdo {
+@DomainObject(logicalTypeName = "demo.EventLogEntry")
+public class EventLogEntryJdo
+extends EventLogEntry {
+
+ // -- FACTORY
public static EventLogEntryJdo of(final UiButtonEvent even) {
val x = new EventLogEntryJdo();
@@ -53,27 +55,14 @@ public class EventLogEntryJdo {
return x;
}
- @ObjectSupport public String title() {
- return getEvent();
- }
-
@javax.jdo.annotations.Column(allowsNull = "false")
@Property(editing = Editing.DISABLED)
- @Getter @Setter
+ @Getter(onMethod_ = {@Override}) @Setter(onMethod_ = {@Override})
private String event;
- // demonstrating 2 methods of changing a property ...
- // - inline edit
- // - via action
-
- public static enum Acknowledge {
- IGNORE,
- CRITICAL
- }
-
@javax.jdo.annotations.Column(allowsNull = "true")
@Property(editing = Editing.ENABLED)
- @Getter @Setter
+ @Getter(onMethod_ = {@Override}) @Setter(onMethod_ = {@Override})
private Acknowledge acknowledge;
@Action
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJdoRepository.java b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJdoRepository.java
index 412fcd6..eb72d2b 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJdoRepository.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJdoRepository.java
@@ -47,12 +47,12 @@ implements EventLogEntryRepository<EventLogEntryJdo> {
}
@Override
- public void add(EventLogEntryJdo entry) {
+ public void add(final EventLogEntryJdo entry) {
repositoryService.persist(entry);
}
@Override
- public EventLogEntryJdo newEntityFor(UiButtonEvent event) {
+ public EventLogEntryJdo newEntityFor(final UiButtonEvent event) {
return EventLogEntryJdo.of(event);
}
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJpa.java b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJpa.java
index 9c86b38..8fd58fe 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJpa.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryJpa.java
@@ -22,6 +22,8 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
import org.springframework.context.annotation.Profile;
@@ -29,7 +31,6 @@ import org.apache.isis.applib.annotation.Action;
import org.apache.isis.applib.annotation.ActionLayout;
import org.apache.isis.applib.annotation.DomainObject;
import org.apache.isis.applib.annotation.Editing;
-import org.apache.isis.applib.annotation.ObjectSupport;
import org.apache.isis.applib.annotation.Property;
import lombok.Getter;
@@ -40,8 +41,11 @@ import demoapp.dom.services.core.eventbusservice.EventBusServiceDemoVm.UiButtonE
@Profile("demo-jpa")
@Entity
-@DomainObject(logicalTypeName = "demo.EventLogEntryJpa")
-public class EventLogEntryJpa {
+@DomainObject(logicalTypeName = "demo.EventLogEntry")
+public class EventLogEntryJpa
+extends EventLogEntry {
+
+ // -- FACTORY
public static EventLogEntryJpa of(final UiButtonEvent even) {
val x = new EventLogEntryJpa();
@@ -49,27 +53,18 @@ public class EventLogEntryJpa {
return x;
}
- @ObjectSupport public String title() {
- return getEvent();
- }
+ @Id
+ @GeneratedValue
+ private Long id;
@javax.persistence.Column(nullable = true)
@Property(editing = Editing.DISABLED)
- @Getter @Setter
+ @Getter(onMethod_ = {@Override}) @Setter(onMethod_ = {@Override})
private String event;
- // demonstrating 2 methods of changing a property ...
- // - inline edit
- // - via action
-
- public static enum Acknowledge {
- IGNORE,
- CRITICAL
- }
-
@javax.persistence.Column(nullable = true)
@Property(editing = Editing.ENABLED)
- @Getter @Setter
+ @Getter(onMethod_ = {@Override}) @Setter(onMethod_ = {@Override})
private Acknowledge acknowledge;
@Action
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryRepository.java b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryRepository.java
index 864d7df..7e65297 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryRepository.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventLogEntryRepository.java
@@ -24,7 +24,7 @@ import lombok.val;
import demoapp.dom.services.core.eventbusservice.EventBusServiceDemoVm.UiButtonEvent;
-public interface EventLogEntryRepository<T> {
+public interface EventLogEntryRepository<T extends EventLogEntry> {
List<T> listAll();
@@ -32,7 +32,7 @@ public interface EventLogEntryRepository<T> {
T newEntityFor(UiButtonEvent event);
- default void storeEvent(UiButtonEvent event) {
+ default void storeEvent(final UiButtonEvent event) {
val entry = newEntityFor(event);
add(entry);
}
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventSubscriberDemoImplementation.java b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventSubscriberDemoImplementation.java
index 6b10f82..d413bcc 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventSubscriberDemoImplementation.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/eventbusservice/EventSubscriberDemoImplementation.java
@@ -51,7 +51,7 @@ public class EventSubscriberDemoImplementation {
final FactoryService factoryService;
@EventListener(UiButtonEvent.class) // <-- listen on the event, triggered by button in the UI
- public void on(UiButtonEvent event) {
+ public void on(final UiButtonEvent event) {
log.info(emphasize("UiButtonEvent")); // <-- log to the console
@@ -66,10 +66,10 @@ public class EventSubscriberDemoImplementation {
logicalTypeName = "demo.eventLogWriter")
public static class EventLogWriter {
- @Inject private EventLogEntryRepository<? extends Object> eventLogEntryRepository;
+ @Inject private EventLogEntryRepository<? extends EventLogEntry> eventLogEntryRepository;
@Action // called asynchronously by above invocation
- public void storeEvent(UiButtonEvent event) {
+ public void storeEvent(final UiButtonEvent event) {
eventLogEntryRepository.storeEvent(event);
}