cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r578796 - /cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoModel.java
Date Mon, 24 Sep 2007 13:02:00 GMT
Author: aadamchik
Date: Mon Sep 24 06:01:59 2007
New Revision: 578796

URL: http://svn.apache.org/viewvc?rev=578796&view=rev
Log:
CAY-848 Support for mapping to-many as Maps and Sets and Collections
support for default map key in the modeler

Modified:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoModel.java

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoModel.java?rev=578796&r1=578795&r2=578796&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoModel.java
Mon Sep 24 06:01:59 2007
@@ -51,6 +51,7 @@
 public class ObjRelationshipInfoModel extends BasicModel {
 
     static final String COLLECTION_TYPE_MAP = "java.util.Map";
+    static final String DEFAULT_MAP_KEY = "ID (default)";
 
     public static final Selector DB_RELATIONSHIP_PATH_SELECTOR = Selector
             .fromString("dbRelationshipPath");
@@ -189,6 +190,8 @@
     private void initMapKeys() {
         this.mapKeys.clear();
 
+        mapKeys.add(DEFAULT_MAP_KEY);
+
         Iterator attributes = this.objectTarget.getAttributes().iterator();
         while (attributes.hasNext()) {
             ObjAttribute attribute = (ObjAttribute) attributes.next();
@@ -198,7 +201,7 @@
         fireModelChange(ModelChangeTypes.VALUE_CHANGED, MAP_KEYS_SELECTOR);
 
         if (mapKey != null && !mapKeys.contains(mapKey)) {
-            mapKey = mapKeys.size() > 0 ? (String) mapKeys.get(0) : null;
+            mapKey = DEFAULT_MAP_KEY;
             fireModelChange(ModelChangeTypes.VALUE_CHANGED, MAP_KEY_SELECTOR);
         }
     }
@@ -314,7 +317,8 @@
         }
 
         // map key only makes sense for Map relationships
-        String mapKey = COLLECTION_TYPE_MAP.equals(collectionType) ? this.mapKey : null;
+        String mapKey = COLLECTION_TYPE_MAP.equals(collectionType)
+                && !DEFAULT_MAP_KEY.equals(this.mapKey) ? this.mapKey : null;
         if (!Util.nullSafeEquals(mapKey, relationship.getMapKey())) {
             hasChanges = true;
             relationship.setMapKey(mapKey);



Mime
View raw message