You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/12/24 04:36:24 UTC
[isis] branch master updated: ISIS-2033: dn-integration: simplify
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 785987d ISIS-2033: dn-integration: simplify
785987d is described below
commit 785987ddbab9f6c5aa1078c3f30046f78694adb9
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Dec 24 05:27:59 2020 +0100
ISIS-2033: dn-integration: simplify
---
.../entities/DnEntityStateProvider.java | 40 +++++++------
.../metamodel/facets/entity/JdoEntityFacet.java | 3 +-
.../persistence/JdoPersistenceSession.java | 8 +--
.../persistence/JdoPersistenceSession5.java | 55 ++++-------------
.../persistence/command/CreateObjectCommand.java | 40 ++++++++++++-
.../DeleteObjectCommand.java} | 23 ++++----
.../persistence/command/DestroyObjectCommand.java | 24 --------
.../persistence/command/PersistenceCommand.java | 8 +--
.../command/PersistenceCommandAbstract.java | 39 ------------
.../command/PersistenceCommandQueue.java | 5 +-
.../commands/AbstractDataNucleusObjectCommand.java | 41 -------------
.../commands/DataNucleusCreateObjectCommand.java | 69 ----------------------
.../jdo/integration/transaction/_Tx.java | 10 ++--
13 files changed, 99 insertions(+), 266 deletions(-)
diff --git a/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/entities/DnEntityStateProvider.java b/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/entities/DnEntityStateProvider.java
index 9c012b3..061ee32 100644
--- a/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/entities/DnEntityStateProvider.java
+++ b/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/entities/DnEntityStateProvider.java
@@ -38,24 +38,7 @@ public class DnEntityStateProvider implements JdoFacetContext {
@Override
public EntityState getEntityState(Object pojo) {
-
- if(pojo==null) {
- return EntityState.NOT_PERSISTABLE;
- }
-
- if (pojo!=null && pojo instanceof Persistable) {
- val persistable = (Persistable) pojo;
- val isDeleted = persistable.dnIsDeleted();
- if(isDeleted) {
- return EntityState.PERSISTABLE_DESTROYED;
- }
- val isPersistent = persistable.dnIsPersistent();
- if(isPersistent) {
- return EntityState.PERSISTABLE_ATTACHED;
- }
- return EntityState.PERSISTABLE_DETACHED;
- }
- return EntityState.NOT_PERSISTABLE;
+ return entityState(pojo);
}
@Override
@@ -76,6 +59,27 @@ public class DnEntityStateProvider implements JdoFacetContext {
jdoMethodsProvidedByEnhancement.contains(method.toString());
}
+ public static EntityState entityState(Object pojo) {
+
+ if(pojo==null) {
+ return EntityState.NOT_PERSISTABLE;
+ }
+
+ if (pojo!=null && pojo instanceof Persistable) {
+ val persistable = (Persistable) pojo;
+ val isDeleted = persistable.dnIsDeleted();
+ if(isDeleted) {
+ return EntityState.PERSISTABLE_DESTROYED;
+ }
+ val isPersistent = persistable.dnIsPersistent();
+ if(isPersistent) {
+ return EntityState.PERSISTABLE_ATTACHED;
+ }
+ return EntityState.PERSISTABLE_DETACHED;
+ }
+ return EntityState.NOT_PERSISTABLE;
+ }
+
// -- HELPER
private static final Set<String> jdoMethodsProvidedByEnhancement = _Sets.newHashSet();
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/metamodel/facets/entity/JdoEntityFacet.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/metamodel/facets/entity/JdoEntityFacet.java
index cc344a2..2e17696 100644
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/metamodel/facets/entity/JdoEntityFacet.java
+++ b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/metamodel/facets/entity/JdoEntityFacet.java
@@ -29,6 +29,7 @@ import org.apache.isis.commons.internal.exceptions._Exceptions;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.spec.ManagedObject;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.persistence.jdo.datanucleus.entities.DnEntityStateProvider;
import org.apache.isis.persistence.jdo.integration.metamodel.JdoMetamodelUtil;
import lombok.val;
@@ -108,7 +109,7 @@ public class JdoEntityFacet extends _JdoEntityFacetAbstract {
@Override
public EntityState getEntityState(Object pojo) {
- return getJdoPersistenceSession().getEntityState(pojo);
+ return DnEntityStateProvider.entityState(pojo);
}
@Override
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/JdoPersistenceSession.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/JdoPersistenceSession.java
index de629d0..b1b42a9 100644
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/JdoPersistenceSession.java
+++ b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/JdoPersistenceSession.java
@@ -24,7 +24,6 @@ import java.util.Optional;
import javax.annotation.Nullable;
import org.apache.isis.applib.query.Query;
-import org.apache.isis.applib.services.repository.EntityState;
import org.apache.isis.commons.collections.Can;
import org.apache.isis.core.metamodel.context.HasMetaModelContext;
import org.apache.isis.core.metamodel.spec.ManagedObject;
@@ -52,7 +51,6 @@ extends
*/
void refreshEntity(Object pojo);
-
/**
* @param pojo a persistable object
* @return String representing an object's id.
@@ -60,11 +58,6 @@ extends
*/
String identifierFor(Object pojo);
- /**
- * @since 2.0
- */
- EntityState getEntityState(Object pojo);
-
/** whether pojo is recognized by the persistence layer, that is, it has an ObjectId
* @since 2.0*/
boolean isRecognized(Object pojo);
@@ -102,4 +95,5 @@ extends
*/
void makePersistentInTransaction(ManagedObject adapter);
+
}
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/JdoPersistenceSession5.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/JdoPersistenceSession5.java
index eef207a..cd99842 100644
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/JdoPersistenceSession5.java
+++ b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/JdoPersistenceSession5.java
@@ -20,7 +20,6 @@ package org.apache.isis.persistence.jdo.integration.persistence;
import java.util.Optional;
-import javax.annotation.Nullable;
import javax.enterprise.inject.Vetoed;
import javax.jdo.FetchGroup;
import javax.jdo.PersistenceManager;
@@ -30,10 +29,8 @@ import org.datanucleus.enhancement.Persistable;
import org.apache.isis.applib.query.Query;
import org.apache.isis.applib.services.exceprecog.ExceptionRecognizer;
-import org.apache.isis.applib.services.repository.EntityState;
import org.apache.isis.applib.services.xactn.TransactionService;
import org.apache.isis.commons.collections.Can;
-import org.apache.isis.commons.internal.exceptions._Exceptions;
import org.apache.isis.core.metamodel.adapter.oid.ObjectNotFoundException;
import org.apache.isis.core.metamodel.adapter.oid.Oid;
import org.apache.isis.core.metamodel.adapter.oid.PojoRefreshException;
@@ -45,14 +42,13 @@ import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.transaction.integration.IsisTransactionObject;
import org.apache.isis.persistence.jdo.applib.exceptions.NotPersistableException;
import org.apache.isis.persistence.jdo.applib.fixturestate.FixturesInstalledStateHolder;
+import org.apache.isis.persistence.jdo.datanucleus.entities.DnEntityStateProvider;
import org.apache.isis.persistence.jdo.datanucleus.oid.JdoObjectIdSerializer;
import org.apache.isis.persistence.jdo.integration.lifecycles.IsisLifecycleListener;
import org.apache.isis.persistence.jdo.integration.lifecycles.JdoStoreLifecycleListenerForIsis;
import org.apache.isis.persistence.jdo.integration.lifecycles.LoadLifecycleListenerForIsis;
import org.apache.isis.persistence.jdo.integration.persistence.command.CreateObjectCommand;
-import org.apache.isis.persistence.jdo.integration.persistence.command.DestroyObjectCommand;
-import org.apache.isis.persistence.jdo.integration.persistence.commands.DataNucleusCreateObjectCommand;
-import org.apache.isis.persistence.jdo.integration.persistence.commands.DataNucleusDeleteObjectCommand;
+import org.apache.isis.persistence.jdo.integration.persistence.command.DeleteObjectCommand;
import org.apache.isis.persistence.jdo.integration.persistence.query.PersistenceQuery;
import lombok.NonNull;
@@ -271,7 +267,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
@Override
public void refreshEntity(final Object domainObject) {
- val state = getEntityState(domainObject);
+ val state = DnEntityStateProvider.entityState(domainObject);
val isRepresentingPersistent = state.isAttached() || state.isDestroyed();
if(!isRepresentingPersistent) {
@@ -302,7 +298,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
val pojo = adapter.getPojo();
- if (getEntityState(pojo).isAttached()) {
+ if (DnEntityStateProvider.entityState(pojo).isAttached()) {
throw new NotPersistableException("Object already persistent: " + adapter);
}
val spec = adapter.getSpecification();
@@ -316,8 +312,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
transactionService.executeWithinTransaction(()->{
log.debug("persist {}", adapter);
- val createObjectCommand = newCreateObjectCommand(adapter);
- commandQueue.addCommand(createObjectCommand);
+ commandQueue.addCommand(newCreateObjectCommand(adapter));
});
}
@@ -329,10 +324,9 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
if (spec.isParented()) {
return;
}
- log.debug("destroyObject {}", adapter);
+ log.debug("deleteObject {}", adapter);
transactionService.executeWithinTransaction(()->{
- val destroyObjectCommand = newDestroyObjectCommand(adapter);
- commandQueue.addCommand(destroyObjectCommand);
+ commandQueue.addCommand(newDeleteObjectCommand(adapter));
});
}
@@ -364,23 +358,23 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
val pojo = adapter.getPojo();
log.debug("create object - creating command for: {}", adapter);
- if (getEntityState(pojo).isAttached()) {
+ if (DnEntityStateProvider.entityState(pojo).isAttached()) {
throw new IllegalArgumentException("Adapter is persistent; adapter: " + adapter);
}
- return new DataNucleusCreateObjectCommand(adapter, this);
+ return new CreateObjectCommand(getPersistenceManager(), adapter);
}
- private DestroyObjectCommand newDestroyObjectCommand(final ManagedObject adapter) {
+ private DeleteObjectCommand newDeleteObjectCommand(final ManagedObject adapter) {
state.ensureOpened();
val pojo = adapter.getPojo();
log.debug("destroy object - creating command for: {}", adapter);
- if (!getEntityState(pojo).isAttached()) {
+ if (!DnEntityStateProvider.entityState(pojo).isAttached()) {
throw new IllegalArgumentException("Adapter is not persistent; adapter: " + adapter);
}
- return new DataNucleusDeleteObjectCommand(adapter, persistenceManager);
+ return new DeleteObjectCommand(getPersistenceManager(), adapter);
}
// -- FrameworkSynchronizer delegate methods
@@ -417,7 +411,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
*/
@Override
public void invokeIsisPersistingCallback(final Persistable pojo) {
- if (getEntityState(pojo).isDetached()) {
+ if (DnEntityStateProvider.entityState(pojo).isDetached()) {
val entity = ManagedObject.of(
getMetaModelContext().getSpecificationLoader()::loadSpecification,
pojo);
@@ -461,29 +455,6 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
getEntityChangeTracker().recognizeUpdating(entity);
}
- @Override //XXX also provided by 'provider' module
- public EntityState getEntityState(@Nullable Object pojo) {
-
- // guard against misuse
- if(pojo instanceof ManagedObject) {
- throw _Exceptions.unexpectedCodeReach();
- }
-
- if (pojo!=null && pojo instanceof Persistable) {
- val persistable = (Persistable) pojo;
- val isDeleted = persistable.dnIsDeleted();
- if(isDeleted) {
- return EntityState.PERSISTABLE_DESTROYED;
- }
- val isPersistent = persistable.dnIsPersistent();
- if(isPersistent) {
- return EntityState.PERSISTABLE_ATTACHED;
- }
- return EntityState.PERSISTABLE_DETACHED;
- }
- return EntityState.NOT_PERSISTABLE;
- }
-
@Override
public boolean isRecognized(Object pojo) {
if (pojo!=null && pojo instanceof Persistable) {
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/CreateObjectCommand.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/CreateObjectCommand.java
index 29966cd..9bba48b 100644
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/CreateObjectCommand.java
+++ b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/CreateObjectCommand.java
@@ -16,9 +16,45 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.isis.persistence.jdo.integration.persistence.command;
-public interface CreateObjectCommand extends PersistenceCommand {
+import javax.jdo.PersistenceManager;
+
+import org.apache.isis.core.metamodel.spec.ManagedObject;
+import org.apache.isis.persistence.jdo.datanucleus.entities.DnEntityStateProvider;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.val;
+import lombok.extern.log4j.Log4j2;
+
+@RequiredArgsConstructor
+@Log4j2
+public class CreateObjectCommand implements PersistenceCommand {
+
+ private final PersistenceManager persistenceManager;
+ @Getter private final ManagedObject entity;
+
+ @Override
+ public void execute() {
+ if (log.isDebugEnabled()) {
+ log.debug("create object - executing command for: {}", entity);
+ }
+
+ val domainObject = entity.getPojo();
+ if(!DnEntityStateProvider.entityState(domainObject).isDetached()) {
+ // this could happen if DN's persistence-by-reachability has already caused the domainobject
+ // to be persisted. It's Isis adapter will have been updated as a result of the postStore
+ // lifecycle callback, so in essence there's nothing to be done.
+ return;
+ }
+
+ persistenceManager.makePersistent(domainObject);
+ }
+
+ @Override
+ public String toString() {
+ return "CreateObjectCommand [entity=" + entity + "]";
+ }
}
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/commands/DataNucleusDeleteObjectCommand.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/DeleteObjectCommand.java
similarity index 69%
rename from persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/commands/DataNucleusDeleteObjectCommand.java
rename to persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/DeleteObjectCommand.java
index c81195c..a6ccc32 100644
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/commands/DataNucleusDeleteObjectCommand.java
+++ b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/DeleteObjectCommand.java
@@ -16,35 +16,34 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.persistence.jdo.integration.persistence.commands;
+package org.apache.isis.persistence.jdo.integration.persistence.command;
import javax.jdo.PersistenceManager;
import org.apache.isis.core.metamodel.spec.ManagedObject;
-import org.apache.isis.persistence.jdo.integration.persistence.command.DestroyObjectCommand;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
+@RequiredArgsConstructor
@Log4j2
-public class DataNucleusDeleteObjectCommand
-extends AbstractDataNucleusObjectCommand
-implements DestroyObjectCommand {
-
- public DataNucleusDeleteObjectCommand(ManagedObject adapter, PersistenceManager persistenceManager) {
- super(adapter, persistenceManager);
- }
+public class DeleteObjectCommand implements PersistenceCommand {
+ private final PersistenceManager persistenceManager;
+ @Getter private final ManagedObject entity;
+
@Override
public void execute() {
if (log.isDebugEnabled()) {
- log.debug("destroy object - executing command for {}", onManagedObject());
+ log.debug("destroy object - executing command for {}", entity);
}
- getPersistenceManager().deletePersistent(onManagedObject().getPojo());
+ persistenceManager.deletePersistent(entity.getPojo());
}
@Override
public String toString() {
- return "DestroyObjectCommand [adapter=" + onManagedObject() + "]";
+ return "DeleteObjectCommand [entity=" + entity + "]";
}
}
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/DestroyObjectCommand.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/DestroyObjectCommand.java
deleted file mode 100644
index 119e64f..0000000
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/DestroyObjectCommand.java
+++ /dev/null
@@ -1,24 +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.persistence.jdo.integration.persistence.command;
-
-public interface DestroyObjectCommand extends PersistenceCommand {
-
-}
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/PersistenceCommand.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/PersistenceCommand.java
index 7234693..4147a93 100644
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/PersistenceCommand.java
+++ b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/PersistenceCommand.java
@@ -16,15 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.isis.persistence.jdo.integration.persistence.command;
import org.apache.isis.core.metamodel.spec.ManagedObject;
-/** captures entity creation and deletion */
public interface PersistenceCommand {
-
+
void execute();
- ManagedObject onManagedObject();
-
+ ManagedObject getEntity();
+
}
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/PersistenceCommandAbstract.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/PersistenceCommandAbstract.java
deleted file mode 100644
index 3332297..0000000
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/PersistenceCommandAbstract.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.persistence.jdo.integration.persistence.command;
-
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-
-public abstract class PersistenceCommandAbstract implements PersistenceCommand {
-
- private final ManagedObject adapter;
-
- public PersistenceCommandAbstract(final ManagedObject adapter) {
- super();
- this.adapter = adapter;
- }
-
- @Override
- public ManagedObject onManagedObject() {
- return adapter;
- }
-
-
-}
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/PersistenceCommandQueue.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/PersistenceCommandQueue.java
index 7301740..66ad7bb 100644
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/PersistenceCommandQueue.java
+++ b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/command/PersistenceCommandQueue.java
@@ -20,6 +20,9 @@ package org.apache.isis.persistence.jdo.integration.persistence.command;
public interface PersistenceCommandQueue {
- void addCommand(PersistenceCommand command);
+ void addCommand(PersistenceCommand persistenceCommand);
+
+ //void createObject(ManagedObject adapter);
+ //void deleteObject(ManagedObject adapter);
}
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/commands/AbstractDataNucleusObjectCommand.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/commands/AbstractDataNucleusObjectCommand.java
deleted file mode 100644
index 36feb62..0000000
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/commands/AbstractDataNucleusObjectCommand.java
+++ /dev/null
@@ -1,41 +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.persistence.jdo.integration.persistence.commands;
-
-import javax.jdo.PersistenceManager;
-
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-import org.apache.isis.persistence.jdo.integration.persistence.command.PersistenceCommandAbstract;
-
-import lombok.Getter;
-
-public abstract class AbstractDataNucleusObjectCommand extends PersistenceCommandAbstract {
-
- @Getter private final PersistenceManager persistenceManager;
-
- AbstractDataNucleusObjectCommand(
- final ManagedObject adapter,
- final PersistenceManager persistenceManager) {
-
- super(adapter);
- this.persistenceManager = persistenceManager;
-
- }
-
-}
\ No newline at end of file
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/commands/DataNucleusCreateObjectCommand.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/commands/DataNucleusCreateObjectCommand.java
deleted file mode 100644
index 5ae5037..0000000
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/persistence/commands/DataNucleusCreateObjectCommand.java
+++ /dev/null
@@ -1,69 +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.persistence.jdo.integration.persistence.commands;
-
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-import org.apache.isis.persistence.jdo.integration.persistence.JdoPersistenceSession;
-import org.apache.isis.persistence.jdo.integration.persistence.command.CreateObjectCommand;
-
-import lombok.val;
-import lombok.extern.log4j.Log4j2;
-
-@Log4j2
-public class DataNucleusCreateObjectCommand
-extends AbstractDataNucleusObjectCommand
-implements CreateObjectCommand {
-
- private final JdoPersistenceSession persistenceSession;
-
- public DataNucleusCreateObjectCommand(ManagedObject adapter, JdoPersistenceSession persistenceSession) {
- super(adapter, persistenceSession.getPersistenceManager());
- this.persistenceSession = persistenceSession;
- }
-
-
- @Override
- public void execute() {
- if (log.isDebugEnabled()) {
- log.debug("create object - executing command for: {}", onManagedObject());
- }
-
- val domainObject = onManagedObject().getPojo();
- if(!isDetached(domainObject)) {
- // this could happen if DN's persistence-by-reachability has already caused the domainobject
- // to be persisted. It's Isis adapter will have been updated as a result of the postStore
- // lifecycle callback, so in essence there's nothing to be done.
- return;
- }
-
- getPersistenceManager().makePersistent(domainObject);
- }
-
- @Override
- public String toString() {
- return "CreateObjectCommand [adapter=" + onManagedObject() + "]";
- }
-
- // -- HELPER
-
- private boolean isDetached(Object pojo) {
- val state = persistenceSession.getEntityState(pojo);
- return state.isDetached();
- }
-}
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/transaction/_Tx.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/transaction/_Tx.java
index fa18a28..9f4aa80 100644
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/transaction/_Tx.java
+++ b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/transaction/_Tx.java
@@ -43,7 +43,7 @@ import org.apache.isis.core.transaction.integration.IsisTransactionFlushExceptio
import org.apache.isis.core.transaction.integration.IsisTransactionManagerException;
import org.apache.isis.persistence.jdo.integration.persistence.JdoPersistenceSession;
import org.apache.isis.persistence.jdo.integration.persistence.command.CreateObjectCommand;
-import org.apache.isis.persistence.jdo.integration.persistence.command.DestroyObjectCommand;
+import org.apache.isis.persistence.jdo.integration.persistence.command.DeleteObjectCommand;
import org.apache.isis.persistence.jdo.integration.persistence.command.PersistenceCommand;
import lombok.Getter;
@@ -225,10 +225,10 @@ class _Tx implements Transaction {
return;
}
- final ManagedObject onObject = command.onManagedObject();
+ final ManagedObject onObject = command.getEntity();
// Destroys are ignored when preceded by a create, or another destroy
- if (command instanceof DestroyObjectCommand) {
+ if (command instanceof DeleteObjectCommand) {
if (alreadyHasCreate(onObject)) {
removeCreate(onObject);
if (log.isDebugEnabled()) {
@@ -258,12 +258,12 @@ class _Tx implements Transaction {
}
private boolean alreadyHasDestroy(final ManagedObject onObject) {
- return alreadyHasCommand(DestroyObjectCommand.class, onObject);
+ return alreadyHasCommand(DeleteObjectCommand.class, onObject);
}
private PersistenceCommand getCommand(final Class<?> commandClass, final ManagedObject onObject) {
for (final PersistenceCommand command : persistenceCommands.snapshot()) {
- if (command.onManagedObject().equals(onObject)) {
+ if (command.getEntity().equals(onObject)) {
if (commandClass.isAssignableFrom(command.getClass())) {
return command;
}