You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2021/03/03 09:06:59 UTC

[isis] branch ISIS-2444 updated (0817c6a -> bbd83ab)

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a change to branch ISIS-2444
in repository https://gitbox.apache.org/repos/asf/isis.git.


    from 0817c6a  ISIS-2444: cleaning up domain event docs
     new 6a723db  ISIS-439: further work removing dead code re: mutable collections
     new 39ebfac  ISIS-439: further work removing dead code re: mutable collections
     new ede3153  ISIS-439: further work removing dead code re: mutable collections
     new 5dead77  ISIS-2444: more on domain event docs
     new bbd83ab  ISIS-439: removes disabled interaction advisor reponsibility from CollectionDomainEventFacet (dead code)

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../applib-classes/pages/events/domainevent.adoc   |   4 +-
 .../events/domainevent/CollectionDomainEvent.adoc  |  50 --------
 .../events/domainevent/PropertyDomainEvent.adoc    |  46 --------
 .../applib/events/domain/ActionDomainEvent.java    |  19 +--
 .../events/domain/CollectionDomainEvent.java       |  73 +-----------
 .../applib/events/domain/PropertyDomainEvent.java  |  73 +++++++++---
 .../core/metamodel/facets/DomainEventHelper.java   | 130 ++++++++-------------
 .../modify/CollectionDomainEventFacet.java         |   2 +-
 .../modify/CollectionDomainEventFacetAbstract.java |  78 +------------
 .../validate/CollectionValidateAddToFacet.java     |  40 -------
 .../CollectionValidateAddToFacetAbstract.java      |  47 --------
 .../CollectionValidateAddToFacetViaMethod.java     |  83 -------------
 .../CollectionValidateRemoveFromFacet.java         |  39 -------
 .../CollectionValidateRemoveFromFacetAbstract.java |  46 --------
 ...CollectionValidateRemoveFromFacetViaMethod.java |  84 -------------
 .../interactions/CollectionAddToContext.java       |  62 ----------
 .../interactions/CollectionRemoveFromContext.java  |  62 ----------
 .../services/metamodel/DomainMemberDefault.java    |  17 +--
 ...HelperTest_newCollectionDomainEvent_forAdd.java |   6 +-
 ...perTest_newCollectionDomainEvent_forRemove.java |   6 +-
 .../rendering/domainobjects/MemberType.java        |   2 -
 21 files changed, 144 insertions(+), 825 deletions(-)
 delete mode 100644 antora/components/refguide/modules/applib-classes/pages/events/domainevent/CollectionDomainEvent.adoc
 delete mode 100644 antora/components/refguide/modules/applib-classes/pages/events/domainevent/PropertyDomainEvent.adoc
 delete mode 100644 core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacet.java
 delete mode 100644 core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacetAbstract.java
 delete mode 100644 core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacetViaMethod.java
 delete mode 100644 core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacet.java
 delete mode 100644 core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacetAbstract.java
 delete mode 100644 core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacetViaMethod.java
 delete mode 100644 core/metamodel/src/main/java/org/apache/isis/core/metamodel/interactions/CollectionAddToContext.java
 delete mode 100644 core/metamodel/src/main/java/org/apache/isis/core/metamodel/interactions/CollectionRemoveFromContext.java


[isis] 04/05: ISIS-2444: more on domain event docs

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-2444
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 5dead7731da9b185a7dd2f6202642a973988fd32
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Mar 3 07:22:48 2021 +0000

    ISIS-2444: more on domain event docs
---
 .../applib-classes/pages/events/domainevent.adoc   |  4 +-
 .../events/domainevent/CollectionDomainEvent.adoc  | 50 ---------------
 .../events/domainevent/PropertyDomainEvent.adoc    | 46 --------------
 .../applib/events/domain/ActionDomainEvent.java    | 19 +++---
 .../events/domain/CollectionDomainEvent.java       | 13 ++--
 .../applib/events/domain/PropertyDomainEvent.java  | 73 +++++++++++++++++-----
 6 files changed, 80 insertions(+), 125 deletions(-)

diff --git a/antora/components/refguide/modules/applib-classes/pages/events/domainevent.adoc b/antora/components/refguide/modules/applib-classes/pages/events/domainevent.adoc
index a26d546..8dcc604 100644
--- a/antora/components/refguide/modules/applib-classes/pages/events/domainevent.adoc
+++ b/antora/components/refguide/modules/applib-classes/pages/events/domainevent.adoc
@@ -6,10 +6,8 @@
 
 This section catalogues the various domain event classes defined by Apache Isis.
 
-These events are broadcast on the xref:refguide:applib:index/services/eventbus/EventBusService.adoc[EventBusService].
-The domain events are broadcast as a result of being specified in the ,   or xref:refguide:applib:index/annotation/Collection.adoc#domainEvent[@Collection#domainEvent()] attributes.
+These events are broadcast through the xref:refguide:applib:index/services/eventbus/EventBusService.adoc[EventBusService] whenever the framework interacts with the domain object members
 
-They are listed in the table below.
 
 .Domain Event Classes
 [cols="1a,2a,2a,2a", options="header"]
