You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2020/07/26 14:12:25 UTC
[isis] 01/02: ISIS-2222: adds @Property#domainEvent demo
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch ISIS-2222
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 3bcdab922b3ced0a37c44dc65fad77532d92b9c8
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Sun Jul 26 14:21:37 2020 +0100
ISIS-2222: adds @Property#domainEvent demo
---
...tySetterOrClearFacetForDomainEventAbstract.java | 17 +-
.../dom/annotDomain/Property/PropertyMenu.java | 12 ++
.../dom/annotDomain/Property/domainEvent/.gitkeep | 0
.../PropertyDomainEventJdo-description.adoc | 15 ++
.../domainEvent/PropertyDomainEventJdo.java | 84 ++++++++++
.../domainEvent/PropertyDomainEventJdo.layout.xml | 50 ++++++
.../PropertyDomainEventJdoEntities.java | 28 ++++
.../PropertyDomainEventJdoSeedService.java | 41 +++++
.../PropertyDomainEventVm_controlTextEditing.java | 179 +++++++++++++++++++++
.../subscribers/PropertyDomainEventVm_events.java | 69 ++++++++
.../subscribers/TextDomainEventAsVm.java | 78 +++++++++
.../subscribers/TextDomainEventAsVm.layout.xml | 40 +++++
.../src/main/java/demoapp/dom/menubars.layout.xml | 1 +
13 files changed, 610 insertions(+), 4 deletions(-)
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/modify/PropertySetterOrClearFacetForDomainEventAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/modify/PropertySetterOrClearFacetForDomainEventAbstract.java
index 6e5dd2a..66458d8 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/modify/PropertySetterOrClearFacetForDomainEventAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/modify/PropertySetterOrClearFacetForDomainEventAbstract.java
@@ -216,12 +216,15 @@ extends SingleValueFacetAbstract<Class<? extends PropertyDomainEvent<?,?>>> {
@Override
public Object execute(final Interaction.PropertyEdit currentExecution) {
+ // TODO: REVIEW - is this safe to do?
+ ManagedObject newValueAdapterMutatable = newValueAdapter;
+
try {
// update the current execution with the DTO (memento)
final PropertyEditDto editDto =
getInteractionDtoServiceInternal().asPropertyEditDto(
- owningProperty, targetAdapter, newValueAdapter);
+ owningProperty, targetAdapter, newValueAdapterMutatable);
currentExecution.setDto(editDto);
@@ -235,7 +238,7 @@ extends SingleValueFacetAbstract<Class<? extends PropertyDomainEvent<?,?>>> {
// ... post the executing event
final Object oldValue = getterFacet.getProperty(targetAdapter, interactionInitiatedBy);
- final Object newValue = UnwrapUtil.single(newValueAdapter);
+ final Object newValue = UnwrapUtil.single(newValueAdapterMutatable);
final PropertyDomainEvent<?, ?> event =
domainEventHelper.postEventForProperty(
@@ -244,13 +247,19 @@ extends SingleValueFacetAbstract<Class<? extends PropertyDomainEvent<?,?>>> {
getIdentified(), head,
oldValue, newValue);
+ Object newValuePossiblyUpdated = event.getNewValue();
+ if(!Objects.equals(newValuePossiblyUpdated, newValue)) {
+ newValueAdapterMutatable = newValuePossiblyUpdated != null
+ ? getObjectManager().adapt(newValuePossiblyUpdated)
+ : null;
+ }
+
// set event onto the execution
currentExecution.setEvent(event);
// invoke method
style.invoke(PropertySetterOrClearFacetForDomainEventAbstract.this, owningProperty,
- targetAdapter, newValueAdapter, interactionInitiatedBy);
-
+ targetAdapter, newValueAdapterMutatable, interactionInitiatedBy);
// reading the actual value from the target object, playing it safe...
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/PropertyMenu.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/PropertyMenu.java
index 21f39d1..f993f91 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/PropertyMenu.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/PropertyMenu.java
@@ -33,6 +33,9 @@ import org.apache.isis.applib.value.Clob;
import lombok.val;
import lombok.extern.log4j.Log4j2;
+import demoapp.dom.annotDomain.Property.domainEvent.PropertyDomainEventJdo;
+import demoapp.dom.annotDomain.Property.domainEvent.PropertyDomainEventJdoEntities;
+import demoapp.dom.annotDomain.Property.domainEvent.PropertyDomainEventJdoSeedService;
import demoapp.dom.annotDomain.Property.editing.PropertyEditingVm;
import demoapp.dom.annotDomain.Property.fileAccept.PropertyFileAcceptVm;
import demoapp.dom.annotDomain.Property.hidden.PropertyHiddenVm;
@@ -48,6 +51,12 @@ import demoapp.dom.types.Samples;
public class PropertyMenu {
@Action(semantics = SemanticsOf.SAFE)
+ @ActionLayout(cssClassFa="fa-asterisk", describedAs = "Decouples interaction of properties")
+ public PropertyDomainEventJdo domainEvent(){
+ return propertyDomainEventJdoEntities.all().stream().findFirst().orElse(null);
+ }
+
+ @Action(semantics = SemanticsOf.SAFE)
@ActionLayout(cssClassFa="fa-pencil-alt", describedAs = "Editable fields")
public PropertyEditingVm editing(){
val vm = new PropertyEditingVm();
@@ -147,4 +156,7 @@ public class PropertyMenu {
Samples<Blob> blobSamples;
@Inject
Samples<Clob> clobSamples;
+ @Inject
+ PropertyDomainEventJdoEntities propertyDomainEventJdoEntities;
+
}
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/.gitkeep b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdo-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdo-description.adoc
new file mode 100644
index 0000000..545f4a1
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdo-description.adoc
@@ -0,0 +1,15 @@
+CAUTION: todo - still to describe.
+
+[source,java]
+----
+include::PropertyDomainEventJdo.java[tags=class]
+----
+
+PropertyDomainEventVm_controlTextEditing mixin:
+
+[source,java]
+----
+include::subscribers/PropertyDomainEventVm_controlTextEditing.java[tags=class]
+----
+
+CAUTION: this demo uses an entity rather than a view model; view models don't correctly allow the EXECUTING to influence the value held.
\ No newline at end of file
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdo.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdo.java
new file mode 100644
index 0000000..e6ee02d
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdo.java
@@ -0,0 +1,84 @@
+/*
+ * 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.annotDomain.Property.domainEvent;
+
+import javax.jdo.annotations.DatastoreIdentity;
+import javax.jdo.annotations.IdGeneratorStrategy;
+import javax.jdo.annotations.IdentityType;
+import javax.jdo.annotations.PersistenceCapable;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.Editing;
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.Nature;
+import org.apache.isis.applib.annotation.Property;
+import org.apache.isis.applib.annotation.PropertyLayout;
+import org.apache.isis.applib.events.domain.PropertyDomainEvent;
+import org.apache.isis.applib.jaxb.PersistentEntityAdapter;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
+
+//tag::class[]
+@PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "demo")
+@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "id")
+@DomainObject(
+ objectType = "demo.PropertyDomainEventJdo",
+ editing = Editing.ENABLED
+)
+@XmlJavaTypeAdapter(PersistentEntityAdapter.class)
+public class PropertyDomainEventJdo implements HasAsciiDocDescription {
+ // ...
+//end::class[]
+
+ public PropertyDomainEventJdo(String text) {
+ this.text = text;
+ }
+
+ public String title() {
+ return "Property#domainEvent";
+ }
+
+ public static class TextDomainEvent // <.>
+ extends PropertyDomainEvent<PropertyDomainEventJdo,String> {}
+//tag::annotation[]
+ @Property(
+ domainEvent = TextDomainEvent.class // <.>
+ )
+ @PropertyLayout(
+ describedAs =
+ "@Property(domainEvent = TextDomainEvent.class)"
+ )
+ @MemberOrder(name = "annotation", sequence = "1")
+ @XmlElement(required = true)
+ @Getter @Setter
+ private String text;
+//end::annotation[]
+
+//tag::class[]
+}
+//end::class[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdo.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdo.layout.xml
new file mode 100644
index 0000000..7c9b042
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdo.layout.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<bs3:grid
+ xsi:schemaLocation="http://isis.apache.org/applib/layout/component http://isis.apache.org/applib/layout/component/component.xsd http://isis.apache.org/applib/layout/grid/bootstrap3 http://isis.apache.org/applib/layout/grid/bootstrap3/bootstrap3.xsd"
+ xmlns:bs3="http://isis.apache.org/applib/layout/grid/bootstrap3"
+ xmlns:cpt="http://isis.apache.org/applib/layout/component"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <bs3:row>
+ <bs3:col span="10" unreferencedActions="true">
+ <cpt:domainObject />
+ <cpt:action id="rebuildMetamodel"/>
+ </bs3:col>
+ <bs3:col span="2">
+ <cpt:fieldSet name="" id="sources" />
+ </bs3:col>
+ </bs3:row>
+
+ <bs3:row>
+ <bs3:col span="6">
+ <bs3:row>
+ <bs3:col span="12">
+ <cpt:fieldSet name="Annotated" id="annotation"/>
+ <cpt:fieldSet name="Contributed" id="contributed"/>
+ <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/>
+ </bs3:col>
+ </bs3:row>
+ <bs3:row>
+ <bs3:col span="12">
+ <cpt:collection id="events"/>
+ </bs3:col>
+ </bs3:row>
+ </bs3:col>
+ <bs3:col span="6">
+ <cpt:fieldSet name="Description" id="description" >
+ <cpt:action id="clearHints" position="PANEL" />
+ <cpt:action id="downloadLayoutXml" position="PANEL_DROPDOWN"/>
+ <cpt:action id="rebuildMetamodel" position="PANEL_DROPDOWN"/>
+ <cpt:action id="downloadMetamodelXml" position="PANEL_DROPDOWN"/>
+ <cpt:action id="inspectMetamodel" position="PANEL_DROPDOWN"/>
+ <cpt:action id="downloadJdoMetadata" position="PANEL_DROPDOWN"/>
+ <cpt:action id="openRestApi" position="PANEL_DROPDOWN" />
+ <cpt:property id="description"/>
+ </cpt:fieldSet>
+ </bs3:col>
+ </bs3:row>
+ <bs3:row>
+ <bs3:col span="12" unreferencedCollections="true"/>
+ </bs3:row>
+
+</bs3:grid>
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdoEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdoEntities.java
new file mode 100644
index 0000000..374b4ba
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdoEntities.java
@@ -0,0 +1,28 @@
+package demoapp.dom.annotDomain.Property.domainEvent;
+
+import java.util.List;
+import java.util.Optional;
+
+import javax.inject.Inject;
+
+import org.springframework.stereotype.Service;
+
+import org.apache.isis.applib.services.repository.RepositoryService;
+
+import demoapp.dom.types.javalang.strings.jdo.JavaLangStringJdo;
+
+@Service
+public class PropertyDomainEventJdoEntities {
+
+ public Optional<PropertyDomainEventJdo> find(final String readOnlyProperty) {
+ return repositoryService.firstMatch(PropertyDomainEventJdo.class, x -> x.getText() == readOnlyProperty);
+ }
+
+ public List<PropertyDomainEventJdo> all() {
+ return repositoryService.allInstances(PropertyDomainEventJdo.class);
+ }
+
+ @Inject
+ RepositoryService repositoryService;
+
+}
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdoSeedService.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdoSeedService.java
new file mode 100644
index 0000000..cbafbcc
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/PropertyDomainEventJdoSeedService.java
@@ -0,0 +1,41 @@
+package demoapp.dom.annotDomain.Property.domainEvent;
+
+import javax.inject.Inject;
+
+import org.springframework.stereotype.Service;
+
+import org.apache.isis.applib.events.domain.PropertyDomainEvent;
+import org.apache.isis.applib.services.repository.RepositoryService;
+import org.apache.isis.testing.fixtures.applib.fixturescripts.FixtureScript;
+
+import demoapp.dom._infra.seed.SeedServiceAbstract;
+import demoapp.dom.types.Samples;
+import demoapp.dom.types.javalang.strings.jdo.JavaLangStringJdo;
+
+@Service
+public class PropertyDomainEventJdoSeedService extends SeedServiceAbstract {
+
+ public PropertyDomainEventJdoSeedService() {
+ super(PropertyDomainEventJdoEntityFixture::new);
+ }
+
+ static class PropertyDomainEventJdoEntityFixture extends FixtureScript {
+
+ @Override
+ protected void execute(ExecutionContext executionContext) {
+ samples.stream()
+ .map(PropertyDomainEventJdo::new)
+ .forEach(domainObject -> {
+ repositoryService.persistAndFlush(domainObject);
+ executionContext.addResult(this, domainObject);
+ });
+
+ }
+
+ @Inject
+ RepositoryService repositoryService;
+
+ @Inject
+ Samples<String> samples;
+ }
+}
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/PropertyDomainEventVm_controlTextEditing.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/PropertyDomainEventVm_controlTextEditing.java
new file mode 100644
index 0000000..71d1e6d
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/PropertyDomainEventVm_controlTextEditing.java
@@ -0,0 +1,179 @@
+/*
+ * 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.annotDomain.Property.domainEvent.subscribers;
+
+import javax.inject.Inject;
+
+import org.springframework.context.event.EventListener;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.PromptStyle;
+import org.apache.isis.applib.services.message.MessageService;
+import org.apache.isis.applib.services.registry.ServiceRegistry;
+
+import lombok.RequiredArgsConstructor;
+
+import demoapp.dom.annotDomain.Property.domainEvent.PropertyDomainEventJdo;
+
+
+//tag::class[]
+@Action()
+@ActionLayout(promptStyle = PromptStyle.DIALOG_SIDEBAR)
+@RequiredArgsConstructor
+public class PropertyDomainEventVm_controlTextEditing {
+
+ private final PropertyDomainEventJdo propertyDomainEventJdo;
+
+ public PropertyDomainEventJdo act(final ControlStrategy controlStrategy) {
+ eventControlService.controlStrategy = controlStrategy;
+ return propertyDomainEventJdo;
+ }
+ public ControlStrategy default0Act() {
+ return eventControlService.controlStrategy;
+ }
+
+ @Inject
+ ControlService eventControlService;
+
+ enum ControlStrategy {
+ HIDE {
+ @Override
+ void on(PropertyDomainEventJdo.TextDomainEvent ev
+ , ServiceRegistry serviceRegistry) {
+ switch (ev.getEventPhase()) {
+ case HIDE:
+ ev.hide();
+ break;
+ }
+ }
+ },
+ DISABLE{
+ @Override
+ void on(PropertyDomainEventJdo.TextDomainEvent ev
+ , ServiceRegistry serviceRegistry) {
+ switch (ev.getEventPhase()) {
+ case DISABLE:
+ ev.disable("ControlStrategy set to DISABLE");
+ break;
+ }
+
+ }
+ },
+ VALIDATE_MUST_BE_UPPER_CASE{
+ @Override
+ void on(PropertyDomainEventJdo.TextDomainEvent ev
+ , ServiceRegistry serviceRegistry) {
+ switch (ev.getEventPhase()) {
+ case VALIDATE:
+ String newValue = ev.getNewValue();
+ if(!newValue.toUpperCase().equals(newValue)) {
+ ev.invalidate("must be upper case");
+ }
+ break;
+ }
+
+ }
+ },
+ VALIDATE_MUST_BE_LOWER_CASE{
+ @Override
+ void on(PropertyDomainEventJdo.TextDomainEvent ev
+ , ServiceRegistry serviceRegistry) {
+
+ switch (ev.getEventPhase()) {
+ case VALIDATE:
+ String newValue = ev.getNewValue();
+ if (!newValue.toLowerCase().equals(newValue)) {
+ ev.invalidate("must be lower case");
+ }
+ break;
+ }
+ }
+ },
+ EXECUTING_FORCE_UPPER_CASE{
+ @Override
+ void on(PropertyDomainEventJdo.TextDomainEvent ev
+ , ServiceRegistry serviceRegistry) {
+
+ switch (ev.getEventPhase()) {
+ case EXECUTING:
+ String newValue = ev.getNewValue().toUpperCase();
+ ev.setNewValue(newValue);
+ break;
+ }
+ }
+ },
+ EXECUTING_FORCE_LOWER_CASE{
+ @Override
+ void on(PropertyDomainEventJdo.TextDomainEvent ev
+ , ServiceRegistry serviceRegistry) {
+
+ switch (ev.getEventPhase()) {
+ case EXECUTING:
+ String newValue = ev.getNewValue().toLowerCase();
+ ev.setNewValue(newValue);
+ break;
+ }
+ }
+ },
+ EXECUTED_ANNOUNCE{
+ @Override
+ void on(PropertyDomainEventJdo.TextDomainEvent ev
+ , ServiceRegistry serviceRegistry) {
+ switch (ev.getEventPhase()) {
+ case EXECUTED:
+ serviceRegistry
+ .lookupService(MessageService.class)
+ .ifPresent(ms ->
+ ms.informUser(
+ String.format("Changed from %s to %s"
+ , ev.getOldValue()
+ , ev.getNewValue()))
+ );
+ break;
+ }
+ }
+ },
+ DO_NOTHING{
+ @Override
+ void on(PropertyDomainEventJdo.TextDomainEvent ev
+ , ServiceRegistry serviceRegistry) {
+
+ }
+ };
+
+ abstract void on(PropertyDomainEventJdo.TextDomainEvent ev
+ , ServiceRegistry serviceRegistry);
+ }
+ @DomainService(objectType = "demo.PropertyDomainEventControlService")
+ static class ControlService {
+
+ ControlStrategy controlStrategy = ControlStrategy.DO_NOTHING;
+
+ @EventListener(PropertyDomainEventJdo.TextDomainEvent.class)
+ public void on(PropertyDomainEventJdo.TextDomainEvent ev) {
+ controlStrategy.on(ev, serviceRegistry);
+ }
+
+ @Inject
+ ServiceRegistry serviceRegistry;
+ }
+}
+//end::class[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/PropertyDomainEventVm_events.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/PropertyDomainEventVm_events.java
new file mode 100644
index 0000000..67249f1
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/PropertyDomainEventVm_events.java
@@ -0,0 +1,69 @@
+/*
+ * 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.annotDomain.Property.domainEvent.subscribers;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.inject.Inject;
+
+import org.springframework.context.event.EventListener;
+
+import org.apache.isis.applib.annotation.Collection;
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.Where;
+
+import lombok.RequiredArgsConstructor;
+
+import demoapp.dom.annotDomain.Property.domainEvent.PropertyDomainEventJdo;
+import demoapp.dom.annotDomain.Property.domainEvent.PropertyDomainEventJdo.TextDomainEvent;
+
+
+//tag::class[]
+@Collection(
+ // hiding for now, is called lots of times but perhaps confuses more than explains
+ hidden = Where.EVERYWHERE
+)
+@RequiredArgsConstructor
+public class PropertyDomainEventVm_events {
+
+ private final PropertyDomainEventJdo PropertyDomainEventJdo;
+
+ public List<TextDomainEventAsVm> coll() {
+ return eventCollectorService.events.stream()
+ .map(TextDomainEventAsVm::new)
+ .collect(Collectors.toList());
+ }
+
+ @Inject
+ CollectorService eventCollectorService;
+
+ @DomainService(objectType = "demo.PropertyDomainEventCollectorService")
+ static class CollectorService {
+
+ @EventListener(TextDomainEvent.class)
+ public void on(TextDomainEvent ev) {
+ events.add(ev);
+ }
+
+ List<TextDomainEvent> events = new ArrayList<>();
+ }
+}
+//end::class[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/TextDomainEventAsVm.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/TextDomainEventAsVm.java
new file mode 100644
index 0000000..ddd7be4
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/TextDomainEventAsVm.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package demoapp.dom.annotDomain.Property.domainEvent.subscribers;
+
+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.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.Nature;
+import org.apache.isis.applib.events.domain.AbstractDomainEvent;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import demoapp.dom.annotDomain.Property.domainEvent.PropertyDomainEventJdo;
+
+//tag::class[]
+@XmlRootElement(name = "root")
+@XmlType
+@XmlAccessorType(XmlAccessType.FIELD)
+@DomainObject(
+ nature=Nature.VIEW_MODEL,
+ objectType = "demo.TextDomainEventAsVm"
+)
+@NoArgsConstructor
+public class TextDomainEventAsVm {
+
+ public TextDomainEventAsVm(PropertyDomainEventJdo.TextDomainEvent ev) {
+ this.phase = ev.getEventPhase();
+ // this.subject = (PropertyDomainEventJdo) ev.getSubject();
+ this.hidden = ev.isHidden();
+ this.oldValue = ev.getOldValue();
+ this.newValue = ev.getOldValue();
+ this.disabledReason = ev.getDisabledReason();
+ this.invalidityReason = ev.getInvalidityReason();
+ }
+
+ @Getter @Setter
+ private AbstractDomainEvent.Phase phase;
+
+ @Getter @Setter
+ private PropertyDomainEventJdo subject;
+
+ @Getter @Setter
+ private String oldValue;
+ @Getter @Setter
+ private String newValue;
+
+ @Getter @Setter
+ private boolean hidden;
+ @Getter @Setter
+ private String disabledReason;
+ @Getter @Setter
+ private String invalidityReason;
+
+
+
+}
+//end::class[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/TextDomainEventAsVm.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/TextDomainEventAsVm.layout.xml
new file mode 100644
index 0000000..db2c715
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/domainEvent/subscribers/TextDomainEventAsVm.layout.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<bs3:grid
+ xsi:schemaLocation="http://isis.apache.org/applib/layout/component http://isis.apache.org/applib/layout/component/component.xsd http://isis.apache.org/applib/layout/grid/bootstrap3 http://isis.apache.org/applib/layout/grid/bootstrap3/bootstrap3.xsd"
+ xmlns:bs3="http://isis.apache.org/applib/layout/grid/bootstrap3"
+ xmlns:cpt="http://isis.apache.org/applib/layout/component"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <bs3:row>
+ <bs3:col span="12" unreferencedActions="true">
+ <cpt:domainObject />
+ <cpt:action id="rebuildMetamodel"/>
+ </bs3:col>
+ </bs3:row>
+
+ <bs3:row>
+ <bs3:col span="6">
+ <bs3:row>
+ <bs3:col span="12">
+ <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/>
+ </bs3:col>
+ </bs3:row>
+ </bs3:col>
+ <bs3:col span="6">
+ <cpt:fieldSet name="Description" id="description" >
+ <cpt:action id="clearHints" position="PANEL" />
+ <cpt:action id="downloadLayoutXml" position="PANEL_DROPDOWN"/>
+ <cpt:action id="rebuildMetamodel" position="PANEL_DROPDOWN"/>
+ <cpt:action id="downloadMetamodelXml" position="PANEL_DROPDOWN"/>
+ <cpt:action id="inspectMetamodel" position="PANEL_DROPDOWN"/>
+ <cpt:action id="downloadJdoMetadata" position="PANEL_DROPDOWN"/>
+ <cpt:action id="openRestApi" position="PANEL_DROPDOWN" />
+ <cpt:property id="description"/>
+ </cpt:fieldSet>
+ </bs3:col>
+ </bs3:row>
+ <bs3:row>
+ <bs3:col span="12" unreferencedCollections="true"/>
+ </bs3:row>
+
+</bs3:grid>
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml
index 050fe05..c1defb5 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml
+++ b/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml
@@ -108,6 +108,7 @@ as a replacement for
<mb3:named>Domain Annotations</mb3:named>
<mb3:section>
<mb3:named>@Property</mb3:named>
+ <mb3:serviceAction objectType="demo.PropertyMenu" id="domainEvent"/>
<mb3:serviceAction objectType="demo.PropertyMenu" id="editing"/>
<mb3:serviceAction objectType="demo.PropertyMenu" id="fileAccept"/>
<mb3:serviceAction objectType="demo.PropertyMenu" id="hidden"/>