cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r479074 - in /incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi: CjpaClassDescriptorFactory.java CjpaEntityDescriptor.java CjpaPersistenceProvider.java
Date Sat, 25 Nov 2006 02:42:48 GMT
Author: aadamchik
Date: Fri Nov 24 18:42:48 2006
New Revision: 479074

URL: http://svn.apache.org/viewvc?view=rev&rev=479074
Log:
CAY-701: "property" package refactoring
(updating JPA package to conform to the new property API)

Removed:
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaEntityDescriptor.java
Modified:
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaClassDescriptorFactory.java
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaClassDescriptorFactory.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaClassDescriptorFactory.java?view=diff&rev=479074&r1=479073&r2=479074
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaClassDescriptorFactory.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaClassDescriptorFactory.java
Fri Nov 24 18:42:48 2006
@@ -17,35 +17,37 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.jpa.cspi;
 
-import org.apache.cayenne.map.EntityDescriptor;
-import org.apache.cayenne.map.EntityDescriptorFactory;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.map.compiled.ClassDescriptorMap;
+import org.apache.cayenne.map.compiled.PersistentDescriptor;
+import org.apache.cayenne.map.compiled.PersistentDescriptorFactory;
+import org.apache.cayenne.property.Accessor;
 import org.apache.cayenne.property.ClassDescriptor;
 
-public class CjpaClassDescriptorFactory extends EntityDescriptorFactory {
+public class CjpaClassDescriptorFactory extends PersistentDescriptorFactory {
 
-    public CjpaClassDescriptorFactory(EntityResolver resolver) {
-        super(resolver);
+    public CjpaClassDescriptorFactory(ClassDescriptorMap descriptorMap) {
+        super(descriptorMap);
     }
 
     @Override
-    protected EntityDescriptor createDescriptor(String entityName) {
-        ObjEntity entity = resolver.getObjEntity(entityName);
-        if (entity == null) {
-            return null;
-        }
-
-        String superEntityName = entity.getSuperEntityName();
-
-        ClassDescriptor superDescriptor = (superEntityName != null) ? resolver
-                .getClassDescriptor(superEntityName) : null;
-
-        // return uncompiled
-        return new CjpaEntityDescriptor(entity, superDescriptor);
+    protected void createToManyProperty(
+            PersistentDescriptor descriptor,
+            ObjRelationship relationship) {
+        ClassDescriptor targetDescriptor = descriptorMap.getDescriptor(relationship
+                .getTargetEntityName());
+        String reverseName = relationship.getReverseRelationshipName();
+
+        Accessor accessor = new CjpaCollectionFieldAccessor(
+                descriptor.getObjectClass(),
+                relationship.getName(),
+                null);
+        descriptor.addDeclaredProperty(new CjpaCollectionProperty(
+                descriptor,
+                targetDescriptor,
+                accessor,
+                reverseName));
     }
-
 }

Modified: incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java?view=diff&rev=479074&r1=479073&r2=479074
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java
Fri Nov 24 18:42:48 2006
@@ -48,6 +48,7 @@
 import org.apache.cayenne.jpa.spi.JpaPersistenceProvider;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.compiled.ClassDescriptorMap;
 import org.apache.cayenne.util.ResourceLocator;
 import org.apache.cayenne.util.Util;
 import org.apache.cayenne.validation.SimpleValidationFailure;
@@ -119,8 +120,11 @@
 
             // configure Cayenne domain
             domain = new DataDomain(name);
-            domain.getEntityResolver().setClassDescriptorFactory(
-                    new CjpaClassDescriptorFactory(domain.getEntityResolver()));
+            ClassDescriptorMap descriptors = domain
+                    .getEntityResolver()
+                    .getClassDescriptorMap();
+
+            descriptors.addFactory(new CjpaClassDescriptorFactory(descriptors));
             configuration.addDomain(domain);
 
             EntityMapLoader loader = new EntityMapLoader(info);



Mime
View raw message