diff --git a/antora/components/refguide/modules/applib-classes/pages/events/domainevent/CollectionDomainEvent.adoc b/antora/components/refguide/modules/applib-classes/pages/events/domainevent/CollectionDomainEvent.adoc
deleted file mode 100644
index e35af06..0000000
--- a/antora/components/refguide/modules/applib-classes/pages/events/domainevent/CollectionDomainEvent.adoc
+++ /dev/null
@@ -1,50 +0,0 @@
-[[CollectionDomainEvent]]
-= `CollectionDomainEvent`
-
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or ag [...]
-:page-partial:
-
-
-
-== API
-
-The API of the class is:
-
-// TODO: v2: use include::[]
-
-[source,java]
-----
-public abstract class CollectionDomainEvent<S,T> extends AbstractDomainEvent<S> {
-
-    public static class Default                                 // <.>
-        extends CollectionDomainEvent<Object, Object> { }
-    public static class Noop                                    // <.>
-        extends CollectionDomainEvent<Object, Object> { }
-    public static class Doop                                    // <.>
-        extends CollectionDomainEvent<Object, Object> { }
-
-    public T getValue();                                        // <.>
-    public Of getOf();                                          // <.>
-}
-----
-<1> The `Default` nested static class is the default for the xref:refguide:applib:index/annotation/Collection.adoc#domainEvent[@Collection#domainEvent()] annotation attribute.
-Whether this raises an event or not depends upon the
-`isis.reflector.facet.collectionAnnotation.domainEvent.postForDefault` configuration property.
-<2> The `Noop` class is provided as a convenience to indicate that an event should _not_ be posted (irrespective of the configuration property setting).
-<3> Similarly, the `Doop` class is provided as a convenience to indicate that an event _should_ be raised (irrespective of the configuration property setting).
-<4> the object being added or removed
-<5> whether this is to add or to remove
-
-where the `Of` enum indicates in turn how the collection is being interacted with:
-
-[source,java]
-----
-public static enum Of {
-    ACCESS,         // <1>
-    ADD_TO,         // <2>
-    REMOVE_FROM     // <3>
-}
-----
-<1> collection is being rendered; set during for hide and disable phases
-<2> collection is being added to; set for validate, executing and executed phases
-<3> or, collection is being removed from; set for validate, executing and executed phases
diff --git a/antora/components/refguide/modules/applib-classes/pages/events/domainevent/PropertyDomainEvent.adoc b/antora/components/refguide/modules/applib-classes/pages/events/domainevent/PropertyDomainEvent.adoc
deleted file mode 100644
index 6f37046..0000000
--- a/antora/components/refguide/modules/applib-classes/pages/events/domainevent/PropertyDomainEvent.adoc
+++ /dev/null
@@ -1,46 +0,0 @@
-[[PropertyDomainEvent]]
-= `PropertyDomainEvent`
-
-:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or ag [...]
-:page-partial:
-
-
-Subclass of xref:applib-classes:events.adoc#AbstractDomainEvent[AbstractDomainEvent] for properties.
-
-The class has a couple of responsibilities (in addition to those it inherits):
-
-* capture the target object being interacted with
-
-* capture the old and new values of the property
-
-
-The class itself is instantiated automatically by the framework whenever interacting with a rendered object's property.
-
-== API
-
-The API of the class is:
-
-// TODO: v2: use include::[]
-
-[source,java]
-----
-public abstract class PropertyDomainEvent<S,T> extends AbstractDomainEvent<S> {
-
-    public static class Default                                 // <.>
-        extends PropertyDomainEvent<Object, Object> { }
-    public static class Noop                                    // <.>
-        extends PropertyDomainEvent<Object, Object> { }
-    public static class Doop                                    // <.>
-        extends PropertyDomainEvent<Object, Object> { }
-
-    public T getOldValue();                                     // <.>
-    public T getNewValue();                                     // <.>
-}
-----
-<1> The `Default` nested static class is the default for the xref:refguide:applib:index/annotation/Property.adoc#domainEvent[@Property#domainEvent()] annotation attribute.
-Whether this raises an event or not depends upon the
-`isis.reflector.facet.propertyAnnotation.domainEvent.postForDefault` configuration property.
-<2> The `Noop` class is provided as a convenience to indicate that an event should _not_ be posted (irrespective of the configuration property setting).
-<3> Similarly, the `Doop` class is provided as a convenience to indicate that an event _should_ be raised (irrespective of the configuration property setting).
-<4> The pre-modification value of the property; populated at validate and subsequent phases.
-<5> The proposed (post-modification) value of the property; populated at validate and subsequent phases
diff --git a/api/applib/src/main/java/org/apache/isis/applib/events/domain/ActionDomainEvent.java b/api/applib/src/main/java/org/apache/isis/applib/events/domain/ActionDomainEvent.java
index 983b711..fb21014 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/events/domain/ActionDomainEvent.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/events/domain/ActionDomainEvent.java
@@ -29,17 +29,20 @@ import lombok.Getter;
 import lombok.Setter;
 
 /**
- * Subclass of {@link AbstractDomainEvent} for actions.
+ * Fired whenever the framework interacts with a domain object's action.
  *
  * <p>
- * The class has a number of responsibilities (in addition to those it inherits):
+ * This is the specialization of {@link AbstractDomainEvent}, for actions,
+ * which should then be further subclassed by domain application.
+ * </p>
+ *
+ * <p>
+ * The class has a number of responsibilities (in addition to those it
+ * inherits):
  * </p>
  *
  * <ul>
  *     <li>
- *          capture the target object being interacted with
- *     </li>
- *     <li>
  *          capture the arguments for each of the action's parameters
  *     </li>
  *     <li>
@@ -49,8 +52,8 @@ import lombok.Setter;
  * </ul>
  *
  * <p>
- * The class itself is instantiated automatically by the framework whenever
- * interacting with a rendered object's action.
+ * The class itself is instantiated automatically by the framework using a
+ * no-arg constructor; fields are set reflectively.
  * </p>
  *
  * @since 1.x {@index}
@@ -63,7 +66,7 @@ public abstract class ActionDomainEvent<S> extends AbstractDomainEvent<S> {
      *
      * <p>
      * Whether this raises an event or not depends upon the
-     * <tt>isis.core.meta-model.annotation.action.domain-event.post-for-default</tt>
+     * <tt>isis.applib.annotation.action.domain-event.post-for-default</tt>
      * configuration property.
      * </p>
      */
diff --git a/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java b/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java
index a126c76..91ee8b8 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java
@@ -24,11 +24,16 @@ import org.apache.isis.applib.util.ToString;
 import lombok.Getter;
 
 /**
- * Subclass of {@link AbstractDomainEvent} for collections.
+ * Fired whenever the framework interacts with a domain object's collection.
  *
  * <p>
- * The class itself is instantiated automatically by the framework whenever
- * interacting with a rendered object's collection.
+ * This is the specialization of {@link AbstractDomainEvent}, for collections,
+ *  * which should then be further subclassed by domain application. .
+ * </p>
+ *
+ * <p>
+ * The class itself is instantiated automatically by the framework using a
+ * no-arg constructor; fields are set reflectively.
  * </p>
  *
  * @since 1.x {@index}
@@ -42,7 +47,7 @@ public abstract class CollectionDomainEvent<S,T> extends AbstractDomainEvent<S>
      *
      * <p>
      * Whether this raises an event or not depends upon the
-     * <tt>isis.core.meta-model.annotation.collection.domain-event.post-for-default</tt>
+     * <tt>isis.applib.annotation.collection.domain-event.post-for-default</tt>
      * configuration property.
      * </p>
      */
