Author: kmenard
Date: Wed Apr 29 01:59:31 2009
New Revision: 769626
URL: http://svn.apache.org/viewvc?rev=769626&view=rev
Log:
Fixed a line ending issue.
Modified:
cayenne/main/trunk/framework/cayenne-modeler/pom.xml
cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/map/naming/SmartNamingStrategy.java
cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/map/naming/SmartNamingStrategyTest.java
Modified: cayenne/main/trunk/framework/cayenne-modeler/pom.xml
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/pom.xml?rev=769626&r1=769625&r2=769626&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/pom.xml (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/pom.xml Wed Apr 29 01:59:31
2009
@@ -1,176 +1,176 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
---><project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.cayenne</groupId>
- <artifactId>cayenne-parent</artifactId>
- <version>3.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>cayenne-modeler</artifactId>
- <name>Cayenne Modeler</name>
- <packaging>jar</packaging>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-pool</groupId>
- <artifactId>commons-pool</artifactId>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>velocity</groupId>
- <artifactId>velocity</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.objectstyle.ashwood</groupId>
- <artifactId>ashwood</artifactId>
- </dependency>
-
- <dependency>
- <groupId>jgoodies</groupId>
- <artifactId>looks</artifactId>
- </dependency>
-
- <dependency>
- <groupId>jgoodies</groupId>
- <artifactId>forms</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.scopemvc</groupId>
- <artifactId>scopemvc</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.cayenne.unpublished</groupId>
- <artifactId>cayenne-legal-unpublished</artifactId>
- <version>${version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.cayenne.unpublished</groupId>
- <artifactId>cayenne-jdk1.5-unpublished</artifactId>
- <version>${version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.cayenne</groupId>
- <artifactId>cayenne-tools</artifactId>
- <version>${version}</version>
- </dependency>
-
- <dependency>
- <groupId>ognl</groupId>
- <artifactId>ognl</artifactId>
- </dependency>
-
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- </dependency>
-
- <dependency>
- <groupId>mockrunner</groupId>
- <artifactId>mockrunner</artifactId>
- </dependency>
-
- <dependency>
- <groupId>net.sf.jedit-syntax</groupId>
- <artifactId>jedit-syntax</artifactId>
- <version>2.2.2</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
-
<artifactId>maven-remote-resources-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>process</goal>
- </goals>
- <phase>process-resources</phase>
- <configuration>
- <outputDirectory>
-
${project.build.directory}/classes
- </outputDirectory>
- <resourceBundles>
- <resourceBundle>
-
org.apache.cayenne.unpublished:cayenne-legal-unpublished:${version}
-
</resourceBundle>
- </resourceBundles>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>bundle-source-jar</id>
- <phase>package</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
-
- </build>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+--><project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.cayenne</groupId>
+ <artifactId>cayenne-parent</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>cayenne-modeler</artifactId>
+ <name>Cayenne Modeler</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>velocity</groupId>
+ <artifactId>velocity</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.objectstyle.ashwood</groupId>
+ <artifactId>ashwood</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jgoodies</groupId>
+ <artifactId>looks</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jgoodies</groupId>
+ <artifactId>forms</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.scopemvc</groupId>
+ <artifactId>scopemvc</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cayenne.unpublished</groupId>
+ <artifactId>cayenne-legal-unpublished</artifactId>
+ <version>${version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cayenne.unpublished</groupId>
+ <artifactId>cayenne-jdk1.5-unpublished</artifactId>
+ <version>${version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cayenne</groupId>
+ <artifactId>cayenne-tools</artifactId>
+ <version>${version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ognl</groupId>
+ <artifactId>ognl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>mockrunner</groupId>
+ <artifactId>mockrunner</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sf.jedit-syntax</groupId>
+ <artifactId>jedit-syntax</artifactId>
+ <version>2.2.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+
<artifactId>maven-remote-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <outputDirectory>
+
${project.build.directory}/classes
+ </outputDirectory>
+ <resourceBundles>
+ <resourceBundle>
+
org.apache.cayenne.unpublished:cayenne-legal-unpublished:${version}
+
</resourceBundle>
+ </resourceBundles>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>bundle-source-jar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ </build>
</project>
\ No newline at end of file
Modified:
cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/map/naming/SmartNamingStrategy.java
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/map/naming/SmartNamingStrategy.java?rev=769626&r1=769625&r2=769626&view=diff
==============================================================================
---
cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/map/naming/SmartNamingStrategy.java
(original)
+++
cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/map/naming/SmartNamingStrategy.java
Wed Apr 29 01:59:31 2009
@@ -1,88 +1,88 @@
-/*****************************************************************
- * 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.Locale;
-
-import org.apache.cayenne.map.naming.BasicNamingStrategy;
-import org.apache.cayenne.map.naming.ExportedKey;
-import org.apache.cayenne.util.NameConverter;
-import org.jvnet.inflector.Noun;
-
-/**
- * SmartNamingStrategy is a new strategy for generating names of
- * entities, attributes etc.
- *
- * Advantages of this strategy are:
- * -Using of FK names at generating relationship names
- * -Dropping 'to' prefix for obj relationships and therefore for generated
class methods' names
- * -Using pluralized form instead-of "ARRAY" suffix for to-many relationships
(i.e. 'adresses'
- * instead-of 'addressArray')
- *
- * @since 3.0
- */
-public class SmartNamingStrategy extends BasicNamingStrategy {
- @Override
- public String createDbRelationshipName(
- ExportedKey key,
- boolean toMany) {
-
- String name;
-
- if (!toMany) {
- String fkColName = key.getFKColumnName();
-
- //trim "ID" in the end
- if (fkColName.toUpperCase().endsWith("_ID") && fkColName.length()
> 3) {
- fkColName = fkColName.substring(0, fkColName.length() - 3);
- }
- else if (fkColName.toUpperCase().endsWith("ID") &&
fkColName.length() > 2) {
- fkColName = 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'
- */
- return super.createDbRelationshipName(key, toMany);
- }
-
- name = fkColName;
- }
- else {
- 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 super.createDbRelationshipName(key, toMany);
- }
- }
-
- return NameConverter.underscoredToJava(name, false);
- }
-}
+/*****************************************************************
+ * 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.Locale;
+
+import org.apache.cayenne.map.naming.BasicNamingStrategy;
+import org.apache.cayenne.map.naming.ExportedKey;
+import org.apache.cayenne.util.NameConverter;
+import org.jvnet.inflector.Noun;
+
+/**
+ * SmartNamingStrategy is a new strategy for generating names of
+ * entities, attributes etc.
+ *
+ * Advantages of this strategy are:
+ * -Using of FK names at generating relationship names
+ * -Dropping 'to' prefix for obj relationships and therefore for generated
class methods' names
+ * -Using pluralized form instead-of "ARRAY" suffix for to-many relationships
(i.e. 'adresses'
+ * instead-of 'addressArray')
+ *
+ * @since 3.0
+ */
+public class SmartNamingStrategy extends BasicNamingStrategy {
+ @Override
+ public String createDbRelationshipName(
+ ExportedKey key,
+ boolean toMany) {
+
+ String name;
+
+ if (!toMany) {
+ String fkColName = key.getFKColumnName();
+
+ //trim "ID" in the end
+ if (fkColName.toUpperCase().endsWith("_ID") && fkColName.length()
> 3) {
+ fkColName = fkColName.substring(0, fkColName.length() - 3);
+ }
+ else if (fkColName.toUpperCase().endsWith("ID") &&
fkColName.length() > 2) {
+ fkColName = 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'
+ */
+ return super.createDbRelationshipName(key, toMany);
+ }
+
+ name = fkColName;
+ }
+ else {
+ 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 super.createDbRelationshipName(key, toMany);
+ }
+ }
+
+ return NameConverter.underscoredToJava(name, false);
+ }
+}
Modified:
cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/map/naming/SmartNamingStrategyTest.java
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/map/naming/SmartNamingStrategyTest.java?rev=769626&r1=769625&r2=769626&view=diff
==============================================================================
---
cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/map/naming/SmartNamingStrategyTest.java
(original)
+++
cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/map/naming/SmartNamingStrategyTest.java
Wed Apr 29 01:59:31 2009
@@ -1,56 +1,56 @@
-/*****************************************************************
- * 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 junit.framework.TestCase;
-
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.naming.ExportedKey;
-
-public class SmartNamingStrategyTest extends TestCase {
- public void testStrategy() throws Exception {
- SmartNamingStrategy strategy = new SmartNamingStrategy();
-
- ExportedKey key = new ExportedKey("ARTIST", "ARTIST_ID", null,
- "PAINTING", "ARTIST_ID", null);
- assertEquals(strategy.createDbRelationshipName(key, false), "artist");
- assertEquals(strategy.createDbRelationshipName(key, true),
"paintings");
-
- key = new ExportedKey("PERSON", "PERSON_ID", null,
- "PERSON", "MOTHER_ID", null);
- assertEquals(strategy.createDbRelationshipName(key, false), "mother");
- assertEquals(strategy.createDbRelationshipName(key, true), "people");
-
- key = new ExportedKey("PERSON", "PERSON_ID", null,
- "ADDRESS", "SHIPPING_ADDRESS_ID", null);
- 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");
- }
-}
+/*****************************************************************
+ * 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 junit.framework.TestCase;
+
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.naming.ExportedKey;
+
+public class SmartNamingStrategyTest extends TestCase {
+ public void testStrategy() throws Exception {
+ SmartNamingStrategy strategy = new SmartNamingStrategy();
+
+ ExportedKey key = new ExportedKey("ARTIST", "ARTIST_ID", null,
+ "PAINTING", "ARTIST_ID", null);
+ assertEquals(strategy.createDbRelationshipName(key, false), "artist");
+ assertEquals(strategy.createDbRelationshipName(key, true),
"paintings");
+
+ key = new ExportedKey("PERSON", "PERSON_ID", null,
+ "PERSON", "MOTHER_ID", null);
+ assertEquals(strategy.createDbRelationshipName(key, false), "mother");
+ assertEquals(strategy.createDbRelationshipName(key, true), "people");
+
+ key = new ExportedKey("PERSON", "PERSON_ID", null,
+ "ADDRESS", "SHIPPING_ADDRESS_ID", null);
+ 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");
+ }
+}