incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmatth...@apache.org
Subject svn commit: r1399269 - in /incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime: persistence/adaptermanager/AdapterManagerDefault.java system/SystemConstants.java
Date Wed, 17 Oct 2012 13:59:37 GMT
Author: rmatthews
Date: Wed Oct 17 13:59:37 2012
New Revision: 1399269

URL: http://svn.apache.org/viewvc?rev=1399269&view=rev
Log:
ISIS-234 - fixing OIDs for aggregate objects

Modified:
    incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerDefault.java
    incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/SystemConstants.java

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerDefault.java?rev=1399269&r1=1399268&r2=1399269&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerDefault.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerDefault.java
Wed Oct 17 13:59:37 2012
@@ -44,6 +44,8 @@ import org.apache.isis.core.metamodel.ad
 import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
 import org.apache.isis.core.metamodel.adapter.version.Version;
 import org.apache.isis.core.metamodel.facets.accessor.PropertyOrCollectionAccessorFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
 import org.apache.isis.core.metamodel.facets.object.aggregated.ParentedFacet;
 import org.apache.isis.core.metamodel.facets.object.value.ValueFacet;
 import org.apache.isis.core.metamodel.facets.typeof.ElementSpecificationProviderFromTypeOfFacet;
@@ -503,28 +505,46 @@ public class AdapterManagerDefault imple
             }
         }
 
+        remapContainedAggregatedObject(adapter, persistedRootOid);
+        
+        // update the adapter's state
+        adapter.changeState(ResolveState.RESOLVED);
+        
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("made persistent " + adapter + "; was " + transientRootOid);
+        }
+    }
+
+    private void remapContainedAggregatedObject(final ObjectAdapter adapter, final RootOid
persistedRootOid) {
         for (final ObjectAssociation association: adapter.getSpecification().getAssociations())
{
-            if (association.getSpecification().isParented()) {
+            if (association.isOneToManyAssociation() && !association.isNotPersisted())
{
+                final ObjectAdapter collection = association.get(adapter);
+                final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
+                for (final ObjectAdapter element : facet.iterable(collection)) {
+                   remapAggregatedObject(element, persistedRootOid);
+                }
+                
+            } else if (association.getSpecification().isParented()) {
                 final ObjectAdapter referencedAdapter = association.get(adapter);
     
                 if(referencedAdapter == null) {
                     continue;
                 }
-                final Oid oid = referencedAdapter.getOid();
-                if (oid instanceof AggregatedOid) {
-                    AggregatedOid aoid = (AggregatedOid) oid;
-                    AggregatedOid childOid = new AggregatedOid(aoid.getObjectSpecId(), persistedRootOid,
aoid.getLocalId());
-                    referencedAdapter.replaceOid(childOid);
-                }
+                remapAggregatedObject(referencedAdapter, persistedRootOid);
             }
         }
-        
-        // update the adapter's state
-        adapter.changeState(ResolveState.RESOLVED);
-        
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("made persistent " + adapter + "; was " + transientRootOid);
+    }
+
+    private void remapAggregatedObject(final ObjectAdapter adapter, final RootOid persistedRootOid)
{
+        final Oid oid = adapter.getOid();
+        if (!(oid instanceof AggregatedOid) || !oid.isTransient()) {
+                return;
         }
+        AggregatedOid aoid = (AggregatedOid) oid;
+        AggregatedOid childOid = new AggregatedOid(aoid.getObjectSpecId(), persistedRootOid,
aoid.getLocalId());
+        adapter.replaceOid(childOid);
+        
+        remapContainedAggregatedObject(adapter, persistedRootOid);
     }
 
 	private static Object getCollectionPojo(final OneToManyAssociation association, final ObjectAdapter
ownerAdapter) {

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/SystemConstants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/SystemConstants.java?rev=1399269&r1=1399268&r2=1399269&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/SystemConstants.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/SystemConstants.java
Wed Oct 17 13:59:37 2012
@@ -47,8 +47,8 @@ public final class SystemConstants {
      * <p>
      * Use {@link DeploymentType#valueOf(String)} to decode.
      */
-    public static final String DEPLOYMENT_TYPE_KEY = ConfigurationConstants.ROOT + "deploymentType";
 
+    public static final String DEPLOYMENT_TYPE_KEY = ConfigurationConstants.ROOT + "deploymentType";
     /**
      * Key used to lookup {@link SpecificationLoaderSpi specification Loader} in
      * {@link IsisConfiguration}, and root for any



Mime
View raw message