diff --git a/api/applib/src/main/java/org/apache/isis/applib/events/domain/PropertyDomainEvent.java b/api/applib/src/main/java/org/apache/isis/applib/events/domain/PropertyDomainEvent.java
index 2801a66..5886dfa 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/events/domain/PropertyDomainEvent.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/events/domain/PropertyDomainEvent.java
@@ -25,27 +25,57 @@ import lombok.Getter;
 import lombok.Setter;
 
 /**
+ * Fired whenever the framework interacts with a domain object's property.
+ *
+ * <p>
+ * This is the specialization of {@link AbstractDomainEvent}, for properties,
+ *  * which should then be further subclassed by domain application.
+ * </p>
+ *
+ * <p>
+ * The class has a number of responsibilities (in addition to those it
+ * inherits):
+ * </p>
+ *
+ * <ul>
+ *     <li>
+ *          capture the old and new values of the property
+ *     </li>
+ * </ul>
+ *
+ * <p>
+ * The class itself is instantiated automatically by the framework using a
+ * no-arg constructor; fields are set reflectively.
+ * </p>
+ *
  * @since 1.x {@index}
  */
 public abstract class PropertyDomainEvent<S,T> extends AbstractDomainEvent<S> {
 
     /**
      * This class is the default for the
-     * {@link org.apache.isis.applib.annotation.Property#domainEvent()} annotation attribute.  Whether this
-     * raises an event or not depends upon the <tt>isis.core.meta-model.annotation.property.domain-event.post-for-default</tt>
+     * {@link org.apache.isis.applib.annotation.Property#domainEvent()}
+     * annotation attribute.
+     *
+     * <p>
+     * Whether this raises an event or not depends upon the
+     * <tt>isis.applib.annotation.property.domain-event.post-for-default</tt>
      * configuration property.
+     * </p>
      */
     public static class Default extends PropertyDomainEvent<Object, Object> {}
 
     /**
-     * Convenience class to use indicating that an event should <i>not</i> be posted (irrespective of the configuration
-     * property setting for the {@link Default} event.
+     * Convenience class to use indicating that an event should <i>not</i> be
+     * posted (irrespective of the configuration property setting for the
+     * {@link Default} event.
      */
     public static class Noop extends PropertyDomainEvent<Object, Object> {}
 
     /**
-     * Convenience class meaning that an event <i>should</i> be posted (irrespective of the configuration
-     * property setting for the {@link Default} event..
+     * Convenience class meaning that an event <i>should</i> be posted
+     * (irrespective of the configuration property setting for the
+     * {@link Default} event..
      */
     public static class Doop extends PropertyDomainEvent<Object, Object> {}
 
@@ -57,21 +87,37 @@ public abstract class PropertyDomainEvent<S,T> extends AbstractDomainEvent<S> {
     }
 
     /**
-     * The current (pre-modification) value of the property; populated at {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#VALIDATE} and subsequent phases
-     * (but null for {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#HIDE hidden} and {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#DISABLE disable} phases).
+     * The current (pre-modification) value of the property.
+     *
+     * <p>
+     * Populated at {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#VALIDATE} and subsequent
+     * phases (but null for
+     * {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#HIDE hidden}
+     * and {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#DISABLE disable}
+     * phases).
+     * </p>
      */
     @Getter @Setter
     private T oldValue;
 
     /**
-     * The proposed (post-modification) value of the property; populated at {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#VALIDATE} and subsequent phases
-     * (but null for {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#HIDE hidden} and {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#DISABLE disable} phases).
+     * The proposed (post-modification) value of the property.
+     *
+     * <p>
+     * Populated at
+     * {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#VALIDATE}
+     * and subsequent phases (but null for
+     * {@link Phase#HIDE hidden}
+     * and {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#DISABLE disable}
+     * phases).
+     * </p>
      *
      * <p>
      *     The proposed new value can also be modified by event handlers
-     *     during the {@link Phase#EXECUTING} phase.  The new value must be
-     *     the same type as the expected value; the framework performs
-     *     no sanity checks.
+     *     during the
+     *     {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#EXECUTING executing}
+     *     phase.  The new value must be the same type as the expected value;
+     *     the framework performs no sanity checks.
      * </p>
      */
     @Getter @Setter
@@ -79,7 +125,6 @@ public abstract class PropertyDomainEvent<S,T> extends AbstractDomainEvent<S> {
 
 
 
-
     private static final ToString<PropertyDomainEvent<?,?>> toString =
             ObjectContracts.<PropertyDomainEvent<?,?>>
     toString("source", PropertyDomainEvent::getSource)


[isis] 02/05: ISIS-439: further work removing dead code re: mutable collections

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-2444
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 39ebfacbba1a42d6d4cc55e1eba54e4abfe615f9
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Mar 3 07:04:12 2021 +0000

    ISIS-439: further work removing dead code re: mutable collections
---
 .../events/domain/CollectionDomainEvent.java       |  35 -------
 .../core/metamodel/facets/DomainEventHelper.java   | 110 ++++++++-------------
 .../modify/CollectionDomainEventFacetAbstract.java |   2 -
 ...HelperTest_newCollectionDomainEvent_forAdd.java |   6 +-
 ...perTest_newCollectionDomainEvent_forRemove.java |   6 +-
 5 files changed, 49 insertions(+), 110 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java b/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java
index 6d4c57c..7b1c489 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java
@@ -93,32 +93,6 @@ public abstract class CollectionDomainEvent<S,T> extends AbstractDomainEvent<S>
     @Getter
     private T value;
 
-    public static enum Of {
-        /**
-         * The collection is being accessed
-         * ({@link AbstractDomainEvent.Phase#HIDE hide} and
-         * {@link AbstractDomainEvent.Phase#DISABLE disable}) checks.
-         */
-        ACCESS,
-
-        /**
-         * The collection is being added to
-         * ({@link AbstractDomainEvent.Phase#VALIDATE validity} check and
-         * {@link AbstractDomainEvent.Phase#EXECUTED execution}).
-         */
-        ADD_TO,
-
-        /**
-         * The collection is being removed from
-         * ({@link AbstractDomainEvent.Phase#VALIDATE validity} check and
-         * {@link AbstractDomainEvent.Phase#EXECUTED execution}).
-         */
-        REMOVE_FROM
-
-    }
-
-    @Getter
-    private Of of;
 
     /**
      * Not API, set by the framework.
@@ -126,14 +100,6 @@ public abstract class CollectionDomainEvent<S,T> extends AbstractDomainEvent<S>
     public void setValue(T value) {
         this.value = value;
     }
-    /**
-     * Not API; updates from {@link Of#ACCESS} to either {@link Of#ADD_TO}
-     * or {@link Of#REMOVE_FROM} when hits the
-     * {@link AbstractDomainEvent.Phase#VALIDATE validation phase}.
-     */
-    public void setOf(Of of) {
-        this.of = of;
-    }
 
 
     private static final ToString<CollectionDomainEvent<?,?>> toString =
@@ -141,7 +107,6 @@ public abstract class CollectionDomainEvent<S,T> extends AbstractDomainEvent<S>
     toString("source", CollectionDomainEvent::getSource)
     .thenToString("identifier", CollectionDomainEvent::getIdentifier)
     .thenToString("eventPhase", CollectionDomainEvent::getEventPhase)
-    .thenToString("of", CollectionDomainEvent::getOf)
     .thenToString("value", CollectionDomainEvent::getValue)
     ;
 
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java
index 8029c45..56cb6d6 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java
@@ -67,7 +67,7 @@ public class DomainEventHelper {
     private final MetamodelEventService metamodelEventService;
 
     // -- postEventForAction
-    
+
     // variant using eventType and no existing event
     public ActionDomainEvent<?> postEventForAction(
             final AbstractDomainEvent.Phase phase,
@@ -77,12 +77,12 @@ public class DomainEventHelper {
             final InteractionHead head,
             final Can<ManagedObject> argumentAdapters,
             final ManagedObject resultAdapter) {
-        
-        return postEventForAction(phase, uncheckedCast(eventType), /*existingEvent*/null, 
-                objectAction, identified, 
+
+        return postEventForAction(phase, uncheckedCast(eventType), /*existingEvent*/null,
+                objectAction, identified,
                 head, argumentAdapters, resultAdapter);
     }
-    
+
     // variant using existing event and not eventType (is derived from event)
     public ActionDomainEvent<?> postEventForAction(
             final AbstractDomainEvent.Phase phase,
@@ -92,9 +92,9 @@ public class DomainEventHelper {
             final InteractionHead head,
             final Can<ManagedObject> argumentAdapters,
             final ManagedObject resultAdapter) {
-        
-        return postEventForAction(phase, 
-                uncheckedCast(existingEvent.getClass()), existingEvent, objectAction, identified, 
+
+        return postEventForAction(phase,
+                uncheckedCast(existingEvent.getClass()), existingEvent, objectAction, identified,
                 head, argumentAdapters, resultAdapter);
     }
 
@@ -107,7 +107,7 @@ public class DomainEventHelper {
             final InteractionHead head,
             final Can<ManagedObject> argumentAdapters,
             final ManagedObject resultAdapter) {
-        
+
         _Assert.assertTypeIsInstanceOf(eventType, ActionDomainEvent.class);
 
         try {
@@ -166,7 +166,7 @@ public class DomainEventHelper {
             final Class<? extends ActionDomainEvent<S>> type,
             final Identifier identifier,
             final S source,
-            final Object... arguments) 
+            final Object... arguments)
         throws IllegalArgumentException,
             NoSuchMethodException, SecurityException {
 
@@ -174,19 +174,19 @@ public class DomainEventHelper {
 
         val noArgConstructor = constructors.filter(paramCount(0)).getFirst().orElse(null);
         if(noArgConstructor!=null) {
-            
+
             final Object event = invokeConstructor(noArgConstructor);
             final ActionDomainEvent<S> ade = uncheckedCast(event);
-            
+
             ade.initSource(source);
             ade.setIdentifier(identifier);
             ade.setArguments(asList(arguments));
             return ade;
         }
-        
+
 
         // else
-        
+
         val updateEventConstructor = constructors
                 .filter(paramCount(3)
                         .and(paramAssignableFrom(0, source.getClass()))
@@ -195,12 +195,12 @@ public class DomainEventHelper {
                         )
                 .getFirst()
                 .orElse(null);
-        
+
         if(updateEventConstructor!=null) {
             val event = invokeConstructor(updateEventConstructor, source, identifier, arguments);
-            return uncheckedCast(event);    
+            return uncheckedCast(event);
         }
-        
+
         throw new NoSuchMethodException(type.getName()+".<init>(? super " + source.getClass().getName() + ", " + Identifier.class.getName() + ", [Ljava.lang.Object;)");
     }
 
@@ -221,7 +221,7 @@ public class DomainEventHelper {
             final InteractionHead head,
             final T oldValue,
             final T newValue) {
-        
+
         _Assert.assertTypeIsInstanceOf(eventType, PropertyDomainEvent.class);
 
         try {
@@ -232,10 +232,10 @@ public class DomainEventHelper {
                 event = existingEvent;
             } else {
                 // all other phases, create a new event
-                
+
                 final S source = uncheckedCast(UnwrapUtil.single(head.getTarget()));
                 final Identifier identifier = identified.getIdentifier();
-                
+
                 event = newPropertyDomainEvent(eventType, identifier, source, oldValue, newValue);
 
                 // copy over if have
@@ -271,7 +271,7 @@ public class DomainEventHelper {
         val constructors = _Reflect.getPublicConstructors(type);
 
         val noArgConstructors = constructors.filter(paramCount(0));
-        
+
         for (val constructor : noArgConstructors) {
             final Object event = invokeConstructor(constructor);
             final PropertyDomainEvent<S, T> pde = uncheckedCast(event);
@@ -292,7 +292,7 @@ public class DomainEventHelper {
                         .and(paramAssignableFromValue(2, oldValue))
                         .and(paramAssignableFromValue(3, newValue))
                         );
-        
+
         for (val constructor : updateEventConstructors) {
             val event = invokeConstructor(constructor, source, identifier, oldValue, newValue);
             return uncheckedCast(event);
@@ -308,14 +308,13 @@ public class DomainEventHelper {
     public <S, T> CollectionDomainEvent<S, T> postEventForCollection(
             AbstractDomainEvent.Phase phase,
             final Class<? extends CollectionDomainEvent<S, T>> eventType,
-                    final CollectionDomainEvent<S, T> existingEvent,
-                    final IdentifiedHolder identified,
-                    final InteractionHead head,
-                    final CollectionDomainEvent.Of of,
-                    final T reference) {
-        
+            final CollectionDomainEvent<S, T> existingEvent,
+            final IdentifiedHolder identified,
+            final InteractionHead head,
+            final T reference) {
+
         _Assert.assertTypeIsInstanceOf(eventType, CollectionDomainEvent.class);
-        
+
         try {
             final CollectionDomainEvent<S, T> event;
             if (existingEvent != null && phase.isExecuted()) {
@@ -325,7 +324,7 @@ public class DomainEventHelper {
                 // all other phases, create a new event
                 final S source = uncheckedCast(UnwrapUtil.single(head.getTarget()));
                 final Identifier identifier = identified.getIdentifier();
-                event = newCollectionDomainEvent(eventType, phase, identifier, source, of, reference);
+                event = newCollectionDomainEvent(eventType, phase, identifier, source, reference);
 
                 // copy over if have
                 head.getMixedIn()
@@ -344,72 +343,49 @@ public class DomainEventHelper {
 
     <S, T> CollectionDomainEvent<S, T> newCollectionDomainEvent(
             final Class<? extends CollectionDomainEvent<S, T>> type,
-                    final AbstractDomainEvent.Phase phase,
-                    final Identifier identifier,
-                    final S source,
-                    final CollectionDomainEvent.Of of,
-                    final T value)
-                            throws NoSuchMethodException, SecurityException, InstantiationException,
-                            IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+            final AbstractDomainEvent.Phase phase,
+            final Identifier identifier,
+            final S source,
+            final T value)
+            throws NoSuchMethodException, SecurityException,
+            IllegalArgumentException {
 
         val constructors = _Reflect.getPublicConstructors(type);
 
         val noArgConstructors = constructors.filter(paramCount(0));
-        
+
         for (val constructor : noArgConstructors) {
             final Object event = invokeConstructor(constructor);
             final CollectionDomainEvent<S, T> cde = uncheckedCast(event);
 
             cde.initSource(source);
             cde.setIdentifier(identifier);
-            cde.setOf(of);
             cde.setValue(value);
             return cde;
         }
-        
+
         // else
         // search for constructor accepting source, identifier, type, value
         val updateEventConstructors = constructors
                 .filter(paramCount(4)
                         .and(paramAssignableFrom(0, source.getClass()))
                         .and(paramAssignableFrom(1, Identifier.class))
-                        .and(paramAssignableFrom(2, CollectionDomainEvent.Of.class))
-                        .and(paramAssignableFromValue(3, value))
+                        .and(paramAssignableFromValue(2, value))
                         );
-        
+
         for (val constructor : updateEventConstructors) {
-            val event = invokeConstructor(constructor, source, identifier, of, value);
+            val event = invokeConstructor(constructor, source, identifier, value);
             return uncheckedCast(event);
         }
-        
-        // else
 
-        if(phase == AbstractDomainEvent.Phase.EXECUTED) {
-            if(of == CollectionDomainEvent.Of.ADD_TO 
-                    || of == CollectionDomainEvent.Of.REMOVE_FROM) {
-                // support for annotations @PostsCollectionAddedTo and @PostsCollectionRemovedFrom:
-                // search for constructor accepting source, identifier, value
-                val eventConstructors = constructors
-                        .filter(paramCount(3)
-                                .and(paramAssignableFrom(0, source.getClass()))
-                                .and(paramAssignableFrom(1, Identifier.class))
-                                .and(paramAssignableFromValue(2, value))
-                                );
-                for (val constructor : eventConstructors) {
-                    val event = invokeConstructor(constructor, source, identifier, value);
-                    return uncheckedCast(event);
-                }
-            }
-        }
-        
         // else
         throw new NoSuchMethodException(type.getName()+".<init>(? super " + source.getClass().getName() + ", " + Identifier.class.getName() + ", java.lang.Object)");
     }
 
     private static <T> T invokeConstructor(
-            @NonNull final Constructor<T> constructor, 
+            @NonNull final Constructor<T> constructor,
             final Object... args){
-        
+
         try {
             return constructor.newInstance(args);
         } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
@@ -418,6 +394,6 @@ public class DomainEventHelper {
                     "failed to invoke constructor %s", constructor, e);
         }
     }
-    
+
 
 }
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
index d63ec04..e400f70 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
@@ -76,7 +76,6 @@ public abstract class CollectionDomainEventFacetAbstract
                         AbstractDomainEvent.Phase.HIDE,
                         getEventType(), null,
                         getIdentified(), ic.getHead(),
-                        CollectionDomainEvent.Of.ACCESS,
                         null);
         if (event != null && event.isHidden()) {
             return "Hidden by subscriber";
@@ -92,7 +91,6 @@ public abstract class CollectionDomainEventFacetAbstract
                         AbstractDomainEvent.Phase.DISABLE,
                         getEventType(), null,
                         getIdentified(), ic.getHead(),
-                        CollectionDomainEvent.Of.ACCESS,
                         null);
         if (event != null && event.isDisabled()) {
             final TranslatableString reasonTranslatable = event.getDisabledReasonTranslatable();
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forAdd.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forAdd.java
index d586a41..5ae89a1 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forAdd.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forAdd.java
@@ -48,7 +48,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forAdd {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<Object, Object> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                CollectionDomainEvent.Default.class, null, identifier, sdo, CollectionDomainEvent.Of.ADD_TO, other);
+                CollectionDomainEvent.Default.class, null, identifier, sdo, other);
         assertSame(ev.getSource(), sdo);
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.ADD_TO));
@@ -63,7 +63,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forAdd {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<Object, Object> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, CollectionDomainEvent.Of.ADD_TO, other);
+                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, other);
         assertSame(ev.getSource(), sdo);
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.ADD_TO));
@@ -78,7 +78,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forAdd {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<SomeDomainObject, SomeReferencedObject> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                SomeDomainObjectCollectionDomainEvent.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, CollectionDomainEvent.Of.ADD_TO, other);
+                SomeDomainObjectCollectionDomainEvent.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, other);
         assertThat(ev.getSource(), is(sdo));
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.ADD_TO));
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forRemove.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forRemove.java
index b07c9e2..dc2c6d0 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forRemove.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forRemove.java
@@ -48,7 +48,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forRemove {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<Object, Object> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, CollectionDomainEvent.Of.REMOVE_FROM, other);
+                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, other);
         assertSame(ev.getSource(), sdo);
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.REMOVE_FROM));
@@ -63,7 +63,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forRemove {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<Object, Object> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, CollectionDomainEvent.Of.REMOVE_FROM, other);
+                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, other);
         assertSame(ev.getSource(), sdo);
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.REMOVE_FROM));
@@ -78,7 +78,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forRemove {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<SomeDomainObject, SomeReferencedObject> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                SomeDomainObjectCollectionRemovedFromDomainEvent.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, CollectionDomainEvent.Of.REMOVE_FROM, other);
+                SomeDomainObjectCollectionRemovedFromDomainEvent.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, other);
         assertThat(ev.getSource(), is(sdo));
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.REMOVE_FROM));


[isis] 03/05: ISIS-439: further work removing dead code re: mutable collections

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-2444
in repository https://gitbox.apache.org/repos/asf/isis.git

commit ede31538525c2199ad458912589c6dda4c44b6cc
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Mar 3 07:09:21 2021 +0000

    ISIS-439: further work removing dead code re: mutable collections
---
 .../events/domain/CollectionDomainEvent.java       | 31 -------------------
 .../core/metamodel/facets/DomainEventHelper.java   | 36 ++++++++--------------
 .../modify/CollectionDomainEventFacetAbstract.java | 12 ++++----
 ...HelperTest_newCollectionDomainEvent_forAdd.java |  6 ++--
 ...perTest_newCollectionDomainEvent_forRemove.java |  6 ++--
 5 files changed, 25 insertions(+), 66 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java b/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java
index 7b1c489..a126c76 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/events/domain/CollectionDomainEvent.java
@@ -27,17 +27,6 @@ import lombok.Getter;
  * Subclass of {@link AbstractDomainEvent} for collections.
  *
  * <p>
- * The class has a couple of responsibilities (in addition to those it
- * inherits):
- * </p>
- *
- * <ul>
- *     <li>
- *      capture the target object being interacted with
- *     </li>
- * </ul>
- *
- * <p>
  * The class itself is instantiated automatically by the framework whenever
  * interacting with a rendered object's collection.
  * </p>
@@ -83,31 +72,11 @@ public abstract class CollectionDomainEvent<S,T> extends AbstractDomainEvent<S>
 
 
 
-    /**
-     * The proposed reference to either add or remove (per {@link #getOf()}), populated at
-     * {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#VALIDATE}
-     * and subsequent phases (is null for
-     * {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#HIDE hidden}
-     * and {@link org.apache.isis.applib.events.domain.AbstractDomainEvent.Phase#DISABLE disable} phases).
-     */
-    @Getter
-    private T value;
-
-
-    /**
-     * Not API, set by the framework.
-     */
-    public void setValue(T value) {
-        this.value = value;
-    }
-
-
     private static final ToString<CollectionDomainEvent<?,?>> toString =
             ObjectContracts.<CollectionDomainEvent<?,?>>
     toString("source", CollectionDomainEvent::getSource)
     .thenToString("identifier", CollectionDomainEvent::getIdentifier)
     .thenToString("eventPhase", CollectionDomainEvent::getEventPhase)
-    .thenToString("value", CollectionDomainEvent::getValue)
     ;
 
     @Override
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java
index 56cb6d6..2eb6e2c 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java
@@ -306,31 +306,24 @@ public class DomainEventHelper {
     // -- postEventForCollection, newCollectionDomainEvent
 
     public <S, T> CollectionDomainEvent<S, T> postEventForCollection(
-            AbstractDomainEvent.Phase phase,
+            final AbstractDomainEvent.Phase phase,
             final Class<? extends CollectionDomainEvent<S, T>> eventType,
-            final CollectionDomainEvent<S, T> existingEvent,
             final IdentifiedHolder identified,
-            final InteractionHead head,
-            final T reference) {
+            final InteractionHead head) {
 
         _Assert.assertTypeIsInstanceOf(eventType, CollectionDomainEvent.class);
 
         try {
             final CollectionDomainEvent<S, T> event;
-            if (existingEvent != null && phase.isExecuted()) {
-                // reuse existing event from the executing phase
-                event = existingEvent;
-            } else {
-                // all other phases, create a new event
-                final S source = uncheckedCast(UnwrapUtil.single(head.getTarget()));
-                final Identifier identifier = identified.getIdentifier();
-                event = newCollectionDomainEvent(eventType, phase, identifier, source, reference);
 
-                // copy over if have
-                head.getMixedIn()
-                .ifPresent(mixedInAdapter->
-                    event.setMixedIn(mixedInAdapter.getPojo()));
-            }
+            final S source = uncheckedCast(UnwrapUtil.single(head.getTarget()));
+            final Identifier identifier = identified.getIdentifier();
+            event = newCollectionDomainEvent(eventType, phase, identifier, source);
+
+            // copy over if have
+            head.getMixedIn()
+            .ifPresent(mixedInAdapter->
+                event.setMixedIn(mixedInAdapter.getPojo()));
 
             event.setEventPhase(phase);
 
@@ -345,8 +338,7 @@ public class DomainEventHelper {
             final Class<? extends CollectionDomainEvent<S, T>> type,
             final AbstractDomainEvent.Phase phase,
             final Identifier identifier,
-            final S source,
-            final T value)
+            final S source)
             throws NoSuchMethodException, SecurityException,
             IllegalArgumentException {
 
@@ -360,21 +352,19 @@ public class DomainEventHelper {
 
             cde.initSource(source);
             cde.setIdentifier(identifier);
-            cde.setValue(value);
             return cde;
         }
 
         // else
-        // search for constructor accepting source, identifier, type, value
+        // search for constructor accepting source, identifier
         val updateEventConstructors = constructors
                 .filter(paramCount(4)
                         .and(paramAssignableFrom(0, source.getClass()))
                         .and(paramAssignableFrom(1, Identifier.class))
-                        .and(paramAssignableFromValue(2, value))
                         );
 
         for (val constructor : updateEventConstructors) {
-            val event = invokeConstructor(constructor, source, identifier, value);
+            val event = invokeConstructor(constructor, source, identifier);
             return uncheckedCast(event);
         }
 
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
index e400f70..7046627 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
@@ -74,9 +74,9 @@ public abstract class CollectionDomainEventFacetAbstract
         final CollectionDomainEvent<?, ?> event =
                 domainEventHelper.postEventForCollection(
                         AbstractDomainEvent.Phase.HIDE,
-                        getEventType(), null,
-                        getIdentified(), ic.getHead(),
-                        null);
+                        getEventType(),
+                        getIdentified(), ic.getHead()
+                );
         if (event != null && event.isHidden()) {
             return "Hidden by subscriber";
         }
@@ -89,9 +89,9 @@ public abstract class CollectionDomainEventFacetAbstract
         final CollectionDomainEvent<?, ?> event =
                 domainEventHelper.postEventForCollection(
                         AbstractDomainEvent.Phase.DISABLE,
-                        getEventType(), null,
-                        getIdentified(), ic.getHead(),
-                        null);
+                        getEventType(),
+                        getIdentified(), ic.getHead()
+                );
         if (event != null && event.isDisabled()) {
             final TranslatableString reasonTranslatable = event.getDisabledReasonTranslatable();
             if(reasonTranslatable != null) {
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forAdd.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forAdd.java
index 5ae89a1..5abc008 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forAdd.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forAdd.java
@@ -48,7 +48,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forAdd {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<Object, Object> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                CollectionDomainEvent.Default.class, null, identifier, sdo, other);
+                CollectionDomainEvent.Default.class, null, identifier, sdo);
         assertSame(ev.getSource(), sdo);
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.ADD_TO));
@@ -63,7 +63,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forAdd {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<Object, Object> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, other);
+                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo);
         assertSame(ev.getSource(), sdo);
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.ADD_TO));
@@ -78,7 +78,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forAdd {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<SomeDomainObject, SomeReferencedObject> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                SomeDomainObjectCollectionDomainEvent.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, other);
+                SomeDomainObjectCollectionDomainEvent.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo);
         assertThat(ev.getSource(), is(sdo));
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.ADD_TO));
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forRemove.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forRemove.java
index dc2c6d0..b4e2a52 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forRemove.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/DomainEventHelperTest_newCollectionDomainEvent_forRemove.java
@@ -48,7 +48,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forRemove {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<Object, Object> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, other);
+                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo);
         assertSame(ev.getSource(), sdo);
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.REMOVE_FROM));
@@ -63,7 +63,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forRemove {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<Object, Object> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, other);
+                CollectionDomainEvent.Default.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo);
         assertSame(ev.getSource(), sdo);
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.REMOVE_FROM));
@@ -78,7 +78,7 @@ public class DomainEventHelperTest_newCollectionDomainEvent_forRemove {
                 LogicalType.fqcn(SomeDomainObject.class), "references");
 
         final CollectionDomainEvent<SomeDomainObject, SomeReferencedObject> ev = Utils.domainEventHelper().newCollectionDomainEvent(
-                SomeDomainObjectCollectionRemovedFromDomainEvent.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo, other);
+                SomeDomainObjectCollectionRemovedFromDomainEvent.class, AbstractDomainEvent.Phase.EXECUTED, identifier, sdo);
         assertThat(ev.getSource(), is(sdo));
         assertThat(ev.getIdentifier(), is(identifier));
         assertThat(ev.getOf(), is(CollectionDomainEvent.Of.REMOVE_FROM));


