cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgen...@apache.org
Subject [36/50] cayenne-modeler git commit: More property adapter refactoring.
Date Thu, 05 Jan 2017 22:09:44 GMT
More property adapter refactoring.


Project: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/commit/fc890cef
Tree: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/tree/fc890cef
Diff: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/diff/fc890cef

Branch: refs/heads/master
Commit: fc890cef6a34c8db0aa27e8415bcfc4e91ef87a0
Parents: cacc34e
Author: mrg <blacknext@gmail.com>
Authored: Sun Oct 9 12:05:24 2016 -0400
Committer: mrg <blacknext@gmail.com>
Committed: Sun Oct 9 12:05:24 2016 -0400

----------------------------------------------------------------------
 .../modeler/adapters/AdapterSupport.java        |  1 +
 .../adapters/CayennePropertyAdapter.java        | 14 +++++-----
 .../modeler/adapters/DataDomainAdapter.java     | 17 ++++++++----
 .../modeler/adapters/DataMapAdapter.java        | 27 ++++++++++++--------
 .../modeler/adapters/DataNodeAdapter.java       |  9 ++++++-
 .../modeler/adapters/DatabaseEntityAdapter.java |  9 ++++++-
 .../adapters/ObjectAttributeAdapter.java        | 15 ++++++++---
 .../modeler/adapters/ObjectEntityAdapter.java   | 11 ++++++--
 8 files changed, 74 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/fc890cef/src/main/java/org/apache/cayenne/modeler/adapters/AdapterSupport.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/adapters/AdapterSupport.java b/src/main/java/org/apache/cayenne/modeler/adapters/AdapterSupport.java
index 04fdfb6..53f228f 100644
--- a/src/main/java/org/apache/cayenne/modeler/adapters/AdapterSupport.java
+++ b/src/main/java/org/apache/cayenne/modeler/adapters/AdapterSupport.java
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.modeler.adapters;
 
