cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1201425 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/ framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/ref/ framework/cayenne-lifecyc...
Date Sun, 13 Nov 2011 13:49:36 GMT
Author: aadamchik
Date: Sun Nov 13 13:49:35 2011
New Revision: 1201425

URL: http://svn.apache.org/viewvc?rev=1201425&view=rev
Log:
CAY-1639 cayenne-lifecycle: don't call String representation of ObjectId a UUID

actually the scope of refactoring ended up being wider than what's in Jira - renaming prompted reorg
of a few packages, making everything more complact and easier to understand

Added:
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/EntityIdCoder.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/uuid/UuidCoder.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/IdCoder.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdBatchFault.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidBatchFault.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdBatchSourceItem.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidBatchSourceItem.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdFault.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidFault.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdPropagatedValueFactory.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/update/UuidPropagatedValueFactory.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationship.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationship.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipBatchFaultingStrategy.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipBatchFaultingStrategy.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipFaultingStrategy.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipFaultingStrategy.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipFilter.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipFilter.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipHandler.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipHandler.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/id/
    cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/id/EntityIdCoderTest.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/uuid/UuidCoderTest.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/id/IdCoderTest.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/ref/ReferenceableHandlerTest.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipHandlerTest.java
      - copied, changed from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipHandlerTest.java
Removed:
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/ref/
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidBatchFault.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidBatchSourceItem.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidFault.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationship.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipBatchFaultingStrategy.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipFaultingStrategy.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipFilter.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipHandler.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/update/
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/uuid/
    cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/ref/
    cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipHandlerTest.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/uuid/
Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/UuidRoot1.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/sort/WeightedAshwoodEntitySorterTest.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1201425&r1=1201424&r2=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Sun Nov 13 13:49:35 2011
@@ -18,6 +18,7 @@ CAY-1608 Implement constructor injection
 CAY-1618 Create database adapters instances with proper injection
 CAY-1637 [PATCH] DataContextFactory is cumbersome to customize
 CAY-1638 [PATCH] Can't disable validation for CayenneContext
+CAY-1639 cayenne-lifecycle: don't call String representation of ObjectId a UUID
 
 Bug Fixes Since 3.1M3:
 

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/EntityIdCoder.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/uuid/UuidCoder.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/EntityIdCoder.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/EntityIdCoder.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/uuid/UuidCoder.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/uuid/UuidCoder.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/EntityIdCoder.java Sun Nov 13 13:49:35 2011
@@ -16,7 +16,7 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.lifecycle.uuid;
+package org.apache.cayenne.lifecycle.id;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
@@ -37,11 +37,11 @@ import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.util.Util;
 
 /**
- * An object to encode/decode persistent objects UUIDs.
+ * An object to encode/decode ObjectIds for a single mapped entity.
  * 
  * @since 3.1
  */