[isis] 01/05: ISIS-439: further work removing dead code re: mutable collections

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-2444
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 6a723db7abc075b2922d0a6a8de87e11ec4cf770
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Mar 3 06:56:44 2021 +0000

    ISIS-439: further work removing dead code re: mutable collections
---
 .../modify/CollectionDomainEventFacet.java         |  2 +-
 .../modify/CollectionDomainEventFacetAbstract.java | 41 +----------
 .../validate/CollectionValidateAddToFacet.java     | 40 -----------
 .../CollectionValidateAddToFacetAbstract.java      | 47 ------------
 .../CollectionValidateAddToFacetViaMethod.java     | 83 ---------------------
 .../CollectionValidateRemoveFromFacet.java         | 39 ----------
 .../CollectionValidateRemoveFromFacetAbstract.java | 46 ------------
 ...CollectionValidateRemoveFromFacetViaMethod.java | 84 ----------------------
 .../interactions/CollectionAddToContext.java       | 62 ----------------
 .../interactions/CollectionRemoveFromContext.java  | 62 ----------------
 .../services/metamodel/DomainMemberDefault.java    | 17 ++---
 .../rendering/domainobjects/MemberType.java        |  2 -
 12 files changed, 10 insertions(+), 515 deletions(-)

diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacet.java
index da2afed..6ebc17a 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacet.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacet.java
@@ -28,7 +28,7 @@ import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
  * Corresponds to <tt>@Collection(domainEvent=...)</tt> annotation in the Isis programming model.
  */
 public interface CollectionDomainEventFacet
