cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1586831 - /cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v7/UpgradeHandler_V7.java
Date Sat, 12 Apr 2014 08:06:34 GMT
Author: aadamchik
Date: Sat Apr 12 08:06:34 2014
New Revision: 1586831

URL: http://svn.apache.org/r1586831
Log:
CAY-1795 "Invisible" ObjAttribute in subclass

patch cleanup:
* removing uneeded collection cloning
* more informative naming

Modified:
    cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v7/UpgradeHandler_V7.java

Modified: cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v7/UpgradeHandler_V7.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v7/UpgradeHandler_V7.java?rev=1586831&r1=1586830&r2=1586831&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v7/UpgradeHandler_V7.java
(original)
+++ cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v7/UpgradeHandler_V7.java
Sat Apr 12 08:06:34 2014
@@ -71,32 +71,24 @@ class UpgradeHandler_V7 extends BaseUpgr
         attachToNamespace((DataChannelDescriptor) project.getRootNode());
         
         // remove "shadow" attributes per CAY-1795
-        checkObjEntities(project);
+        removeShadowAttributes(project);
         
         // load and safe cycle removes objects no longer supported, specifically listeners
         projectSaver.save(project); 
         return project.getConfigurationResource();
     }
     
-    private void checkObjEntities(Project project) {
+    private void removeShadowAttributes(Project project) {
         DataChannelDescriptor rootNode = (DataChannelDescriptor) project.getRootNode();
 
-        List<DataMap> dataList = new ArrayList<DataMap>(rootNode.getDataMaps());
-        List<ObjEntity> objEntityList = null;
+        for (DataMap dataMap : rootNode.getDataMaps()) {
 
-        // take ObjEntities from DataMap
-        if (!dataList.isEmpty()) {
-            for (DataMap dataMap : dataList) {
-                objEntityList = new ArrayList<ObjEntity>(dataMap.getObjEntities());
-                ObjEntity superEntity = null;
-
-                // if objEntity has super entity, then checks it
-                // for duplicated attributes
-                for (ObjEntity objEntity : objEntityList) {
-                    superEntity = objEntity.getSuperEntity();
-                    if (superEntity != null) {
-                        removeDuplicatedAttributes(objEntity, superEntity);
-                    }
+            // if objEntity has super entity, then checks it
+            // for duplicated attributes
+            for (ObjEntity objEntity : dataMap.getObjEntities()) {
+                ObjEntity superEntity = objEntity.getSuperEntity();
+                if (superEntity != null) {
+                    removeShadowAttributes(objEntity, superEntity);
                 }
             }
         }
@@ -106,23 +98,19 @@ class UpgradeHandler_V7 extends BaseUpgr
      * Remove attributes from objEntity, if superEntity has attributes with same
      * names.
      */
-    private void removeDuplicatedAttributes(ObjEntity objEntity, ObjEntity superEntity) {
-        List<ObjAttribute> entityAttr = new ArrayList<ObjAttribute>(objEntity.getDeclaredAttributes());
-        List<ObjAttribute> superEntityAttr = new ArrayList<ObjAttribute>(superEntity.getAttributes());
+    private void removeShadowAttributes(ObjEntity objEntity, ObjEntity superEntity) {
+
         List<String> delList = new ArrayList<String>();
-        // entityAttr - attributes of objEntity, without inherited
-        // superEntityAttr - all attributes in the superEntity inheritance
-        // hierarchy
-        // delList - attributes, that will be removed from objEntity
 
         // if subAttr and superAttr have same names, adds subAttr to delList
-        for (ObjAttribute subAttr : entityAttr) {
-            for (ObjAttribute superAttr : superEntityAttr) {
+        for (ObjAttribute subAttr : objEntity.getDeclaredAttributes()) {
+            for (ObjAttribute superAttr : superEntity.getAttributes()) {
                 if (subAttr.getName().equals(superAttr.getName())) {
                     delList.add(subAttr.getName());
                 }
             }
         }
+
         if (!delList.isEmpty()) {
             for (String i : delList) {
                 objEntity.removeAttribute(i);



Mime
View raw message