cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: CAY-2116 Split schema synchronization code in a separate module
Date Sun, 02 Oct 2016 18:44:39 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 38e4e7fda -> 413c72045


CAY-2116 Split schema synchronization code in a separate module

Refactoring:
* gathering all naming services under a single package
* better method names and javadocs for ObjectNameGenerator


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

Branch: refs/heads/master
Commit: 413c720457f60275296e1834736a542e97b76b49
Parents: 38e4e7f
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Sun Oct 2 16:04:12 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Sun Oct 2 21:40:50 2016 +0300

----------------------------------------------------------------------
 .../dbsync/merge/CreateTableToModel.java        | 18 ++--
 .../dbsync/merge/EntityMergeSupport.java        |  8 +-
 .../cayenne/dbsync/merge/MergerContext.java     |  4 +-
 .../naming/DefaultObjectNameGenerator.java      | 94 ++++++++++++++++++++
 .../naming/LegacyObjectNameGenerator.java       | 58 ++++++++++++
 .../dbsync/naming/ObjectNameGenerator.java      | 54 +++++++++++
 .../cayenne/dbsync/reverse/db/DbLoader.java     | 12 +--
 .../reverse/db/ManyToManyCandidateEntity.java   |  4 +-
 .../naming/DefaultObjectNameGenerator.java      | 94 --------------------
 .../naming/LegacyObjectNameGenerator.java       | 58 ------------
 .../reverse/naming/ObjectNameGenerator.java     | 53 -----------
 .../dbsync/merge/EntityMergeSupportIT.java      |  2 +-
 .../naming/DefaultObjectNameGeneratorTest.java  | 61 +++++++++++++
 .../naming/LegacyObjectNameGeneratorTest.java   | 55 ++++++++++++
 .../db/ManyToManyCandidateEntityTest.java       |  2 +-
 .../naming/DefaultObjectNameGeneratorTest.java  | 60 -------------
 .../naming/LegacyObjectNameGeneratorTest.java   | 54 -----------
 .../apache/cayenne/tools/DbImporterTask.java    |  2 +-
 .../tools/dbimport/DbImportConfiguration.java   |  4 +-
 .../tools/dbimport/DefaultDbImportAction.java   |  2 +-
 .../dbimport/DefaultDbImportActionTest.java     |  2 +-
 .../modeler/action/CreateObjEntityAction.java   |  4 +-
 .../InferRelationshipsController.java           |  2 +-
 .../InferRelationshipsControllerBase.java       |  4 +-
 .../dialog/objentity/EntitySyncController.java  |  2 +-
 .../dialog/objentity/ObjRelationshipInfo.java   |  4 +-
 .../modeler/util/NameGeneratorPreferences.java  |  6 +-
 27 files changed, 362 insertions(+), 361 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/CreateTableToModel.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/CreateTableToModel.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/CreateTableToModel.java
index ba93d2c..b57a6dd 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/CreateTableToModel.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/CreateTableToModel.java
@@ -20,7 +20,7 @@ package org.apache.cayenne.dbsync.merge;
 
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactory;
 import org.apache.cayenne.dbsync.naming.NameBuilder;