-extends SingleClassValueFacet, HidingInteractionAdvisor, DisablingInteractionAdvisor, ValidatingInteractionAdvisor {
+extends SingleClassValueFacet, HidingInteractionAdvisor, DisablingInteractionAdvisor {
 
 }
 
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
index 23cb8b9..d63ec04 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
@@ -28,13 +28,12 @@ import org.apache.isis.core.metamodel.facetapi.FacetHolder;
 import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
 import org.apache.isis.core.metamodel.facets.DomainEventHelper;
 import org.apache.isis.core.metamodel.facets.SingleClassValueFacetAbstract;
-import org.apache.isis.core.metamodel.interactions.CollectionAddToContext;
-import org.apache.isis.core.metamodel.interactions.ProposedHolder;
 import org.apache.isis.core.metamodel.interactions.UsabilityContext;
-import org.apache.isis.core.metamodel.interactions.ValidityContext;
 import org.apache.isis.core.metamodel.interactions.VisibilityContext;
 
-public abstract class CollectionDomainEventFacetAbstract extends SingleClassValueFacetAbstract implements CollectionDomainEventFacet {
+public abstract class CollectionDomainEventFacetAbstract
+        extends SingleClassValueFacetAbstract
+        implements CollectionDomainEventFacet {
 
     private final DomainEventHelper domainEventHelper;
     private final TranslationService translationService;
@@ -105,38 +104,4 @@ public abstract class CollectionDomainEventFacetAbstract extends SingleClassValu
         return null;
     }
 
-    @Override
-    public String invalidates(final ValidityContext ic) {
-
-        // if this is a mixin, then this ain't true.
-        if(!(ic instanceof ProposedHolder)) {
-            return null;
-        }
-        final ProposedHolder catc = (ProposedHolder) ic;
-        final Object proposed = catc.getProposed().getPojo();
-
-        final CollectionDomainEvent.Of of =
-                ic instanceof CollectionAddToContext
-                ? CollectionDomainEvent.Of.ADD_TO
-                        : CollectionDomainEvent.Of.REMOVE_FROM;
-
-        final CollectionDomainEvent<?, ?> event =
-                domainEventHelper.postEventForCollection(
-                        AbstractDomainEvent.Phase.VALIDATE,
-                        getEventType(), null,
-                        getIdentified(), ic.getHead(),
-                        of,
-                        proposed);
-        if (event != null && event.isInvalid()) {
-            final TranslatableString reasonTranslatable = event.getInvalidityReasonTranslatable();
-            if(reasonTranslatable != null) {
-                return reasonTranslatable.translate(translationService, translationContext);
-            }
-            return event.getInvalidityReason();
-        }
-
-        return null;
-    }
-
-
 }
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacet.java
deleted file mode 100644
index b6a97f0..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacet.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.collections.validate;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-
-/**
- * Validate that an object can be added to a collection.
- *
- * <p>
- * In the standard Apache Isis Programming Model, corresponds to invoking the
- * <tt>validateAddToXxx</tt> support method for a collection.
- *
- */
-public interface CollectionValidateAddToFacet extends Facet, ValidatingInteractionAdvisor {
-
-    /**
-     * Reason the object cannot be added, or <tt>null</tt> if okay.
-     */
-    public String invalidReason(ManagedObject target, ManagedObject proposedArgument);
-}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacetAbstract.java
deleted file mode 100644
index 0cdeb01..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacetAbstract.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.collections.validate;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.interactions.CollectionAddToContext;
-import org.apache.isis.core.metamodel.interactions.ValidityContext;
-
-public abstract class CollectionValidateAddToFacetAbstract extends FacetAbstract implements CollectionValidateAddToFacet {
-
-    public static Class<? extends Facet> type() {
-        return CollectionValidateAddToFacet.class;
-    }
-
-    public CollectionValidateAddToFacetAbstract(final FacetHolder holder) {
-        super(type(), holder, Derivation.NOT_DERIVED);
-    }
-
-    @Override
-    public String invalidates(final ValidityContext context) {
-        if (!(context instanceof CollectionAddToContext)) {
-            return null;
-        }
-        final CollectionAddToContext collectionAddToContext = (CollectionAddToContext) context;
-        return invalidReason(context.getTarget(), collectionAddToContext.getProposed());
-    }
-
-}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacetViaMethod.java
deleted file mode 100644
index 7d1427b..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateAddToFacetViaMethod.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.collections.validate;
-
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.isis.applib.services.i18n.TranslatableString;
-import org.apache.isis.applib.services.i18n.TranslationService;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.ImperativeFacet;
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-import org.apache.isis.core.metamodel.spec.ManagedObjects;
-
-public class CollectionValidateAddToFacetViaMethod extends CollectionValidateAddToFacetAbstract implements ImperativeFacet {
-
-    private final Method method;
-    private final TranslationService translationService;
-    private final String translationContext;
-
-    public CollectionValidateAddToFacetViaMethod(final Method method, final TranslationService translationService, final String translationContext, final FacetHolder holder) {
-        super(holder);
-        this.method = method;
-        this.translationService = translationService;
-        this.translationContext = translationContext;
-    }
-
-    /**
-     * Returns a singleton list of the {@link Method} provided in the
-     * constructor.
-     */
-    @Override
-    public List<Method> getMethods() {
-        return Collections.singletonList(method);
-    }
-
-    @Override
-    public Intent getIntent(final Method method) {
-        return Intent.CHECK_IF_VALID;
-    }
-
-    @Override
-    public String invalidReason(final ManagedObject owningAdapter, final ManagedObject proposedAdapter) {
-        final Object returnValue = ManagedObjects.InvokeUtil.invoke(method, owningAdapter, proposedAdapter);
-        if(returnValue instanceof String) {
-            return (String) returnValue;
-        }
-        if(returnValue instanceof TranslatableString) {
-            final TranslatableString ts = (TranslatableString) returnValue;
-            return ts.translate(translationService, translationContext);
-        }
-        return null;
-    }
-
-    @Override
-    protected String toStringValues() {
-        return "method=" + method;
-    }
-
-    @Override public void appendAttributesTo(final Map<String, Object> attributeMap) {
-        super.appendAttributesTo(attributeMap);
-        ImperativeFacet.Util.appendAttributesTo(this, attributeMap);
-    }
-}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacet.java
deleted file mode 100644
index e097440..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacet.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.collections.validate;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-
-/**
- * Validate that an object can be removed to a collection.
- *
- * <p>
- * In the standard Apache Isis Programming Model, corresponds to invoking the
- * <tt>validateRemoveFromXxx</tt> support method for a collection.
- */
-public interface CollectionValidateRemoveFromFacet extends Facet, ValidatingInteractionAdvisor {
-
-    /**
-     * Reason the object cannot be removed, or <tt>null</tt> if okay.
-     */
-    public String invalidReason(ManagedObject inObject, ManagedObject value);
-}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacetAbstract.java
deleted file mode 100644
index 97a779b..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacetAbstract.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.collections.validate;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.interactions.CollectionRemoveFromContext;
-import org.apache.isis.core.metamodel.interactions.ValidityContext;
-
-public abstract class CollectionValidateRemoveFromFacetAbstract extends FacetAbstract implements CollectionValidateRemoveFromFacet {
-
-    public static Class<? extends Facet> type() {
-        return CollectionValidateRemoveFromFacet.class;
-    }
-
-    public CollectionValidateRemoveFromFacetAbstract(final FacetHolder holder) {
-        super(type(), holder, Derivation.NOT_DERIVED);
-    }
-
-    @Override
-    public String invalidates(final ValidityContext context) {
-        if (!(context instanceof CollectionRemoveFromContext)) {
-            return null;
-        }
-        final CollectionRemoveFromContext collectionRemoveFromContext = (CollectionRemoveFromContext) context;
-        return invalidReason(context.getTarget(), collectionRemoveFromContext.getProposed());
-    }
-}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacetViaMethod.java
deleted file mode 100644
index 978287b..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/validate/CollectionValidateRemoveFromFacetViaMethod.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.collections.validate;
-
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.isis.applib.services.i18n.TranslatableString;
-import org.apache.isis.applib.services.i18n.TranslationService;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.ImperativeFacet;
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-import org.apache.isis.core.metamodel.spec.ManagedObjects;
-
-public class CollectionValidateRemoveFromFacetViaMethod extends CollectionValidateRemoveFromFacetAbstract implements ImperativeFacet {
-
-    private final Method method;
-    private final TranslationService translationService;
-    private final String translationContext;
-
-    public CollectionValidateRemoveFromFacetViaMethod(final Method method, final TranslationService translationService, final String translationContext, final FacetHolder holder) {
-        super(holder);
-        this.method = method;
-        this.translationService = translationService;
-        this.translationContext = translationContext;
-    }
-
-    /**
-     * Returns a singleton list of the {@link Method} provided in the
-     * constructor.
-     */
-    @Override
-    public List<Method> getMethods() {
-        return Collections.singletonList(method);
-    }
-
-    @Override
-    public Intent getIntent(final Method method) {
-        return Intent.CHECK_IF_VALID;
-    }
-
-    @Override
-    public String invalidReason(final ManagedObject owningAdapter, final ManagedObject proposedAdapter) {
-        final Object returnValue = ManagedObjects.InvokeUtil.invoke(method, owningAdapter, proposedAdapter);
-        if(returnValue instanceof String) {
-            return (String) returnValue;
-        }
-        if(returnValue instanceof TranslatableString) {
-            final TranslatableString ts = (TranslatableString) returnValue;
-            return ts.translate(translationService, translationContext);
-        }
-        return null;
-    }
-
-    @Override
-    protected String toStringValues() {
-        return "method=" + method;
-    }
-
-    @Override public void appendAttributesTo(final Map<String, Object> attributeMap) {
-        super.appendAttributesTo(attributeMap);
-        ImperativeFacet.Util.appendAttributesTo(this, attributeMap);
-    }
-
-}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/interactions/CollectionAddToContext.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/interactions/CollectionAddToContext.java
deleted file mode 100644
index 9ac9bfc..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/interactions/CollectionAddToContext.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.metamodel.interactions;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.applib.services.wrapper.events.CollectionAddToEvent;
-import org.apache.isis.core.metamodel.consent.InteractionContextType;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-import org.apache.isis.core.metamodel.spec.ManagedObjects.UnwrapUtil;
-
-/**
- * See {@link InteractionContext} for overview; analogous to
- * {@link CollectionAddToEvent}.
- */
-public class CollectionAddToContext 
-extends ValidityContext 
-implements ProposedHolder {
-
-    private final ManagedObject proposed;
-
-    public CollectionAddToContext(
-            final InteractionHead head,
-            final Identifier id,
-            final ManagedObject proposed,
-            final InteractionInitiatedBy interactionInitiatedBy) {
-        super(InteractionContextType.COLLECTION_ADD_TO, head, id, interactionInitiatedBy);
-
-        this.proposed = proposed;
-    }
-
-    @Override
-    public ManagedObject getProposed() {
-        return proposed;
-    }
-
-    @Override
-    public CollectionAddToEvent createInteractionEvent() {
-        return new CollectionAddToEvent(
-                UnwrapUtil.single(getTarget()), 
-                getIdentifier(), 
-                UnwrapUtil.single(getProposed()));
-    }
-
-}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/interactions/CollectionRemoveFromContext.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/interactions/CollectionRemoveFromContext.java
deleted file mode 100644
index 088cf24..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/interactions/CollectionRemoveFromContext.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.metamodel.interactions;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.applib.services.wrapper.events.CollectionRemoveFromEvent;
-import org.apache.isis.core.metamodel.consent.InteractionContextType;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-import org.apache.isis.core.metamodel.spec.ManagedObjects.UnwrapUtil;
-
-/**
- * See {@link InteractionContext} for overview; analogous to
- * {@link CollectionRemoveFromEvent}.
- */
-public class CollectionRemoveFromContext 
-extends ValidityContext 
-implements ProposedHolder{
-
-    private final ManagedObject proposed;
-
-    public CollectionRemoveFromContext(
-            final InteractionHead head,
-            final Identifier identifier,
-            final ManagedObject proposed,
-            final InteractionInitiatedBy interactionInitiatedBy) {
-        super(InteractionContextType.COLLECTION_REMOVE_FROM, head, identifier, interactionInitiatedBy);
-
-        this.proposed = proposed;
-    }
-
-    @Override
-    public ManagedObject getProposed() {
-        return proposed;
-    }
-
-    @Override
-    public CollectionRemoveFromEvent createInteractionEvent() {
-        return new CollectionRemoveFromEvent(
-                UnwrapUtil.single(getTarget()), 
-                getIdentifier(), 
-                UnwrapUtil.single(getProposed()));
-    }
-
-}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/metamodel/DomainMemberDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/metamodel/DomainMemberDefault.java
index 253704c..c5287a9 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/metamodel/DomainMemberDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/metamodel/DomainMemberDefault.java
@@ -37,8 +37,6 @@ import org.apache.isis.core.metamodel.facets.ImperativeFacet;
 import org.apache.isis.core.metamodel.facets.actions.defaults.ActionDefaultsFacet;
 import org.apache.isis.core.metamodel.facets.actions.validate.ActionValidationFacet;
 import org.apache.isis.core.metamodel.facets.all.hide.HiddenFacet;
-import org.apache.isis.core.metamodel.facets.collections.validate.CollectionValidateAddToFacet;
-import org.apache.isis.core.metamodel.facets.collections.validate.CollectionValidateRemoveFromFacet;
 import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacet;
 import org.apache.isis.core.metamodel.facets.param.autocomplete.ActionParameterAutoCompleteFacet;
 import org.apache.isis.core.metamodel.facets.param.choices.ActionChoicesFacet;
@@ -69,7 +67,7 @@ public class DomainMemberDefault implements DomainMember {
     private final ObjectMember member;
     private ObjectAction action;
 
-    // to support JAX-B marshaling 
+    // to support JAX-B marshaling
     DomainMemberDefault(){
         throw _Exceptions.unexpectedCodeReach();
     }
@@ -209,7 +207,7 @@ public class DomainMemberDefault implements DomainMember {
                 addIfNotEmpty(interpretFacet(facet), interpretations);
             }
             return !interpretations.isEmpty()
-                    ? interpretations.stream().collect(Collectors.joining(";"))
+                    ? String.join(";", interpretations)
                             : interpretRowAndFacet(ActionDefaultsFacet.class);
         }
     }