+@Deprecated // Don't think this is needed anymore.
 public interface AdapterSupport<T>
 {
 //    public BeanPathAdapter<T> getBeanPathAdapter();

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/fc890cef/src/main/java/org/apache/cayenne/modeler/adapters/CayennePropertyAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/adapters/CayennePropertyAdapter.java
b/src/main/java/org/apache/cayenne/modeler/adapters/CayennePropertyAdapter.java
index edbf6d2..6d57759 100644
--- a/src/main/java/org/apache/cayenne/modeler/adapters/CayennePropertyAdapter.java
+++ b/src/main/java/org/apache/cayenne/modeler/adapters/CayennePropertyAdapter.java
@@ -28,18 +28,20 @@ import javafx.beans.property.adapter.JavaBeanStringPropertyBuilder;
 
 public abstract class CayennePropertyAdapter
 {
-    public static BooleanProperty bindBoolean(Object bean, String property) throws NoSuchMethodException
+    public BooleanProperty bindBoolean(String property) throws NoSuchMethodException
     {
-        return JavaBeanBooleanPropertyBuilder.create().bean(bean).name(property).build();
+        return JavaBeanBooleanPropertyBuilder.create().bean(getWrappedObject()).name(property).build();
     }
 
-    public static IntegerProperty bindInteger(Object bean, String property) throws NoSuchMethodException
+    public IntegerProperty bindInteger(String property) throws NoSuchMethodException
     {
-        return JavaBeanIntegerPropertyBuilder.create().bean(bean).name(property).build();
+        return JavaBeanIntegerPropertyBuilder.create().bean(getWrappedObject()).name(property).build();
     }
 
-    public static StringProperty bindString(Object bean, String property) throws NoSuchMethodException
+    public StringProperty bindString(String property) throws NoSuchMethodException
     {
-        return JavaBeanStringPropertyBuilder.create().bean(bean).name(property).build();
+        return JavaBeanStringPropertyBuilder.create().bean(getWrappedObject()).name(property).build();
     }
+
+    public abstract Object getWrappedObject();
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/fc890cef/src/main/java/org/apache/cayenne/modeler/adapters/DataDomainAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/adapters/DataDomainAdapter.java b/src/main/java/org/apache/cayenne/modeler/adapters/DataDomainAdapter.java
index e83efeb..26e3db0 100644
--- a/src/main/java/org/apache/cayenne/modeler/adapters/DataDomainAdapter.java
+++ b/src/main/java/org/apache/cayenne/modeler/adapters/DataDomainAdapter.java
@@ -50,6 +50,7 @@ public class DataDomainAdapter extends CayennePropertyAdapter // implements
Adap
 
     public DataDomainAdapter(final CayenneProject cayenneProject)
     {
+        // Must be assigned before property binding.
         this.cayenneProject = cayenneProject;
 
         cayenneProject.getDataMaps().stream().forEach(dataMap -> dataMapAdapters.add(new
DataMapAdapter(dataMap)));
@@ -57,11 +58,11 @@ public class DataDomainAdapter extends CayennePropertyAdapter // implements
Adap
 
         try
         {
-            nameProperty                      = bindString(cayenneProject, DATA_DOMAIN_NAME);
-            validatingObjectsProperty         = bindBoolean(cayenneProject, VALIDATING_OBJECTS);
-            sizeOfObjectCacheProperty         = bindInteger(cayenneProject, OBJECT_CACHE_SIZE);
-            useSharedCacheProperty            = bindBoolean(cayenneProject, USE_SHARED_CACHE);
-            remoteChangeNotificationsProperty = bindBoolean(cayenneProject, REMOTE_CHANGE_NOTIFICATIONS);
+            nameProperty                      = bindString(DATA_DOMAIN_NAME);
+            validatingObjectsProperty         = bindBoolean(VALIDATING_OBJECTS);
+            sizeOfObjectCacheProperty         = bindInteger(OBJECT_CACHE_SIZE);
+            useSharedCacheProperty            = bindBoolean(USE_SHARED_CACHE);
+            remoteChangeNotificationsProperty = bindBoolean(REMOTE_CHANGE_NOTIFICATIONS);
         }
         catch (final NoSuchMethodException e)
         {
@@ -98,4 +99,10 @@ public class DataDomainAdapter extends CayennePropertyAdapter // implements
Adap
     {
         return dataNodeAdapters;
     }
+
+    @Override
+    public Object getWrappedObject()
+    {
+        return cayenneProject;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/fc890cef/src/main/java/org/apache/cayenne/modeler/adapters/DataMapAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/adapters/DataMapAdapter.java b/src/main/java/org/apache/cayenne/modeler/adapters/DataMapAdapter.java
index dc9d8d9..f5cfbe3 100644
--- a/src/main/java/org/apache/cayenne/modeler/adapters/DataMapAdapter.java
+++ b/src/main/java/org/apache/cayenne/modeler/adapters/DataMapAdapter.java
@@ -56,26 +56,27 @@ public class DataMapAdapter extends CayennePropertyAdapter // implements
Adapter
 
     public DataMapAdapter(final DataMap dataMap)
     {
+        // Must be assigned before property binding.
         this.dataMap = dataMap;
 
         try
         {
-            nameProperty = bindString(dataMap, "name");
+            nameProperty = bindString("name");
 //            locationProperty = JavaBeanStringPropertyBuilder.create().bean(dataMap).name("map").build();
 
             // TODO: Fix Cayenne?  The DEFAULT_QUOTE_SQL_IDENTIFIERS_PROPERTY constant is
incorrect.
-            quoteSQLIdentifiersProperty = bindBoolean(dataMap, "quotingSQLIdentifiers");
+            quoteSQLIdentifiersProperty = bindBoolean("quotingSQLIdentifiers");
 
-            defaultCatalogProperty = bindString(dataMap, DataMap.DEFAULT_CATALOG_PROPERTY);
-            defaultSchemaProperty  = bindString(dataMap, DataMap.DEFAULT_SCHEMA_PROPERTY);
-            defaultPackageProperty = bindString(dataMap, DataMap.DEFAULT_PACKAGE_PROPERTY);
+            defaultCatalogProperty = bindString(DataMap.DEFAULT_CATALOG_PROPERTY);
+            defaultSchemaProperty  = bindString(DataMap.DEFAULT_SCHEMA_PROPERTY);
+            defaultPackageProperty = bindString(DataMap.DEFAULT_PACKAGE_PROPERTY);
 
-            defaultSuperclassProperty = bindString(dataMap, DataMap.DEFAULT_SUPERCLASS_PROPERTY);
-            defaultLockTypeProperty   = bindInteger(dataMap, DataMap.DEFAULT_LOCK_TYPE_PROPERTY);
+            defaultSuperclassProperty = bindString(DataMap.DEFAULT_SUPERCLASS_PROPERTY);
+            defaultLockTypeProperty   = bindInteger(DataMap.DEFAULT_LOCK_TYPE_PROPERTY);
 
-            clientSupportedProperty         = bindBoolean(dataMap, DataMap.CLIENT_SUPPORTED_PROPERTY);
-            defaultClientPackageProperty    = bindString(dataMap, DataMap.DEFAULT_CLIENT_PACKAGE_PROPERTY);
-            defaultClientSuperclassProperty = bindString(dataMap, DataMap.DEFAULT_CLIENT_SUPERCLASS_PROPERTY);
+            clientSupportedProperty         = bindBoolean(DataMap.CLIENT_SUPPORTED_PROPERTY);
+            defaultClientPackageProperty    = bindString(DataMap.DEFAULT_CLIENT_PACKAGE_PROPERTY);
+            defaultClientSuperclassProperty = bindString(DataMap.DEFAULT_CLIENT_SUPERCLASS_PROPERTY);
         }
         catch (final NoSuchMethodException e)
         {
@@ -157,4 +158,10 @@ public class DataMapAdapter extends CayennePropertyAdapter // implements
Adapter
                 return ObjectUtils.compare(entity1.nameProperty().get(), entity2.nameProperty().get());
             });
     }
+
+    @Override
+    public Object getWrappedObject()
+    {
+        return dataMap;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/fc890cef/src/main/java/org/apache/cayenne/modeler/adapters/DataNodeAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/adapters/DataNodeAdapter.java b/src/main/java/org/apache/cayenne/modeler/adapters/DataNodeAdapter.java
index 7a667f6..c1ca8fe 100644
--- a/src/main/java/org/apache/cayenne/modeler/adapters/DataNodeAdapter.java
+++ b/src/main/java/org/apache/cayenne/modeler/adapters/DataNodeAdapter.java
@@ -35,11 +35,12 @@ public class DataNodeAdapter extends CayennePropertyAdapter
 
     public DataNodeAdapter(final DataNodeDescriptor dataNode)
     {
+        // Must be assigned before property binding.
         this.dataNode = dataNode;
 
         try
         {
-            nameProperty                 = bindString(dataNode, "name");
+            nameProperty                 = bindString("name");
 //            dataSourceLocationProperty       = JavaBeanStringPropertyBuilder.create().bean(dataNode).name("dataSourceLocation").build();
 //            dataSourceFactoryProperty        = JavaBeanStringPropertyBuilder.create().bean(dataNode).name("dataSourceFactory").build();
 //            schemaUpdateStrategyNameProperty = JavaBeanStringPropertyBuilder.create().bean(dataNode).name("schemaUpdateStrategyName").build();
@@ -53,4 +54,10 @@ public class DataNodeAdapter extends CayennePropertyAdapter
     public StringProperty nameProperty() { return nameProperty; }
     public String getName() { return nameProperty.get(); }
     public void setName(final String value) { nameProperty.set(value); }
+
+    @Override
+    public Object getWrappedObject()
+    {
+        return dataNode;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/fc890cef/src/main/java/org/apache/cayenne/modeler/adapters/DatabaseEntityAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/adapters/DatabaseEntityAdapter.java
b/src/main/java/org/apache/cayenne/modeler/adapters/DatabaseEntityAdapter.java
index bc1fbad..3e741f1 100644
--- a/src/main/java/org/apache/cayenne/modeler/adapters/DatabaseEntityAdapter.java
+++ b/src/main/java/org/apache/cayenne/modeler/adapters/DatabaseEntityAdapter.java
@@ -54,11 +54,12 @@ public class DatabaseEntityAdapter extends CayennePropertyAdapter // implements
 
     public DatabaseEntityAdapter(final DbEntity databaseEntity)
     {
+        // Must be assigned before property binding.
         this.databaseEntity = databaseEntity;
 
         try
         {
-            nameProperty = bindString(databaseEntity, "name");
+            nameProperty = bindString("name");
         }
         catch (final NoSuchMethodException e)
         {
@@ -73,4 +74,10 @@ public class DatabaseEntityAdapter extends CayennePropertyAdapter // implements
     public StringProperty locationProperty() { return locationProperty; }
     public String getLocationProperty() { return locationProperty.get(); }
     public void setLocationProperty(final String value) { locationProperty.set(value); }
+
+    @Override
+    public Object getWrappedObject()
+    {
+        return databaseEntity;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/fc890cef/src/main/java/org/apache/cayenne/modeler/adapters/ObjectAttributeAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/adapters/ObjectAttributeAdapter.java
b/src/main/java/org/apache/cayenne/modeler/adapters/ObjectAttributeAdapter.java
index d2b756e..bc2087e 100644
--- a/src/main/java/org/apache/cayenne/modeler/adapters/ObjectAttributeAdapter.java
+++ b/src/main/java/org/apache/cayenne/modeler/adapters/ObjectAttributeAdapter.java
@@ -51,14 +51,15 @@ public class ObjectAttributeAdapter extends CayennePropertyAdapter //
implements
 
     public ObjectAttributeAdapter(final ObjAttribute objectAttribute)
     {
+        // Must be assigned before property binding.
         this.objectAttribute = objectAttribute;
 
         try
         {
-            nameProperty                  = bindString(objectAttribute, "name");
-            javaTypeProperty              = bindString(objectAttribute, "type");
-            databaseAttributePathProperty = bindString(objectAttribute, "dbAttributePath");
-            usedForLockingProperty        = bindBoolean(objectAttribute, "usedForLocking");
+            nameProperty                  = bindString("name");
+            javaTypeProperty              = bindString("type");
+            databaseAttributePathProperty = bindString("dbAttributePath");
+            usedForLockingProperty        = bindBoolean("usedForLocking");
 
 
 //            locationProperty = JavaBeanStringPropertyBuilder.create().bean(dataMap).name("map").build();
@@ -111,4 +112,10 @@ public class ObjectAttributeAdapter extends CayennePropertyAdapter //
implements
     {
         return objectAttribute;
     }
+
+    @Override
+    public Object getWrappedObject()
+    {
+        return objectAttribute;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/fc890cef/src/main/java/org/apache/cayenne/modeler/adapters/ObjectEntityAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/adapters/ObjectEntityAdapter.java b/src/main/java/org/apache/cayenne/modeler/adapters/ObjectEntityAdapter.java
index f8bd74a..a2b00d9 100644
--- a/src/main/java/org/apache/cayenne/modeler/adapters/ObjectEntityAdapter.java
+++ b/src/main/java/org/apache/cayenne/modeler/adapters/ObjectEntityAdapter.java
@@ -52,12 +52,13 @@ public class ObjectEntityAdapter extends CayennePropertyAdapter // implements
Ad
 
     public ObjectEntityAdapter(final ObjEntity objectEntity)
     {
+        // Must be assigned before property binding.
         this.objectEntity = objectEntity;
 
         try
         {
-            nameProperty          = bindString(objectEntity, "name");
-            abstractClassProperty = bindBoolean(objectEntity, "abstract");
+            nameProperty          = bindString("name");
+            abstractClassProperty = bindBoolean("abstract");
 
 
 //            locationProperty = JavaBeanStringPropertyBuilder.create().bean(dataMap).name("map").build();
@@ -95,4 +96,10 @@ public class ObjectEntityAdapter extends CayennePropertyAdapter // implements
Ad
     {
         return objectAttributeAdapters;
     }
+
+    @Override
+    public Object getWrappedObject()
+    {
+        return objectEntity;
+    }
 }


Mime
View raw message