-public class UuidCoder {
+public class EntityIdCoder {
 
     static final String UUID_SEPARATOR = ":";
 
@@ -49,24 +49,25 @@ public class UuidCoder {
     private SortedMap<String, Converter> converters;
     private int idSize;
 
-    public static String getEntityName(String uuid) {
-        int separator = uuid.indexOf(UUID_SEPARATOR);
-        if (separator <= 0 || separator == uuid.length() - 1) {
-            throw new IllegalArgumentException("Invalid uuid: " + uuid);
+    public static String getEntityName(String id) {
+        int separator = id.indexOf(UUID_SEPARATOR);
+        if (separator <= 0 || separator == id.length() - 1) {
+            throw new IllegalArgumentException("Invalid uuid: " + id);
         }
 
-        return uuid.substring(0, separator);
+        return id.substring(0, separator);
     }
 
-    public UuidCoder(ObjEntity entity) {
+    public EntityIdCoder(ObjEntity entity) {
 
         this.entityName = entity.getName();
         this.converters = new TreeMap<String, Converter>();
 
         for (ObjAttribute attribute : entity.getAttributes()) {
             if (attribute.isPrimaryKey()) {
-                converters.put(attribute.getDbAttributeName(), create(attribute
-                        .getJavaClass()));
+                converters.put(
+                        attribute.getDbAttributeName(),
+                        create(attribute.getJavaClass()));
             }
         }
 
@@ -92,7 +93,10 @@ public class UuidCoder {
         this.idSize = (int) Math.ceil(converters.size() / 0.75d);
     }
 
-    public String toUuid(ObjectId id) {
+    /**
+     * Returns a consistent String representation of the ObjectId
+     */
+    public String toStringId(ObjectId id) {
 
         if (id.isTemporary() && !id.isReplacementIdAttached()) {
             throw new IllegalArgumentException(

Added: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/IdCoder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/IdCoder.java?rev=1201425&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/IdCoder.java (added)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/IdCoder.java Sun Nov 13 13:49:35 2011
@@ -0,0 +1,87 @@
+/*****************************************************************
+ *   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.cayenne.lifecycle.id;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.Persistent;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.ObjEntity;
+
+/**
+ * An object to encode/decode ObjectIds for all entities found in a mapping namespace.
+ * 
+ * @since 3.1
+ */
+public class IdCoder {
+
+    protected EntityResolver entityResolver;
+    protected Map<String, EntityIdCoder> coders;
+
+    public IdCoder(EntityResolver entityResolver) {
+        this.entityResolver = entityResolver;
+        this.coders = new ConcurrentHashMap<String, EntityIdCoder>();
+    }
+
+    /**
+     * Returns an ObjectId for a given String ID.
+     */
+    public ObjectId getObjectId(String id) {
+
+        String entityName = EntityIdCoder.getEntityName(id);
+        EntityIdCoder coder = getCoder(entityName);
+        return coder.toObjectId(id);
+    }
+
+    public String getStringId(Persistent referenceable) {
+
+        if (referenceable == null) {
+            throw new NullPointerException("Null object");
+        }
+
+        ObjectId id = referenceable.getObjectId();
+
+        EntityIdCoder coder = getCoder(id.getEntityName());
+        return coder.toStringId(id);
+    }
+
+    protected EntityIdCoder getCoder(String entityName) {
+        EntityIdCoder coder = coders.get(entityName);
+        if (coder == null) {
+
+            coder = createCoder(entityName);
+            coders.put(entityName, coder);
+        }
+
+        return coder;
+    }
+
+    protected EntityIdCoder createCoder(String entityName) {
+        ObjEntity entity = entityResolver.getObjEntity(entityName);
+        if (entity == null) {
+            throw new IllegalArgumentException("Entity '"
+                    + entityName
+                    + "' is not mapped");
+        }
+
+        return new EntityIdCoder(entity);
+    }
+}

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdBatchFault.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidBatchFault.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdBatchFault.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdBatchFault.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidBatchFault.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidBatchFault.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdBatchFault.java Sun Nov 13 13:49:35 2011
@@ -29,24 +29,25 @@ import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.lifecycle.uuid.UuidCoder;
+import org.apache.cayenne.lifecycle.id.EntityIdCoder;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.SelectQuery;
 
 /**
- * Provides lazy faulting functionality for a map of objects identified by UUID.
+ * Provides lazy faulting functionality for a map of objects identified by String
+ * ObjectId.
  * 
  * @since 3.1
  */
-class UuidBatchFault {
+class ObjectIdBatchFault {
 
     private ObjectContext context;
-    private List<UuidBatchSourceItem> sources;
+    private List<ObjectIdBatchSourceItem> sources;
     private volatile Map<String, Object> resolved;
 
-    UuidBatchFault(ObjectContext context, List<UuidBatchSourceItem> sources) {
+    ObjectIdBatchFault(ObjectContext context, List<ObjectIdBatchSourceItem> sources) {
         this.context = context;
         this.sources = sources;
     }
@@ -77,11 +78,11 @@ class UuidBatchFault {
         // simple case of one query, handle it separately for performance reasons
         if (sources.size() == 1) {
 
-            String uuid = sources.get(0).getUuid();
-            String entityName = UuidCoder.getEntityName(uuid);
+            String uuid = sources.get(0).getId();
+            String entityName = EntityIdCoder.getEntityName(uuid);
 
             ObjEntity entity = resolver.getObjEntity(entityName);
-            ObjectId id = new UuidCoder(entity).toObjectId(uuid);
+            ObjectId id = new EntityIdCoder(entity).toObjectId(uuid);
 
             Object object = Cayenne.objectForQuery(context, new ObjectIdQuery(id));
             if (object == null) {
@@ -93,17 +94,17 @@ class UuidBatchFault {
         }
 
         Map<String, SelectQuery> queriesByEntity = new HashMap<String, SelectQuery>();
-        Map<String, UuidCoder> codersByEntity = new HashMap<String, UuidCoder>();
+        Map<String, EntityIdCoder> codersByEntity = new HashMap<String, EntityIdCoder>();
 
-        for (UuidBatchSourceItem source : sources) {
+        for (ObjectIdBatchSourceItem source : sources) {
 
-            String uuid = source.getUuid();
-            String entityName = UuidCoder.getEntityName(uuid);
-            UuidCoder coder = codersByEntity.get(entityName);
+            String uuid = source.getId();
+            String entityName = EntityIdCoder.getEntityName(uuid);
+            EntityIdCoder coder = codersByEntity.get(entityName);
             SelectQuery query;
 
             if (coder == null) {
-                coder = new UuidCoder(resolver.getObjEntity(entityName));
+                coder = new EntityIdCoder(resolver.getObjEntity(entityName));
                 codersByEntity.put(entityName, coder);
 
                 query = new SelectQuery(entityName);
@@ -125,10 +126,10 @@ class UuidBatchFault {
 
         for (SelectQuery query : queriesByEntity.values()) {
 
-            UuidCoder coder = codersByEntity.get(query.getRoot());
+            EntityIdCoder coder = codersByEntity.get(query.getRoot());
             List<DataObject> objects = context.performQuery(query);
             for (DataObject object : objects) {
-                String uuid = coder.toUuid(object.getObjectId());
+                String uuid = coder.toStringId(object.getObjectId());
                 results.put(uuid, object);
             }
         }

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdBatchSourceItem.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidBatchSourceItem.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdBatchSourceItem.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdBatchSourceItem.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidBatchSourceItem.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidBatchSourceItem.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdBatchSourceItem.java Sun Nov 13 13:49:35 2011
@@ -20,27 +20,27 @@ package org.apache.cayenne.lifecycle.rel
 
 import org.apache.cayenne.DataObject;
 
-final class UuidBatchSourceItem {
+final class ObjectIdBatchSourceItem {
 
     private final DataObject object;
-    private final String uuid;
-    private final String uuidRelationship;
+    private final String id;
+    private final String objectIdRelationship;
 
-    UuidBatchSourceItem(DataObject object, String uuid, String uuidRelationship) {
+    ObjectIdBatchSourceItem(DataObject object, String id, String objectIdRelationship) {
         this.object = object;
-        this.uuid = uuid;
-        this.uuidRelationship = uuidRelationship;
+        this.id = id;
+        this.objectIdRelationship = objectIdRelationship;
     }
 
     DataObject getObject() {
         return object;
     }
 
-    String getUuidRelationship() {
-        return uuidRelationship;
+    String getObjectIdRelationship() {
+        return objectIdRelationship;
     }
 
-    String getUuid() {
-        return uuid;
+    String getId() {
+        return id;
     }
 }

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdFault.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidFault.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdFault.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdFault.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidFault.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidFault.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdFault.java Sun Nov 13 13:49:35 2011
@@ -24,18 +24,18 @@ import org.apache.cayenne.Persistent;
 /**
  * @since 3.1
  */
-class UuidFault extends Fault {
+class ObjectIdFault extends Fault {
 
-    private String uuid;
-    private UuidBatchFault batchFault;
+    private String id;
+    private ObjectIdBatchFault batchFault;
 
-    UuidFault(UuidBatchFault batchFault, String uuid) {
+    ObjectIdFault(ObjectIdBatchFault batchFault, String id) {
         this.batchFault = batchFault;
-        this.uuid = uuid;
+        this.id = id;
     }
 
     @Override
     public Object resolveFault(Persistent sourceObject, String relationshipName) {
-        return uuid != null ? batchFault.getObjects().get(uuid) : null;
+        return id != null ? batchFault.getObjects().get(id) : null;
     }
 }

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdPropagatedValueFactory.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/update/UuidPropagatedValueFactory.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdPropagatedValueFactory.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdPropagatedValueFactory.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/update/UuidPropagatedValueFactory.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/update/UuidPropagatedValueFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdPropagatedValueFactory.java Sun Nov 13 13:49:35 2011
@@ -16,25 +16,26 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.lifecycle.relationship.update;
+package org.apache.cayenne.lifecycle.relationship;
 
-import org.apache.cayenne.lifecycle.ref.ReferenceableHandler;
+import org.apache.cayenne.Persistent;
+import org.apache.cayenne.lifecycle.id.IdCoder;
 import org.apache.commons.collections.Factory;
 
 /**
  * @since 3.1
  */
-public class UuidPropagatedValueFactory implements Factory {
+class ObjectIdPropagatedValueFactory implements Factory {
 
-    private ReferenceableHandler referenceableHandler;
-    private Object to;
+    private IdCoder referenceableHandler;
+    private Persistent to;
 
-    public UuidPropagatedValueFactory(ReferenceableHandler referenceableHandler, Object to) {
+    ObjectIdPropagatedValueFactory(IdCoder referenceableHandler, Persistent to) {
         this.referenceableHandler = referenceableHandler;
         this.to = to;
     }
 
     public Object create() {
-        return referenceableHandler.getUuid(to);
+        return referenceableHandler.getStringId(to);
     }
 }

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationship.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationship.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationship.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationship.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationship.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationship.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationship.java Sun Nov 13 13:49:35 2011
@@ -26,18 +26,19 @@ import java.lang.annotation.RetentionPol
 import java.lang.annotation.Target;
 
 /**
- * Defines a "virtual" read-only to-one relationship based on an FK that is a UUID. This
- * way a related object can be of any entity type.
+ * Defines a "virtual" read-only to-one relationship based on an FK that is a character
+ * representation of Cayenne ObjectId. A target object of this relationship can be of any
+ * entity type. 
  * 
  * @since 3.1
  */
-@Target( {
+@Target({
     ElementType.TYPE
 })
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
 @Inherited
-public @interface UuidRelationship {
+public @interface ObjectIdRelationship {
 
     /**
      * Returns the name of the property of the source entity of the relationship that

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipBatchFaultingStrategy.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipBatchFaultingStrategy.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipBatchFaultingStrategy.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipBatchFaultingStrategy.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipBatchFaultingStrategy.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipBatchFaultingStrategy.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipBatchFaultingStrategy.java Sun Nov 13 13:49:35 2011
@@ -24,67 +24,67 @@ import java.util.List;
 import org.apache.cayenne.DataObject;
 
 /**
- * A faulting strategy that does batch-faulting of related objects whenever a first UUID
- * relationship is accessed.
+ * A faulting strategy that does batch-faulting of related objects whenever a first
+ * ObjectId relationship is accessed.
  * 
  * @since 3.1
  */
-public class UuidRelationshipBatchFaultingStrategy implements
-        UuidRelationshipFaultingStrategy {
+public class ObjectIdRelationshipBatchFaultingStrategy implements
+        ObjectIdRelationshipFaultingStrategy {
 
-    private ThreadLocal<List<UuidBatchSourceItem>> batchSources;
+    private ThreadLocal<List<ObjectIdBatchSourceItem>> batchSources;
 
-    public UuidRelationshipBatchFaultingStrategy() {
-        this.batchSources = new ThreadLocal<List<UuidBatchSourceItem>>();
+    public ObjectIdRelationshipBatchFaultingStrategy() {
+        this.batchSources = new ThreadLocal<List<ObjectIdBatchSourceItem>>();
     }
 
     public void afterObjectLoaded(DataObject object) {
 
-        String uuidProperty = uuidPropertyName(object);
-        String uuidRelationship = uuidRelationshipName(uuidProperty);
+        String uuidProperty = objectIdPropertyName(object);
+        String uuidRelationship = objectIdRelationshipName(uuidProperty);
         String uuid = (String) object.readProperty(uuidProperty);
         if (uuid == null) {
             object.writePropertyDirectly(uuidRelationship, null);
         }
         else {
-            List<UuidBatchSourceItem> sources = batchSources.get();
+            List<ObjectIdBatchSourceItem> sources = batchSources.get();
 
             if (sources == null) {
-                sources = new ArrayList<UuidBatchSourceItem>();
+                sources = new ArrayList<ObjectIdBatchSourceItem>();
                 batchSources.set(sources);
             }
 
-            sources.add(new UuidBatchSourceItem(object, uuid, uuidRelationship));
+            sources.add(new ObjectIdBatchSourceItem(object, uuid, uuidRelationship));
         }
     }
 
     public void afterQuery() {
 
-        List<UuidBatchSourceItem> sources = batchSources.get();
+        List<ObjectIdBatchSourceItem> sources = batchSources.get();
         if (sources != null) {
             batchSources.set(null);
 
-            UuidBatchFault batchFault = new UuidBatchFault(sources
+            ObjectIdBatchFault batchFault = new ObjectIdBatchFault(sources
                     .get(0)
                     .getObject()
                     .getObjectContext(), sources);
 
-            for (UuidBatchSourceItem source : sources) {
+            for (ObjectIdBatchSourceItem source : sources) {
                 source.getObject().writePropertyDirectly(
-                        source.getUuidRelationship(),
-                        new UuidFault(batchFault, source.getUuid()));
+                        source.getObjectIdRelationship(),
+                        new ObjectIdFault(batchFault, source.getId()));
             }
         }
     }
 
-    String uuidRelationshipName(String uuidPropertyName) {
+    String objectIdRelationshipName(String uuidPropertyName) {
         return "cay:related:" + uuidPropertyName;
     }
 
-    String uuidPropertyName(DataObject object) {
+    String objectIdPropertyName(DataObject object) {
 
-        UuidRelationship annotation = object.getClass().getAnnotation(
-                UuidRelationship.class);
+        ObjectIdRelationship annotation = object.getClass().getAnnotation(
+                ObjectIdRelationship.class);
 
         if (annotation == null) {
             throw new IllegalArgumentException(

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipFaultingStrategy.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipFaultingStrategy.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipFaultingStrategy.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipFaultingStrategy.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipFaultingStrategy.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipFaultingStrategy.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipFaultingStrategy.java Sun Nov 13 13:49:35 2011
@@ -21,11 +21,11 @@ package org.apache.cayenne.lifecycle.rel
 import org.apache.cayenne.DataObject;
 
 /**
- * An abstract strategy for resolving UUID relationships.
+ * An abstract strategy for resolving ObjectId relationships.
  * 
  * @since 3.1
  */
-public interface UuidRelationshipFaultingStrategy {
+public interface ObjectIdRelationshipFaultingStrategy {
 
     void afterObjectLoaded(DataObject object);
 

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipFilter.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipFilter.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipFilter.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipFilter.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipFilter.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipFilter.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipFilter.java Sun Nov 13 13:49:35 2011
@@ -18,8 +18,6 @@
  ****************************************************************/
 package org.apache.cayenne.lifecycle.relationship;
 
-import java.util.Collections;
-
 import org.apache.cayenne.DataChannel;
 import org.apache.cayenne.DataChannelFilter;
 import org.apache.cayenne.DataChannelFilterChain;
@@ -30,48 +28,23 @@ import org.apache.cayenne.annotation.Pos
 import org.apache.cayenne.annotation.PostPersist;
 import org.apache.cayenne.annotation.PostUpdate;
 import org.apache.cayenne.graph.GraphDiff;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.query.Query;
 
 /**
- * A {@link DataChannelFilter} that implements UUID relationships read functionality.
+ * A {@link DataChannelFilter} that implements ObjectId relationships read functionality.
  * 
  * @since 3.1
  */
-public class UuidRelationshipFilter implements DataChannelFilter {
+public class ObjectIdRelationshipFilter implements DataChannelFilter {
 
-    private UuidRelationshipFaultingStrategy faultingStrategy;
+    private ObjectIdRelationshipFaultingStrategy faultingStrategy;
 
     public void init(DataChannel channel) {
         this.faultingStrategy = createFaultingStrategy();
-        registerUuidRelationships(channel);
-    }
-
-    protected void registerUuidRelationships(DataChannel channel) {
-
-        // TODO: create a DI-managed chain of mapping post processors, and extract this
-        // code to a UuidRelationshipModule. The following code in DataDomainProvider
-        // should be in the standard chain, and this method code - in an extension
-        // dataDomain.getEntityResolver().applyDBLayerDefaults();
-        // dataDomain.getEntityResolver().applyObjectLayerDefaults();
-
-        EntityResolver resolver = channel.getEntityResolver();
-        for (ObjEntity entity : resolver.getObjEntities()) {
-
-            Class<?> type = resolver
-                    .getClassDescriptor(entity.getName())
-                    .getObjectClass();
-            
-            UuidRelationship a = type.getAnnotation(UuidRelationship.class);
-            if(a != null) {
-                
-            }
-        }
     }
 
-    protected UuidRelationshipFaultingStrategy createFaultingStrategy() {
-        return new UuidRelationshipBatchFaultingStrategy();
+    protected ObjectIdRelationshipFaultingStrategy createFaultingStrategy() {
+        return new ObjectIdRelationshipBatchFaultingStrategy();
     }
 
     public GraphDiff onSync(
@@ -96,8 +69,8 @@ public class UuidRelationshipFilter impl
         }
     }
 
-    @PostUpdate(entityAnnotations = UuidRelationship.class)
-    @PostPersist(entityAnnotations = UuidRelationship.class)
+    @PostUpdate(entityAnnotations = ObjectIdRelationship.class)
+    @PostPersist(entityAnnotations = ObjectIdRelationship.class)
     void postCommit(DataObject object) {
         // invalidate after commit to ensure UUID property is re-read...
         object.getObjectContext().invalidateObjects(object);
@@ -107,7 +80,7 @@ public class UuidRelationshipFilter impl
      * A lifecycle callback method that delegates object post load event processing to the
      * underlying faulting strategy.
      */
-    @PostLoad(entityAnnotations = UuidRelationship.class)
+    @PostLoad(entityAnnotations = ObjectIdRelationship.class)
     void postLoad(DataObject object) {
         faultingStrategy.afterObjectLoaded(object);
     }

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipHandler.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipHandler.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipHandler.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipHandler.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipHandler.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipHandler.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipHandler.java Sun Nov 13 13:49:35 2011
@@ -19,28 +19,27 @@
 package org.apache.cayenne.lifecycle.relationship;
 
 import org.apache.cayenne.DataObject;
-import org.apache.cayenne.lifecycle.ref.ReferenceableHandler;
-import org.apache.cayenne.lifecycle.relationship.update.UuidPropagatedValueFactory;
+import org.apache.cayenne.lifecycle.id.IdCoder;
 
 /**
  * @since 3.1
  */
-public class UuidRelationshipHandler {
+public class ObjectIdRelationshipHandler {
 
-    protected ReferenceableHandler referenceableHandler;
+    protected IdCoder referenceableHandler;
 
-    public UuidRelationshipHandler(ReferenceableHandler referenceableHandler) {
+    public ObjectIdRelationshipHandler(IdCoder referenceableHandler) {
         this.referenceableHandler = referenceableHandler;
     }
 
-    public String uuidRelationshipName(String uuidPropertyName) {
+    public String objectIdRelationshipName(String uuidPropertyName) {
         return "cay:related:" + uuidPropertyName;
     }
 
-    public String uuidPropertyName(DataObject object) {
+    public String objectIdPropertyName(DataObject object) {
 
-        UuidRelationship annotation = object.getClass().getAnnotation(
-                UuidRelationship.class);
+        ObjectIdRelationship annotation = object.getClass().getAnnotation(
+                ObjectIdRelationship.class);
 
         if (annotation == null) {
             throw new IllegalArgumentException(
@@ -55,8 +54,8 @@ public class UuidRelationshipHandler {
     }
 
     /**
-     * Establishes a UUID relationship between two objects. Objects must be registered in
-     * the same ObjectContext. "from" argument is the object annotated with
+     * Establishes an ObjectId relationship between two objects. Objects must be
+     * registered in the same ObjectContext. "from" argument is the object annotated with
      * UuidRelationship. Second argument can optionally be null.
      */
     public void relate(DataObject from, DataObject to) {
@@ -65,8 +64,8 @@ public class UuidRelationshipHandler {
             throw new IllegalArgumentException("'from' has null ObjectContext");
         }
 
-        String property = uuidPropertyName(from);
-        String relationship = uuidRelationshipName(property);
+        String property = objectIdPropertyName(from);
+        String relationship = objectIdRelationshipName(property);
 
         if (to != null) {
             if (to.getObjectContext() == null) {
@@ -83,13 +82,13 @@ public class UuidRelationshipHandler {
             if (to.getObjectId().isTemporary()
                     && !to.getObjectId().isReplacementIdAttached()) {
 
-                // defer UUID resolving till commit
-                from.writeProperty(property, new UuidPropagatedValueFactory(
+                // defer ObjectId resolving till commit
+                from.writeProperty(property, new ObjectIdPropagatedValueFactory(
                         referenceableHandler,
                         to));
             }
             else {
-                String uuid = referenceableHandler.getUuid(to);
+                String uuid = referenceableHandler.getStringId(to);
                 from.writeProperty(property, uuid);
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/UuidRoot1.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/UuidRoot1.java?rev=1201425&r1=1201424&r2=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/UuidRoot1.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/UuidRoot1.java Sun Nov 13 13:49:35 2011
@@ -1,9 +1,9 @@
 package org.apache.cayenne.lifecycle.db;
 
 import org.apache.cayenne.lifecycle.db.auto._UuidRoot1;
-import org.apache.cayenne.lifecycle.relationship.UuidRelationship;
+import org.apache.cayenne.lifecycle.relationship.ObjectIdRelationship;
 
-@UuidRelationship(_UuidRoot1.UUID_PROPERTY)
+@ObjectIdRelationship(_UuidRoot1.UUID_PROPERTY)
 public class UuidRoot1 extends _UuidRoot1 {
 
 }

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/id/EntityIdCoderTest.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/uuid/UuidCoderTest.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/id/EntityIdCoderTest.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/id/EntityIdCoderTest.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/uuid/UuidCoderTest.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/uuid/UuidCoderTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/id/EntityIdCoderTest.java Sun Nov 13 13:49:35 2011
@@ -16,7 +16,7 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.lifecycle.uuid;
+package org.apache.cayenne.lifecycle.id;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -28,12 +28,12 @@ import java.util.Map;
 import junit.framework.TestCase;
 
 import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.lifecycle.uuid.UuidCoder;
+import org.apache.cayenne.lifecycle.id.EntityIdCoder;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 
-public class UuidCoderTest extends TestCase {
+public class EntityIdCoderTest extends TestCase {
 
     public void testSingleIntPk() {
         DbEntity dbEntity = new DbEntity("X");
@@ -49,8 +49,8 @@ public class UuidCoderTest extends TestC
 
         ObjectId id = new ObjectId("x", "ID", 3);
 
-        UuidCoder coder = new UuidCoder(entity);
-        assertEquals("x:3", coder.toUuid(id));
+        EntityIdCoder coder = new EntityIdCoder(entity);
+        assertEquals("x:3", coder.toStringId(id));
 
         ObjectId parsedId = coder.toObjectId("x:3");
         assertEquals(id, parsedId);
@@ -70,8 +70,8 @@ public class UuidCoderTest extends TestC
 
         ObjectId id = new ObjectId("x", "ID", 3l);
 
-        UuidCoder coder = new UuidCoder(entity);
-        assertEquals("x:3", coder.toUuid(id));
+        EntityIdCoder coder = new EntityIdCoder(entity);
+        assertEquals("x:3", coder.toStringId(id));
 
         ObjectId parsedId = coder.toObjectId("x:3");
         assertEquals(id, parsedId);
@@ -89,10 +89,10 @@ public class UuidCoderTest extends TestC
         when(entity.getDbEntityName()).thenReturn(dbEntity.getName());
         when(entity.getDbEntity()).thenReturn(dbEntity);
 
-        UuidCoder coder = new UuidCoder(entity);
+        EntityIdCoder coder = new EntityIdCoder(entity);
 
         ObjectId id = new ObjectId("x", "ID", "AbC");
-        assertEquals("x:AbC", coder.toUuid(id));
+        assertEquals("x:AbC", coder.toStringId(id));
 
         ObjectId parsedId = coder.toObjectId("x:AbC");
         assertEquals(id, parsedId);
@@ -110,10 +110,10 @@ public class UuidCoderTest extends TestC
         when(entity.getDbEntityName()).thenReturn(dbEntity.getName());
         when(entity.getDbEntity()).thenReturn(dbEntity);
 
-        UuidCoder coder = new UuidCoder(entity);
+        EntityIdCoder coder = new EntityIdCoder(entity);
 
         ObjectId id = new ObjectId("x", "ID", "Ab:C");
-        assertEquals("x:Ab%3AC", coder.toUuid(id));
+        assertEquals("x:Ab%3AC", coder.toStringId(id));
 
         ObjectId parsedId = coder.toObjectId("x:Ab%3AC");
         assertEquals(id, parsedId);
@@ -141,14 +141,14 @@ public class UuidCoderTest extends TestC
         when(entity.getDbEntityName()).thenReturn(dbEntity.getName());
         when(entity.getDbEntity()).thenReturn(dbEntity);
 
-        UuidCoder coder = new UuidCoder(entity);
+        EntityIdCoder coder = new EntityIdCoder(entity);
 
         Map<String, Object> idMap = new HashMap<String, Object>();
         idMap.put("ID", "X;Y");
         idMap.put("ABC", 6783463l);
         idMap.put("ZZZ", "'_'");
         ObjectId id = new ObjectId("x", idMap);
-        assertEquals("x:6783463:X%3BY:%27_%27", coder.toUuid(id));
+        assertEquals("x:6783463:X%3BY:%27_%27", coder.toStringId(id));
 
         ObjectId parsedId = coder.toObjectId("x:6783463:X%3BY:%27_%27");
         assertEquals(id, parsedId);

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/id/IdCoderTest.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/ref/ReferenceableHandlerTest.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/id/IdCoderTest.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/id/IdCoderTest.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/ref/ReferenceableHandlerTest.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/ref/ReferenceableHandlerTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/id/IdCoderTest.java Sun Nov 13 13:49:35 2011
@@ -16,15 +16,16 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.lifecycle.ref;
+package org.apache.cayenne.lifecycle.id;
 
 import junit.framework.TestCase;
 
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.configuration.server.ServerRuntime;
 import org.apache.cayenne.lifecycle.db.E1;
+import org.apache.cayenne.lifecycle.id.IdCoder;
 
-public class ReferenceableHandlerTest extends TestCase {
+public class IdCoderTest extends TestCase {
 
     private ServerRuntime runtime;
 
@@ -38,41 +39,35 @@ public class ReferenceableHandlerTest ex
         runtime.shutdown();
     }
 
-    public void testGetUuid() {
-        ReferenceableHandler handler = new ReferenceableHandler(runtime
-                .getChannel()
-                .getEntityResolver());
+    public void testGetStringId() {
+        IdCoder handler = new IdCoder(runtime.getChannel().getEntityResolver());
 
         E1 e1 = new E1();
         e1.setObjectId(new ObjectId("E1", "ID", 5));
-        assertEquals("E1:5", handler.getUuid(e1));
+        assertEquals("E1:5", handler.getStringId(e1));
     }
 
-    public void testGetUuid_TempException() {
-        ReferenceableHandler handler = new ReferenceableHandler(runtime
-                .getChannel()
-                .getEntityResolver());
+    public void testGetStringId_TempException() {
+        IdCoder handler = new IdCoder(runtime.getChannel().getEntityResolver());
 
         E1 e1 = new E1();
         e1.setObjectId(new ObjectId("E1"));
 
         try {
-            handler.getUuid(e1);
+            handler.getStringId(e1);
         }
         catch (IllegalArgumentException e) {
             // expected
         }
     }
 
-    public void testGetUuid_TempWithReplacement() {
-        ReferenceableHandler handler = new ReferenceableHandler(runtime
-                .getChannel()
-                .getEntityResolver());
+    public void testGetSringId_TempWithReplacement() {
+        IdCoder handler = new IdCoder(runtime.getChannel().getEntityResolver());
 
         E1 e1 = new E1();
         e1.setObjectId(new ObjectId("E1"));
         e1.getObjectId().getReplacementIdMap().put("ID", 6);
 
-        assertEquals("E1:6", handler.getUuid(e1));
+        assertEquals("E1:6", handler.getStringId(e1));
     }
 }

Copied: cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipHandlerTest.java (from r1196974, cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipHandlerTest.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipHandlerTest.java?p2=cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipHandlerTest.java&p1=cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipHandlerTest.java&r1=1196974&r2=1201425&rev=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/relationship/UuidRelationshipHandlerTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/relationship/ObjectIdRelationshipHandlerTest.java Sun Nov 13 13:49:35 2011
@@ -25,12 +25,12 @@ import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.configuration.server.ServerRuntime;
 import org.apache.cayenne.lifecycle.db.E1;
 import org.apache.cayenne.lifecycle.db.UuidRoot1;
-import org.apache.cayenne.lifecycle.ref.ReferenceableHandler;
+import org.apache.cayenne.lifecycle.id.IdCoder;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.test.jdbc.TableHelper;
 
-public class UuidRelationshipHandlerTest extends TestCase {
+public class ObjectIdRelationshipHandlerTest extends TestCase {
 
     private ServerRuntime runtime;
 
@@ -42,7 +42,7 @@ public class UuidRelationshipHandlerTest
         runtime = new ServerRuntime("cayenne-lifecycle.xml");
 
         // a filter is required to invalidate root objects after commit
-        UuidRelationshipFilter filter = new UuidRelationshipFilter();
+        ObjectIdRelationshipFilter filter = new ObjectIdRelationshipFilter();
         runtime.getDataDomain().addFilter(filter);
         runtime.getDataDomain().getEntityResolver().getCallbackRegistry().addListener(
                 filter);
@@ -70,9 +70,9 @@ public class UuidRelationshipHandlerTest
 
         UuidRoot1 r1 = context.newObject(UuidRoot1.class);
 
-        ReferenceableHandler refHandler = new ReferenceableHandler(context
+        IdCoder refHandler = new IdCoder(context
                 .getEntityResolver());
-        UuidRelationshipHandler handler = new UuidRelationshipHandler(refHandler);
+        ObjectIdRelationshipHandler handler = new ObjectIdRelationshipHandler(refHandler);
         handler.relate(r1, e1);
 
         assertEquals("E1:1", r1.getUuid());
@@ -91,9 +91,9 @@ public class UuidRelationshipHandlerTest
 
         UuidRoot1 r1 = context.newObject(UuidRoot1.class);
 
-        ReferenceableHandler refHandler = new ReferenceableHandler(context
+        IdCoder refHandler = new IdCoder(context
                 .getEntityResolver());
-        UuidRelationshipHandler handler = new UuidRelationshipHandler(refHandler);
+        ObjectIdRelationshipHandler handler = new ObjectIdRelationshipHandler(refHandler);
         handler.relate(r1, e1);
 
         assertSame(e1, r1.readPropertyDirectly("cay:related:uuid"));
@@ -119,9 +119,9 @@ public class UuidRelationshipHandlerTest
 
         E1 e1 = context.newObject(E1.class);
 
-        ReferenceableHandler refHandler = new ReferenceableHandler(context
+        IdCoder refHandler = new IdCoder(context
                 .getEntityResolver());
-        UuidRelationshipHandler handler = new UuidRelationshipHandler(refHandler);
+        ObjectIdRelationshipHandler handler = new ObjectIdRelationshipHandler(refHandler);
         handler.relate(r1, e1);
 
         assertSame(e1, r1.readPropertyDirectly("cay:related:uuid"));

Modified: cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/sort/WeightedAshwoodEntitySorterTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/sort/WeightedAshwoodEntitySorterTest.java?rev=1201425&r1=1201424&r2=1201425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/sort/WeightedAshwoodEntitySorterTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/sort/WeightedAshwoodEntitySorterTest.java Sun Nov 13 13:49:35 2011
@@ -24,7 +24,7 @@ import java.util.List;
 import junit.framework.TestCase;
 
 import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.lifecycle.relationship.UuidRelationshipFilter;
+import org.apache.cayenne.lifecycle.relationship.ObjectIdRelationshipFilter;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.EntityResolver;
 
@@ -38,7 +38,7 @@ public class WeightedAshwoodEntitySorter
         runtime = new ServerRuntime("cayenne-lifecycle.xml");
 
         // a filter is required to invalidate root objects after commit
-        UuidRelationshipFilter filter = new UuidRelationshipFilter();
+        ObjectIdRelationshipFilter filter = new ObjectIdRelationshipFilter();
         runtime.getDataDomain().addFilter(filter);
         runtime.getDataDomain().getEntityResolver().getCallbackRegistry().addListener(
                 filter);



Mime
View raw message