@@ -219,10 +217,7 @@ public class DomainMemberDefault implements DomainMember {
         if(memberType == MemberType.PROPERTY) {
             return interpretRowAndFacet(PropertyValidateFacet.class);
         } else if(memberType == MemberType.COLLECTION) {
-            final SortedSet<String> interpretations = _Sets.newTreeSet();
-            addIfNotEmpty(interpretRowAndFacet(CollectionValidateAddToFacet.class), interpretations);
-            addIfNotEmpty(interpretRowAndFacet(CollectionValidateRemoveFromFacet.class), interpretations);
-            return interpretations.stream().collect(Collectors.joining(";"));
+            return String.join(";", _Sets.newTreeSet());
         } else {
             return interpretRowAndFacet(ActionValidationFacet.class);
         }
@@ -264,7 +259,7 @@ public class DomainMemberDefault implements DomainMember {
         if (ignore(name)) {
             return "";
         }
-        //[ahuber] not sure why abbreviated, so I disabled abbreviation        
+        //[ahuber] not sure why abbreviated, so I disabled abbreviation
         //        final String abbr = StringExtensions.toAbbreviation(name);
         //        return abbr.length()>0 ? abbr : name;
 
@@ -276,11 +271,11 @@ public class DomainMemberDefault implements DomainMember {
                 .contains(name);
     }
 
-    private static final Comparator<DomainMember> comparator = 
+    private static final Comparator<DomainMember> comparator =
             Comparator.comparing(DomainMember::getClassType)
             .thenComparing(DomainMember::getClassName)
             .thenComparing(DomainMember::getType, Comparator.reverseOrder()) // desc
             .thenComparing(DomainMember::getMemberName);
 
 
-}
\ No newline at end of file
+}
diff --git a/viewers/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/MemberType.java b/viewers/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/MemberType.java
index 42207b7..3e35181 100644
--- a/viewers/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/MemberType.java
+++ b/viewers/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/MemberType.java
@@ -25,8 +25,6 @@ import org.apache.isis.applib.util.Enums;
 import org.apache.isis.commons.internal.collections._Maps;
 import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet;
 import org.apache.isis.core.metamodel.facets.actions.validate.ActionValidationFacet;
