You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2013/04/11 20:51:47 UTC

svn commit: r1467044 - in /cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src: main/java/org/apache/cayenne/wocompat/ test/java/org/apache/cayenne/wocompat/ test/resources/wotests/flattened.eomodeld/

Author: aadamchik
Date: Thu Apr 11 18:51:46 2013
New Revision: 1467044

URL: http://svn.apache.org/r1467044
Log:
CAY-1806  Error importing eomodel

Added:
    cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/
    cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/Artist.plist
    cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/ArtistExhibit.plist
    cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/Exhibit.plist
    cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/index.eomodeld
Modified:
    cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java
    cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/java/org/apache/cayenne/wocompat/EOModelProcessorTest.java

Modified: cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java?rev=1467044&r1=1467043&r2=1467044&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java (original)
+++ cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java Thu Apr 11 18:51:46 2013
@@ -32,6 +32,7 @@ import java.util.Map;
 import java.util.StringTokenizer;
 
 import org.apache.cayenne.dba.TypesMapping;
+import org.apache.cayenne.exp.ExpressionException;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbJoin;
@@ -45,11 +46,15 @@ import org.apache.cayenne.wocompat.parse
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.Predicate;
 import org.apache.commons.collections.PredicateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Class for converting stored Apple EOModel mapping files to Cayenne DataMaps.
  */
 public class EOModelProcessor {
+    
+    private static final Log logger = LogFactory.getLog(EOModelProcessor.class);
 
     protected Predicate prototypeChecker;
 
@@ -663,7 +668,13 @@ public class EOModelProcessor {
             ObjRelationship flatRel = new ObjRelationship();
             flatRel.setName((String) relMap.get("name"));
             flatRel.setSourceEntity(e);
-            flatRel.setDbRelationshipPath(targetPath);
+            
+            try {
+                flatRel.setDbRelationshipPath(targetPath);
+            } catch (ExpressionException ex) {
+                logger.warn("Invalid relationship: " + targetPath);
+                continue;
+            }
 
             // find target entity
             Map entityInfo = info;

Modified: cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/java/org/apache/cayenne/wocompat/EOModelProcessorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/java/org/apache/cayenne/wocompat/EOModelProcessorTest.java?rev=1467044&r1=1467043&r2=1467044&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/java/org/apache/cayenne/wocompat/EOModelProcessorTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/java/org/apache/cayenne/wocompat/EOModelProcessorTest.java Thu Apr 11 18:51:46 2013
@@ -79,6 +79,19 @@ public class EOModelProcessorTest extend
         assertEquals(0, entity.getRelationships().size());
         assertEquals(0, entity.getDbEntity().getRelationships().size());
     }
+    
+    public void testLoadFlattened() throws Exception {
+        URL url = getClass().getClassLoader().getResource("wotests/flattened.eomodeld/");
+        assertNotNull(url);
+
+        // see CAY-1806
+        DataMap map = processor.loadEOModel(url);
+        ObjEntity artistE = map.getObjEntity("Artist");
+        assertNotNull(artistE);
+        assertEquals(2, artistE.getRelationships().size());
+        assertNotNull(artistE.getRelationship("exhibitArray"));
+        assertNotNull(artistE.getRelationship("artistExhibitArray"));
+    }
 
     public void testLoadBrokenModel() throws Exception {
         URL url = getClass().getClassLoader().getResource("art-with-errors.eomodeld/");

Added: cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/Artist.plist
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/Artist.plist?rev=1467044&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/Artist.plist (added)
+++ cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/Artist.plist Thu Apr 11 18:51:46 2013
@@ -0,0 +1,55 @@
+{
+    attributes = (
+        {
+            columnName = "ARTIST_ID"; 
+            externalType = int; 
+            name = artistId; 
+            valueClassName = NSNumber; 
+            valueType = i; 
+        }, 
+        {
+            columnName = "ARTIST_NAME"; 
+            externalType = varchar; 
+            name = artistName; 
+            valueClassName = NSString; 
+            width = 254; 
+        }, 
+        {
+            allowsNull = Y; 
+            columnName = "DATE_OF_BIRTH"; 
+            externalType = datetime; 
+            internalInfo = {"_nameInObjectStore" = "DATE_OF_BIRTH"; }; 
+            name = dateOfBirth; 
+            valueClassName = NSCalendarDate; 
+        }
+    ); 
+    attributesUsedForLocking = (artistId); 
+    className = "org.apache.art.Artist"; 
+    classProperties = (artistName, dateOfBirth, artistExhibitArray, paintingArray, exhibitArray); 
+    externalName = ARTIST; 
+    fetchSpecificationDictionary = {}; 
+    name = Artist; 
+    primaryKeyAttributes = (artistId); 
+    relationships = (
+    {
+            deleteRule = EODeleteRuleCascade; 
+            destination = ArtistExhibit; 
+            isToMany = Y; 
+            joinSemantic = EOInnerJoin; 
+            joins = ({destinationAttribute = artistId; sourceAttribute = artistId; }); 
+            name = artistExhibitArray; 
+            ownsDestination = Y; 
+            propagatesPrimaryKey = Y; 
+        }, 
+        {
+            definition = "artistExhibitArray.toExhibit";  
+            joinSemantic = EOInnerJoin; 
+            name = exhibitArray; 
+        }, 
+        {
+            definition = "artistExhibitArray.nosuchthing";  
+            joinSemantic = EOInnerJoin; 
+            name = exhibitArray1; 
+        }
+    ); 
+}

Added: cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/ArtistExhibit.plist
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/ArtistExhibit.plist?rev=1467044&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/ArtistExhibit.plist (added)
+++ cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/ArtistExhibit.plist Thu Apr 11 18:51:46 2013
@@ -0,0 +1,42 @@
+{
+    attributes = (
+        {
+            columnName = "ARTIST_ID"; 
+            externalType = int; 
+            name = artistId; 
+            valueClassName = NSNumber; 
+            valueType = i; 
+        }, 
+        {
+            columnName = "EXHIBIT_ID"; 
+            externalType = int; 
+            name = exhibitId; 
+            valueClassName = NSNumber; 
+            valueType = i; 
+        }
+    ); 
+    attributesUsedForLocking = (artistId, exhibitId); 
+    className = "org.apache.art.ArtistExhibit"; 
+    classProperties = (toExhibit, toArtist); 
+    externalName = "ARTIST_EXHIBIT"; 
+    fetchSpecificationDictionary = {}; 
+    internalInfo = {"_nameInObjectStore" = "ARTIST_EXIBIT"; }; 
+    name = ArtistExhibit; 
+    primaryKeyAttributes = (artistId, exhibitId); 
+    relationships = (
+        {
+            destination = Artist; 
+            isToMany = N; 
+            joinSemantic = EOInnerJoin; 
+            joins = ({destinationAttribute = artistId; sourceAttribute = artistId; }); 
+            name = toArtist; 
+        }, 
+        {
+            destination = Exhibit; 
+            isToMany = N; 
+            joinSemantic = EOInnerJoin; 
+            joins = ({destinationAttribute = exhibitId; sourceAttribute = exhibitId; }); 
+            name = toExhibit; 
+        }
+    ); 
+}

Added: cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/Exhibit.plist
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/Exhibit.plist?rev=1467044&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/Exhibit.plist (added)
+++ cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/Exhibit.plist Thu Apr 11 18:51:46 2013
@@ -0,0 +1,78 @@
+{
+    attributes = (
+        {
+            columnName = "CLOSING_DATE"; 
+            externalType = datetime; 
+            name = closingDate; 
+            valueClassName = NSCalendarDate; 
+        }, 
+        {
+            columnName = "EXHIBIT_ID"; 
+            externalType = int; 
+            name = exhibitId; 
+            valueClassName = NSNumber; 
+            valueType = i; 
+        }, 
+        {
+            allowsNull = Y; 
+            columnName = "EXHIBIT_TYPE_ID"; 
+            externalType = int; 
+            name = exhibitTypeId; 
+            valueClassName = NSNumber; 
+            valueType = i; 
+        }, 
+        {
+            columnName = "GALLERY_ID"; 
+            externalType = int; 
+            name = galleryId; 
+            valueClassName = NSNumber; 
+            valueType = i; 
+        }, 
+        {
+            columnName = "OPENING_DATE"; 
+            externalType = datetime; 
+            name = openingDate; 
+            valueClassName = NSCalendarDate; 
+        }
+    ); 
+    attributesUsedForLocking = (exhibitId, galleryId, exhibitTypeId); 
+    className = "org.apache.art.Exhibit"; 
+    classProperties = (
+        closingDate, 
+        openingDate, 
+        toGallery, 
+        artistExhibitArray, 
+        exhibitTypeId, 
+        toExhibitType
+    ); 
+    externalName = EXHIBIT; 
+    fetchSpecificationDictionary = {}; 
+    name = Exhibit; 
+    primaryKeyAttributes = (exhibitId); 
+    relationships = (
+        {
+            deleteRule = EODeleteRuleCascade; 
+            destination = ArtistExhibit; 
+            isToMany = Y; 
+            joinSemantic = EOInnerJoin; 
+            joins = ({destinationAttribute = exhibitId; sourceAttribute = exhibitId; }); 
+            name = artistExhibitArray; 
+            ownsDestination = Y; 
+            propagatesPrimaryKey = Y; 
+        }, 
+        {
+            destination = ExhibitType; 
+            isToMany = N; 
+            joinSemantic = EOInnerJoin; 
+            joins = ({destinationAttribute = exhibitTypeId; sourceAttribute = exhibitTypeId; }); 
+            name = toExhibitType; 
+        }, 
+        {
+            destination = Gallery; 
+            isToMany = N; 
+            joinSemantic = EOInnerJoin; 
+            joins = ({destinationAttribute = galleryId; sourceAttribute = galleryId; }); 
+            name = toGallery; 
+        }
+    ); 
+}

Added: cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/index.eomodeld
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/index.eomodeld?rev=1467044&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/index.eomodeld (added)
+++ cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/resources/wotests/flattened.eomodeld/index.eomodeld Thu Apr 11 18:51:46 2013
@@ -0,0 +1,10 @@
+{
+    EOModelVersion = "2.1"; 
+    adaptorName = None; 
+    connectionDictionary = {}; 
+    entities = (
+        {className = "org.apache.art.Artist"; name = Artist; }, 
+        {className = "org.apache.art.ArtistExhibit"; name = ArtistExhibit; }, 
+        {className = "org.apache.art.Exhibit"; name = Exhibit; }
+    ); 
+}