This is an automated email from the ASF dual-hosted git repository. danhaywood pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/isis.git
commit 25e4450c5d1bd988dadb59a9c1910ebf0500a5c5 Author: danhaywood <[email protected]> AuthorDate: Sat Aug 22 12:08:06 2020 +0100 ISIS-2222: completes demo for @DomainObject#publishing ... hooray! --- .../ActionPublishingJdo-description.adoc | 20 +++ .../annotDomain/DomainObject/DomainObjectMenu.java | 4 - ...ainObjectPublishingDisabledJdo-description.adoc | 1 - ...mainObjectPublishingEnabledJdo-description.adoc | 1 - .../DomainObjectPublishingVm-description.adoc | 170 ++++++++++----------- .../publishing/DomainObjectPublishingVm.layout.xml | 6 +- .../DomainObjectPublishingVm_create.java | 57 ++++++- .../DomainObjectPublishingVm_delete.java | 53 ++++++- ...ectPublishingVm_publishingDisabledEntities.java | 24 --- ...jectPublishingVm_publishingEnabledEntities.java | 24 --- .../DomainObjectPublishingVm_updateAll.java | 47 +++++- ...ainObjectPublishingDisabledJdo-description.adoc | 7 + .../DomainObjectPublishingDisabledJdo.java | 19 +-- .../DomainObjectPublishingDisabledJdo.layout.xml | 0 .../DomainObjectPublishingDisabledJdoEntities.java | 8 +- ...mainObjectPublishingDisabledJdoSeedService.java | 2 +- ...hingVm_publishingDisabledAnnotatedEntities.java | 28 ++++ ...mainObjectPublishingEnabledJdo-description.adoc | 8 + .../enabled}/DomainObjectPublishingEnabledJdo.java | 19 +-- .../DomainObjectPublishingEnabledJdo.layout.xml | 0 .../DomainObjectPublishingEnabledJdoEntities.java | 7 +- ...omainObjectPublishingEnabledJdoSeedService.java | 2 +- ...shingVm_publishingEnabledAnnotatedEntities.java | 28 ++++ ...omainObjectPublishingEnabledMetaAnnotation.java | 6 +- ...lishingEnabledMetaAnnotatedJdo-description.adoc | 18 +++ ...inObjectPublishingEnabledMetaAnnotatedJdo.java} | 28 ++-- ...ctPublishingEnabledMetaAnnotatedJdo.layout.xml} | 0 ...tPublishingEnabledMetaAnnotatedJdoEntities.java | 41 +++++ ...lishingEnabledMetaAnnotatedJdoSeedService.java} | 8 +- ...gVm_publishingEnabledMetaAnnotatedEntities.java | 26 ++++ ...mainObjectPublishingDisabledMetaAnnotation.java | 6 +- ...gEnabledMetaAnnotOverriddenJdo-description.adoc | 18 +++ ...ctPublishingEnabledMetaAnnotOverriddenJdo.java} | 27 ++-- ...ishingEnabledMetaAnnotOverriddenJdo.layout.xml} | 0 ...shingEnabledMetaAnnotOverriddenJdoEntities.java | 41 +++++ ...gEnabledMetaAnnotOverriddenJdoSeedService.java} | 8 +- ...blishingEnabledMetaAnnotOverriddenEntities.java | 26 ++++ .../PublisherServiceSpiForDomainObject.java | 4 +- .../PropertyPublishingJdo-description.adoc | 16 ++ .../demo/domain/src/main/resources/application.yml | 4 + .../src/main/resources/static/css/application.css | 6 + .../main/resources/static/scripts/application.js | 1 + 42 files changed, 581 insertions(+), 238 deletions(-) diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/publishing/ActionPublishingJdo-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/publishing/ActionPublishingJdo-description.adoc index 8071721..c5a8948 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/publishing/ActionPublishingJdo-description.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/publishing/ActionPublishingJdo-description.adoc @@ -116,3 +116,23 @@ include::spiimpl/ActionPublishingJdo_interactionExecutions.java[tags=class] include::spiimpl/ActionPublishingJdo_clearInteractionExecutions.java[tags=class] ---- + +== Configuration + +By default, publishing of action invocations is disabled. +This can be configured globally: + +[source,yaml] +.application.yml +---- +isis: + applib: + annotation: + action: + publishing: none +---- + +In addition to globally enabling or disabling action publishing, it is also possible to specify `ignore_safe`. + +This enables publishing for all actions except those that have safe (that is, query-only) semantics. +In other words actions are published except for those that don't change (aren't declared as changing) the state of the system. diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/DomainObjectMenu.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/DomainObjectMenu.java index 58099a2..48b91b3 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/DomainObjectMenu.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/DomainObjectMenu.java @@ -18,8 +18,6 @@ */ package demoapp.dom.annotDomain.DomainObject; -import javax.inject.Inject; - import org.apache.isis.applib.annotation.Action; import org.apache.isis.applib.annotation.ActionLayout; import org.apache.isis.applib.annotation.DomainService; @@ -28,8 +26,6 @@ import org.apache.isis.applib.annotation.SemanticsOf; import lombok.extern.log4j.Log4j2; -import demoapp.dom.annotDomain.DomainObject.publishing.DomainObjectPublishingEnabledJdo; -import demoapp.dom.annotDomain.DomainObject.publishing.DomainObjectPublishingEnabledJdoEntities; import demoapp.dom.annotDomain.DomainObject.publishing.DomainObjectPublishingVm; @DomainService(nature=NatureOfService.VIEW, objectType = "demo.DomainObjectMenu") diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdo-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdo-description.adoc deleted file mode 100644 index d5b090d..0000000 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdo-description.adoc +++ /dev/null @@ -1 +0,0 @@ -CAUTION: TODO \ No newline at end of file diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo-description.adoc deleted file mode 100644 index d5b090d..0000000 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo-description.adoc +++ /dev/null @@ -1 +0,0 @@ -CAUTION: TODO \ No newline at end of file diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm-description.adoc index 38bc66f..b28a636 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm-description.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm-description.adoc @@ -1,100 +1,86 @@ -The `publishing` semantic for a domain object means that all registered implementation(s) of link:https://isis.apache.org/refguide/2.0.0-M3/applib-svc/PublisherService.html#spi[`PublisherService` SPI] will be notified of the identity and nature of change (created/updated/deleted) of the domain object. +The `publishing` semantic for a domain object means that all registered implementation(s) of the link:https://isis.apache.org/refguide/2.0.0-M3/applib-svc/PublisherService.html#spi[`PublisherService` SPI] will be notified of the identity and nature of the change (created/updated/deleted) to the domain object. This is done _after_ the interaction in which the object(s) was changed has completed. This notification is done only once per interaction, so will include _all_ domain objects that were changed. The event object can be converted to type xref:https://isis.apache.org/refguide/2.0.0-M3/schema/chg.html[ChangesDto]. -NOTE: This is only supported for domain entities, not view models. - -Common use cases are to replicate data to another system, or for gathering metrics (which objects are changed the most?). +Common use cases are to replicate data to another system, or for gathering metrics ("which objects change the most?"). A typical SPI implementation could publish the event over the network, or perhaps store in a database. (Note that the framework provides an link:https://isis.apache.org/mappings/2.0.0-M3/outbox-publisher/about.html[out-of-the-box implementation] of the link:https://microservices.io/patterns/data/transactional-outbox.html[outbox pattern]). -The semantic can be specified using either the `@Property` annotation, or through a meta-annotation. - -NOTE: The demo shows publishing of entities, as this is much more common use case than publishing a view model. - -CAUTION: TODO - -//== Annotated -// -//The `publisher` semantic can be specified explicitly using an annotation through `@Property#publishing()`: -// -//[source,java,indent=0] -//---- -//include::PropertyPublishingJdo.java[tags=annotation] -//---- -//<.> explicitly specifies that modifying the property should be published. -// -//The annotation could also be applied to a mixin, but would have little effect because mixin properties are always read-only. -// -//== Meta-annotated -// -//The `publishing` semantic can also be specified using a custom meta-annotation: -// -//* the meta-annotation is defined as: -//+ -//[source,java] -//---- -//include::PropertyPublishingEnabledMetaAnnotation.java[tags=class] -//---- -//<.> annotated for a property -//<.> annotation can be applied to a property (either its getter or the field directly) -// -//* and can be applied to a property: -//+ -//[source,java,indent=0] -//---- -//include::PropertyPublishingJdo.java[tags=meta-annotated] -//---- -//<.> semantic is inherited from the meta-annotation -// -// -// -//=== Meta-annotated Overridden -// -//The meta-annotation can itself be overridden: -// -//* in a property: -//+ -//[source,java,indent=0] -//---- -//include::PropertyPublishingJdo.java[tags=meta-annotated-overridden] -//---- -//<.> semantic from meta-annotation ... -//<.> \... is overridden by the `@Property` annotation -// -// -//== PublisherService -// -//The demo provides a simple implementation of `PublisherService` that just stores the DTOs in memory: -// -//[source,java] -//---- -//include::spiimpl/PublisherServiceSpiForProperties.java[tags=class] -//---- -//<.> serializes to `InteractionDto`, as defined by the link:https://isis.apache.org/refguide/2.0.0-M3/schema/ixn.html[Apache Isis schema]. -// -//The demo implementation also provides a way to query these executions: -// -//[source,java,indent=0] -//---- -//include::spiimpl/PublisherServiceSpiForProperties.java[tags=demo] -//---- -// -//Supporting mixins surface this list as contributions on the object: -// -//* `interactionExecutions` collection: -//+ -//[source,java,indent=0] -//---- -//include::spiimpl/PropertyPublishingJdo_interactionExecutions.java[tags=class] -//---- -// -//* `clearInteractionExecutions` action: -//+ -//[source,java,indent=0] -//---- -//include::spiimpl/PropertyPublishingJdo_clearInteractionExecutions.java[tags=class] -//---- -// +The semantic can be specified using either the `@DomainObject` annotation, or through a meta-annotation. + +NOTE: Publishing of domain objects is only supported for domain entities, not view models. + + +== Explanation of the Demo + +The demo provides a view model which can be used to create, update or delete four variations of a domain entity: + +* annotated using `@DomainObject(publishing=...)` for both enabled and disabled +* meta-annotated as enabled +* meta-annotated as disabled, but then overridden + +These can be updated using the view model's `create`, `update all` and `delete` actions, generating publishing events. + +TIP: Click through to the entity objects to see examples of the annotations applied. + +== PublisherService + +The demo also has a simple implementation of `PublisherService` that just stores the DTOs in memory: + +[source,java] +---- +include::spiimpl/PublisherServiceSpiForDomainObject.java[tags=class] +---- +<.> serializes to `ChangesDto`, as defined by the link:https://isis.apache.org/refguide/2.0.0-M3/schema/chg.html[Apache Isis schema]. + +The demo implementation also provides a way to query these executions: + +[source,java,indent=0] +---- +include::spiimpl/PublisherServiceSpiForDomainObject.java[tags=demo] +---- + +Supporting mixins surface this list as contributions on the object: + +* `publishedObjects` collection: ++ +[source,java,indent=0] +---- +include::spiimpl/DomainObjectPublishingVm_publishedObjects.java[tags=class] +---- + +* `clearPublishedObjects` action: ++ +[source,java,indent=0] +---- +include::spiimpl/DomainObjectPublishingVm_clearPublishedObjects.java[tags=class] +---- + + +For the three (of the four in total) domain entities where publishing is enabled, this collection should be appended to when the `create`, `update all` or `delete` actions are invoked. + +[NOTE] +==== +Because the `Publisher` is notified after the interaction has completed, it's necessary to refresh the page to see the collection of changes being updated. + +This can be done simply by clicking on the view model's title. +==== + + +== Configuration + +By default, publishing of domain objects is disabled. +This can be configured globally: + +[source,yaml] +.application.yml +---- +isis: + applib: + annotation: + domain-object: + publishing: none +---- + diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm.layout.xml index 6126994..900adeb 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm.layout.xml +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm.layout.xml @@ -21,8 +21,10 @@ <bs3:col span="6"> <bs3:row> <bs3:col span="12"> - <cpt:collection id="publishingEnabledEntities"/> - <cpt:collection id="publishingDisabledEntities"/> + <cpt:collection id="publishingEnabledAnnotatedEntities"/> + <cpt:collection id="publishingDisabledAnnotatedEntities"/> + <cpt:collection id="publishingEnabledMetaAnnotatedEntities"/> + <cpt:collection id="publishingEnabledMetaAnnotOverriddenEntities"/> <cpt:collection id="publishedObjects"/> </bs3:col> </bs3:row> diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_create.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_create.java index a045fa6..854c11d 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_create.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_create.java @@ -8,10 +8,15 @@ import org.apache.isis.applib.annotation.MemberOrder; import org.apache.isis.applib.annotation.SemanticsOf; import org.apache.isis.applib.services.repository.RepositoryService; -import lombok.val; - import demoapp.dom._infra.samples.NameSamples; -import demoapp.dom.types.Samples; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.disabled.DomainObjectPublishingDisabledJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.disabled.DomainObjectPublishingDisabledJdoEntities; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled.DomainObjectPublishingEnabledJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled.DomainObjectPublishingEnabledJdoEntities; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.enabled.DomainObjectPublishingEnabledMetaAnnotatedJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.enabled.DomainObjectPublishingEnabledMetaAnnotatedJdoEntities; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnotOverridden.enabled.DomainObjectPublishingEnabledMetaAnnotOverriddenJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnotOverridden.enabled.DomainObjectPublishingEnabledMetaAnnotOverriddenJdoEntities; //tag::class[] @Action(semantics = SemanticsOf.NON_IDEMPOTENT) @@ -26,17 +31,55 @@ public class DomainObjectPublishingVm_create { } @MemberOrder(sequence = "1.0") - public DomainObjectPublishingVm act(String newValue) { - repositoryService.persistAndFlush(new DomainObjectPublishingEnabledJdo(newValue)); - repositoryService.persistAndFlush(new DomainObjectPublishingDisabledJdo(newValue)); + public DomainObjectPublishingVm act( + String newValue + , boolean publishingEnabled + , boolean publishingDisabled + , boolean publishingEnabledMetaAnnotated + , boolean publishingEnabledMetaAnnotOverridden + ) { + if(publishingEnabled) { + publishingEnabledJdoEntities.create(newValue); + } + if(publishingDisabled) { + publishingDisabledJdoEntities.create(newValue); + } + if(publishingEnabledMetaAnnotated) { + publishingEnabledMetaAnnotatedJdoEntities.create(newValue); + } + if(publishingEnabledMetaAnnotOverridden) { + publishingEnabledMetaAnnotOverriddenJdoEntities.create(newValue); + } return domainObjectPublishingVm; } public String default0Act() { return nameSamples.random(); } + public boolean default1Act() { + return true; + } + public boolean default2Act() { + return true; + } + public boolean default3Act() { + return true; + } + public boolean default4Act() { + return true; + } + + @Inject + DomainObjectPublishingEnabledJdoEntities publishingEnabledJdoEntities; + + @Inject + DomainObjectPublishingDisabledJdoEntities publishingDisabledJdoEntities; @Inject - RepositoryService repositoryService; + DomainObjectPublishingEnabledMetaAnnotatedJdoEntities publishingEnabledMetaAnnotatedJdoEntities; + + @Inject + DomainObjectPublishingEnabledMetaAnnotOverriddenJdoEntities publishingEnabledMetaAnnotOverriddenJdoEntities; + @Inject NameSamples nameSamples; } diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_delete.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_delete.java index 02a2e82..b5ea910 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_delete.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_delete.java @@ -1,12 +1,21 @@ package demoapp.dom.annotDomain.DomainObject.publishing; +import javax.annotation.Nullable; import javax.inject.Inject; import org.apache.isis.applib.annotation.Action; import org.apache.isis.applib.annotation.ActionLayout; import org.apache.isis.applib.annotation.MemberOrder; import org.apache.isis.applib.annotation.SemanticsOf; -import org.apache.isis.applib.services.repository.RepositoryService; + +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.disabled.DomainObjectPublishingDisabledJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.disabled.DomainObjectPublishingDisabledJdoEntities; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled.DomainObjectPublishingEnabledJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled.DomainObjectPublishingEnabledJdoEntities; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.enabled.DomainObjectPublishingEnabledMetaAnnotatedJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.enabled.DomainObjectPublishingEnabledMetaAnnotatedJdoEntities; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnotOverridden.enabled.DomainObjectPublishingEnabledMetaAnnotOverriddenJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnotOverridden.enabled.DomainObjectPublishingEnabledMetaAnnotOverriddenJdoEntities; //tag::class[] @Action(semantics = SemanticsOf.IDEMPOTENT) @@ -21,21 +30,49 @@ public class DomainObjectPublishingVm_delete { } @MemberOrder(sequence = "3.0") - public DomainObjectPublishingVm act(DomainObjectPublishingEnabledJdo enabledJdo, DomainObjectPublishingDisabledJdo disabledJdo) { - enabledJdoEntities.remove(enabledJdo); - disabledJdoEntities.remove(disabledJdo); + public DomainObjectPublishingVm act( + @Nullable DomainObjectPublishingEnabledJdo enabledJdo + , @Nullable DomainObjectPublishingDisabledJdo disabledJdo + , @Nullable DomainObjectPublishingEnabledMetaAnnotatedJdo metaAnnotatedJdo + , @Nullable DomainObjectPublishingEnabledMetaAnnotOverriddenJdo metaAnnotOverriddenJdo + ) { + if(enabledJdo != null) { + publishingEnabledJdoEntities.remove(enabledJdo); + } + if(disabledJdo != null) { + publishingDisabledJdoEntities.remove(disabledJdo); + } + if(metaAnnotatedJdo != null) { + publishingEnabledMetaAnnotatedJdoEntities.remove(metaAnnotatedJdo); + } + if(metaAnnotOverriddenJdo != null) { + publishingEnabledMetaAnnotOverriddenJdoEntities.remove(metaAnnotOverriddenJdo); + } return domainObjectPublishingVm; } public DomainObjectPublishingEnabledJdo default0Act() { - return enabledJdoEntities.first(); + return publishingEnabledJdoEntities.first(); } public DomainObjectPublishingDisabledJdo default1Act() { - return disabledJdoEntities.first(); + return publishingDisabledJdoEntities.first(); + } + public DomainObjectPublishingEnabledMetaAnnotatedJdo default2Act() { + return publishingEnabledMetaAnnotatedJdoEntities.first(); } + public DomainObjectPublishingEnabledMetaAnnotOverriddenJdo default3Act() { + return publishingEnabledMetaAnnotOverriddenJdoEntities.first(); + } + + @Inject + DomainObjectPublishingEnabledJdoEntities publishingEnabledJdoEntities; + + @Inject + DomainObjectPublishingDisabledJdoEntities publishingDisabledJdoEntities; @Inject - DomainObjectPublishingEnabledJdoEntities enabledJdoEntities; + DomainObjectPublishingEnabledMetaAnnotatedJdoEntities publishingEnabledMetaAnnotatedJdoEntities; + @Inject - DomainObjectPublishingDisabledJdoEntities disabledJdoEntities; + DomainObjectPublishingEnabledMetaAnnotOverriddenJdoEntities publishingEnabledMetaAnnotOverriddenJdoEntities; } //end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_publishingDisabledEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_publishingDisabledEntities.java deleted file mode 100644 index 9c00c4b..0000000 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_publishingDisabledEntities.java +++ /dev/null @@ -1,24 +0,0 @@ -package demoapp.dom.annotDomain.DomainObject.publishing; - -import java.util.List; - -import javax.inject.Inject; - -import org.apache.isis.applib.annotation.Collection; - -@Collection() -public class DomainObjectPublishingVm_publishingDisabledEntities { - - private final DomainObjectPublishingVm domainObjectPublishingVm; - - public DomainObjectPublishingVm_publishingDisabledEntities(DomainObjectPublishingVm domainObjectPublishingVm) { - this.domainObjectPublishingVm = domainObjectPublishingVm; - } - - public List<DomainObjectPublishingDisabledJdo> coll() { - return publishingDisabledJdoEntities.all(); - } - - @Inject - DomainObjectPublishingDisabledJdoEntities publishingDisabledJdoEntities; -} diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_publishingEnabledEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_publishingEnabledEntities.java deleted file mode 100644 index d0bc170..0000000 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_publishingEnabledEntities.java +++ /dev/null @@ -1,24 +0,0 @@ -package demoapp.dom.annotDomain.DomainObject.publishing; - -import java.util.List; - -import javax.inject.Inject; - -import org.apache.isis.applib.annotation.Collection; - -@Collection() -public class DomainObjectPublishingVm_publishingEnabledEntities { - - private final DomainObjectPublishingVm domainObjectPublishingVm; - - public DomainObjectPublishingVm_publishingEnabledEntities(DomainObjectPublishingVm domainObjectPublishingVm) { - this.domainObjectPublishingVm = domainObjectPublishingVm; - } - - public List<DomainObjectPublishingEnabledJdo> coll() { - return publishingEnabledJdoEntities.all(); - } - - @Inject - DomainObjectPublishingEnabledJdoEntities publishingEnabledJdoEntities; -} diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_updateAll.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_updateAll.java index c719744..7ffcd77 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_updateAll.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingVm_updateAll.java @@ -9,10 +9,14 @@ import org.apache.isis.applib.annotation.Action; import org.apache.isis.applib.annotation.ActionLayout; import org.apache.isis.applib.annotation.MemberOrder; import org.apache.isis.applib.annotation.SemanticsOf; -import org.apache.isis.applib.services.repository.RepositoryService; import lombok.val; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.disabled.DomainObjectPublishingDisabledJdoEntities; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled.DomainObjectPublishingEnabledJdoEntities; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.enabled.DomainObjectPublishingEnabledMetaAnnotatedJdoEntities; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnotOverridden.enabled.DomainObjectPublishingEnabledMetaAnnotOverriddenJdoEntities; + //tag::class[] @Action(semantics = SemanticsOf.IDEMPOTENT) @ActionLayout( @@ -26,13 +30,40 @@ public class DomainObjectPublishingVm_updateAll { } @MemberOrder(sequence = "2.0") - public DomainObjectPublishingVm act() { + public DomainObjectPublishingVm act( + boolean publishingEnabled + , boolean publishingDisabled + , boolean publishingEnabledMetaAnnotated + , boolean publishingEnabledMetaAnnotOverridden + ) { - renumber((List)publishingEnabledJdoEntities.all()); - renumber((List)publishingDisabledJdoEntities.all()); + if(publishingEnabled) { + renumber((List)publishingEnabledJdoEntities.all()); + } + if(publishingDisabled) { + renumber((List)publishingDisabledJdoEntities.all()); + } + if(publishingEnabledMetaAnnotated) { + renumber((List)publishingEnabledMetaAnnotatedJdoEntities.all()); + } + if(publishingEnabledMetaAnnotOverridden) { + renumber((List)publishingEnabledMetaAnnotOverriddenJdoEntities.all()); + } return domainObjectPublishingVm; } + public boolean default0Act() { + return true; + } + public boolean default1Act() { + return true; + } + public boolean default2Act() { + return true; + } + public boolean default3Act() { + return true; + } private static void renumber(List<DomainObjectPublishingJdo> all) { val ai = new AtomicInteger(0); @@ -40,9 +71,15 @@ public class DomainObjectPublishingVm_updateAll { } @Inject + DomainObjectPublishingEnabledJdoEntities publishingEnabledJdoEntities; + + @Inject DomainObjectPublishingDisabledJdoEntities publishingDisabledJdoEntities; @Inject - DomainObjectPublishingEnabledJdoEntities publishingEnabledJdoEntities; + DomainObjectPublishingEnabledMetaAnnotatedJdoEntities publishingEnabledMetaAnnotatedJdoEntities; + + @Inject + DomainObjectPublishingEnabledMetaAnnotOverriddenJdoEntities publishingEnabledMetaAnnotOverriddenJdoEntities; } //end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdo-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdo-description.adoc new file mode 100644 index 0000000..9c2b9a8 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdo-description.adoc @@ -0,0 +1,7 @@ +If publishing has been enabled by default, then it can of course also be disabled: + +[source,java,indent=0] +---- +include::DomainObjectPublishingDisabledJdo.java[tags=class] +---- +<.> explicitly specifies that modifying the domain object should _not_ be published. diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdo.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdo.java similarity index 82% rename from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdo.java rename to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdo.java index 7b3d486..88642b3 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdo.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdo.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.annotated.disabled; import javax.jdo.annotations.DatastoreIdentity; import javax.jdo.annotations.IdGeneratorStrategy; @@ -39,21 +39,22 @@ import lombok.Getter; import lombok.Setter; import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription; +import demoapp.dom.annotDomain.DomainObject.publishing.DomainObjectPublishingJdo; //tag::class[] @PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "demo") @DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "id") @DomainObject( - nature=Nature.JDO_ENTITY - , objectType = "demo.DomainObjectPublishingDisabledJdo" - , publishing = Publishing.DISABLED // <.> - , bounding = Bounding.BOUNDED + nature=Nature.JDO_ENTITY + , objectType = "demo.DomainObjectPublishingDisabledJdo" + , publishing = Publishing.DISABLED // <.> + , bounding = Bounding.BOUNDED ) @DomainObjectLayout( - describedAs = - "@DomainObject(publishing=DISABLED)" + describedAs = "@DomainObject(publishing=DISABLED)" ) -public class DomainObjectPublishingDisabledJdo implements DomainObjectPublishingJdo { +public class DomainObjectPublishingDisabledJdo + implements DomainObjectPublishingJdo { // ... //end::class[] @@ -62,7 +63,6 @@ public class DomainObjectPublishingDisabledJdo implements DomainObjectPublishing this.propertyUpdatedByAction = initialValue; } -//tag::class[] @Title(sequence = "1.0") @Getter @Setter private String property; @@ -71,5 +71,6 @@ public class DomainObjectPublishingDisabledJdo implements DomainObjectPublishing @Title(sequence = "2.0", prepend = " / ") private String propertyUpdatedByAction; +//tag::class[] } //end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdo.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdo.layout.xml similarity index 100% rename from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdo.layout.xml rename to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdo.layout.xml diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdoEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdoEntities.java similarity index 72% rename from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdoEntities.java rename to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdoEntities.java index d7d714b..01e8166 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdoEntities.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdoEntities.java @@ -1,4 +1,4 @@ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.annotated.disabled; import java.util.List; import java.util.Objects; @@ -10,6 +10,8 @@ import org.springframework.stereotype.Service; import org.apache.isis.applib.services.repository.RepositoryService; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled.DomainObjectPublishingEnabledJdo; + @Service public class DomainObjectPublishingDisabledJdoEntities { @@ -25,6 +27,10 @@ public class DomainObjectPublishingDisabledJdoEntities { return all().stream().findFirst().get(); } + public DomainObjectPublishingDisabledJdo create(String newValue) { + return repositoryService.persistAndFlush(new DomainObjectPublishingDisabledJdo(newValue)); + } + public void remove(DomainObjectPublishingDisabledJdo disabledJdo) { repositoryService.removeAndFlush(disabledJdo); } diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdoSeedService.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdoSeedService.java similarity index 93% rename from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdoSeedService.java rename to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdoSeedService.java index 34b0fe9..e699056 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledJdoSeedService.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingDisabledJdoSeedService.java @@ -1,4 +1,4 @@ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.annotated.disabled; import javax.inject.Inject; diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingVm_publishingDisabledAnnotatedEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingVm_publishingDisabledAnnotatedEntities.java new file mode 100644 index 0000000..b8e664c --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/disabled/DomainObjectPublishingVm_publishingDisabledAnnotatedEntities.java @@ -0,0 +1,28 @@ +package demoapp.dom.annotDomain.DomainObject.publishing.annotated.disabled; + +import java.util.List; + +import javax.inject.Inject; + +import org.apache.isis.applib.annotation.Collection; + +import demoapp.dom.annotDomain.DomainObject.publishing.DomainObjectPublishingVm; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.disabled.DomainObjectPublishingDisabledJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.disabled.DomainObjectPublishingDisabledJdoEntities; + +@Collection() +public class DomainObjectPublishingVm_publishingDisabledAnnotatedEntities { + + private final DomainObjectPublishingVm domainObjectPublishingVm; + + public DomainObjectPublishingVm_publishingDisabledAnnotatedEntities(DomainObjectPublishingVm domainObjectPublishingVm) { + this.domainObjectPublishingVm = domainObjectPublishingVm; + } + + public List<DomainObjectPublishingDisabledJdo> coll() { + return publishingDisabledJdoEntities.all(); + } + + @Inject + DomainObjectPublishingDisabledJdoEntities publishingDisabledJdoEntities; +} diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdo-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdo-description.adoc new file mode 100644 index 0000000..02527ab --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdo-description.adoc @@ -0,0 +1,8 @@ +The `publishing` semantic can be specified explicitly using an annotation through `@DomainObject#publishing()`: + +[source,java,indent=0] +---- +include::DomainObjectPublishingEnabledJdo.java[tags=class] +---- +<.> explicitly specifies that modifying the domain object should be published. + diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdo.java similarity index 82% copy from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.java copy to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdo.java index 0e8c341..6fb181f 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdo.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled; import javax.jdo.annotations.DatastoreIdentity; import javax.jdo.annotations.IdGeneratorStrategy; @@ -39,21 +39,22 @@ import lombok.Getter; import lombok.Setter; import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription; +import demoapp.dom.annotDomain.DomainObject.publishing.DomainObjectPublishingJdo; //tag::class[] @PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "demo") @DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "id") @DomainObject( - nature=Nature.JDO_ENTITY - , objectType = "demo.DomainObjectPublishingEnabledJdo" - , publishing = Publishing.ENABLED // <.> - , bounding = Bounding.BOUNDED + nature=Nature.JDO_ENTITY + , objectType = "demo.DomainObjectPublishingEnabledJdo" + , publishing = Publishing.ENABLED // <.> + , bounding = Bounding.BOUNDED ) @DomainObjectLayout( - describedAs = - "@DomainObject(publishing=ENABLED)" + describedAs = "@DomainObject(publishing=ENABLED)" ) -public class DomainObjectPublishingEnabledJdo implements DomainObjectPublishingJdo { +public class DomainObjectPublishingEnabledJdo + implements DomainObjectPublishingJdo { // ... //end::class[] @@ -62,7 +63,6 @@ public class DomainObjectPublishingEnabledJdo implements DomainObjectPublishingJ this.propertyUpdatedByAction = initialValue; } -//tag::class[] @Title(sequence = "1.0") @Getter @Setter private String property; @@ -71,5 +71,6 @@ public class DomainObjectPublishingEnabledJdo implements DomainObjectPublishingJ @Title(sequence = "2.0", prepend = " / ") private String propertyUpdatedByAction; +//tag::class[] } //end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdo.layout.xml similarity index 100% copy from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.layout.xml copy to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdo.layout.xml diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdoEntities.java similarity index 76% rename from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoEntities.java rename to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdoEntities.java index f224f69..303e1f0 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoEntities.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdoEntities.java @@ -1,4 +1,4 @@ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled; import java.util.List; import java.util.Objects; @@ -25,9 +25,8 @@ public class DomainObjectPublishingEnabledJdoEntities { return all().stream().findFirst().get(); } - public DomainObjectPublishingEnabledJdo cloneAndPersist(DomainObjectPublishingEnabledJdo original) { - return repositoryService.persistAndFlush( - new DomainObjectPublishingEnabledJdo(original.getProperty())); + public DomainObjectPublishingEnabledJdo create(String newValue) { + return repositoryService.persistAndFlush(new DomainObjectPublishingEnabledJdo(newValue)); } public void remove(DomainObjectPublishingEnabledJdo enabledJdo) { diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoSeedService.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdoSeedService.java similarity index 93% copy from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoSeedService.java copy to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdoSeedService.java index 3880748..42ad49a 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoSeedService.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingEnabledJdoSeedService.java @@ -1,4 +1,4 @@ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled; import javax.inject.Inject; diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingVm_publishingEnabledAnnotatedEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingVm_publishingEnabledAnnotatedEntities.java new file mode 100644 index 0000000..a2f05fa --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/annotated/enabled/DomainObjectPublishingVm_publishingEnabledAnnotatedEntities.java @@ -0,0 +1,28 @@ +package demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled; + +import java.util.List; + +import javax.inject.Inject; + +import org.apache.isis.applib.annotation.Collection; + +import demoapp.dom.annotDomain.DomainObject.publishing.DomainObjectPublishingVm; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled.DomainObjectPublishingEnabledJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled.DomainObjectPublishingEnabledJdoEntities; + +@Collection() +public class DomainObjectPublishingVm_publishingEnabledAnnotatedEntities { + + private final DomainObjectPublishingVm domainObjectPublishingVm; + + public DomainObjectPublishingVm_publishingEnabledAnnotatedEntities(DomainObjectPublishingVm domainObjectPublishingVm) { + this.domainObjectPublishingVm = domainObjectPublishingVm; + } + + public List<DomainObjectPublishingEnabledJdo> coll() { + return publishingEnabledJdoEntities.all(); + } + + @Inject + DomainObjectPublishingEnabledJdoEntities publishingEnabledJdoEntities; +} diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledMetaAnnotation.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/DomainObjectPublishingEnabledMetaAnnotation.java similarity index 72% rename from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledMetaAnnotation.java rename to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/DomainObjectPublishingEnabledMetaAnnotation.java index 54cfde5..57e592d 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledMetaAnnotation.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/DomainObjectPublishingEnabledMetaAnnotation.java @@ -1,4 +1,4 @@ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; @@ -11,10 +11,10 @@ import org.apache.isis.applib.annotation.Property; import org.apache.isis.applib.annotation.Publishing; //tag::class[] -@DomainObject(publishing = Publishing.ENABLED) // <.> +@DomainObject(publishing = Publishing.ENABLED) // <.> @Inherited @Target({ - ElementType.TYPE // <.> + ElementType.TYPE, ElementType.ANNOTATION_TYPE // <.> }) @Retention(RetentionPolicy.RUNTIME) public @interface DomainObjectPublishingEnabledMetaAnnotation { diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdo-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdo-description.adoc new file mode 100644 index 0000000..884dc96 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdo-description.adoc @@ -0,0 +1,18 @@ +The `publishing` semantic can also be specified using a custom meta-annotation: + +* the meta-annotation is defined as: ++ +[source,java] +---- +include::../DomainObjectPublishingEnabledMetaAnnotation.java[tags=class] +---- +<.> annotated for a domain object +<.> annotation can be applied to the type or a further meta-annotation type only + +* and can be applied to a domain object: ++ +[source,java,indent=0] +---- +include::DomainObjectPublishingEnabledMetaAnnotatedJdo.java[tags=class] +---- +<.> semantic is inherited from the meta-annotation diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdo.java similarity index 70% copy from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.java copy to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdo.java index 0e8c341..2ecb370 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdo.java @@ -16,53 +16,48 @@ * specific language governing permissions and limitations * under the License. */ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.enabled; import javax.jdo.annotations.DatastoreIdentity; import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.PersistenceCapable; -import org.apache.isis.applib.annotation.Action; import org.apache.isis.applib.annotation.Bounding; import org.apache.isis.applib.annotation.DomainObject; import org.apache.isis.applib.annotation.DomainObjectLayout; -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.Publishing; -import org.apache.isis.applib.annotation.SemanticsOf; import org.apache.isis.applib.annotation.Title; import lombok.Getter; import lombok.Setter; -import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription; +import demoapp.dom.annotDomain.DomainObject.publishing.DomainObjectPublishingJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.DomainObjectPublishingEnabledMetaAnnotation; //tag::class[] @PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "demo") @DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "id") +@DomainObjectPublishingEnabledMetaAnnotation // <.> @DomainObject( - nature=Nature.JDO_ENTITY - , objectType = "demo.DomainObjectPublishingEnabledJdo" - , publishing = Publishing.ENABLED // <.> - , bounding = Bounding.BOUNDED + nature=Nature.JDO_ENTITY + , objectType = "demo.DomainObjectPublishingEnabledMetaAnnotatedJdo" + , bounding = Bounding.BOUNDED ) @DomainObjectLayout( - describedAs = - "@DomainObject(publishing=ENABLED)" + describedAs = "@DomainObjectPublishingEnabledMetaAnnotation" ) -public class DomainObjectPublishingEnabledJdo implements DomainObjectPublishingJdo { +public class DomainObjectPublishingEnabledMetaAnnotatedJdo + implements DomainObjectPublishingJdo { // ... //end::class[] - public DomainObjectPublishingEnabledJdo(String initialValue) { + public DomainObjectPublishingEnabledMetaAnnotatedJdo(String initialValue) { this.property = initialValue; this.propertyUpdatedByAction = initialValue; } -//tag::class[] @Title(sequence = "1.0") @Getter @Setter private String property; @@ -71,5 +66,6 @@ public class DomainObjectPublishingEnabledJdo implements DomainObjectPublishingJ @Title(sequence = "2.0", prepend = " / ") private String propertyUpdatedByAction; +//tag::class[] } //end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdo.layout.xml similarity index 100% copy from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.layout.xml copy to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdo.layout.xml diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdoEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdoEntities.java new file mode 100644 index 0000000..3c4f352 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdoEntities.java @@ -0,0 +1,41 @@ +package demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.enabled; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +import javax.inject.Inject; + +import org.springframework.stereotype.Service; + +import org.apache.isis.applib.services.repository.RepositoryService; + +import demoapp.dom.annotDomain.DomainObject.publishing.annotated.enabled.DomainObjectPublishingEnabledJdo; + +@Service +public class DomainObjectPublishingEnabledMetaAnnotatedJdoEntities { + + public Optional<DomainObjectPublishingEnabledMetaAnnotatedJdo> find(final String value) { + return repositoryService.firstMatch(DomainObjectPublishingEnabledMetaAnnotatedJdo.class, x -> Objects.equals(x.getProperty(), value)); + } + + public List<DomainObjectPublishingEnabledMetaAnnotatedJdo> all() { + return repositoryService.allInstances(DomainObjectPublishingEnabledMetaAnnotatedJdo.class); + } + + public DomainObjectPublishingEnabledMetaAnnotatedJdo first() { + return all().stream().findFirst().get(); + } + + public DomainObjectPublishingEnabledMetaAnnotatedJdo create(String newValue) { + return repositoryService.persistAndFlush(new DomainObjectPublishingEnabledMetaAnnotatedJdo(newValue)); + } + + public void remove(DomainObjectPublishingEnabledMetaAnnotatedJdo enabledJdo) { + repositoryService.removeAndFlush(enabledJdo); + } + + @Inject + RepositoryService repositoryService; + +} diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoSeedService.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdoSeedService.java similarity index 73% copy from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoSeedService.java copy to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdoSeedService.java index 3880748..d581a9e 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoSeedService.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingEnabledMetaAnnotatedJdoSeedService.java @@ -1,4 +1,4 @@ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.enabled; import javax.inject.Inject; @@ -11,9 +11,9 @@ import demoapp.dom._infra.seed.SeedServiceAbstract; import demoapp.dom.types.Samples; @Service -public class DomainObjectPublishingEnabledJdoSeedService extends SeedServiceAbstract { +public class DomainObjectPublishingEnabledMetaAnnotatedJdoSeedService extends SeedServiceAbstract { - public DomainObjectPublishingEnabledJdoSeedService() { + public DomainObjectPublishingEnabledMetaAnnotatedJdoSeedService() { super(PropertyPublishingJdoEntityFixture::new); } @@ -22,7 +22,7 @@ public class DomainObjectPublishingEnabledJdoSeedService extends SeedServiceAbst @Override protected void execute(ExecutionContext executionContext) { samples.stream() - .map(DomainObjectPublishingEnabledJdo::new) + .map(DomainObjectPublishingEnabledMetaAnnotatedJdo::new) .forEach(domainObject -> { repositoryService.persist(domainObject); executionContext.addResult(this, domainObject); diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingVm_publishingEnabledMetaAnnotatedEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingVm_publishingEnabledMetaAnnotatedEntities.java new file mode 100644 index 0000000..191c139 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnot/enabled/DomainObjectPublishingVm_publishingEnabledMetaAnnotatedEntities.java @@ -0,0 +1,26 @@ +package demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.enabled; + +import java.util.List; + +import javax.inject.Inject; + +import org.apache.isis.applib.annotation.Collection; + +import demoapp.dom.annotDomain.DomainObject.publishing.DomainObjectPublishingVm; + +@Collection() +public class DomainObjectPublishingVm_publishingEnabledMetaAnnotatedEntities { + + private final DomainObjectPublishingVm domainObjectPublishingVm; + + public DomainObjectPublishingVm_publishingEnabledMetaAnnotatedEntities(DomainObjectPublishingVm domainObjectPublishingVm) { + this.domainObjectPublishingVm = domainObjectPublishingVm; + } + + public List<DomainObjectPublishingEnabledMetaAnnotatedJdo> coll() { + return publishingEnabledJdoEntities.all(); + } + + @Inject + DomainObjectPublishingEnabledMetaAnnotatedJdoEntities publishingEnabledJdoEntities; +} diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledMetaAnnotation.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/DomainObjectPublishingDisabledMetaAnnotation.java similarity index 71% rename from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledMetaAnnotation.java rename to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/DomainObjectPublishingDisabledMetaAnnotation.java index 7344b36..087fa20 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingDisabledMetaAnnotation.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/DomainObjectPublishingDisabledMetaAnnotation.java @@ -1,4 +1,4 @@ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.metaAnnotOverridden; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; @@ -11,10 +11,10 @@ import org.apache.isis.applib.annotation.Property; import org.apache.isis.applib.annotation.Publishing; //tag::class[] -@DomainObject(publishing = Publishing.DISABLED) // <.> +@DomainObject(publishing = Publishing.DISABLED) // <.> @Inherited @Target({ - ElementType.TYPE // <.> + ElementType.TYPE, ElementType.ANNOTATION_TYPE // <.> }) @Retention(RetentionPolicy.RUNTIME) public @interface DomainObjectPublishingDisabledMetaAnnotation { diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdo-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdo-description.adoc new file mode 100644 index 0000000..c306895 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdo-description.adoc @@ -0,0 +1,18 @@ +The `publishing` semantic can also be specified using a custom meta-annotation: + +* the meta-annotation is defined as: ++ +[source,java] +---- +include::../DomainObjectPublishingDisabledMetaAnnotation.java[tags=class] +---- +<.> annotated for a domain object +<.> annotation can be applied to the type or a further meta-annotation type only + +* and can be applied to a domain object: ++ +[source,java,indent=0] +---- +include::DomainObjectPublishingEnabledMetaAnnotOverriddenJdo.java[tags=class] +---- +<.> semantic is inherited from the meta-annotation diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdo.java similarity index 68% rename from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.java rename to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdo.java index 0e8c341..af6b81f 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdo.java @@ -16,53 +16,51 @@ * specific language governing permissions and limitations * under the License. */ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.metaAnnotOverridden.enabled; import javax.jdo.annotations.DatastoreIdentity; import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.PersistenceCapable; -import org.apache.isis.applib.annotation.Action; import org.apache.isis.applib.annotation.Bounding; import org.apache.isis.applib.annotation.DomainObject; import org.apache.isis.applib.annotation.DomainObjectLayout; -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.Publishing; -import org.apache.isis.applib.annotation.SemanticsOf; import org.apache.isis.applib.annotation.Title; import lombok.Getter; import lombok.Setter; -import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription; +import demoapp.dom.annotDomain.DomainObject.publishing.DomainObjectPublishingJdo; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.DomainObjectPublishingEnabledMetaAnnotation; +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnotOverridden.DomainObjectPublishingDisabledMetaAnnotation; //tag::class[] @PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "demo") @DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "id") +@DomainObjectPublishingDisabledMetaAnnotation // <.> @DomainObject( nature=Nature.JDO_ENTITY - , objectType = "demo.DomainObjectPublishingEnabledJdo" - , publishing = Publishing.ENABLED // <.> + , objectType = "demo.DomainObjectPublishingEnabledMetaAnnotOverriddenJdo" + , publishing = Publishing.ENABLED // <.> , bounding = Bounding.BOUNDED ) @DomainObjectLayout( - describedAs = - "@DomainObject(publishing=ENABLED)" + describedAs = + "@DomainObjectPublishingDisabledMetaAnnotation " + + "@DomainObject(publishing=ENABLED)" ) -public class DomainObjectPublishingEnabledJdo implements DomainObjectPublishingJdo { +public class DomainObjectPublishingEnabledMetaAnnotOverriddenJdo implements DomainObjectPublishingJdo { // ... //end::class[] - public DomainObjectPublishingEnabledJdo(String initialValue) { + public DomainObjectPublishingEnabledMetaAnnotOverriddenJdo(String initialValue) { this.property = initialValue; this.propertyUpdatedByAction = initialValue; } -//tag::class[] @Title(sequence = "1.0") @Getter @Setter private String property; @@ -71,5 +69,6 @@ public class DomainObjectPublishingEnabledJdo implements DomainObjectPublishingJ @Title(sequence = "2.0", prepend = " / ") private String propertyUpdatedByAction; +//tag::class[] } //end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdo.layout.xml similarity index 100% rename from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdo.layout.xml rename to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdo.layout.xml diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdoEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdoEntities.java new file mode 100644 index 0000000..9f83119 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdoEntities.java @@ -0,0 +1,41 @@ +package demoapp.dom.annotDomain.DomainObject.publishing.metaAnnotOverridden.enabled; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +import javax.inject.Inject; + +import org.springframework.stereotype.Service; + +import org.apache.isis.applib.services.repository.RepositoryService; + +import demoapp.dom.annotDomain.DomainObject.publishing.metaAnnot.enabled.DomainObjectPublishingEnabledMetaAnnotatedJdo; + +@Service +public class DomainObjectPublishingEnabledMetaAnnotOverriddenJdoEntities { + + public Optional<DomainObjectPublishingEnabledMetaAnnotOverriddenJdo> find(final String value) { + return repositoryService.firstMatch(DomainObjectPublishingEnabledMetaAnnotOverriddenJdo.class, x -> Objects.equals(x.getProperty(), value)); + } + + public List<DomainObjectPublishingEnabledMetaAnnotOverriddenJdo> all() { + return repositoryService.allInstances(DomainObjectPublishingEnabledMetaAnnotOverriddenJdo.class); + } + + public DomainObjectPublishingEnabledMetaAnnotOverriddenJdo first() { + return all().stream().findFirst().get(); + } + + public DomainObjectPublishingEnabledMetaAnnotOverriddenJdo create(String newValue) { + return repositoryService.persistAndFlush(new DomainObjectPublishingEnabledMetaAnnotOverriddenJdo(newValue)); + } + + public void remove(DomainObjectPublishingEnabledMetaAnnotOverriddenJdo enabledJdo) { + repositoryService.removeAndFlush(enabledJdo); + } + + @Inject + RepositoryService repositoryService; + +} diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoSeedService.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdoSeedService.java similarity index 72% rename from examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoSeedService.java rename to examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdoSeedService.java index 3880748..fe3e27f 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/DomainObjectPublishingEnabledJdoSeedService.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingEnabledMetaAnnotOverriddenJdoSeedService.java @@ -1,4 +1,4 @@ -package demoapp.dom.annotDomain.DomainObject.publishing; +package demoapp.dom.annotDomain.DomainObject.publishing.metaAnnotOverridden.enabled; import javax.inject.Inject; @@ -11,9 +11,9 @@ import demoapp.dom._infra.seed.SeedServiceAbstract; import demoapp.dom.types.Samples; @Service -public class DomainObjectPublishingEnabledJdoSeedService extends SeedServiceAbstract { +public class DomainObjectPublishingEnabledMetaAnnotOverriddenJdoSeedService extends SeedServiceAbstract { - public DomainObjectPublishingEnabledJdoSeedService() { + public DomainObjectPublishingEnabledMetaAnnotOverriddenJdoSeedService() { super(PropertyPublishingJdoEntityFixture::new); } @@ -22,7 +22,7 @@ public class DomainObjectPublishingEnabledJdoSeedService extends SeedServiceAbst @Override protected void execute(ExecutionContext executionContext) { samples.stream() - .map(DomainObjectPublishingEnabledJdo::new) + .map(DomainObjectPublishingEnabledMetaAnnotOverriddenJdo::new) .forEach(domainObject -> { repositoryService.persist(domainObject); executionContext.addResult(this, domainObject); diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingVm_publishingEnabledMetaAnnotOverriddenEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingVm_publishingEnabledMetaAnnotOverriddenEntities.java new file mode 100644 index 0000000..9e5627c --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/metaAnnotOverridden/enabled/DomainObjectPublishingVm_publishingEnabledMetaAnnotOverriddenEntities.java @@ -0,0 +1,26 @@ +package demoapp.dom.annotDomain.DomainObject.publishing.metaAnnotOverridden.enabled; + +import java.util.List; + +import javax.inject.Inject; + +import org.apache.isis.applib.annotation.Collection; + +import demoapp.dom.annotDomain.DomainObject.publishing.DomainObjectPublishingVm; + +@Collection() +public class DomainObjectPublishingVm_publishingEnabledMetaAnnotOverriddenEntities { + + private final DomainObjectPublishingVm domainObjectPublishingVm; + + public DomainObjectPublishingVm_publishingEnabledMetaAnnotOverriddenEntities(DomainObjectPublishingVm domainObjectPublishingVm) { + this.domainObjectPublishingVm = domainObjectPublishingVm; + } + + public List<DomainObjectPublishingEnabledMetaAnnotOverriddenJdo> coll() { + return publishingEnabledJdoEntities.all(); + } + + @Inject + DomainObjectPublishingEnabledMetaAnnotOverriddenJdoEntities publishingEnabledJdoEntities; +} diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/spiimpl/PublisherServiceSpiForDomainObject.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/spiimpl/PublisherServiceSpiForDomainObject.java index ccb27bf..265f574 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/spiimpl/PublisherServiceSpiForDomainObject.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/DomainObject/publishing/spiimpl/PublisherServiceSpiForDomainObject.java @@ -20,7 +20,9 @@ public class PublisherServiceSpiForDomainObject implements PublisherService { private final List<ChangesDto> publishedObjects = new ArrayList<>(); @Override - public void publish(PublishedObjects publishedObjects) { + public void publish( + PublishedObjects publishedObjects // <.> + ) { val dto = publishedObjects.getDto(); this.publishedObjects.add(dto); } diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/publishing/PropertyPublishingJdo-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/publishing/PropertyPublishingJdo-description.adoc index 6d1403f..dcf4afb 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/publishing/PropertyPublishingJdo-description.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Property/publishing/PropertyPublishingJdo-description.adoc @@ -92,3 +92,19 @@ include::spiimpl/PropertyPublishingJdo_interactionExecutions.java[tags=class] include::spiimpl/PropertyPublishingJdo_clearInteractionExecutions.java[tags=class] ---- + + +== Configuration + +By default, publishing of property edits is disabled. +This can be configured globally: + +[source,yaml] +.application.yml +---- +isis: + applib: + annotation: + property: + publishing: none +---- diff --git a/examples/demo/domain/src/main/resources/application.yml b/examples/demo/domain/src/main/resources/application.yml index 2c67478..b24f0c1 100644 --- a/examples/demo/domain/src/main/resources/application.yml +++ b/examples/demo/domain/src/main/resources/application.yml @@ -23,6 +23,7 @@ isis: annotation: action: explicit: true + publishing: none action-layout: css-class-fa: patterns: @@ -38,6 +39,9 @@ isis: delete.*:btn-danger domain-object: editing: false + publishing: none + property: + publishing: none property-layout: label-position: LEFT parameter-layout: diff --git a/examples/demo/domain/src/main/resources/static/css/application.css b/examples/demo/domain/src/main/resources/static/css/application.css index a20b144..71f3d23 100644 --- a/examples/demo/domain/src/main/resources/static/css/application.css +++ b/examples/demo/domain/src/main/resources/static/css/application.css @@ -211,6 +211,11 @@ div.sectionbody > div.ulist > ul { margin-left: -23px; } +div.sectionbody > div.listingblock > div.title { + font-style: italic; + color: #c7254e; +} + header.navbar-fixed-top { position: sticky; } @@ -249,3 +254,4 @@ table.tableblock.grid-all th.tableblock { table.tableblock.grid-all td.tableblock { padding: 5px; } + diff --git a/examples/demo/domain/src/main/resources/static/scripts/application.js b/examples/demo/domain/src/main/resources/static/scripts/application.js index de6c2c4..49fa3a8 100644 --- a/examples/demo/domain/src/main/resources/static/scripts/application.js +++ b/examples/demo/domain/src/main/resources/static/scripts/application.js @@ -8,6 +8,7 @@ $(document).ready(function() { /// and instead, if on a link, then clicks it window.addEventListener('keydown', function(e) { if (e.keyCode === 32) { + console.log(e.target) if (e.target === document.body) { e.preventDefault(); } else if (e.target.tagName.toLowerCase() === 'a') {
