diff --git a/api/applib/src/main/java/org/apache/causeway/applib/annotation/Publishing.java b/api/applib/src/main/java/org/apache/causeway/applib/annotation/Publishing.java
index b0fcc085537..95f6de2f085 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/annotation/Publishing.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/annotation/Publishing.java
@@ -55,6 +55,29 @@ public enum Publishing {
*/
ENABLED,
+ /**
+ * Applies only to {@link EntityPropertyChangeSubscriber}, whereby events are published for modifications to the
+ * object, but no events are published for the initial creation of an object.
+ *
+ *
+ * In the case of audit trail extension,
+ * this effectively suppresses all of the "[NEW] -> value" entries that are created for every property of the
+ * entity when it is being created, and also all of the "value -> [DELETED]" entries that are created for every property of the
+ * entity when it is being deleted.
+ *
+ *
+ *
+ * This variant is intended only where the application code has enough traceability built into the domain
+ * (perhaps to provide visibility to the end-users) that the technical auditing is overkill. It will also
+ * of course reduce the volume of auditing, so improves performance (likely both response times and throughput).
+ *
+ *
+ *
+ * For other subscribers, behaviour is the same as {@link #ENABLED}.
+ *
+ */
+ ENABLED_FOR_UPDATES_ONLY,
+
/**
* Do not publish data triggered by interaction with this object
* (even if otherwise configured to enable publishing).
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/command/CommandPublishingFacetForActionAnnotation.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/command/CommandPublishingFacetForActionAnnotation.java
index 8f4dd4a4d15..cf6690083e8 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/command/CommandPublishingFacetForActionAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/command/CommandPublishingFacetForActionAnnotation.java
@@ -93,6 +93,7 @@ public static Optional create(
case DISABLED:
return new CommandPublishingFacetForActionAnnotation.Disabled(processor, holder, servicesInjector);
case ENABLED:
+ case ENABLED_FOR_UPDATES_ONLY:
return new CommandPublishingFacetForActionAnnotation.Enabled(processor, holder, servicesInjector);
default:
throw new IllegalStateException(String.format("@Action#commandPublishing '%s' not recognised", publishing));
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/command/CommandPublishingFacetForPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/command/CommandPublishingFacetForPropertyAnnotation.java
index 6a5a8196c38..1dcf9b314be 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/command/CommandPublishingFacetForPropertyAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/command/CommandPublishingFacetForPropertyAnnotation.java
@@ -92,6 +92,7 @@ public static CommandPublishingFacet create(
case DISABLED:
return new CommandPublishingFacetForPropertyAnnotation.Disabled(processor, holder, servicesInjector);
case ENABLED:
+ case ENABLED_FOR_UPDATES_ONLY:
return new CommandPublishingFacetForPropertyAnnotation.Enabled(processor, holder, servicesInjector);
default:
throw new IllegalStateException(String.format("@Property#commandPublishing '%s' not recognised", publishing));
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/execution/ExecutionPublishingFacetForActionAnnotation.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/execution/ExecutionPublishingFacetForActionAnnotation.java
index a4fa9d55538..362d9c7f817 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/execution/ExecutionPublishingFacetForActionAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/execution/ExecutionPublishingFacetForActionAnnotation.java
@@ -83,6 +83,7 @@ public static Optional create(
case DISABLED:
return new ExecutionPublishingFacetForActionAnnotation.Disabled(holder);
case ENABLED:
+ case ENABLED_FOR_UPDATES_ONLY:
return new ExecutionPublishingFacetForActionAnnotation.Enabled(holder);
default:
throw new IllegalStateException(String.format("@Action#executionPublishing '%s' not recognised", publishing));
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/execution/ExecutionPublishingFacetForPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/execution/ExecutionPublishingFacetForPropertyAnnotation.java
index 7b95449fb09..7508fccf894 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/execution/ExecutionPublishingFacetForPropertyAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/members/publish/execution/ExecutionPublishingFacetForPropertyAnnotation.java
@@ -83,6 +83,7 @@ public static ExecutionPublishingFacet create(
case DISABLED:
return new ExecutionPublishingFacetForPropertyAnnotation.Disabled(holder);
case ENABLED:
+ case ENABLED_FOR_UPDATES_ONLY:
return new ExecutionPublishingFacetForPropertyAnnotation.Enabled(holder);
default:
throw new IllegalStateException(String.format("@Property#executionPublishing '%s' not recognised", publishing));
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetForDomainObjectAnnotation.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetForDomainObjectAnnotation.java
index a5d5ef82091..cbae5f96212 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetForDomainObjectAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetForDomainObjectAnnotation.java
@@ -57,17 +57,19 @@ public static Optional create(
: new EntityChangePublishingFacetFromConfiguration(holder, true));
}
case DISABLED:
- return Optional.of(new EntityChangePublishingFacetForDomainObjectAnnotation(holder, false));
+ return Optional.of(new EntityChangePublishingFacetForDomainObjectAnnotation(holder, false, false, false, false));
case ENABLED:
- return Optional.of(new EntityChangePublishingFacetForDomainObjectAnnotation(holder, true));
+ return Optional.of(new EntityChangePublishingFacetForDomainObjectAnnotation(holder, true, true, true, true));
+ case ENABLED_FOR_UPDATES_ONLY:
+ return Optional.of(new EntityChangePublishingFacetForDomainObjectAnnotation(holder, true, false, true, false));
default:
throw _Exceptions.unmatchedCase(publish);
}
}
- protected EntityChangePublishingFacetForDomainObjectAnnotation(final FacetHolder holder, boolean enabled) {
- super(holder, enabled);
+ protected EntityChangePublishingFacetForDomainObjectAnnotation(final FacetHolder holder, boolean enabled, boolean enabledForCreate, boolean enabledForUpdate, boolean enabledForDelete) {
+ super(holder, enabled, enabledForCreate, enabledForUpdate, enabledForDelete);
}
}
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetForDomainObjectAnnotationAsConfigured.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetForDomainObjectAnnotationAsConfigured.java
index 1221b4b7a4f..d272222c8b6 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetForDomainObjectAnnotationAsConfigured.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetForDomainObjectAnnotationAsConfigured.java
@@ -25,7 +25,7 @@
public class EntityChangePublishingFacetForDomainObjectAnnotationAsConfigured extends EntityChangePublishingFacetForDomainObjectAnnotation {
public EntityChangePublishingFacetForDomainObjectAnnotationAsConfigured(final FacetHolder facetHolder, final boolean enabled) {
- super(facetHolder, enabled);
+ super(facetHolder, enabled, enabled, enabled, enabled);
}
}
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetFromConfiguration.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetFromConfiguration.java
index 0a1ef173341..133bed5c6a4 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetFromConfiguration.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/domainobject/entitychangepublishing/EntityChangePublishingFacetFromConfiguration.java
@@ -32,7 +32,7 @@ public class EntityChangePublishingFacetFromConfiguration
extends EntityChangePublishingFacetAbstract {
public EntityChangePublishingFacetFromConfiguration(final FacetHolder facetHolder, final boolean enabled) {
- super(facetHolder, enabled);
+ super(facetHolder, enabled, enabled, enabled, enabled);
}
}
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/publish/entitychange/EntityChangePublishingFacet.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/publish/entitychange/EntityChangePublishingFacet.java
index fba7a8388ef..76ce2cdeb07 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/publish/entitychange/EntityChangePublishingFacet.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/publish/entitychange/EntityChangePublishingFacet.java
@@ -34,7 +34,7 @@
*/
public interface EntityChangePublishingFacet extends Facet {
- public static boolean isPublishingEnabled(final FacetHolder facetHolder) {
+ static boolean isPublishingEnabled(final FacetHolder facetHolder) {
if(facetHolder==null) {
return false;
}
@@ -50,6 +50,57 @@ public static boolean isPublishingEnabled(final FacetHolder facetHolder) {
&& entityChangePublishingFacet.isEnabled();
}
+ static boolean isPublishingEnabledForCreate(final FacetHolder facetHolder) {
+ if(facetHolder==null) {
+ return false;
+ }
+
+ if(facetHolder instanceof ObjectSpecification) {
+ if(!((ObjectSpecification)facetHolder).isEntity()) {
+ return false;
+ }
+ }
+
+ val entityChangePublishingFacet = facetHolder.getFacet(EntityChangePublishingFacet.class);
+ return entityChangePublishingFacet != null
+ && entityChangePublishingFacet.isEnabledForCreate();
+ }
+
+ static boolean isPublishingEnabledForUpdate(final FacetHolder facetHolder) {
+ if(facetHolder==null) {
+ return false;
+ }
+
+ if(facetHolder instanceof ObjectSpecification) {
+ if(!((ObjectSpecification)facetHolder).isEntity()) {
+ return false;
+ }
+ }
+
+ val entityChangePublishingFacet = facetHolder.getFacet(EntityChangePublishingFacet.class);
+ return entityChangePublishingFacet != null
+ && entityChangePublishingFacet.isEnabledForUpdate();
+ }
+
+ static boolean isPublishingEnabledForDelete(final FacetHolder facetHolder) {
+ if(facetHolder==null) {
+ return false;
+ }
+
+ if(facetHolder instanceof ObjectSpecification) {
+ if(!((ObjectSpecification)facetHolder).isEntity()) {
+ return false;
+ }
+ }
+
+ val entityChangePublishingFacet = facetHolder.getFacet(EntityChangePublishingFacet.class);
+ return entityChangePublishingFacet != null
+ && entityChangePublishingFacet.isEnabledForDelete();
+ }
+
boolean isEnabled();
+ boolean isEnabledForCreate();
+ boolean isEnabledForUpdate();
+ boolean isEnabledForDelete();
}
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/publish/entitychange/EntityChangePublishingFacetAbstract.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/publish/entitychange/EntityChangePublishingFacetAbstract.java
index af60b3f0544..13cd84b84e5 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/publish/entitychange/EntityChangePublishingFacetAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/publish/entitychange/EntityChangePublishingFacetAbstract.java
@@ -35,9 +35,21 @@ private static final Class extends Facet> type() {
@Getter
private final boolean enabled;
- public EntityChangePublishingFacetAbstract(final FacetHolder facetHolder, boolean enabled) {
+ @Getter
+ private final boolean enabledForCreate;
+
+ @Getter
+ private final boolean enabledForUpdate;
+
+ @Getter
+ private final boolean enabledForDelete;
+
+ public EntityChangePublishingFacetAbstract(final FacetHolder facetHolder, boolean enabled, boolean enabledForCreate, boolean enabledForUpdate, boolean enabledForDelete) {
super(EntityChangePublishingFacetAbstract.type(), facetHolder);
this.enabled = enabled;
+ this.enabledForCreate = enabledForCreate;
+ this.enabledForUpdate = enabledForUpdate;
+ this.enabledForDelete = enabledForDelete;
}
}
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/property/entitychangepublishing/EntityPropertyChangePublishingPolicyFacet.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/property/entitychangepublishing/EntityPropertyChangePublishingPolicyFacet.java
index 5156fb936e2..bd35418b1fe 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/property/entitychangepublishing/EntityPropertyChangePublishingPolicyFacet.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/property/entitychangepublishing/EntityPropertyChangePublishingPolicyFacet.java
@@ -34,7 +34,7 @@
public interface EntityPropertyChangePublishingPolicyFacet extends Facet {
/**
- * Must be one of Publishing.ENABLED or Publishing.DISABLED.
+ * Must be one of {@link Publishing#ENABLED}, {@link Publishing#ENABLED_FOR_UPDATES_ONLY} or {@link Publishing#DISABLED}.
*/
@NonNull Publishing getEntityChangePublishing();
@@ -43,7 +43,7 @@ default boolean isPublishingVetoed() {
}
default boolean isPublishingAllowed() {
- return getEntityChangePublishing() == Publishing.ENABLED;
+ return getEntityChangePublishing() == Publishing.ENABLED || getEntityChangePublishing() == Publishing.ENABLED_FOR_UPDATES_ONLY;
}
static boolean isExcludedFromPublishing(final @NonNull OneToOneAssociation property) {
@@ -59,7 +59,7 @@ static boolean isExcludedFromPublishing(final @NonNull OneToOneAssociation prope
.map(EntityPropertyChangePublishingPolicyFacet::isPublishingAllowed)
.orElse(false);
- //XXX CAUSEWAY-1488, exclude Bob/Clob from property change publishing unless explicitly allowed
+ //XXX CAUSEWAY-1488, exclude Blob/Clob from property change publishing unless explicitly allowed
return !isExplictlyAllowed;
}
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/property/entitychangepublishing/EntityPropertyChangePublishingPolicyFacetForPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/property/entitychangepublishing/EntityPropertyChangePublishingPolicyFacetForPropertyAnnotation.java
index dbf4cc19abc..cd51e46cd04 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/property/entitychangepublishing/EntityPropertyChangePublishingPolicyFacetForPropertyAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/property/entitychangepublishing/EntityPropertyChangePublishingPolicyFacetForPropertyAnnotation.java
@@ -35,8 +35,9 @@ public static Optional create(
.map(Property::entityChangePublishing)
// only install facet if policy is explicit ('enabled' or 'disabled')
.filter(entityChangePublishing ->
- entityChangePublishing == Publishing.ENABLED
- || entityChangePublishing == Publishing.DISABLED)
+ entityChangePublishing == Publishing.ENABLED ||
+ entityChangePublishing == Publishing.ENABLED_FOR_UPDATES_ONLY ||
+ entityChangePublishing == Publishing.DISABLED)
.map(entityChangePublishing ->
new EntityPropertyChangePublishingPolicyFacetForPropertyAnnotation(entityChangePublishing, holder));
}
diff --git a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/FacetFactoryTestAbstract.java b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/FacetFactoryTestAbstract.java
index 2985f0a3fe6..400bf2d3dae 100644
--- a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/FacetFactoryTestAbstract.java
+++ b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/FacetFactoryTestAbstract.java
@@ -124,8 +124,7 @@ public static CollectionScenarioBuilder builder(final Class> declaringClass, f
// --
- @Getter(onMethod_ = {@Override})
- private MetaModelContext metaModelContext;
+ @Getter(onMethod_ = {@Override}) protected MetaModelContext metaModelContext;
private MethodRemover_forTesting methodRemover;
diff --git a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java
index 879d70ca2d7..6448a0b53a7 100644
--- a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java
+++ b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java
@@ -22,8 +22,11 @@
import javax.inject.Named;
+import org.apache.causeway.applib.annotation.Publishing;
+
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -78,7 +81,7 @@ protected void tearDown() throws Exception {
facetFactory = null;
}
- class Customer {
+ static class Customer {
}
class SomeHasInteractionId implements HasInteractionId {
@@ -108,7 +111,8 @@ protected void ignoringConfiguration() {
}
- public static class EntityChangePublishing extends DomainObjectAnnotationFacetFactoryTest {
+ @Nested
+ public class EntityChangePublishing {
@DomainObject(entityChangePublishing = org.apache.causeway.applib.annotation.Publishing.AS_CONFIGURED)
class CustomerWithDomainObjectAndAuditingSetToAsConfigured {
@@ -122,8 +126,13 @@ class CustomerWithDomainObjectAndAuditingSetToDisabled {
class CustomerWithDomainObjectAndAuditingSetToEnabled {
}
+ @DomainObject(entityChangePublishing = Publishing.ENABLED_FOR_UPDATES_ONLY)
+ class CustomerWithDomainObjectAndEntityChangePublishingSetToEnabledForUpdatesOnly {
+ }
+
- public static class WhenNotAnnotatedAndDefaultsFromConfiguration extends EntityChangePublishing {
+ @Nested
+ public class WhenNotAnnotatedAndDefaultsFromConfiguration {
@Test
void configured_value_set_to_all() {
@@ -157,7 +166,8 @@ void configured_value_set_to_none() {
}
- public static class WithDomainObjectAnnotationWithAuditingSetToAsConfigured extends EntityChangePublishing {
+ @Nested
+ public class WithDomainObjectAnnotationWithAuditingSetToAsConfigured {
@Test
public void configured_value_set_to_all() {
@@ -190,7 +200,8 @@ public void configured_value_set_to_none() {
}
- public static class WithDomainObjectAnnotationWithAuditingSetToEnabled extends EntityChangePublishing {
+ @Nested
+ public class WithDomainObjectAnnotationWithAuditingSetToEnabled {
@Test
public void irrespective_of_configured_value() {
@@ -208,7 +219,31 @@ public void irrespective_of_configured_value() {
}
- public static class WithDomainObjectAnnotationWithAuditingSetToDisabled extends EntityChangePublishing {
+ @Nested
+ public class WithDomainObjectAnnotationWithEntityChangePublishingSetToEnabledForUpdatesOnly {
+
+ @Test
+ public void irrespective_of_configured_value() {
+ allowingEntityChangePublishingToReturn(null);
+ objectScenario(CustomerWithDomainObjectAndEntityChangePublishingSetToEnabledForUpdatesOnly.class, (processClassContext, facetHolder)->{
+ facetFactory.process(processClassContext);
+
+ final Facet facet = facetHolder.getFacet(EntityChangePublishingFacet.class);
+ assertNotNull(facet);
+ assertTrue(facet instanceof EntityChangePublishingFacetForDomainObjectAnnotation);
+
+ assertFalse(EntityChangePublishingFacet.isPublishingEnabledForCreate(facetHolder));
+ assertTrue(EntityChangePublishingFacet.isPublishingEnabledForUpdate(facetHolder));
+ assertFalse(EntityChangePublishingFacet.isPublishingEnabledForDelete(facetHolder));
+
+ assertNoMethodsRemoved();
+ });
+ }
+
+ }
+
+ @Nested
+ public class WithDomainObjectAnnotationWithAuditingSetToDisabled {
@Test
public void irrespective_of_configured_value() {
@@ -226,7 +261,8 @@ public void irrespective_of_configured_value() {
}
- public static class AutoComplete extends DomainObjectAnnotationFacetFactoryTest {
+ @Nested
+ public class AutoComplete {
class CustomerRepository {
public String lookup(final String x) { return null; }
@@ -317,7 +353,8 @@ public void whenNoDomainObjectAnnotation() {
}
- public static class Bounded extends DomainObjectAnnotationFacetFactoryTest {
+ @Nested
+ public class Bounded {
@DomainObject(bounding = Bounding.BOUNDED)
class CustomerWithDomainObjectAndBoundedSetToTrue {
@@ -331,10 +368,8 @@ class CustomerWithDomainObjectAndBoundedSetToFalse {
class CustomerWithDomainObjectButNoBounded {
}
- @Override
@BeforeEach
public void setUp() throws Exception {
- super.setUp();
ignoringConfiguration();
}
@@ -382,25 +417,23 @@ public void whenNoDomainObjectAnnotation() {
}
- public static class Editing extends DomainObjectAnnotationFacetFactoryTest {
-
- class CustomerWithImmutableAnnotation {
- }
-
- @DomainObject(editing = org.apache.causeway.applib.annotation.Editing.AS_CONFIGURED)
- class CustomerWithDomainObjectAndEditingSetToAsConfigured {
- }
+ @DomainObject(editing = org.apache.causeway.applib.annotation.Editing.AS_CONFIGURED)
+ static class CustomerWithDomainObjectAndEditingSetToAsConfigured {
+ }
- @DomainObject(editing = org.apache.causeway.applib.annotation.Editing.DISABLED)
- class CustomerWithDomainObjectAndEditingSetToDisabled {
- }
+ @DomainObject(editing = org.apache.causeway.applib.annotation.Editing.DISABLED)
+ static class CustomerWithDomainObjectAndEditingSetToDisabled {
+ }
- @DomainObject(editing = org.apache.causeway.applib.annotation.Editing.ENABLED)
- class CustomerWithDomainObjectAndEditingSetToEnabled {
- }
+ @DomainObject(editing = org.apache.causeway.applib.annotation.Editing.ENABLED)
+ static class CustomerWithDomainObjectAndEditingSetToEnabled {
+ }
+ @Nested
+ public class Editing {
- public static class WhenNotAnnotatedAndDefaultsFromConfiguration extends Editing {
+ @Nested
+ public class WhenNotAnnotatedAndDefaultsFromConfiguration {
@Test
public void configured_value_set_to_true() {
@@ -448,8 +481,8 @@ public void configured_value_set_to_defaults() {
}
}
-
- public static class WithDomainObjectAnnotationWithEditingSetToAsConfigured extends Editing {
+ @Nested
+ public class WithDomainObjectAnnotationWithEditingSetToAsConfigured {
@Test
public void configured_value_set_to_true() {
@@ -493,7 +526,8 @@ public void configured_value_set_to_defaults() {
}
}
- public static class WithDomainObjectAnnotationWithEditingSetToEnabled extends Editing {
+ @Nested
+ public class WithDomainObjectAnnotationWithEditingSetToEnabled {
@Test
public void irrespective_of_configured_value() {
@@ -509,7 +543,8 @@ public void irrespective_of_configured_value() {
}
}
- public static class WithDomainObjectAnnotationWithEditingSetToDisabled extends Editing {
+ @Nested
+ public class WithDomainObjectAnnotationWithEditingSetToDisabled {
@Test
public void irrespective_of_configured_value() {
@@ -527,27 +562,27 @@ public void irrespective_of_configured_value() {
}
}
- public static class LogicalTypeName extends DomainObjectAnnotationFacetFactoryTest {
+ @Named("CUS")
+ @DomainObject
+ static class LogicalTypeNameCustomerWithDomainObjectAndObjectTypeSet {
+ }
- @Named("CUS")
- @DomainObject
- class CustomerWithDomainObjectAndObjectTypeSet {
- }
+ @DomainObject
+ static class LogicalTypeNameCustomerWithDomainObjectButNoObjectType {
+ }
- @DomainObject
- class CustomerWithDomainObjectButNoObjectType {
- }
- @Override
+ @Nested
+ public class LogicalTypeName {
+
@BeforeEach
public void setUp() throws Exception {
- super.setUp();
ignoringConfiguration();
}
@Test
public void whenDomainObjectAndObjectTypeSetToTrue() {
- assertThat(LogicalType.infer(CustomerWithDomainObjectAndObjectTypeSet.class).logicalName(),
+ assertThat(LogicalType.infer(LogicalTypeNameCustomerWithDomainObjectAndObjectTypeSet.class).logicalName(),
is("CUS"));
assertNoMethodsRemoved();
}
@@ -555,7 +590,7 @@ public void whenDomainObjectAndObjectTypeSetToTrue() {
@Test
public void whenDomainObjectAndObjectTypeNotSet() {
- objectScenario(CustomerWithDomainObjectButNoObjectType.class, (processClassContext, facetHolder)->{
+ objectScenario(LogicalTypeNameCustomerWithDomainObjectButNoObjectType.class, (processClassContext, facetHolder)->{
facetFactory.process(processClassContext);
final Facet facet = facetHolder.getFacet(AliasedFacet.class);
@@ -580,28 +615,28 @@ public void whenNoDomainObjectAnnotation() {
}
- public static class Nature extends DomainObjectAnnotationFacetFactoryTest {
- @DomainObject(nature = org.apache.causeway.applib.annotation.Nature.ENTITY)
- class CustomerWithDomainObjectAndNatureSetToJdoEntity {
- }
+ @DomainObject(nature = org.apache.causeway.applib.annotation.Nature.ENTITY)
+ static class CustomerWithDomainObjectAndNatureSetToJdoEntity {
+ }
- @DomainObject(nature = org.apache.causeway.applib.annotation.Nature.NOT_SPECIFIED)
- class CustomerWithDomainObjectAndNatureSetToNotSpecified {
- }
+ @DomainObject(nature = org.apache.causeway.applib.annotation.Nature.NOT_SPECIFIED)
+ static class CustomerWithDomainObjectAndNatureSetToNotSpecified {
+ }
- @DomainObject(nature = org.apache.causeway.applib.annotation.Nature.VIEW_MODEL)
- class CustomerWithDomainObjectAndNatureSetToViewModel {
- }
+ @DomainObject(nature = org.apache.causeway.applib.annotation.Nature.VIEW_MODEL)
+ static class CustomerWithDomainObjectAndNatureSetToViewModel {
+ }
- @DomainObject
- class CustomerWithDomainObjectButNoNature {
- }
+ @DomainObject
+ static class CustomerWithDomainObjectButNoNature {
+ }
+
+ @Nested
+ public class Nature {
- @Override
@BeforeEach
public void setUp() throws Exception {
- super.setUp();
ignoringConfiguration();
}
@@ -663,18 +698,20 @@ public void whenNoDomainObjectAnnotation() {
}
- public static class Alias extends AbstractTestWithMetaModelContext {
- DomainObjectAnnotationFacetFactory facetFactory;
+ @Named("object.name")
+ @DomainObject(aliased = {"object.name", "object.alias"})
+ static class AliasDomainObjectWithAliases {
+ }
- @Named("object.name")
- @DomainObject(aliased = {"object.name", "object.alias"})
- class DomainObjectWithAliases {
- }
+ @Named("service.name")
+ @DomainService(aliased = {"service.name", "service.alias"})
+ static class AliasDomainServiceWithAliases {
+ }
- @Named("service.name")
- @DomainService(aliased = {"service.name", "service.alias"})
- class DomainServiceWithAliases {
- }
+
+ @Nested
+ public class Alias {
+ DomainObjectAnnotationFacetFactory facetFactory;
@Test
public void testValidationDomainObjectWithAliasesConfigured() {
@@ -685,7 +722,7 @@ public void testValidationDomainObjectWithAliasesConfigured() {
facetFactory = new DomainObjectAnnotationFacetFactory(getMetaModelContext());
((MetaModelContext_forTesting) getMetaModelContext()).getProgrammingModel();//kicks off the programming model factory
- getMetaModelContext().getSpecificationLoader().loadSpecification(DomainObjectWithAliases.class, IntrospectionState.FULLY_INTROSPECTED);
+ getMetaModelContext().getSpecificationLoader().loadSpecification(AliasDomainObjectWithAliases.class, IntrospectionState.FULLY_INTROSPECTED);
ValidationFailures validationFailures = getMetaModelContext().getSpecificationLoader().getOrAssessValidationResult();
assertFalse(validationFailures.hasFailures());
}
@@ -699,7 +736,7 @@ public void testValidationDomainServiceWithAliasesConfigured() {
facetFactory = new DomainObjectAnnotationFacetFactory(getMetaModelContext());
((MetaModelContext_forTesting) getMetaModelContext()).getProgrammingModel();//kicks off the programming model factory
- getMetaModelContext().getSpecificationLoader().loadSpecification(DomainServiceWithAliases.class, IntrospectionState.FULLY_INTROSPECTED);
+ getMetaModelContext().getSpecificationLoader().loadSpecification(AliasDomainServiceWithAliases.class, IntrospectionState.FULLY_INTROSPECTED);
ValidationFailures validationFailures = getMetaModelContext().getSpecificationLoader().getOrAssessValidationResult();
assertFalse(validationFailures.hasFailures());
}
@@ -711,7 +748,7 @@ public void testValidationDomainObjectWithAliasesDefault() {
facetFactory = new DomainObjectAnnotationFacetFactory(getMetaModelContext());
((MetaModelContext_forTesting) getMetaModelContext()).getProgrammingModel();//kicks off the programming model factory
- getMetaModelContext().getSpecificationLoader().loadSpecification(DomainObjectWithAliases.class, IntrospectionState.FULLY_INTROSPECTED);
+ getMetaModelContext().getSpecificationLoader().loadSpecification(AliasDomainObjectWithAliases.class, IntrospectionState.FULLY_INTROSPECTED);
ValidationFailures validationFailures = getMetaModelContext().getSpecificationLoader().getOrAssessValidationResult();
assertTrue(validationFailures.hasFailures());
}
@@ -724,7 +761,7 @@ public void testValidationDomainServiceWithAliasesDefault() {
facetFactory = new DomainObjectAnnotationFacetFactory(getMetaModelContext());
((MetaModelContext_forTesting) getMetaModelContext()).getProgrammingModel();//kicks off the programming model factory
- getMetaModelContext().getSpecificationLoader().loadSpecification(DomainServiceWithAliases.class, IntrospectionState.FULLY_INTROSPECTED);
+ getMetaModelContext().getSpecificationLoader().loadSpecification(AliasDomainServiceWithAliases.class, IntrospectionState.FULLY_INTROSPECTED);
ValidationFailures validationFailures = getMetaModelContext().getSpecificationLoader().getOrAssessValidationResult();
assertTrue(validationFailures.hasFailures());
}
diff --git a/persistence/commons/src/main/java/org/apache/causeway/persistence/commons/integration/changetracking/EntityChangeTrackerDefault.java b/persistence/commons/src/main/java/org/apache/causeway/persistence/commons/integration/changetracking/EntityChangeTrackerDefault.java
index 997e1e54515..9e5878f2ebb 100644
--- a/persistence/commons/src/main/java/org/apache/causeway/persistence/commons/integration/changetracking/EntityChangeTrackerDefault.java
+++ b/persistence/commons/src/main/java/org/apache/causeway/persistence/commons/integration/changetracking/EntityChangeTrackerDefault.java
@@ -536,7 +536,8 @@ public void enlistCreated(final ManagedObject entity) {
_Xray.enlistCreated(entity, interactionProviderProvider);
- if (isEntityExcludedForChangePublishing(entity)) {
+ if ( isEntityExcludedForChangePublishing(entity) ||
+ !EntityChangePublishingFacet.isPublishingEnabledForCreate(entity.objSpec())) {
return;
}
@@ -558,7 +559,8 @@ public void enlistUpdating(
_Xray.enlistUpdating(entity, interactionProviderProvider);
- if (isEntityExcludedForChangePublishing(entity)) {
+ if ( isEntityExcludedForChangePublishing(entity) ||
+ !EntityChangePublishingFacet.isPublishingEnabledForUpdate(entity.objSpec())) {
return;
}
@@ -596,7 +598,10 @@ public void enlistDeleting(final ManagedObject entity) {
_Xray.enlistDeleting(entity, interactionProviderProvider);
- if (isEntityExcludedForChangePublishing(entity)) return;
+ if ( isEntityExcludedForChangePublishing(entity) ||
+ !EntityChangePublishingFacet.isPublishingEnabledForDelete(entity.objSpec())) {
+ return;
+ }
suppressAutoFlushIfRequired(() -> {
final boolean enlisted = enlistForChangeKindPublishing(entity, EntityChangeKind.DELETE);