cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [3/5] cayenne git commit: CAY-2116 Split schema synchronization code in a separate module
Date Fri, 30 Sep 2016 18:04:59 GMT
CAY-2116 Split schema synchronization code in a separate module


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

Branch: refs/heads/master
Commit: 2df9f66d8d56b201120cd984614a0e00b0aef4f5
Parents: 633303c
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Fri Sep 30 17:34:49 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Fri Sep 30 18:24:56 2016 +0300

----------------------------------------------------------------------
 .../dbsync/merge/CreateTableToModel.java        |   2 +-
 .../naming/DefaultObjectNameGenerator.java      |   1 -
 .../naming/LegacyObjectNameGenerator.java       |   1 -
 .../dbsync/reverse/naming/NameConverter.java    | 154 ++++++++++++++++++
 .../reverse/naming/NameConverterTest.java       | 115 ++++++++++++++
 .../cayenne/map/naming/NameConverter.java       | 157 -------------------
 .../apache/cayenne/util/NameConverterTest.java  | 116 --------------
 .../cayenne/gen/ClientDataMapArtifact.java      |   9 +-
 .../org/apache/cayenne/gen/DataMapArtifact.java |  11 +-
 .../org/apache/cayenne/gen/DataMapUtils.java    |   2 +-
 .../org/apache/cayenne/gen/StringUtils.java     |   2 +-
 .../action/CreateCallbackMethodAction.java      |   2 +-
 .../modeler/action/CreateObjEntityAction.java   |   2 +-
 .../cayenne/modeler/editor/CallbackType.java    |   2 +-
 14 files changed, 284 insertions(+), 292 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/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 69e18b3..0997e9b 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
