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 2017/10/16 16:01:29 UTC

[isis] 07/09: ISIS-1742: removes DomainObjectContainer's #isPersistent, #persistIfNotAlready, #removeIfNotAlready - use RepositoryService instead

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

danhaywood pushed a commit to branch dev/2.0.0/ISIS-1742-remove-deprecations
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 8aa71c1ec7866c233da19ca826f6f59867b125e6
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Oct 16 16:44:12 2017 +0100

    ISIS-1742: removes DomainObjectContainer's #isPersistent, #persistIfNotAlready, #removeIfNotAlready - use RepositoryService instead
---
 ...mainObjectContainer_object-persistence-api.adoc | 34 +++++++++++-----------
 ...vc_persistence-layer-api_RepositoryService.adoc |  5 ----
 .../apache/isis/applib/DomainObjectContainer.java  | 25 ++--------------
 .../container/DomainObjectContainerDefault.java    | 27 -----------------
 todo-deprecation-list.txt                          |  3 +-
 5 files changed, 21 insertions(+), 73 deletions(-)

diff --git a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_core-domain-api_DomainObjectContainer_object-persistence-api.adoc b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_core-domain-api_DomainObjectContainer_object-persistence-api.adoc
index b3de7d4..7d2f874 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_core-domain-api_DomainObjectContainer_object-persistence-api.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_core-domain-api_DomainObjectContainer_object-persistence-api.adoc
@@ -7,7 +7,12 @@
 
 
 