-import org.apache.cayenne.dbsync.reverse.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
@@ -60,22 +60,20 @@ public class CreateTableToModel extends AbstractToModelToken.Entity {
         map.addDbEntity(dbEntity);
 
         // create a ObjEntity
-
-        // TODO: name generator must be injected...
-        // TODO: should we use DbEntity name as a basis instead of generic name like "ObjEntity1"?
-        String baseName = new DefaultObjectNameGenerator().createObjEntityName(dbEntity);
-
         ObjEntity objEntity = new ObjEntity();
 
-        String name = NameBuilder.builder(objEntity, dbEntity.getDataMap()).baseName(baseName).name();
-        objEntity.setName(name);
+        objEntity.setName(NameBuilder
+                .builder(objEntity, dbEntity.getDataMap())
+                // TODO: name generator must be injected...
+                .baseName(new DefaultObjectNameGenerator().objEntityName(dbEntity))
+                .name());
         objEntity.setDbEntity(getEntity());
 
         // try to find a class name for the ObjEntity
         String className = objEntityClassName;
         if (className == null) {
-            // we should generate a className based on the objEntityName
-            className = map.getNameWithDefaultPackage(name);
+            // generate a className based on the objEntityName
+            className = map.getNameWithDefaultPackage(objEntity.getName());
         }
 
         objEntity.setClassName(className);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/EntityMergeSupport.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/EntityMergeSupport.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/EntityMergeSupport.java
index e3692b0..11f2ac4 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/EntityMergeSupport.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/EntityMergeSupport.java
@@ -21,7 +21,7 @@ package org.apache.cayenne.dbsync.merge;
 
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.dbsync.naming.NameBuilder;
-import org.apache.cayenne.dbsync.reverse.naming.ObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -200,7 +200,7 @@ public class EntityMergeSupport {
     private boolean createObjRelationship(ObjEntity entity, DbRelationship dr, String targetEntityName) {
         ObjRelationship or = new ObjRelationship();
         or.setName(NameBuilder.builder(or, entity)
-                .baseName(nameGenerator.createObjRelationshipName(dr))
+                .baseName(nameGenerator.objRelationshipName(dr))
                 .name());
 
         or.addDbRelationship(dr);
@@ -264,7 +264,7 @@ public class EntityMergeSupport {
 
             if (dbRelationship.getTargetEntityName() != null) {
                 boolean needGeneratedEntity = createObjRelationship(entity, dbRelationship,
-                        nameGenerator.createObjEntityName(targetEntity));
+                        nameGenerator.objEntityName(targetEntity));
                 if (needGeneratedEntity) {
                     LOG.warn("Can't find ObjEntity for " + dbRelationship.getTargetEntityName());
                     LOG.warn("Db Relationship (" + dbRelationship + ") will have GUESSED Obj Relationship reflection. ");
@@ -276,7 +276,7 @@ public class EntityMergeSupport {
     private void addMissingAttribute(ObjEntity entity, DbAttribute da) {
         ObjAttribute oa = new ObjAttribute();
         oa.setName(NameBuilder.builder(oa, entity)
-                .baseName(nameGenerator.createObjAttributeName(da))
+                .baseName(nameGenerator.objAttributeName(da))
                 .name());
         oa.setEntity(entity);
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/MergerContext.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/MergerContext.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/MergerContext.java
index 3605e10..77f9e61 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/MergerContext.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/MergerContext.java
@@ -20,8 +20,8 @@ package org.apache.cayenne.dbsync.merge;
 
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dbsync.reverse.naming.DefaultObjectNameGenerator;
-import org.apache.cayenne.dbsync.reverse.naming.ObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.validation.ValidationResult;
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/DefaultObjectNameGenerator.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/DefaultObjectNameGenerator.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/DefaultObjectNameGenerator.java
new file mode 100644
index 0000000..a201325
--- /dev/null
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/DefaultObjectNameGenerator.java
@@ -0,0 +1,94 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.dbsync.naming;
+
+import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.util.Util;
+import org.jvnet.inflector.Noun;
+
+import java.util.Locale;
+
+/**
+ * A strategy for generating names of entities, attributes etc.
+ * 
+ * @since 4.0
+ */
+public class DefaultObjectNameGenerator implements ObjectNameGenerator {
+
+	@Override
+	public String dbRelationshipName(ExportedKey key, boolean toMany) {
+
+		String name;
+
+		if (toMany) {
+			try {
+				/**
+				 * by default we use english language rules here. uppercase is
+				 * required for NameConverter to work properly
+				 */
+				name = Noun.pluralOf(key.getFKTableName().toLowerCase(), Locale.ENGLISH).toUpperCase();
+			} catch (Exception inflectorError) {
+				/**
+				 * seems that Inflector cannot be trusted. For instance, it
+				 * throws an exception when invoked for word "ADDRESS" (although
+				 * lower case works fine). To feel safe, we use superclass'
+				 * behavior if something's gone wrong
+				 */
+				return key.getFKTableName().toLowerCase();
+			}
+		} else {
+			String fkColName = key.getFKColumnName();
+
+			// trim "ID" in the end
+			if (fkColName == null) {
+				name = key.getPKTableName();
+			} else if (fkColName.toUpperCase().endsWith("_ID") && fkColName.length() > 3) {
+				name = fkColName.substring(0, fkColName.length() - 3);
+			} else if (fkColName.toUpperCase().endsWith("ID") && fkColName.length() > 2) {
+				name = fkColName.substring(0, fkColName.length() - 2);
+			} else {
+				/**
+				 * We don't want relationship to conflict with attribute, so
+				 * we'd better return superior value with 'to'
+				 */
+				name = key.getPKTableName();
+			}
+		}
+
+		return Util.underscoredToJava(name, false);
+	}
+
+	@Override
+	public String objEntityName(DbEntity dbEntity) {
+		return Util.underscoredToJava(dbEntity.getName(), true);
+	}
+
+	@Override
+	public String objAttributeName(DbAttribute attr) {
+		return Util.underscoredToJava(attr.getName(), false);
+	}
+
+	@Override
+	public String objRelationshipName(DbRelationship dbRel) {
+		return Util.underscoredToJava(dbRel.getName(), false);
+	}
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/LegacyObjectNameGenerator.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/LegacyObjectNameGenerator.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/LegacyObjectNameGenerator.java
new file mode 100644
index 0000000..430fbbc
--- /dev/null
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/LegacyObjectNameGenerator.java
@@ -0,0 +1,58 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.dbsync.naming;
+
+import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.util.Util;
+
+/**
+ * An ObjectNameGenerator that creates names in Cayenne's old-fashioned style. I.e. the same way Cayenne did before 3.0,
+ * with "to" prefixes and "array" suffixes.
+ *
+ * @since 4.0
+ */
+public class LegacyObjectNameGenerator implements ObjectNameGenerator {
+
+    @Override
+    public String dbRelationshipName(
+            ExportedKey key,
+            boolean toMany) {
+
+        String uglyName = (toMany) ? key.getFKTableName() + "_ARRAY" : "to_" + key.getPKTableName();
+        return Util.underscoredToJava(uglyName, false);
+    }
+
+    @Override
+    public String objEntityName(DbEntity dbEntity) {
+        return Util.underscoredToJava(dbEntity.getName(), true);
+    }
+
+    @Override
+    public String objAttributeName(DbAttribute attr) {
+        return Util.underscoredToJava(attr.getName(), false);
+    }
+
+    @Override
+    public String objRelationshipName(DbRelationship dbRel) {
+        return Util.underscoredToJava(dbRel.getName(), false);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/ObjectNameGenerator.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/ObjectNameGenerator.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/ObjectNameGenerator.java
new file mode 100644
index 0000000..0383c8e
--- /dev/null
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/ObjectNameGenerator.java
@@ -0,0 +1,54 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.dbsync.naming;
+
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
+
+/**
+ * A strategy for creating names for object layer metadata artifacts based on their DB counterpart naming. Generated
+ * names should normally be further cleaned by passing them through {@link org.apache.cayenne.dbsync.naming.NameBuilder},
+ * that will resolve duplication conflicts.
+ *
+ * @since 4.0
+ */
+public interface ObjectNameGenerator {
+
+    /**
+     * Generates a name for ObjEntity derived from DbEntity name.
+     */
+    String objEntityName(DbEntity dbEntity);
+
+    /**
+     * Generates a name for ObjAttribute derived from DbAttribute name.
+     */
+    String objAttributeName(DbAttribute dbAttribute);
+
+    /**
+     * Generates a name for DbRelationship derived from the DB foreign key name.
+     */
+    String dbRelationshipName(ExportedKey key, boolean toMany);
+
+    /**
+     * Generates a name for ObjRelationship derived from DbRelationship name.
+     */
+    String objRelationshipName(DbRelationship dbRelationship);
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/db/DbLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/db/DbLoader.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/db/DbLoader.java
index ecdfa70..888d6d4 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/db/DbLoader.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/db/DbLoader.java
@@ -26,8 +26,8 @@ import org.apache.cayenne.dbsync.reverse.filters.CatalogFilter;
 import org.apache.cayenne.dbsync.reverse.filters.FiltersConfig;
 import org.apache.cayenne.dbsync.reverse.filters.SchemaFilter;
 import org.apache.cayenne.dbsync.reverse.filters.TableFilter;
-import org.apache.cayenne.dbsync.reverse.naming.LegacyObjectNameGenerator;
-import org.apache.cayenne.dbsync.reverse.naming.ObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.LegacyObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -134,7 +134,7 @@ public class DbLoader {
             ObjEntity objEntity = new ObjEntity();
             objEntity.setName(NameBuilder
                     .builder(objEntity, map)
-                    .baseName(nameGenerator.createObjEntityName(dbEntity))
+                    .baseName(nameGenerator.objEntityName(dbEntity))
                     .name());
 
             objEntity.setDbEntity(dbEntity);
@@ -318,7 +318,7 @@ public class DbLoader {
             DbRelationship forwardRelationship = new DbRelationship();
             forwardRelationship.setName(NameBuilder
                     .builder(forwardRelationship, pkEntity)
-                    .baseName(nameGenerator.createDbRelationshipName(key, true))
+                    .baseName(nameGenerator.dbRelationshipName(key, true))
                     .name());
 
             forwardRelationship.setSourceEntity(pkEntity);
@@ -332,7 +332,7 @@ public class DbLoader {
             DbRelationshipDetected reverseRelationship = new DbRelationshipDetected();
             reverseRelationship.setName(NameBuilder
                     .builder(reverseRelationship, fkEntity)
-                    .baseName(nameGenerator.createDbRelationshipName(key, false))
+                    .baseName(nameGenerator.dbRelationshipName(key, false))
                     .name());
 
             reverseRelationship.setFkName(key.getFKName());
@@ -353,7 +353,7 @@ public class DbLoader {
             // TODO: can we avoid resetting the name twice? Do we need a placeholder name above?
             forwardRelationship.setName(NameBuilder
                             .builder(forwardRelationship, pkEntity)
-                            .baseName(nameGenerator.createDbRelationshipName(key, !isOneToOne))
+                            .baseName(nameGenerator.dbRelationshipName(key, !isOneToOne))
                             .name());
 
             if (delegate.dbRelationshipLoaded(fkEntity, reverseRelationship)) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/db/ManyToManyCandidateEntity.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/db/ManyToManyCandidateEntity.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/db/ManyToManyCandidateEntity.java
index 7f2f815..f93c7cf 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/db/ManyToManyCandidateEntity.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/db/ManyToManyCandidateEntity.java
@@ -19,7 +19,7 @@
 package org.apache.cayenne.dbsync.reverse.db;
 
 import org.apache.cayenne.dbsync.naming.NameBuilder;
-import org.apache.cayenne.dbsync.reverse.naming.ObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
@@ -114,7 +114,7 @@ class ManyToManyCandidateEntity {
         ObjRelationship newRelationship = new ObjRelationship();
         newRelationship.setName(NameBuilder
                 .builder(newRelationship, srcEntity)
-                .baseName(nameGenerator.createDbRelationshipName(key, true))
+                .baseName(nameGenerator.dbRelationshipName(key, true))
                 .name());
 
         newRelationship.setSourceEntity(srcEntity);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/DefaultObjectNameGenerator.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/DefaultObjectNameGenerator.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/DefaultObjectNameGenerator.java
deleted file mode 100644
index a2d2264..0000000
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/DefaultObjectNameGenerator.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.dbsync.reverse.naming;
-
-import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.util.Util;
-import org.jvnet.inflector.Noun;
-
-import java.util.Locale;
-
-/**
- * A strategy for generating names of entities, attributes etc.
- * 
- * @since 4.0
- */
-public class DefaultObjectNameGenerator implements ObjectNameGenerator {
-
-	@Override
-	public String createDbRelationshipName(ExportedKey key, boolean toMany) {
-
-		String name;
-
-		if (toMany) {
-			try {
-				/**
-				 * by default we use english language rules here. uppercase is
-				 * required for NameConverter to work properly
-				 */
-				name = Noun.pluralOf(key.getFKTableName().toLowerCase(), Locale.ENGLISH).toUpperCase();
-			} catch (Exception inflectorError) {
-				/**
-				 * seems that Inflector cannot be trusted. For instance, it
-				 * throws an exception when invoked for word "ADDRESS" (although
-				 * lower case works fine). To feel safe, we use superclass'
-				 * behavior if something's gone wrong
-				 */
-				return key.getFKTableName().toLowerCase();
-			}
-		} else {
-			String fkColName = key.getFKColumnName();
-
-			// trim "ID" in the end
-			if (fkColName == null) {
-				name = key.getPKTableName();
-			} else if (fkColName.toUpperCase().endsWith("_ID") && fkColName.length() > 3) {
-				name = fkColName.substring(0, fkColName.length() - 3);
-			} else if (fkColName.toUpperCase().endsWith("ID") && fkColName.length() > 2) {
-				name = fkColName.substring(0, fkColName.length() - 2);
-			} else {
-				/**
-				 * We don't want relationship to conflict with attribute, so
-				 * we'd better return superior value with 'to'
-				 */
-				name = key.getPKTableName();
-			}
-		}
-
-		return Util.underscoredToJava(name, false);
-	}
-
-	@Override
-	public String createObjEntityName(DbEntity dbEntity) {
-		return Util.underscoredToJava(dbEntity.getName(), true);
-	}
-
-	@Override
-	public String createObjAttributeName(DbAttribute attr) {
-		return Util.underscoredToJava(attr.getName(), false);
-	}
-
-	@Override
-	public String createObjRelationshipName(DbRelationship dbRel) {
-		return Util.underscoredToJava(dbRel.getName(), false);
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGenerator.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGenerator.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGenerator.java
deleted file mode 100644
index 986b192..0000000
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGenerator.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.dbsync.reverse.naming;
-
-import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.util.Util;
-
-/**
- * An ObjectNameGenerator that creates names in Cayenne's old-fashioned style. I.e. the same way Cayenne did before 3.0,
- * with "to" prefixes and "array" suffixes.
- *
- * @since 4.0
- */
-public class LegacyObjectNameGenerator implements ObjectNameGenerator {
-
-    @Override
-    public String createDbRelationshipName(
-            ExportedKey key,
-            boolean toMany) {
-
-        String uglyName = (toMany) ? key.getFKTableName() + "_ARRAY" : "to_" + key.getPKTableName();
-        return Util.underscoredToJava(uglyName, false);
-    }
-
-    @Override
-    public String createObjEntityName(DbEntity dbEntity) {
-        return Util.underscoredToJava(dbEntity.getName(), true);
-    }
-
-    @Override
-    public String createObjAttributeName(DbAttribute attr) {
-        return Util.underscoredToJava(attr.getName(), false);
-    }
-
-    @Override
-    public String createObjRelationshipName(DbRelationship dbRel) {
-        return Util.underscoredToJava(dbRel.getName(), false);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/ObjectNameGenerator.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/ObjectNameGenerator.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/ObjectNameGenerator.java
deleted file mode 100644
index da45ab3..0000000
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/ObjectNameGenerator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.dbsync.reverse.naming;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
-
-/**
- * ObjectNameGenerator is a strategy for creating names for entities,
- * attributes, relationships from DB metadata.
- * 
- * @since 4.0
- */
-public interface ObjectNameGenerator {
-
-	/**
-	 * Creates new name for ObjEntity
-	 */
-	String createObjEntityName(DbEntity entity);
-
-	/**
-	 * Creates new name for ObjAttribute
-	 */
-	String createObjAttributeName(DbAttribute attr);
-
-	/**
-	 * Creates new name for DbRelationship
-	 */
-	String createDbRelationshipName(ExportedKey key, boolean toMany);
-
-	/**
-	 * Creates new name for ObjRelationship
-	 */
-	String createObjRelationshipName(DbRelationship dbRel);
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/EntityMergeSupportIT.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/EntityMergeSupportIT.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/EntityMergeSupportIT.java
index d21b58c..8d304da 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/EntityMergeSupportIT.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/EntityMergeSupportIT.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.dbsync.merge;
 
-import org.apache.cayenne.dbsync.reverse.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbJoin;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/DefaultObjectNameGeneratorTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/DefaultObjectNameGeneratorTest.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/DefaultObjectNameGeneratorTest.java
new file mode 100644
index 0000000..dbd9dc3
--- /dev/null
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/DefaultObjectNameGeneratorTest.java
@@ -0,0 +1,61 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.dbsync.naming;
+
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class DefaultObjectNameGeneratorTest {
+
+    @Test
+    public void testStrategy() throws Exception {
+        DefaultObjectNameGenerator strategy = new DefaultObjectNameGenerator();
+        
+        ExportedKey key = new ExportedKey("ARTIST", "ARTIST_ID", null,
+                "PAINTING", "ARTIST_ID", null, (short) 1);
+        assertEquals(strategy.dbRelationshipName(key, false), "artist");
+        assertEquals(strategy.dbRelationshipName(key, true), "paintings");
+        
+        key = new ExportedKey("PERSON", "PERSON_ID", null,
+                "PERSON", "MOTHER_ID", null, (short) 1);
+        assertEquals(strategy.dbRelationshipName(key, false), "mother");
+        assertEquals(strategy.dbRelationshipName(key, true), "people");
+        
+        key = new ExportedKey("PERSON", "PERSON_ID", null,
+                "ADDRESS", "SHIPPING_ADDRESS_ID", null, (short) 1);
+        assertEquals(strategy.dbRelationshipName(key, false), "shippingAddress");
+        assertEquals(strategy.dbRelationshipName(key, true), "addresses");
+        
+        assertEquals(strategy.objEntityName(new DbEntity("ARTIST")), "Artist");
+        assertEquals(strategy.objEntityName(new DbEntity("ARTIST_WORK")), "ArtistWork");
+        
+        assertEquals(strategy.objAttributeName(new DbAttribute("NAME")), "name");
+        assertEquals(strategy.objAttributeName(new DbAttribute("ARTIST_NAME")), "artistName");
+        
+        assertEquals(strategy.objRelationshipName(new DbRelationship("mother")), "mother");
+        assertEquals(strategy.objRelationshipName(new DbRelationship("persons")), "persons");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/LegacyObjectNameGeneratorTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/LegacyObjectNameGeneratorTest.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/LegacyObjectNameGeneratorTest.java
new file mode 100644
index 0000000..b1f5619
--- /dev/null
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/naming/LegacyObjectNameGeneratorTest.java
@@ -0,0 +1,55 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.dbsync.naming;
+
+import org.apache.cayenne.dbsync.naming.LegacyObjectNameGenerator;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class LegacyObjectNameGeneratorTest {
+
+    @Test
+    public void testStrategy() throws Exception {
+        LegacyObjectNameGenerator strategy = new LegacyObjectNameGenerator();
+        
+        ExportedKey key = new ExportedKey("ARTIST", "ARTIST_ID", null,
+                "PAINTING", "ARTIST_ID", null, (short) 1);
+        assertEquals(strategy.dbRelationshipName(key, false), "toArtist");
+        assertEquals(strategy.dbRelationshipName(key, true), "paintingArray");
+        
+        key = new ExportedKey("PERSON", "PERSON_ID", null,
+                "PERSON", "MOTHER_ID", null, (short) 1);
+        assertEquals(strategy.dbRelationshipName(key, false), "toPerson");
+        assertEquals(strategy.dbRelationshipName(key, true), "personArray");
+        
+        assertEquals(strategy.objEntityName(new DbEntity("ARTIST")), "Artist");
+        assertEquals(strategy.objEntityName(new DbEntity("ARTIST_WORK")), "ArtistWork");
+        
+        assertEquals(strategy.objAttributeName(new DbAttribute("NAME")), "name");
+        assertEquals(strategy.objAttributeName(new DbAttribute("ARTIST_NAME")), "artistName");
+        
+        assertEquals(strategy.objRelationshipName(new DbRelationship("toArtist")), "toArtist");
+        assertEquals(strategy.objRelationshipName(new DbRelationship("paintingArray")), "paintingArray");
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/db/ManyToManyCandidateEntityTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/db/ManyToManyCandidateEntityTest.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/db/ManyToManyCandidateEntityTest.java
index 4f36005..d56560a 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/db/ManyToManyCandidateEntityTest.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/db/ManyToManyCandidateEntityTest.java
@@ -36,7 +36,7 @@ import org.apache.cayenne.di.spi.DefaultClassLoaderManager;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Relationship;
-import org.apache.cayenne.dbsync.reverse.naming.LegacyObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.LegacyObjectNameGenerator;
 import org.apache.cayenne.resource.URLResource;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/DefaultObjectNameGeneratorTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/DefaultObjectNameGeneratorTest.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/DefaultObjectNameGeneratorTest.java
deleted file mode 100644
index a29c786..0000000
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/DefaultObjectNameGeneratorTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.dbsync.reverse.naming;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class DefaultObjectNameGeneratorTest {
-
-    @Test
-    public void testStrategy() throws Exception {
-        DefaultObjectNameGenerator strategy = new DefaultObjectNameGenerator();
-        
-        ExportedKey key = new ExportedKey("ARTIST", "ARTIST_ID", null,
-                "PAINTING", "ARTIST_ID", null, (short) 1);
-        assertEquals(strategy.createDbRelationshipName(key, false), "artist"); 
-        assertEquals(strategy.createDbRelationshipName(key, true), "paintings");
-        
-        key = new ExportedKey("PERSON", "PERSON_ID", null,
-                "PERSON", "MOTHER_ID", null, (short) 1);
-        assertEquals(strategy.createDbRelationshipName(key, false), "mother"); 
-        assertEquals(strategy.createDbRelationshipName(key, true), "people");
-        
-        key = new ExportedKey("PERSON", "PERSON_ID", null,
-                "ADDRESS", "SHIPPING_ADDRESS_ID", null, (short) 1);
-        assertEquals(strategy.createDbRelationshipName(key, false), "shippingAddress"); 
-        assertEquals(strategy.createDbRelationshipName(key, true), "addresses");
-        
-        assertEquals(strategy.createObjEntityName(new DbEntity("ARTIST")), "Artist");
-        assertEquals(strategy.createObjEntityName(new DbEntity("ARTIST_WORK")), "ArtistWork");
-        
-        assertEquals(strategy.createObjAttributeName(new DbAttribute("NAME")), "name");
-        assertEquals(strategy.createObjAttributeName(new DbAttribute("ARTIST_NAME")), "artistName");
-        
-        assertEquals(strategy.createObjRelationshipName(new DbRelationship("mother")), "mother");
-        assertEquals(strategy.createObjRelationshipName(new DbRelationship("persons")), "persons");
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGeneratorTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGeneratorTest.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGeneratorTest.java
deleted file mode 100644
index ea4902d..0000000
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/LegacyObjectNameGeneratorTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.dbsync.reverse.naming;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class LegacyObjectNameGeneratorTest {
-
-    @Test
-    public void testStrategy() throws Exception {
-        LegacyObjectNameGenerator strategy = new LegacyObjectNameGenerator();
-        
-        ExportedKey key = new ExportedKey("ARTIST", "ARTIST_ID", null,
-                "PAINTING", "ARTIST_ID", null, (short) 1);
-        assertEquals(strategy.createDbRelationshipName(key, false), "toArtist"); 
-        assertEquals(strategy.createDbRelationshipName(key, true), "paintingArray");
-        
-        key = new ExportedKey("PERSON", "PERSON_ID", null,
-                "PERSON", "MOTHER_ID", null, (short) 1);
-        assertEquals(strategy.createDbRelationshipName(key, false), "toPerson"); 
-        assertEquals(strategy.createDbRelationshipName(key, true), "personArray");
-        
-        assertEquals(strategy.createObjEntityName(new DbEntity("ARTIST")), "Artist");
-        assertEquals(strategy.createObjEntityName(new DbEntity("ARTIST_WORK")), "ArtistWork");
-        
-        assertEquals(strategy.createObjAttributeName(new DbAttribute("NAME")), "name");
-        assertEquals(strategy.createObjAttributeName(new DbAttribute("ARTIST_NAME")), "artistName");
-        
-        assertEquals(strategy.createObjRelationshipName(new DbRelationship("toArtist")), "toArtist");
-        assertEquals(strategy.createObjRelationshipName(new DbRelationship("paintingArray")), "paintingArray");
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
index adea83a..921db3b 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
@@ -40,7 +40,7 @@ import org.apache.cayenne.dbsync.reverse.FiltersConfigBuilder;
 import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.dbsync.reverse.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
 import org.apache.cayenne.resource.Resource;
 import org.apache.cayenne.resource.URLResource;
 import org.apache.cayenne.tools.configuration.ToolsModule;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
index 57953c5..b5c2fa7 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportConfiguration.java
@@ -35,8 +35,8 @@ import org.apache.cayenne.dbsync.reverse.db.DefaultDbLoaderDelegate;
 import org.apache.cayenne.dbsync.reverse.db.LoggingDbLoaderDelegate;
 import org.apache.cayenne.dbsync.reverse.filters.CatalogFilter;
 import org.apache.cayenne.dbsync.reverse.filters.FiltersConfig;
-import org.apache.cayenne.dbsync.reverse.naming.DefaultObjectNameGenerator;
-import org.apache.cayenne.dbsync.reverse.naming.ObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.EntityResolver;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
index e7adb7c..8f5ef79 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
@@ -33,7 +33,7 @@ import org.apache.cayenne.dbsync.merge.ModelMergeDelegate;
 import org.apache.cayenne.dbsync.merge.ProxyModelMergeDelegate;
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactory;
 import org.apache.cayenne.dbsync.reverse.db.DbLoader;
-import org.apache.cayenne.dbsync.reverse.naming.ObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.EntityResolver;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DefaultDbImportActionTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DefaultDbImportActionTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DefaultDbImportActionTest.java
index f5d5bbc..98842a3 100644
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DefaultDbImportActionTest.java
+++ b/cayenne-tools/src/test/java/org/apache/cayenne/tools/dbimport/DefaultDbImportActionTest.java
@@ -36,7 +36,7 @@ import org.apache.cayenne.dbsync.merge.factory.DefaultMergerTokenFactory;
 import org.apache.cayenne.dbsync.reverse.db.DbLoader;
 import org.apache.cayenne.dbsync.reverse.db.DbLoaderConfiguration;
 import org.apache.cayenne.dbsync.reverse.db.DbLoaderDelegate;
-import org.apache.cayenne.dbsync.reverse.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
 import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.map.DataMap;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityAction.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityAction.java
index 8569697..b5a95d7 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityAction.java
@@ -23,7 +23,7 @@ import org.apache.cayenne.configuration.ConfigurationNode;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.dbsync.merge.EntityMergeSupport;
 import org.apache.cayenne.dbsync.naming.NameBuilder;
-import org.apache.cayenne.dbsync.reverse.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
@@ -96,7 +96,7 @@ public class CreateObjEntityAction extends CayenneAction {
             entity.setDbEntity(dbEntity);
 
             // TODO: use injectable name generator
-            String baseName = new DefaultObjectNameGenerator().createObjEntityName(dbEntity);
+            String baseName = new DefaultObjectNameGenerator().objEntityName(dbEntity);
             entity.setName(NameBuilder
                     .builder(entity, dbEntity.getDataMap())
                     .baseName(baseName)

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/autorelationship/InferRelationshipsController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/autorelationship/InferRelationshipsController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/autorelationship/InferRelationshipsController.java
index b03f8da..71540c4 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/autorelationship/InferRelationshipsController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/autorelationship/InferRelationshipsController.java
@@ -29,7 +29,7 @@ import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.event.MapEvent;
 import org.apache.cayenne.map.event.RelationshipEvent;
-import org.apache.cayenne.dbsync.reverse.naming.ObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ClassLoadingService;
 import org.apache.cayenne.modeler.ProjectController;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/autorelationship/InferRelationshipsControllerBase.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/autorelationship/InferRelationshipsControllerBase.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/autorelationship/InferRelationshipsControllerBase.java
index 3d3ab37..8530dfd 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/autorelationship/InferRelationshipsControllerBase.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/autorelationship/InferRelationshipsControllerBase.java
@@ -31,7 +31,7 @@ import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbJoin;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
-import org.apache.cayenne.dbsync.reverse.naming.ObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.modeler.util.CayenneController;
 import org.apache.commons.collections.Predicate;
 
@@ -211,7 +211,7 @@ public class InferRelationshipsControllerBase extends CayenneController {
                                      myir.getSource().getName(),
                                      myir.getJoinSource().getName());
             }
-            myir.setName(strategy.createDbRelationshipName(key, myir.isToMany()));
+            myir.setName(strategy.dbRelationshipName(key, myir.isToMany()));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/EntitySyncController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/EntitySyncController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/EntitySyncController.java
index 276f258..0680e5c 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/EntitySyncController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/EntitySyncController.java
@@ -22,7 +22,7 @@ package org.apache.cayenne.modeler.dialog.objentity;
 import org.apache.cayenne.dbsync.merge.EntityMergeSupport;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.dbsync.reverse.naming.ObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.modeler.util.CayenneController;
 import org.apache.cayenne.modeler.util.NameGeneratorPreferences;
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
index 11172fb..56ad7e6 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
@@ -28,7 +28,7 @@ import org.apache.cayenne.map.ObjRelationship;
 import org.apache.cayenne.map.Relationship;
 import org.apache.cayenne.map.event.RelationshipEvent;
 import org.apache.cayenne.dbsync.reverse.db.ExportedKey;
-import org.apache.cayenne.dbsync.reverse.naming.ObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ClassLoadingService;
 import org.apache.cayenne.modeler.ProjectController;
@@ -342,7 +342,7 @@ public class ObjRelationshipInfo extends CayenneController implements TreeSelect
         dbRelationship.setName(createNamingStrategy(NameGeneratorPreferences
                 .getInstance()
                 .getLastUsedStrategies()
-                .get(0)).createDbRelationshipName(
+                .get(0)).dbRelationshipName(
                 new ExportedKey(targetModel.getSource().getName(), null, null,
                                 targetModel.getTarget().getName(), null, null, (short) 1),
                 targetModel.isToMany()));

http://git-wip-us.apache.org/repos/asf/cayenne/blob/413c7204/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/NameGeneratorPreferences.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/NameGeneratorPreferences.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/NameGeneratorPreferences.java
index c215e2b..9380e2b 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/NameGeneratorPreferences.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/NameGeneratorPreferences.java
@@ -22,9 +22,9 @@ import java.util.Arrays;
 import java.util.Vector;
 import java.util.prefs.Preferences;
 
-import org.apache.cayenne.dbsync.reverse.naming.LegacyObjectNameGenerator;
-import org.apache.cayenne.dbsync.reverse.naming.DefaultObjectNameGenerator;
-import org.apache.cayenne.dbsync.reverse.naming.ObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.LegacyObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.dbsync.naming.ObjectNameGenerator;
 import org.apache.cayenne.modeler.Application;
 
 /**


Mime
View raw message