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 2012/12/13 08:30:03 UTC
[13/58] [partial] ISIS-188: renaming packages in line with
groupId:artifactId
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java
deleted file mode 100644
index eb2b4d5..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java
+++ /dev/null
@@ -1,106 +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.runtimes.dflt.objectstores.jdo.datanucleus.persistence.spi;
-
-import java.util.UUID;
-
-import javax.jdo.PersistenceManager;
-import javax.jdo.spi.PersistenceCapable;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.DataNucleusObjectStore;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.IdentifierGenerator;
-
-public class DataNucleusIdentifierGenerator implements IdentifierGenerator {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = Logger.getLogger(DataNucleusIdentifierGenerator.class);
-
-
-
- // //////////////////////////////////////////////////////////////
- // main api
- // //////////////////////////////////////////////////////////////
-
- @Override
- public String createTransientIdentifierFor(ObjectSpecId objectSpecId, Object pojo) {
- return UUID.randomUUID().toString();
- }
-
-
- @Override
- public String createAggregateLocalId(ObjectSpecId objectSpecId, Object pojo, ObjectAdapter parentAdapter) {
- return UUID.randomUUID().toString();
- }
-
-
- @Override
- public String createPersistentIdentifierFor(ObjectSpecId objectSpecId, Object pojo, RootOid transientRootOid) {
-
- // hack to deal with services
- if(!(pojo instanceof PersistenceCapable)) {
- return "1";
- }
-
- final Object jdoOid = getJdoPersistenceManager().getObjectId(pojo);
-
- return JdoObjectIdSerializer.toOidIdentifier(jdoOid);
- }
-
-
-
- // //////////////////////////////////////////////////////////////
- // Debugging
- // //////////////////////////////////////////////////////////////
-
-
- public String debugTitle() {
- return "DataNucleus Identifier Generator";
- }
-
-
- @Override
- public void debugData(DebugBuilder debug) {
-
- }
-
-
- // //////////////////////////////////////////////////////////////
- // Dependencies (from context)
- // //////////////////////////////////////////////////////////////
-
-
- protected PersistenceManager getJdoPersistenceManager() {
- final DataNucleusObjectStore objectStore = getDataNucleusObjectStore();
- return objectStore.getPersistenceManager();
- }
-
-
- protected DataNucleusObjectStore getDataNucleusObjectStore() {
- return (DataNucleusObjectStore) IsisContext.getPersistenceSession().getObjectStore();
- }
-
-}
-// Copyright (c) Naked Objects Group Ltd.
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java
deleted file mode 100644
index eb2fd53..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java
+++ /dev/null
@@ -1,77 +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.runtimes.dflt.objectstores.jdo.datanucleus.persistence.spi;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.lang.ToString;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackUtils;
-import org.apache.isis.core.metamodel.facets.object.callbacks.PersistingCallbackFacet;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.PersistAlgorithmAbstract;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.ToPersistObjectSet;
-
-
-/**
- * A {@link PersistAlgorithm} which simply saves the object made persistent.
- */
-public class DataNucleusSimplePersistAlgorithm extends PersistAlgorithmAbstract {
-
- private static final Logger LOG = Logger
- .getLogger(DataNucleusSimplePersistAlgorithm.class);
-
-
- // ////////////////////////////////////////////////////////////////
- // name
- // ////////////////////////////////////////////////////////////////
-
- public String name() {
- return "SimplePersistAlgorithm";
- }
-
-
- // ////////////////////////////////////////////////////////////////
- // makePersistent
- // ////////////////////////////////////////////////////////////////
-
- public void makePersistent(final ObjectAdapter adapter,
- final ToPersistObjectSet toPersistObjectSet) {
- if (alreadyPersistedOrNotPersistable(adapter)) {
- return;
- }
- if (LOG.isInfoEnabled()) {
- LOG.info("persist " + adapter);
- }
- CallbackUtils.callCallback(adapter, PersistingCallbackFacet.class);
- toPersistObjectSet.addCreateObjectCommand(adapter);
- }
-
-
- // ////////////////////////////////////////////////////////////////
- // toString
- // ////////////////////////////////////////////////////////////////
-
- @Override
- public String toString() {
- final ToString toString = new ToString(this);
- return toString.toString();
- }
-}
-// Copyright (c) Naked Objects Group Ltd.
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransaction.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransaction.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransaction.java
deleted file mode 100644
index fa0a3ae..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransaction.java
+++ /dev/null
@@ -1,92 +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.runtimes.dflt.objectstores.jdo.datanucleus.persistence.spi;
-
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.isis.applib.clock.Clock;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.runtimes.dflt.objectstores.jdo.applib.AuditService;
-import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.auditable.AuditableFacet;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.TransactionalResource;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
-import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.runtimes.dflt.runtime.system.transaction.MessageBroker;
-import org.apache.isis.runtimes.dflt.runtime.system.transaction.UpdateNotifier;
-
-public class DataNucleusTransaction extends IsisTransaction {
-
- private final AuditService auditService;
-
- public DataNucleusTransaction(
- final IsisTransactionManager transactionManager,
- final MessageBroker messageBroker,
- final UpdateNotifier updateNotifier,
- final TransactionalResource objectStore,
- final AuditService auditService) {
- super(transactionManager, messageBroker, updateNotifier, objectStore);
- this.auditService = auditService;
- }
-
- @Override
- protected void doAudit(final Set<Entry<AdapterAndProperty, PreAndPostValues>> auditEntries) {
- if(auditService == null) {
- super.doAudit(auditEntries);
- return;
- }
- final String currentUser = getAuthenticationSession().getUserName();
- final long currentTimestampEpoch = currentTimestampEpoch();
- for (Entry<AdapterAndProperty, PreAndPostValues> auditEntry : auditEntries) {
- audit(currentUser, currentTimestampEpoch, auditEntry);
- }
- }
-
- private long currentTimestampEpoch() {
- return Clock.getTime();
- }
-
- private void audit(final String currentUser, final long currentTimestampEpoch, final Entry<AdapterAndProperty, PreAndPostValues> auditEntry) {
- final AdapterAndProperty aap = auditEntry.getKey();
- final ObjectAdapter adapter = aap.getAdapter();
- if(!adapter.getSpecification().containsFacet(AuditableFacet.class)) {
- return;
- }
- final RootOid oid = (RootOid) adapter.getOid();
- final String objectType = oid.getObjectSpecId().asString();
- final String identifier = oid.getIdentifier();
- final PreAndPostValues papv = auditEntry.getValue();
- final String preValue = asString(papv.getPre());
- final String postValue = asString(papv.getPost());
- auditService.audit(currentUser, currentTimestampEpoch, objectType, identifier, preValue, postValue);
- }
-
- private static String asString(Object object) {
- return object != null? object.toString(): null;
- }
-
-
- protected AuthenticationSession getAuthenticationSession() {
- return IsisContext.getAuthenticationSession();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransactionManager.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransactionManager.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransactionManager.java
deleted file mode 100644
index ca81a8e..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransactionManager.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.runtimes.dflt.objectstores.jdo.datanucleus.persistence.spi;
-
-import org.apache.isis.runtimes.dflt.objectstores.jdo.applib.AuditService;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.TransactionalResource;
-import org.apache.isis.runtimes.dflt.runtime.system.transaction.EnlistedObjectDirtying;
-import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
-import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.runtimes.dflt.runtime.system.transaction.MessageBroker;
-import org.apache.isis.runtimes.dflt.runtime.system.transaction.UpdateNotifier;
-
-public class DataNucleusTransactionManager extends IsisTransactionManager {
-
- private final AuditService auditService;
-
- public DataNucleusTransactionManager(
- final EnlistedObjectDirtying objectPersistor,
- final TransactionalResource objectStore,
- final AuditService auditService) {
- super(objectPersistor, objectStore);
- this.auditService = auditService;
- }
-
- @Override
- protected IsisTransaction createTransaction(final MessageBroker messageBroker, final UpdateNotifier updateNotifier) {
- return new DataNucleusTransaction(this, messageBroker, updateNotifier, getTransactionalResource(), auditService);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java
deleted file mode 100644
index b27e63d..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java
+++ /dev/null
@@ -1,150 +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.runtimes.dflt.objectstores.jdo.datanucleus.persistence.spi;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.jdo.identity.IntIdentity;
-import javax.jdo.identity.LongIdentity;
-import javax.jdo.identity.StringIdentity;
-
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.datanucleus.identity.OID;
-
-public final class JdoObjectIdSerializer {
-
- private static final char SEPARATOR = '_';
-
- private JdoObjectIdSerializer(){}
-
- public static class Exception extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- public Exception(java.lang.Exception ex) {
- super(ex);
- }
- }
-
- public static String toOidIdentifier(Object jdoOid) {
- if(jdoOid instanceof javax.jdo.identity.IntIdentity) {
- return "i" + SEPARATOR + jdoOid;
- }
- if(jdoOid instanceof javax.jdo.identity.StringIdentity) {
- return "s" + SEPARATOR + jdoOid;
- }
- if(jdoOid instanceof javax.jdo.identity.LongIdentity) {
- return "l" + SEPARATOR + jdoOid;
- }
- if(jdoOid instanceof OID) {
- OID dnOid = (OID) jdoOid;
- Object keyValue = dnOid.getKeyValue();
-
- // prettier handling of these common cases
- if(keyValue instanceof String) {
- return "S" + SEPARATOR + keyValue;
- }
-
- if(keyValue instanceof Long) {
- return "L" + SEPARATOR + keyValue;
- }
-
- if(keyValue instanceof BigInteger) {
- return "B" + SEPARATOR + keyValue;
- }
-
- if(keyValue instanceof Integer) {
- return "I" + SEPARATOR + keyValue;
- }
-
- }
-
- // the JDO spec (5.4.3) requires that OIDs are serializable toString and
- // recreatable through the constructor
- return jdoOid.getClass().getName().toString() + SEPARATOR + jdoOid.toString();
- }
-
- private static List<String> dnPrefixes = Arrays.asList("S", "I", "L", "B");
-
- public static Object toJdoObjectId(RootOid oid) {
- String idStr = oid.getIdentifier();
- final int colonIdx = idStr.indexOf(SEPARATOR);
- final String keyStr = idStr.substring(colonIdx+1);
-
- final String firstPart = idStr.substring(0, colonIdx);
-
- if("s".equals(firstPart)) {
- return new StringIdentity(objectTypeClassFor(oid), keyStr);
- }
-
- if("i".equals(firstPart)) {
- return new IntIdentity(objectTypeClassFor(oid), keyStr);
- }
-
- if("l".equals(firstPart)) {
- return new LongIdentity(objectTypeClassFor(oid), keyStr);
- }
-
- if(dnPrefixes.contains(firstPart)) {
- ObjectSpecId objectSpecId = oid.getObjectSpecId();
- ObjectSpecification spec = getSpecificationLoader().lookupBySpecId(objectSpecId);
- return keyStr + "[OID]" + spec.getFullIdentifier();
- }
-
- final String clsName = firstPart;
- try {
- final Class<?> cls = Thread.currentThread().getContextClassLoader().loadClass(clsName);
- final Constructor<?> cons = cls.getConstructor(String.class);
- final Object dnOid = cons.newInstance(keyStr);
- return dnOid.toString();
- } catch (ClassNotFoundException e) {
- throw new JdoObjectIdSerializer.Exception(e);
- } catch (IllegalArgumentException e) {
- throw new JdoObjectIdSerializer.Exception(e);
- } catch (InstantiationException e) {
- throw new JdoObjectIdSerializer.Exception(e);
- } catch (IllegalAccessException e) {
- throw new JdoObjectIdSerializer.Exception(e);
- } catch (InvocationTargetException e) {
- throw new JdoObjectIdSerializer.Exception(e);
- } catch (SecurityException e) {
- throw new JdoObjectIdSerializer.Exception(e);
- } catch (NoSuchMethodException e) {
- throw new JdoObjectIdSerializer.Exception(e);
- }
- }
-
- private static Class<?> objectTypeClassFor(RootOid oid) {
- final ObjectSpecId objectSpecId = oid.getObjectSpecId();
- final ObjectSpecification spec = getSpecificationLoader().lookupBySpecId(objectSpecId);
- final Class<?> correspondingClass = spec.getCorrespondingClass();
- return correspondingClass;
- }
-
- private static SpecificationLoaderSpi getSpecificationLoader() {
- return IsisContext.getSpecificationLoader();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/ResolveStateUtil.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/ResolveStateUtil.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/ResolveStateUtil.java
deleted file mode 100644
index 47e0329..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/ResolveStateUtil.java
+++ /dev/null
@@ -1,122 +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.runtimes.dflt.objectstores.jdo.datanucleus.persistence.spi;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.ResolveState;
-
-public final class ResolveStateUtil {
-
- private ResolveStateUtil() {}
-
-
- public static void moveToResolving(final ObjectAdapter adapter) {
-
- moveUpToResolving(adapter);
- }
-
- public static void markAsResolved(final ObjectAdapter adapter) {
-
- moveUpToResolving(adapter);
-
- // move to ResolveState.RESOLVED;
-
- if (adapter.isResolving()) {
- adapter.changeState(ResolveState.RESOLVED);
-
- } else if (adapter.isResolved()) {
- // nothing to do.
-
-// } else if (adapter.getResolveState().isPartlyResolved()) {
-// adapter.changeState(ResolveState.RESOLVED);
-
- } else if (adapter.isUpdating()) {
- adapter.changeState(ResolveState.RESOLVED);
- }
- }
-
-
- private static void moveUpToResolving(final ObjectAdapter adapter) {
- // move these on so we can get to part_resolved or resolved.
- if (adapter.isTransient()) {
- adapter.changeState(ResolveState.RESOLVED);
- adapter.changeState(ResolveState.GHOST);
- adapter.changeState(ResolveState.RESOLVING);
-
- } else if (adapter.isNew()) {
- adapter.changeState(ResolveState.GHOST);
- adapter.changeState(ResolveState.RESOLVING);
-
- } else if (adapter.isGhost()) {
- adapter.changeState(ResolveState.RESOLVING);
- }
- }
-
- public static void markAsGhost(final ObjectAdapter adapter) {
-
- if (adapter.isValue()) {
- // TODO: what should we do here? throw exception?
- }
- if (adapter.isDestroyed()) {
- // TODO: what should we do here? throw exception?
- }
-
- if (adapter.isTransient()) {
- adapter.changeState(ResolveState.RESOLVED);
- adapter.changeState(ResolveState.GHOST);
-
- } else if (adapter.isNew()) {
- adapter.changeState(ResolveState.GHOST);
-
-// } else if (adapter.getResolveState().isPartlyResolved()) {
-// adapter.changeState(ResolveState.RESOLVING);
-// adapter.changeState(ResolveState.RESOLVED);
-// adapter.changeState(ResolveState.GHOST);
-
- } else if (adapter.isResolving()) {
- adapter.changeState(ResolveState.RESOLVED);
- adapter.changeState(ResolveState.GHOST);
-
- } else if (adapter.isUpdating()) {
- adapter.changeState(ResolveState.RESOLVED);
- adapter.changeState(ResolveState.GHOST);
-
- } else if (adapter.isResolved()) {
- adapter.changeState(ResolveState.GHOST);
-
- } else if (adapter.isGhost()) {
- // nothing to do.
- }
- }
-
-
- public static void markAsUpdating(final ObjectAdapter adapter) {
-
- if (adapter.isTransient()) {
- adapter.changeState(ResolveState.RESOLVED);
- }
- if (adapter.isResolved()) {
- adapter.changeState(ResolveState.UPDATING);
- }
- }
-
-}
-
-
-// Copyright (c) Naked Objects Group Ltd.
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobConverter.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobConverter.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobConverter.java
deleted file mode 100644
index aadd5fc..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobConverter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
-
-import org.apache.isis.applib.adapters.EncoderDecoder;
-import org.apache.isis.applib.value.Blob;
-import org.apache.isis.core.progmodel.facets.value.blobs.BlobValueSemanticsProvider;
-import org.datanucleus.store.types.converters.TypeConverter;
-
-public class IsisBlobConverter implements TypeConverter<Blob, String>{
-
- private static final long serialVersionUID = 1L;
- private EncoderDecoder<Blob> encoderDecoder;
-
- public IsisBlobConverter() {
- encoderDecoder = new BlobValueSemanticsProvider().getEncoderDecoder();
- }
-
- @Override
- public String toDatastoreType(Blob memberValue) {
- return encoderDecoder.toEncodedString(memberValue);
- }
-
- @Override
- public Blob toMemberType(String datastoreValue) {
- return encoderDecoder.fromEncodedString(datastoreValue);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobMapping.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobMapping.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobMapping.java
deleted file mode 100644
index 02d50ee..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobMapping.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
-
-import org.apache.isis.applib.value.Blob;
-import org.datanucleus.ClassLoaderResolver;
-import org.datanucleus.ClassNameConstants;
-import org.datanucleus.NucleusContext;
-import org.datanucleus.metadata.AbstractMemberMetaData;
-import org.datanucleus.store.ExecutionContext;
-import org.datanucleus.store.mapped.DatastoreContainerObject;
-import org.datanucleus.store.mapped.MappedStoreManager;
-import org.datanucleus.store.mapped.mapping.SingleFieldMultiMapping;
-
-public class IsisBlobMapping extends SingleFieldMultiMapping {
-
- public IsisBlobMapping() {
- }
-
- @Override
- public Class<?> getJavaType() {
- return org.apache.isis.applib.value.Blob.class;
- }
-
- public void initialize(AbstractMemberMetaData mmd, DatastoreContainerObject container, ClassLoaderResolver clr)
- {
- super.initialize(mmd, container, clr);
- addDatastoreFields();
- }
-
- public void initialize(MappedStoreManager storeMgr, String type)
- {
- super.initialize(storeMgr, type);
- addDatastoreFields();
- }
-
- protected void addDatastoreFields()
- {
- addDatastoreField(ClassNameConstants.JAVA_LANG_STRING); // name
- addDatastoreField(ClassNameConstants.JAVA_LANG_STRING); // mime type
- addDatastoreField(ClassNameConstants.JAVA_LANG_BYTE_ARRAY); // bytes
- }
-
- public Object getValueForDatastoreMapping(NucleusContext nucleusCtx, int index, Object value)
- {
- Blob blob = ((Blob)value);
- switch (index) {
- case 0: return blob.getName();
- case 1: return blob.getMimeType().getBaseType();
- case 2: return blob.getBytes();
- }
- throw new IndexOutOfBoundsException();
- }
-
- public void setObject(ExecutionContext ec, Object preparedStmt, int[] exprIndex, Object value)
- {
- Blob blob = ((Blob)value);
- if (blob == null) {
- getDatastoreMapping(0).setObject(preparedStmt, exprIndex[0], null);
- getDatastoreMapping(1).setObject(preparedStmt, exprIndex[1], null);
- getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], null);
- } else {
- getDatastoreMapping(0).setString(preparedStmt, exprIndex[0], blob.getName());
- getDatastoreMapping(1).setString(preparedStmt, exprIndex[1], blob.getMimeType().getBaseType());
- getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], blob.getBytes());
- }
- }
-
- public Object getObject(ExecutionContext ec, Object resultSet, int[] exprIndex)
- {
- try
- {
- // Check for null entries
- if (getDatastoreMapping(0).getObject(resultSet, exprIndex[0]) == null)
- {
- return null;
- }
- }
- catch (Exception e)
- {
- // Do nothing
- }
-
- String name = getDatastoreMapping(0).getString(resultSet, exprIndex[0]);
- String mimeTypeBase = getDatastoreMapping(1).getString(resultSet, exprIndex[1]);
- byte[] bytes = (byte[]) getDatastoreMapping(2).getObject(resultSet,exprIndex[2]);
- return new Blob(name, mimeTypeBase, bytes);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobConverter.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobConverter.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobConverter.java
deleted file mode 100644
index 024b619..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobConverter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
-
-import org.apache.isis.applib.adapters.EncoderDecoder;
-import org.apache.isis.applib.value.Clob;
-import org.apache.isis.core.progmodel.facets.value.clobs.ClobValueSemanticsProvider;
-import org.datanucleus.store.types.converters.TypeConverter;
-
-public class IsisClobConverter implements TypeConverter<Clob, String>{
-
- private static final long serialVersionUID = 1L;
- private EncoderDecoder<Clob> encoderDecoder;
-
- public IsisClobConverter() {
- encoderDecoder = new ClobValueSemanticsProvider().getEncoderDecoder();
- }
-
- @Override
- public String toDatastoreType(Clob memberValue) {
- return encoderDecoder.toEncodedString(memberValue);
- }
-
- @Override
- public Clob toMemberType(String datastoreValue) {
- return encoderDecoder.fromEncodedString(datastoreValue);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobMapping.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobMapping.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobMapping.java
deleted file mode 100644
index 5ab97fa..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobMapping.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
-
-import org.apache.isis.applib.value.Blob;
-import org.apache.isis.applib.value.Clob;
-import org.datanucleus.ClassLoaderResolver;
-import org.datanucleus.ClassNameConstants;
-import org.datanucleus.NucleusContext;
-import org.datanucleus.metadata.AbstractMemberMetaData;
-import org.datanucleus.store.ExecutionContext;
-import org.datanucleus.store.mapped.DatastoreContainerObject;
-import org.datanucleus.store.mapped.MappedStoreManager;
-import org.datanucleus.store.mapped.mapping.SingleFieldMultiMapping;
-
-public class IsisClobMapping extends SingleFieldMultiMapping {
-
- public IsisClobMapping() {
- }
-
- @Override
- public Class<?> getJavaType() {
- return org.apache.isis.applib.value.Clob.class;
- }
-
- public void initialize(AbstractMemberMetaData mmd, DatastoreContainerObject container, ClassLoaderResolver clr)
- {
- super.initialize(mmd, container, clr);
- addDatastoreFields();
- }
-
- public void initialize(MappedStoreManager storeMgr, String type)
- {
- super.initialize(storeMgr, type);
- addDatastoreFields();
- }
-
- protected void addDatastoreFields()
- {
- addDatastoreField(ClassNameConstants.JAVA_LANG_STRING); // name
- addDatastoreField(ClassNameConstants.JAVA_LANG_STRING); // mime type
- addDatastoreField(ClassNameConstants.JAVA_LANG_CHARACTER_ARRAY); // chars
- }
-
- public Object getValueForDatastoreMapping(NucleusContext nucleusCtx, int index, Object value)
- {
- Clob clob = ((Clob)value);
- switch (index) {
- case 0: return clob.getName();
- case 1: return clob.getMimeType().getBaseType();
- case 2: return clob.getChars();
- }
- throw new IndexOutOfBoundsException();
- }
-
- public void setObject(ExecutionContext ec, Object preparedStmt, int[] exprIndex, Object value)
- {
- Clob clob = ((Clob)value);
- if (clob == null) {
- getDatastoreMapping(0).setObject(preparedStmt, exprIndex[0], null);
- getDatastoreMapping(1).setObject(preparedStmt, exprIndex[1], null);
- getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], null);
- } else {
- getDatastoreMapping(0).setString(preparedStmt, exprIndex[0], clob.getName());
- getDatastoreMapping(1).setString(preparedStmt, exprIndex[1], clob.getMimeType().getBaseType());
- getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], clob.getChars());
- }
- }
-
- public Object getObject(ExecutionContext ec, Object resultSet, int[] exprIndex)
- {
- try
- {
- // Check for null entries
- if (getDatastoreMapping(0).getObject(resultSet, exprIndex[0]) == null)
- {
- return null;
- }
- }
- catch (Exception e)
- {
- // Do nothing
- }
-
- String name = getDatastoreMapping(0).getString(resultSet, exprIndex[0]);
- String mimeTypeBase = getDatastoreMapping(1).getString(resultSet, exprIndex[1]);
- char[] chars = (char[]) getDatastoreMapping(2).getObject(resultSet,exprIndex[2]);
- return new Clob(name, mimeTypeBase, chars);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateConverter.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateConverter.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateConverter.java
deleted file mode 100644
index 4723286..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateConverter.java
+++ /dev/null
@@ -1,68 +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.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
-
-import org.apache.isis.applib.value.Date;
-import org.datanucleus.store.types.converters.TypeConverter;
-
-public class IsisDateConverter implements TypeConverter<Date, Long>{
-
- private static final long serialVersionUID = 1L;
-
- public IsisDateConverter() {
-
- }
-
-// @Override
-// public Long toLong(Date object) {
-// if(object == null) {
-// return null;
-// }
-//
-// Date d = (Date)object;
-// return d.getMillisSinceEpoch();
-// }
-//
-// @Override
-// public Date toObject(Long value) {
-// if(value == null) {
-// return null;
-// }
-// return new Date(value);
-// }
-
- @Override
- public Long toDatastoreType(Date memberValue) {
- if(memberValue == null) {
- return null;
- }
-
- Date d = (Date)memberValue;
- return d.getMillisSinceEpoch();
- }
-
- @Override
- public Date toMemberType(Long datastoreValue) {
- if(datastoreValue == null) {
- return null;
- }
- return new Date(datastoreValue);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateMapping.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateMapping.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateMapping.java
deleted file mode 100644
index 7063d2b..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateMapping.java
+++ /dev/null
@@ -1,48 +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.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
-
-import org.datanucleus.store.mapped.mapping.ObjectAsLongMapping;
-
-import org.apache.isis.applib.value.Date;
-
-public class IsisDateMapping extends ObjectAsLongMapping {
-
- private final IsisDateConverter dateConverter = new IsisDateConverter();
-
- public IsisDateMapping() {
-
- }
-
- @Override
- public Class<?> getJavaType() {
- return org.apache.isis.applib.value.Date.class;
- }
-
- @Override
- protected Long objectToLong(Object object) {
- return dateConverter.toDatastoreType((Date) object);
- }
-
- @Override
- protected Object longToObject(Long datastoreValue) {
- return dateConverter.toMemberType(datastoreValue);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeConverter.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeConverter.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeConverter.java
deleted file mode 100644
index 7e7cb29..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeConverter.java
+++ /dev/null
@@ -1,50 +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.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
-
-import org.apache.isis.applib.value.DateTime;
-import org.datanucleus.store.types.converters.TypeConverter;
-
-public class IsisDateTimeConverter implements TypeConverter<DateTime, Long>{
-
- private static final long serialVersionUID = 1L;
-
- public IsisDateTimeConverter() {
-
- }
-
- @Override
- public Long toDatastoreType(DateTime memberValue) {
- if(memberValue == null) {
- return null;
- }
-
- DateTime d = (DateTime)memberValue;
- return d.getMillisSinceEpoch();
- }
-
- @Override
- public DateTime toMemberType(Long datastoreValue) {
- if(datastoreValue == null) {
- return null;
- }
- return new DateTime(datastoreValue);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeMapping.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeMapping.java b/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeMapping.java
deleted file mode 100644
index 44d9bbf..0000000
--- a/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeMapping.java
+++ /dev/null
@@ -1,48 +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.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
-
-import org.datanucleus.store.mapped.mapping.ObjectAsLongMapping;
-
-import org.apache.isis.applib.value.DateTime;
-
-public class IsisDateTimeMapping extends ObjectAsLongMapping {
-
- private final IsisDateTimeConverter dateConverter = new IsisDateTimeConverter();
-
- public IsisDateTimeMapping() {
-
- }
-
- @Override
- public Class<?> getJavaType() {
- return org.apache.isis.applib.value.DateTime.class;
- }
-
- @Override
- protected Long objectToLong(Object object) {
- return dateConverter.toDatastoreType((DateTime) object);
- }
-
- @Override
- protected Object longToObject(Long datastoreValue) {
- return dateConverter.toMemberType(datastoreValue);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java
new file mode 100644
index 0000000..fe7a089
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java
@@ -0,0 +1,48 @@
+/*
+ * 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.objectstore.jdo.datanucleus;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
+
+public class DataNucleusPersistenceMechanismInstallerTest_getName {
+
+ private DataNucleusPersistenceMechanismInstaller installer;
+
+ @Before
+ public void setUp() throws Exception {
+ installer = new DataNucleusPersistenceMechanismInstaller();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void isSet() {
+ assertThat(installer.getName(), is("datanucleus"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java
new file mode 100644
index 0000000..44a5b46
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java
@@ -0,0 +1,62 @@
+/*
+ * 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.objectstore.jdo.datanucleus;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
+
+public class DataNucleusPersistenceMechanismInstallerTest_services {
+
+ private PrimitiveValuedEntityRepository repo = new PrimitiveValuedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void servicesBootstrapped() {
+ final List<Object> services = IsisContext.getServices();
+ assertThat(services.size(), is(1));
+ assertThat(services.get(0), is((Object)repo));
+
+ final ObjectAdapter serviceAdapter = IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(repo);
+ assertThat(serviceAdapter, is(not(nullValue())));
+
+ assertThat(serviceAdapter.getOid(), is(equalTo((Oid)RootOidDefault.create(ObjectSpecId.of("PrimitiveValuedEntities"), "1"))));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/Utils.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/Utils.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/Utils.java
new file mode 100644
index 0000000..b941c5e
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/Utils.java
@@ -0,0 +1,126 @@
+/*
+ * 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.objectstore.jdo.datanucleus;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.joda.time.LocalDate;
+import org.joda.time.LocalDateTime;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationDefault;
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore;
+import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
+
+public class Utils {
+
+ private Utils(){}
+
+ public static IsisSystemWithFixtures.Builder systemBuilder() {
+ return IsisSystemWithFixtures.builder()
+ .with(configurationForDataNucleusDb())
+ .with(new DataNucleusPersistenceMechanismInstaller());
+ }
+
+ public static IsisSystemWithFixtures.Listener listenerToDeleteFrom(final String... tables) {
+ return new IsisSystemWithFixtures.ListenerAdapter(){
+
+ @Override
+ public void postSetupSystem(boolean firstTime) throws Exception {
+ Connection connection = getConnection();
+ try {
+ final Statement statement = connection.createStatement();
+ for(String table: tables) {
+ statement.executeUpdate("DELETE FROM " + table);
+ }
+ } catch(Exception ex) {
+ connection.rollback();
+ throw ex;
+ } finally {
+ connection.commit();
+ }
+ }
+
+ private Connection getConnection() {
+ final DataNucleusObjectStore objectStore = (DataNucleusObjectStore) IsisContext.getPersistenceSession().getObjectStore();
+ return objectStore.getJavaSqlConnection();
+ }
+ };
+ }
+
+ public static IsisConfiguration configurationForDataNucleusDb() {
+ final IsisConfigurationDefault configuration = new IsisConfigurationDefault();
+ Properties props = new Properties();
+
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.PersistenceManagerFactoryClass", "org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
+
+ // last one wins!
+ configureHsqlDbFileBased(props);
+ configureForMsSqlServer(props);
+ configureHsqlDbInMemory(props);
+
+ props.put("isis.persistor.datanucleus.impl.datanucleus.autoCreateSchema", "true");
+ props.put("isis.persistor.datanucleus.impl.datanucleus.validateTables", "true");
+ props.put("isis.persistor.datanucleus.impl.datanucleus.validateConstraints", "true");
+
+ props.put("isis.persistor.datanucleus.impl.datanucleus.cache.level2.type", "none");
+
+ configuration.add(props);
+ return configuration;
+ }
+
+
+ private static void configureHsqlDbInMemory(Properties props) {
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName", "org.hsqldb.jdbcDriver");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL", "jdbc:hsqldb:mem:test");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName", "sa");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword", "");
+ }
+
+ private static void configureHsqlDbFileBased(Properties props) {
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName", "org.hsqldb.jdbcDriver");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL", "jdbc:hsqldb:file:hsql-db/test;hsqldb.write_delay=false;shutdown=true");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName", "sa");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword", "");
+ }
+
+ private static void configureForMsSqlServer(Properties props) {
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL", "jdbc:sqlserver://127.0.0.1:1433;instance=SQLEXPRESS;databaseName=jdo;");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName", "jdo");
+ props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword", "jdopass");
+ }
+
+
+
+ public static long toMillis(int year, int monthOfYear, int dayOfMonth) {
+ LocalDate d = new LocalDate(year, monthOfYear, dayOfMonth);
+ return d.toDateMidnight().getMillis();
+ }
+
+ public static long toMillis(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute) {
+ LocalDateTime d = new LocalDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute);
+ return d.toDateTime().getMillis();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.java
new file mode 100644
index 0000000..d1b175f
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.java
@@ -0,0 +1,153 @@
+/*
+ * 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.objectstore.jdo.datanucleus.persistence.spi;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.math.BigInteger;
+import java.util.Date;
+
+import org.apache.isis.applib.annotation.ObjectType;
+import org.apache.isis.core.commons.matchers.IsisMatchers;
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.objectstore.jdo.datanucleus.persistence.spi.JdoObjectIdSerializer;
+import org.datanucleus.identity.OIDImpl;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class JdoObjectIdSerializerTest {
+
+ @ObjectType("CUS")
+ public static class Customer {}
+
+ public static class CustomerRepository {
+ public void foo(Customer x) {}
+ }
+
+ @Rule
+ public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
+ .withServices(new CustomerRepository())
+ .build();
+
+
+
+ @Test
+ public void whenJavaxJdoIntIdentity() throws Exception {
+ Object jdoObjectId = new javax.jdo.identity.IntIdentity(Customer.class, 123);
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoObjectId);
+ assertThat(id, is("i_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoObjectIdRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoObjectIdRecreated, is(jdoObjectId));
+ }
+
+
+ @Test
+ public void whenJavaxJdoStringIdentity() throws Exception {
+ Object jdoObjectId = new javax.jdo.identity.StringIdentity(Customer.class, "123");
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoObjectId);
+ assertThat(id, is("s_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoObjectIdRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoObjectIdRecreated, is(jdoObjectId));
+ }
+
+
+ @Test
+ public void whenJavaxJdoLongIdentity() throws Exception {
+ Object jdoObjectId = new javax.jdo.identity.LongIdentity(Customer.class, 123L);
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoObjectId);
+ assertThat(id, is("l_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoObjectIdRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoObjectIdRecreated, is(jdoObjectId));
+ }
+
+
+ @Test
+ public void whenLong() throws Exception {
+ Object jdoOid = new OIDImpl(Customer.class.getName(), 123L);
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+ assertThat(id, is("L_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoOidRecreated, is((Object)("123"+ "[OID]" + Customer.class.getName())));
+ }
+
+ @Test
+ public void whenDataNucleusOidAndLong() throws Exception {
+ Object jdoOid = new OIDImpl(Customer.class.getName(), 123L);
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+ assertThat(id, is("L_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoOidRecreated, is((Object)("123"+ "[OID]" + Customer.class.getName())));
+ }
+
+ @Test
+ public void whenDataNucleusOidAndBigInteger() throws Exception {
+ Object jdoOid = new OIDImpl(Customer.class.getName(), new BigInteger("123"));
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+ assertThat(id, is("B_123"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoOidRecreated, is(((Object)("123"+ "[OID]" + Customer.class.getName()))));
+ }
+
+ @Test
+ public void whenDataNucleusOidAndString() throws Exception {
+ Object jdoOid = new OIDImpl(Customer.class.getName(), "456");
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+ assertThat(id, is("S_456"));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoOidRecreated, is((Object)("456" + "[OID]" + Customer.class.getName())));
+ }
+
+ @Test
+ public void whenDataNucleusOidAndOtherKeyValue() throws Exception {
+ Date key = new Date();
+ Object jdoOid = new OIDImpl(Customer.class.getName(), key);
+ String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+ assertThat(id, IsisMatchers.startsWith(OIDImpl.class.getName() + "_" + key.toString()));
+
+ RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+ Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+ assertThat(jdoOidRecreated, is((Object)(key.toString() + "[OID]" + Customer.class.getName())));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_lazyLoading.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_lazyLoading.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_lazyLoading.java
new file mode 100644
index 0000000..1110ec7
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_lazyLoading.java
@@ -0,0 +1,85 @@
+/*
+ * 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.objectstore.jdo.datanucleus.scenarios.adaptermanager;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencedEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencedEntityRepository;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencingEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencingEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Persistence_lazyLoading {
+
+ private UnidirReferencingEntityRepository referencingRepo = new UnidirReferencingEntityRepository();
+ private UnidirReferencedEntityRepository referencedRepo = new UnidirReferencedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("UNIDIRREFERENCINGENTITY"))
+ .with(Utils.listenerToDeleteFrom("UNIDIRREFERENCEDENTITY"))
+ .withServices(referencingRepo, referencedRepo)
+ .build();
+
+ @Test
+ public void lazyLoading_and_adapters() throws Exception {
+ iswf.beginTran();
+ referencedRepo.newEntity().setName("Referenced 1");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ UnidirReferencedEntity referencedEntity1 = referencedRepo.list().get(0);
+
+ UnidirReferencingEntity referencingEntity1 = referencingRepo.newEntity();
+ referencingEntity1.setName("Referencing 1");
+ referencingEntity1.setReferenced(referencedEntity1);
+
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<UnidirReferencingEntity> list = referencingRepo.list();
+ referencingEntity1 = list.get(0);
+
+ assertThat(referencingEntity1.referenced, is(nullValue())); // lazy loading
+ UnidirReferencedEntity referenced = referencingEntity1.getReferenced();
+ ObjectAdapter referencedAdapter = iswf.adapterFor(referenced);
+ assertThat(referencedAdapter.getResolveState(), is(ResolveState.RESOLVED));
+ assertThat(referenced, is(not(nullValue())));
+
+ iswf.commitTran();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_loadObject.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_loadObject.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_loadObject.java
new file mode 100644
index 0000000..2d86e48
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_loadObject.java
@@ -0,0 +1,101 @@
+/*
+ * 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.objectstore.jdo.datanucleus.scenarios.adaptermanager;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencedEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencedEntityRepository;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencingEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencingEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Persistence_loadObject {
+
+ private UnidirReferencingEntityRepository referencingRepo = new UnidirReferencingEntityRepository();
+ private UnidirReferencedEntityRepository referencedRepo = new UnidirReferencedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("UNIDIRREFERENCINGENTITY"))
+ .with(Utils.listenerToDeleteFrom("UNIDIRREFERENCEDENTITY"))
+ .withServices(referencingRepo, referencedRepo)
+ .build();
+
+
+ @Test
+ public void persist_then_update_using_persistentAdapterFor() throws Exception {
+
+ iswf.beginTran();
+ UnidirReferencedEntity referencedEntity1 = referencedRepo.newEntity();
+ referencedEntity1.setName("Referenced 1");
+ UnidirReferencedEntity referencedEntity2 = referencedRepo.newEntity();
+ referencedEntity2.setName("Referenced 2");
+
+ UnidirReferencingEntity referencingEntity1 = referencingRepo.newEntity();
+ referencingEntity1.setName("Referencing 1");
+ referencingEntity1.setReferenced(referencedEntity1);
+ UnidirReferencingEntity referencingEntity2 = referencingRepo.newEntity();
+ referencingEntity2.setName("Referencing 2");
+ referencingEntity2.setReferenced(referencedEntity1);
+ UnidirReferencingEntity referencingEntity3 = referencingRepo.newEntity();
+ referencingEntity3.setName("Referencing 3");
+ referencingEntity3.setReferenced(referencedEntity2);
+
+ iswf.commitTran();
+
+ TypedOid referencingOid2 = (TypedOid) iswf.adapterFor(referencingEntity2).getOid();
+
+ TypedOid referencedOid1 = (TypedOid) iswf.adapterFor(referencedEntity1).getOid();
+ TypedOid referencedOid2 = (TypedOid) iswf.adapterFor(referencedEntity2).getOid();
+
+
+ // when ...
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+
+ ObjectAdapter referencingAdapter2 = iswf.getPersistor().loadObject(referencingOid2);
+ referencingEntity2 = (UnidirReferencingEntity) referencingAdapter2.getObject();
+
+ UnidirReferencedEntity referenced = referencingEntity2.getReferenced();
+
+ ObjectAdapter referencedAdapter1 = iswf.getAdapterManager().adapterFor(referencedOid1);
+ assertThat(referenced, is(referencedAdapter1.getObject()));
+
+ // ...switch to refer to other
+
+ ObjectAdapter referencedAdapter2 = iswf.getAdapterManager().adapterFor(referencedOid2);
+ referencedEntity2 = (UnidirReferencedEntity) referencedAdapter2.getObject();
+
+ referencingEntity2.setReferenced(referencedEntity2);
+ iswf.commitTran();
+
+ }
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_persistentAdapterFor.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_persistentAdapterFor.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_persistentAdapterFor.java
new file mode 100644
index 0000000..d16d827
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/adaptermanager/Persistence_persistentAdapterFor.java
@@ -0,0 +1,114 @@
+/*
+ * 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.objectstore.jdo.datanucleus.scenarios.adaptermanager;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencedEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencedEntityRepository;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencingEntity;
+import org.apache.isis.core.tck.dom.refs.UnidirReferencingEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Persistence_persistentAdapterFor {
+
+ private UnidirReferencingEntityRepository referencingRepo = new UnidirReferencingEntityRepository();
+ private UnidirReferencedEntityRepository referencedRepo = new UnidirReferencedEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("UNIDIRREFERENCINGENTITY"))
+ .with(Utils.listenerToDeleteFrom("UNIDIRREFERENCEDENTITY"))
+ .withServices(referencingRepo, referencedRepo)
+ .build();
+
+
+ @Test
+ public void persist_then_update_using_persistentAdapterFor() throws Exception {
+
+ iswf.beginTran();
+ UnidirReferencedEntity referencedEntity1 = referencedRepo.newEntity();
+ referencedEntity1.setName("Referenced 1");
+ UnidirReferencedEntity referencedEntity2 = referencedRepo.newEntity();
+ referencedEntity2.setName("Referenced 2");
+
+ UnidirReferencingEntity referencingEntity1 = referencingRepo.newEntity();
+ referencingEntity1.setName("Referencing 1");
+ referencingEntity1.setReferenced(referencedEntity1);
+ UnidirReferencingEntity referencingEntity2 = referencingRepo.newEntity();
+ referencingEntity2.setName("Referencing 2");
+ referencingEntity2.setReferenced(referencedEntity1);
+ UnidirReferencingEntity referencingEntity3 = referencingRepo.newEntity();
+ referencingEntity3.setName("Referencing 3");
+ referencingEntity3.setReferenced(referencedEntity2);
+
+ iswf.commitTran();
+
+ TypedOid referencingOid2 = (TypedOid) iswf.adapterFor(referencingEntity2).getOid();
+
+ TypedOid referencedOid1 = (TypedOid) iswf.adapterFor(referencedEntity1).getOid();
+ TypedOid referencedOid2 = (TypedOid) iswf.adapterFor(referencedEntity2).getOid();
+
+
+ // when ...
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+
+ ObjectAdapter referencingAdapter2 = iswf.getAdapterManager().adapterFor(referencingOid2);
+ referencingEntity2 = (UnidirReferencingEntity) referencingAdapter2.getObject();
+
+ UnidirReferencedEntity referenced = referencingEntity2.getReferenced();
+
+ ObjectAdapter referencedAdapter1 = iswf.getAdapterManager().adapterFor(referencedOid1);
+ assertThat(referenced, is(referencedAdapter1.getObject()));
+
+ // ...switch to refer to other
+
+ ObjectAdapter referencedAdapter2 = iswf.getAdapterManager().adapterFor(referencedOid2);
+ referencedEntity2 = (UnidirReferencedEntity) referencedAdapter2.getObject();
+
+ referencingEntity2.setReferenced(referencedEntity2);
+ iswf.commitTran();
+
+ // then...
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+
+ referencingAdapter2 = iswf.getAdapterManager().adapterFor(referencingOid2);
+ referencingEntity2 = (UnidirReferencingEntity) referencingAdapter2.getObject();
+
+ referenced = referencingEntity2.getReferenced();
+
+ referencedAdapter2 = iswf.getAdapterManager().adapterFor(referencedOid2);
+
+ // ...is switched
+ assertThat(referenced, is(referencedAdapter2.getObject()));
+
+ iswf.commitTran();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithListParent.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithListParent.java b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithListParent.java
new file mode 100644
index 0000000..b618efd
--- /dev/null
+++ b/component/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/objectstore/jdo/datanucleus/scenarios/refs/Persistence_persist_bidirWithListParent.java
@@ -0,0 +1,86 @@
+/*
+ * 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.objectstore.jdo.datanucleus.scenarios.refs;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
+import org.apache.isis.core.tck.dom.refs.BidirWithListChildEntity;
+import org.apache.isis.core.tck.dom.refs.BidirWithListParentEntity;
+import org.apache.isis.core.tck.dom.refs.BidirWithListParentEntityRepository;
+import org.apache.isis.objectstore.jdo.datanucleus.Utils;
+
+public class Persistence_persist_bidirWithListParent {
+
+ private BidirWithListParentEntityRepository repo = new BidirWithListParentEntityRepository();
+
+ @Rule
+ public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+ .with(Utils.listenerToDeleteFrom("BIDIRWITHLISTCHILDeNTITY"))
+ .with(Utils.listenerToDeleteFrom("BIDIRWITHLISTPARENTENTITY"))
+ .withServices(repo)
+ .build();
+
+ @Test
+ public void persistTwoParents() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ List<BidirWithListParentEntity> list = repo.list();
+ assertThat(list.size(), is(2));
+ iswf.commitTran();
+ }
+
+ @Test
+ public void persistTwoChildrenOfParent() throws Exception {
+ iswf.beginTran();
+ repo.newEntity().setName("Parent 1");
+ repo.newEntity().setName("Parent 2");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ BidirWithListParentEntity retrievedEntity = repo.list().get(0);
+ retrievedEntity.newChild("Child 1 of Parent 1");
+ retrievedEntity.newChild("Child 2 of Parent 1");
+ retrievedEntity.newChild("Child 3 of Parent 1");
+ iswf.commitTran();
+
+ iswf.bounceSystem();
+
+ iswf.beginTran();
+ retrievedEntity = repo.list().get(0);
+ List<BidirWithListChildEntity> children = retrievedEntity.getChildren();
+ assertThat(children.size(), is(3));
+ iswf.commitTran();
+ }
+
+}