-The persistence API is used to persist newly created objects (as per xref:../rgsvc/rgsvc.adoc#_rgsvc_core-domain-api_DomainObjectContainer_object-creation-api[`#newTransientInstance(...)`], above and to delete (remove) objects that are persistent.
+The (deprecated) persistence API is used to persist newly created objects (as per xref:../rgsvc/rgsvc.adoc#_rgsvc_core-domain-api_DomainObjectContainer_object-creation-api[`#newTransientInstance(...)`], above and to delete (remove) objects that are persistent.
+
+[TIP]
+====
+Instead, use xref:rgsvc.adoc#_rgsvc_persistence-layer-api_RepositoryService[`RepositoryService`] API.
+====
 
 Note that there is no API for updating existing objects; the framework (or rather, JDO/DataNucleus) performs object dirty tracking and so any objects that are modified in the course of a request will be automatically updated).
 
@@ -17,24 +22,21 @@ Note that there is no API for updating existing objects; the framework (or rathe
 ----
 public interface DomainObjectContainer {
 
-    boolean isPersistent(Object domainObject);          // <1>
-    boolean isViewModel(Object domainObject);           // <2>
-
-    void persist(Object domainObject);                  // <3>
-    void persistIfNotAlready(Object domainObject);      // <4>
-
-    void remove(Object persistentDomainObject);         // <5>
-    void removeIfNotAlready(Object domainObject);       // <6>
+    boolean isViewModel(Object domainObject);           // <1>
+    void persist(Object domainObject);                  // <2>
+    void remove(Object persistentDomainObject);         // <3>
 
     ...
 }
 ----
-<1> test whether a particular domain object is persistent or not.
-<2> test whether a particular domain object is a view model or not.  Note that this includes any domain objects annotated with xref:../rgant/rgant.adoc#_rgant-DomainObject_nature[`@DomainObject#nature=Nature.EXTERNAL_ENTITY)`] or xref:../rgant/rgant.adoc#_rgant-DomainObject_nature[`@DomainObject#nature=Nature.INMEMORY_ENTITY`]
-<3> persist a transient object.  Note though that this will throw an exception if the object is already persistent; this can happen if JDO/DataNucleus's link:http://www.datanucleus.org/products/accessplatform_4_0/jdo/orm/cascading.html[persistence-by-reachability] is in effect.  For this reason it is generally better to use `persistIfNotAlready(...)`. Also note that `persist(...)` has been deprecate.  When moving to xref:rgsvc.adoc#_rgsvc_persistence-layer-api_RepositoryService[`Reposito [...]
-<4> persist an object but only if know to not have been persistent.  But if the object is persistent, is a no-op
-<5> remove (ie DELETE) a persistent object.  For similar reasons to the persistence, it is generally better to use:
-<6> remove (ie DELETE) an object only if known to be persistent.  But if the object has already been deleted, then is a no-op.
+<1> test whether a particular domain object is a view model or not.
+Note that this includes any domain objects annotated with xref:../rgant/rgant.adoc#_rgant-DomainObject_nature[`@DomainObject#nature=Nature.EXTERNAL_ENTITY)`] or xref:../rgant/rgant.adoc#_rgant-DomainObject_nature[`@DomainObject#nature=Nature.INMEMORY_ENTITY`]
+<2> persist a transient object.
+Note though that this will throw an exception if the object is already persistent; this can happen if JDO/DataNucleus's link:http://www.datanucleus.org/products/accessplatform_4_0/jdo/orm/cascading.html[persistence-by-reachability] is in effect.
+For this reason it is generally better to use xref:rgsvc.adoc#_rgsvc_persistence-layer-api_RepositoryService[`RepositoryService#persist()`], which is a no-op if the object is persistent.
+<5> remove (ie DELETE) a persistent object.
+However, the object must be persistent already, otherwise an exception will be thrown.
+It is generally therefore better to use use xref:rgsvc.adoc#_rgsvc_persistence-layer-api_RepositoryService[`RepositoryService#remove()`], which is a no-op if the object is not persistent.
 
 For example:
 
@@ -48,5 +50,3 @@ container.persistIfNotAlready(cust);
 
 You should be aware that by default Apache Isis queues up calls to `#persist()` and `#remove()`.  These are then executed either when the request completes (and the transaction commits), or if the queue is flushed.  This can be done either implicitly by the framework, or as the result of a direct call to `TransactionService#flushTransaction()`.
 
-
-
diff --git a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_persistence-layer-api_RepositoryService.adoc b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_persistence-layer-api_RepositoryService.adoc
index 3bad5ff..a36e5ce 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_persistence-layer-api_RepositoryService.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_persistence-layer-api_RepositoryService.adoc
@@ -12,11 +12,6 @@ You can use it during prototyping to write naive queries (find all rows, then fi
 As an alternative, you could also use link:http://www.datanucleus.org/products/accessplatform_4_0/jdo/jdoql_typesafe.html[JDO typesafe queries] through the xref:../rgsvc/rgsvc.adoc#_rgsvc_persistence-layer-api_IsisJdoSupport[`IsisJdoSupport`] service.
 
 
-[NOTE]
-====
-The methods in this service replace similar methods (now deprecated) in xref:../rgsvc/rgsvc.adoc#_rgsvc_core-domain-api_DomainObjectContainer[`DomainObjectContainer`].
-====
-
 
 == API
 
diff --git a/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java b/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
index e45a9f8..1099cf0 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
@@ -161,43 +161,22 @@ public interface DomainObjectContainer {
 
     //endregion
 
-    //region > isPersistent, persist, remove (DEPRECATED)
+    //region > persist, remove (DEPRECATED)
 
     /**
-     * @deprecated - use {@link org.apache.isis.applib.services.repository.RepositoryService#isPersistent(Object)} instead.
-     */
-    @Deprecated
-    @Programmatic
-    boolean isPersistent(Object domainObject);
-
-    /**
-     * @deprecated - use {@link org.apache.isis.applib.services.repository.RepositoryService#persist(Object)} instead. Please note that {@link org.apache.isis.applib.services.repository.RepositoryService#persist(Object)} will not throw an exception if the Domain Object is already persistent, so the implementation will be the same as that of {@link org.apache.isis.applib.services.repository.RepositoryService#persist(Object)} (or the equivalent, deprecated {@link org.apache.isis.applib.Dom [...]
+     * @deprecated - use {@link org.apache.isis.applib.services.repository.RepositoryService#persist(Object)} instead. Please note that {@link org.apache.isis.applib.services.repository.RepositoryService#persist(Object)} will not throw an exception if the Domain Object is already persistent, so the implementation will be the same as that of {@link org.apache.isis.applib.services.repository.RepositoryService#persist(Object)}instead.
      */
     @Deprecated
     @Programmatic
     void persist(Object domainObject);
 
     /**
-     * @deprecated - use {@link org.apache.isis.applib.services.repository.RepositoryService#persist(Object)} instead.
-     */
-    @Deprecated
-    @Programmatic
-    void persistIfNotAlready(Object domainObject);
-
-    /**
      * @deprecated - use {@link org.apache.isis.applib.services.repository.RepositoryService#remove(Object)} instead.
      */
     @Deprecated
     @Programmatic
     void remove(Object persistentDomainObject);
 
-    /**
-     * @deprecated - use {@link org.apache.isis.applib.services.repository.RepositoryService#remove(Object)} instead.
-     */
-    @Deprecated
-    @Programmatic
-    void removeIfNotAlready(Object domainObject);
-
     //endregion
 
 
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
index 7a041f8..9687c0e 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
@@ -92,12 +92,6 @@ public class DomainObjectContainerDefault
         persistenceSessionServiceInternal.remove(adapter);
     }
 
-    @Programmatic
-    @Override
-    public void removeIfNotAlready(final Object object) {
-        repositoryService.remove(object);
-    }
-
     //endregion
 
 
@@ -197,12 +191,6 @@ public class DomainObjectContainerDefault
     //region > persistence
 
 
-    @Programmatic
-    @Override
-    public boolean isPersistent(final Object domainObject) {
-        return repositoryService.isPersistent(domainObject);
-    }
-
     /**
      * {@inheritDoc}
      */
@@ -224,15 +212,6 @@ public class DomainObjectContainerDefault
         persistenceSessionServiceInternal.makePersistent(adapter);
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Programmatic
-    @Override
-    public void persistIfNotAlready(final Object object) {
-        repositoryService.persist(object);
-    }
-
 
     //endregion
 
@@ -310,12 +289,6 @@ public class DomainObjectContainerDefault
     SpecificationLoader specificationLoader;
 
     @javax.inject.Inject
-    FactoryService factoryService;
-
-    @javax.inject.Inject
-    RepositoryService repositoryService;
-
-    @javax.inject.Inject
     ServiceRegistry serviceRegistry;
 
     @javax.inject.Inject
diff --git a/todo-deprecation-list.txt b/todo-deprecation-list.txt
index 3cc8760..7810656 100644
--- a/todo-deprecation-list.txt
+++ b/todo-deprecation-list.txt
@@ -470,4 +470,5 @@ org.apache.isis.applib
     - newAggregatedInstance - no replacement
     - newPersistentInstance - no replacement
     - newInstance - no replacement
-    - mixin - use FactoryService#mixin
\ No newline at end of file
+    - mixin - use FactoryService#mixin
+    - isPersistent, persistIfNotAlready, removeIfNotAlready - use RepositoryService instead
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.