-import org.apache.isis.core.metamodel.facets.collections.validate.CollectionValidateAddToFacet;
-import org.apache.isis.core.metamodel.facets.collections.validate.CollectionValidateRemoveFromFacet;
 import org.apache.isis.core.metamodel.facets.properties.update.clear.PropertyClearFacet;
 import org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacet;
 import org.apache.isis.core.metamodel.facets.properties.validating.PropertyValidateFacet;


[isis] 05/05: ISIS-439: removes disabled interaction advisor reponsibility from CollectionDomainEventFacet (dead code)

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-2444
in repository https://gitbox.apache.org/repos/asf/isis.git

commit bbd83abae048baf712d6c996f85fedcb6cd3b448
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Mar 3 09:06:11 2021 +0000

    ISIS-439: removes disabled interaction advisor reponsibility from CollectionDomainEventFacet (dead code)
---
 .../modify/CollectionDomainEventFacet.java         |  2 +-
 .../modify/CollectionDomainEventFacetAbstract.java | 29 ----------------------
 2 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacet.java
index 6ebc17a..8d79acb 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacet.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacet.java
@@ -28,7 +28,7 @@ import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
  * Corresponds to <tt>@Collection(domainEvent=...)</tt> annotation in the Isis programming model.
  */
 public interface CollectionDomainEventFacet