@@ -22,7 +22,7 @@ import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactory;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.naming.NameConverter;
+import org.apache.cayenne.dbsync.reverse.naming.NameConverter;
 
 /**
  * A {@link MergerToken} to add a {@link DbEntity} to a {@link DataMap}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/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
index 8cb59db..d299338 100644
--- 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
@@ -22,7 +22,6 @@ 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.apache.cayenne.map.naming.NameConverter;
 import org.jvnet.inflector.Noun;
 
 import java.util.Locale;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/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
index 47e7ea5..16f7f7a 100644
--- 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
@@ -22,7 +22,6 @@ 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.apache.cayenne.map.naming.NameConverter;
 
 /**
  * BasicNamingStrategy is an naming strategy that creates names in Cayenne's

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/NameConverter.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/NameConverter.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/NameConverter.java
new file mode 100644
index 0000000..63c4dcb
--- /dev/null
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/naming/NameConverter.java
@@ -0,0 +1,154 @@
+/*****************************************************************
+ *   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 java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * Utility class to convert from different naming styles to Java convention. For example
+ * names like "ABCD_EFG" can be converted to "abcdEfg".
+ */
+// TODO: deprecate
+public class NameConverter {
+
+    private static final Map<String, String> SPECIAL_CHAR_TO_JAVA_MAPPING = new HashMap<>();
+
+    static {
+        SPECIAL_CHAR_TO_JAVA_MAPPING.put("#", "pound");
+    }
+
+    /**
+     * Converts a String name to a String following java convention for the static final
+     * variables. E.g. "abcXyz" will be converted to "ABC_XYZ".
+     */
+    // TODO: move to the only user....
+    public static String javaToUnderscored(String name) {
+        if (name == null) {
+            return null;
+        }
+
+        // clear of non-java chars. While the method name implies that a passed identifier
+        // is pure Java, it is used to build pk columns names and such, so extra safety
+        // check is a good idea
+        name = specialCharsToJava(name);
+
+        char charArray[] = name.toCharArray();
+        StringBuilder buffer = new StringBuilder();
+
+        for (int i = 0; i < charArray.length; i++) {
+            if ((Character.isUpperCase(charArray[i])) && (i != 0)) {
+
+                char prevChar = charArray[i - 1];
+                if ((Character.isLowerCase(prevChar))) {
+                    buffer.append("_");
+                }
+            }
+
+            buffer.append(Character.toUpperCase(charArray[i]));
+        }
+
+        return buffer.toString();
+    }
+
+    /**
+     * Converts names like "ABCD_EFG_123" to Java-style names like "abcdEfg123". If
+     * <code>capitalize</code> is true, returned name is capitalized (for instance
if
+     * this is a class name).
+     *
+     * @since 1.2
+     */
+    // TODO: migrate users to ObjectNameGenerator
+    public static String underscoredToJava(String name, boolean capitalize) {
+        StringTokenizer st = new StringTokenizer(name, "_");
+        StringBuilder buf = new StringBuilder();
+
+        boolean first = true;
+        while (st.hasMoreTokens()) {
+            String token = st.nextToken();
+
+            // clear of non-java chars
+            token = specialCharsToJava(token);
+
+            int len = token.length();
+            if (len == 0) {
+                continue;
+            }
+
+            // sniff mixed case vs. single case styles
+            boolean hasLowerCase = false;
+            boolean hasUpperCase = false;
+            for (int i = 0; i < len && !(hasUpperCase && hasLowerCase);
i++) {
+                if (Character.isUpperCase(token.charAt(i))) {
+                    hasUpperCase = true;
+                } else if (Character.isLowerCase(token.charAt(i))) {
+                    hasLowerCase = true;
+                }
+            }
+
+            // if mixed case, preserve it, if all upper, convert to lower
+            if (hasUpperCase && !hasLowerCase) {
+                token = token.toLowerCase();
+            }
+
+            if (first) {
+                // apply explicit capitalization rules, if this is the first token
+                first = false;
+                if (capitalize) {
+                    buf.append(Character.toUpperCase(token.charAt(0)));
+                } else {
+                    buf.append(Character.toLowerCase(token.charAt(0)));
+                }
+            } else {
+                buf.append(Character.toUpperCase(token.charAt(0)));
+            }
+
+            if (len > 1) {
+                buf.append(token.substring(1, len));
+            }
+        }
+        return buf.toString();
+    }
+
+    /**
+     * Replaces special chars with human-readable and Java-id-compatible symbols.
+     */
+    static String specialCharsToJava(String string) {
+        int len = string.length();
+        if (len == 0) {
+            return string;
+        }
+
+        StringBuilder buffer = new StringBuilder(len);
+        for (int i = 0; i < len; i++) {
+
+            char c = string.charAt(i);
+            if (Character.isJavaIdentifierPart(c)) {
+                buffer.append(c);
+            } else {
+                Object word = SPECIAL_CHAR_TO_JAVA_MAPPING.get(String.valueOf(c));
+                buffer.append(word != null ? word : "_");
+            }
+        }
+
+        return buffer.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/NameConverterTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/NameConverterTest.java
b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/NameConverterTest.java
new file mode 100644
index 0000000..1c52f6e
--- /dev/null
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/naming/NameConverterTest.java
@@ -0,0 +1,115 @@
+/*****************************************************************
+ *   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.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class NameConverterTest {
+
+    @Test
+    public void testUnderscoredToJava1() throws Exception {
+        String expected = "ClassNameIdentifier";
+        assertEquals(expected, NameConverter.underscoredToJava(
+                "_CLASS_NAME_IDENTIFIER_",
+                true));
+    }
+
+    @Test
+    public void testUnderscoredToJava2() throws Exception {
+        String expected = "propNameIdentifier123";
+        assertEquals(expected, NameConverter.underscoredToJava(
+                "_prop_name_Identifier_123",
+                false));
+    }
+
+    @Test
+    public void testUnderscoredToJava3() throws Exception {
+        String expected = "lastName";
+        assertEquals(expected, NameConverter.underscoredToJava("lastName", false));
+    }
+
+    @Test
+    public void testUnderscoredToJava4() throws Exception {
+        String expected = "lastName";
+        assertEquals(expected, NameConverter.underscoredToJava("LastName", false));
+    }
+
+    @Test
+    public void testUnderscoredToJava5() throws Exception {
+        String expected = "LastName";
+        assertEquals(expected, NameConverter.underscoredToJava("LastName", true));
+    }
+
+    @Test
+    public void testUnderscoredToJavaSpecialChars() throws Exception {
+        assertEquals("ABCpoundXyz", NameConverter.underscoredToJava("ABC#_XYZ", true));
+    }
+
+    @Test
+    public void testJavaToUnderscored1() throws Exception {
+        String expected = "LAST_NAME";
+        assertEquals(expected, NameConverter.javaToUnderscored("LastName"));
+    }
+
+    @Test
+    public void testJavaToUnderscored2() throws Exception {
+        String expected = "A_CLASS";
+        assertEquals(expected, NameConverter.javaToUnderscored("aClass"));
+    }
+
+    @Test
+    public void testJavaToUnderscored3() throws Exception {
+        String expected = "VAR_A";
+        assertEquals(expected, NameConverter.javaToUnderscored("varA"));
+    }
+
+    @Test
+    public void testJavaToUnderscored4() throws Exception {
+        String expected = "LAST_NAME";
+        assertEquals(expected, NameConverter.javaToUnderscored("LAST_NAME"));
+    }
+
+    @Test
+    public void testJavaToUnderscored5() throws Exception {
+        String expected = "ABC_A";
+        assertEquals(expected, NameConverter.javaToUnderscored("abc_A"));
+    }
+
+    @Test
+    public void testJavaToUnderscored6() throws Exception {
+        String expected = "A123";
+        assertEquals(expected, NameConverter.javaToUnderscored("a123"));
+    }
+
+    @Test
+    public void testJavaToUnderscored7() throws Exception {
+        String expected = "AB_CDEF";
+        assertEquals(expected, NameConverter.javaToUnderscored("abCDEF"));
+    }
+
+    @Test
+    public void testJavaToUnderscored8() throws Exception {
+        String expected = "AB_CE";
+        assertEquals(expected, NameConverter.javaToUnderscored("abCe"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/cayenne-server/src/main/java/org/apache/cayenne/map/naming/NameConverter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/naming/NameConverter.java
b/cayenne-server/src/main/java/org/apache/cayenne/map/naming/NameConverter.java
deleted file mode 100644
index 7e4ceed..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/naming/NameConverter.java
+++ /dev/null
@@ -1,157 +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.map.naming;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-/**
- * Utility class to convert from different naming styles to Java convention. For example
- * names like "ABCD_EFG" can be converted to "abcdEfg".
- */
-public class NameConverter {
-
-    private static final Map<String, String> SPECIAL_CHAR_TO_JAVA_MAPPING = new HashMap<>();
-
-    static {
-        SPECIAL_CHAR_TO_JAVA_MAPPING.put("#", "pound");
-    }
-
-    /**
-     * Converts a String name to a String forllowing java convention for the static final
-     * variables. E.g. "abcXyz" will be converted to "ABC_XYZ".
-     * 
-     * @since 1.0.3
-     */
-    public static String javaToUnderscored(String name) {
-        if (name == null) {
-            return null;
-        }
-
-        // clear of non-java chars. While the method name implies that a passed identifier
-        // is pure Java, it is used to build pk columns names and such, so extra safety
-        // check is a good idea
-        name = specialCharsToJava(name);
-
-        char charArray[] = name.toCharArray();
-        StringBuilder buffer = new StringBuilder();
-
-        for (int i = 0; i < charArray.length; i++) {
-            if ((Character.isUpperCase(charArray[i])) && (i != 0)) {
-
-                char prevChar = charArray[i - 1];
-                if ((Character.isLowerCase(prevChar))) {
-                    buffer.append("_");
-                }
-            }
-
-            buffer.append(Character.toUpperCase(charArray[i]));
-        }
-
-        return buffer.toString();
-    }
-
-    /**
-     * Converts names like "ABCD_EFG_123" to Java-style names like "abcdEfg123". If
-     * <code>capitalize</code> is true, returned name is capitalized (for instance
if
-     * this is a class name).
-     * 
-     * @since 1.2
-     */
-    public static String underscoredToJava(String name, boolean capitalize) {
-        StringTokenizer st = new StringTokenizer(name, "_");
-        StringBuilder buf = new StringBuilder();
-
-        boolean first = true;
-        while (st.hasMoreTokens()) {
-            String token = st.nextToken();
-
-            // clear of non-java chars
-            token = specialCharsToJava(token);
-
-            int len = token.length();
-            if (len == 0) {
-                continue;
-            }
-
-            // sniff mixed case vs. single case styles
-            boolean hasLowerCase = false;
-            boolean hasUpperCase = false;
-            for (int i = 0; i < len && !(hasUpperCase && hasLowerCase);
i++) {
-                if (Character.isUpperCase(token.charAt(i))) {
-                    hasUpperCase = true;
-                }
-                else if (Character.isLowerCase(token.charAt(i))) {
-                    hasLowerCase = true;
-                }
-            }
-
-            // if mixed case, preserve it, if all upper, convert to lower
-            if (hasUpperCase && !hasLowerCase) {
-                token = token.toLowerCase();
-            }
-
-            if (first) {
-                // apply explicit capitalization rules, if this is the first token
-                first = false;
-                if (capitalize) {
-                    buf.append(Character.toUpperCase(token.charAt(0)));
-                }
-                else {
-                    buf.append(Character.toLowerCase(token.charAt(0)));
-                }
-            }
-            else {
-                buf.append(Character.toUpperCase(token.charAt(0)));
-            }
-
-            if (len > 1) {
-                buf.append(token.substring(1, len));
-            }
-        }
-        return buf.toString();
-    }
-
-    /**
-     * Replaces special chars with human-readable and Java-id-compatible symbols.
-     */
-    public static String specialCharsToJava(String string) {
-        int len = string.length();
-        if (len == 0) {
-            return string;
-        }
-
-        StringBuilder buffer = new StringBuilder(len);
-        for (int i = 0; i < len; i++) {
-
-            char c = string.charAt(i);
-            if (Character.isJavaIdentifierPart(c)) {
-                buffer.append(c);
-            }
-            else {
-                Object word = SPECIAL_CHAR_TO_JAVA_MAPPING.get(String.valueOf(c));
-                buffer.append(word != null ? word : "_");
-            }
-        }
-
-        return buffer.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/cayenne-server/src/test/java/org/apache/cayenne/util/NameConverterTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/util/NameConverterTest.java b/cayenne-server/src/test/java/org/apache/cayenne/util/NameConverterTest.java
deleted file mode 100644
index 61b7e5f..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/util/NameConverterTest.java
+++ /dev/null
@@ -1,116 +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.util;
-
-import org.apache.cayenne.map.naming.NameConverter;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class NameConverterTest {
-
-    @Test
-    public void testUnderscoredToJava1() throws Exception {
-        String expected = "ClassNameIdentifier";
-        assertEquals(expected, NameConverter.underscoredToJava(
-                "_CLASS_NAME_IDENTIFIER_",
-                true));
-    }
-
-    @Test
-    public void testUnderscoredToJava2() throws Exception {
-        String expected = "propNameIdentifier123";
-        assertEquals(expected, NameConverter.underscoredToJava(
-                "_prop_name_Identifier_123",
-                false));
-    }
-
-    @Test
-    public void testUnderscoredToJava3() throws Exception {
-        String expected = "lastName";
-        assertEquals(expected, NameConverter.underscoredToJava("lastName", false));
-    }
-
-    @Test
-    public void testUnderscoredToJava4() throws Exception {
-        String expected = "lastName";
-        assertEquals(expected, NameConverter.underscoredToJava("LastName", false));
-    }
-
-    @Test
-    public void testUnderscoredToJava5() throws Exception {
-        String expected = "LastName";
-        assertEquals(expected, NameConverter.underscoredToJava("LastName", true));
-    }
-
-    @Test
-    public void testUnderscoredToJavaSpecialChars() throws Exception {
-        assertEquals("ABCpoundXyz", NameConverter.underscoredToJava("ABC#_XYZ", true));
-    }
-
-    @Test
-    public void testJavaToUnderscored1() throws Exception {
-        String expected = "LAST_NAME";
-        assertEquals(expected, NameConverter.javaToUnderscored("LastName"));
-    }
-
-    @Test
-    public void testJavaToUnderscored2() throws Exception {
-        String expected = "A_CLASS";
-        assertEquals(expected, NameConverter.javaToUnderscored("aClass"));
-    }
-
-    @Test
-    public void testJavaToUnderscored3() throws Exception {
-        String expected = "VAR_A";
-        assertEquals(expected, NameConverter.javaToUnderscored("varA"));
-    }
-
-    @Test
-    public void testJavaToUnderscored4() throws Exception {
-        String expected = "LAST_NAME";
-        assertEquals(expected, NameConverter.javaToUnderscored("LAST_NAME"));
-    }
-
-    @Test
-    public void testJavaToUnderscored5() throws Exception {
-        String expected = "ABC_A";
-        assertEquals(expected, NameConverter.javaToUnderscored("abc_A"));
-    }
-
-    @Test
-    public void testJavaToUnderscored6() throws Exception {
-        String expected = "A123";
-        assertEquals(expected, NameConverter.javaToUnderscored("a123"));
-    }
-
-    @Test
-    public void testJavaToUnderscored7() throws Exception {
-        String expected = "AB_CDEF";
-        assertEquals(expected, NameConverter.javaToUnderscored("abCDEF"));
-    }
-
-    @Test
-    public void testJavaToUnderscored8() throws Exception {
-        String expected = "AB_CE";
-        assertEquals(expected, NameConverter.javaToUnderscored("abCe"));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
index 0e6da3e..d99a577 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
@@ -19,13 +19,13 @@
 
 package org.apache.cayenne.gen;
 
-import java.util.Collection;
-
+import org.apache.cayenne.dbsync.reverse.naming.NameConverter;
 import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.naming.NameConverter;
 import org.apache.cayenne.map.QueryDescriptor;
 import org.apache.cayenne.util.Util;
 
+import java.util.Collection;
+
 public class ClientDataMapArtifact extends DataMapArtifact {
 
     public ClientDataMapArtifact(DataMap dataMap, Collection<QueryDescriptor> queries)
{
@@ -46,7 +46,6 @@ public class ClientDataMapArtifact extends DataMapArtifact {
             clientPrefix = "Client_";
         }
 
-        return dataMap.getNameWithDefaultClientPackage(NameConverter
-                .underscoredToJava(clientPrefix + NameConverter.specialCharsToJava(dataMap.getName()),
true));
+        return dataMap.getNameWithDefaultClientPackage(NameConverter.underscoredToJava(clientPrefix
+ dataMap.getName(), true));
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
index 838f1c6..e01d002 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
@@ -19,14 +19,14 @@
 
 package org.apache.cayenne.gen;
 
-import java.util.Collection;
-import java.util.LinkedList;
-
+import org.apache.cayenne.dbsync.reverse.naming.NameConverter;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.cayenne.map.naming.NameConverter;
 import org.apache.velocity.VelocityContext;
 
+import java.util.Collection;
+import java.util.LinkedList;
+
 /**
  * {@link Artifact} facade for a DataMap.
  * 
@@ -58,8 +58,7 @@ public class DataMapArtifact implements Artifact {
     }
 
     public String getQualifiedClassName() {
-        return dataMap.getNameWithDefaultPackage(NameConverter
-                .underscoredToJava(NameConverter.specialCharsToJava(dataMap.getName()), true));
+        return dataMap.getNameWithDefaultPackage(NameConverter.underscoredToJava(dataMap.getName(),
true));
     }
 
     public Object getObject() {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
index 64a3a38..9d5c75a 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
@@ -42,7 +42,7 @@ import org.apache.cayenne.map.ObjRelationship;
 import org.apache.cayenne.map.PathComponent;
 import org.apache.cayenne.map.QueryDescriptor;
 import org.apache.cayenne.map.SelectQueryDescriptor;
-import org.apache.cayenne.map.naming.NameConverter;
+import org.apache.cayenne.dbsync.reverse.naming.NameConverter;
 import org.apache.cayenne.query.Ordering;
 import org.apache.cayenne.util.CayenneMapEntry;
 import org.apache.commons.collections.set.ListOrderedSet;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java
index bd5c453..34ccfb3 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java
@@ -20,7 +20,7 @@
 package org.apache.cayenne.gen;
 
 import org.apache.cayenne.project.validation.NameValidationHelper;
-import org.apache.cayenne.map.naming.NameConverter;
+import org.apache.cayenne.dbsync.reverse.naming.NameConverter;
 import org.apache.cayenne.util.Util;
 
 /**

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java
index 5835ac9..df6a43a 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java
@@ -30,7 +30,7 @@ import org.apache.cayenne.modeler.editor.CallbackType;
 import org.apache.cayenne.modeler.event.CallbackMethodEvent;
 import org.apache.cayenne.modeler.undo.CreateCallbackMethodUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
-import org.apache.cayenne.map.naming.NameConverter;
+import org.apache.cayenne.dbsync.reverse.naming.NameConverter;
 
 /**
  * Action class for creating callback methods on ObjEntity

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/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 cb656d9..8b4406b 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
@@ -29,7 +29,7 @@ import org.apache.cayenne.map.event.EntityEvent;
 import org.apache.cayenne.map.event.MapEvent;
 import org.apache.cayenne.map.naming.UniqueNameGenerator;
 import org.apache.cayenne.map.naming.NameCheckers;
-import org.apache.cayenne.map.naming.NameConverter;
+import org.apache.cayenne.dbsync.reverse.naming.NameConverter;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.EntityDisplayEvent;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2df9f66d/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java
index f0de775..932e345 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java
@@ -21,7 +21,7 @@ package org.apache.cayenne.modeler.editor;
 import java.io.Serializable;
 
 import org.apache.cayenne.map.LifecycleEvent;
-import org.apache.cayenne.map.naming.NameConverter;
+import org.apache.cayenne.dbsync.reverse.naming.NameConverter;
 
 /**
  * Entity for callback type. Contains type and type name


Mime
View raw message