-extends SingleClassValueFacet, HidingInteractionAdvisor, DisablingInteractionAdvisor {
+extends SingleClassValueFacet, HidingInteractionAdvisor {
 
 }
 
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
index 7046627..39c1bdc 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/modify/CollectionDomainEventFacetAbstract.java
@@ -21,14 +21,10 @@ package org.apache.isis.core.metamodel.facets.collections.collection.modify;
 
 import org.apache.isis.applib.events.domain.AbstractDomainEvent;
 import org.apache.isis.applib.events.domain.CollectionDomainEvent;
-import org.apache.isis.applib.services.i18n.TranslatableString;
-import org.apache.isis.applib.services.i18n.TranslationService;
 import org.apache.isis.commons.internal.base._Casts;
 import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
 import org.apache.isis.core.metamodel.facets.DomainEventHelper;
 import org.apache.isis.core.metamodel.facets.SingleClassValueFacetAbstract;
-import org.apache.isis.core.metamodel.interactions.UsabilityContext;
 import org.apache.isis.core.metamodel.interactions.VisibilityContext;
 
 public abstract class CollectionDomainEventFacetAbstract
@@ -36,8 +32,6 @@ public abstract class CollectionDomainEventFacetAbstract
         implements CollectionDomainEventFacet {
 
     private final DomainEventHelper domainEventHelper;
-    private final TranslationService translationService;
-    private final String translationContext;
 
     public CollectionDomainEventFacetAbstract(
             final Class<? extends CollectionDomainEvent<?, ?>> eventType,
@@ -46,10 +40,6 @@ public abstract class CollectionDomainEventFacetAbstract
         super(CollectionDomainEventFacet.class, holder, eventType);
         this.eventType = eventType;
 
-        this.translationService = getTranslationService();
-        // sadness: same as in TranslationFactory
-        this.translationContext = ((IdentifiedHolder)holder).getIdentifier().getTranslationContext();
-
         domainEventHelper = DomainEventHelper.ofServiceRegistry(getServiceRegistry());
     }
 
@@ -83,23 +73,4 @@ public abstract class CollectionDomainEventFacetAbstract
         return null;
     }
 
-    @Override
-    public String disables(final UsabilityContext ic) {
-
-        final CollectionDomainEvent<?, ?> event =
-                domainEventHelper.postEventForCollection(
-                        AbstractDomainEvent.Phase.DISABLE,
-                        getEventType(),
-                        getIdentified(), ic.getHead()
-                );
-        if (event != null && event.isDisabled()) {
-            final TranslatableString reasonTranslatable = event.getDisabledReasonTranslatable();
-            if(reasonTranslatable != null) {
-                return reasonTranslatable.translate(translationService, translationContext);
-            }
-            return event.getDisabledReason();
-        }
-        return null;
-    }
-
 }