cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [05/10] cayenne git commit: CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant
Date Wed, 01 Feb 2017 13:23:53 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/filter/NamePatternMatcherTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/filter/NamePatternMatcherTest.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/filter/NamePatternMatcherTest.java
index d99ba09..0b4674b 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/filter/NamePatternMatcherTest.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/filter/NamePatternMatcherTest.java
@@ -21,27 +21,11 @@ package org.apache.cayenne.dbsync.filter;
 
 import org.junit.Test;
 
-import static org.apache.cayenne.dbsync.filter.NamePatternMatcher.replaceWildcardInStringWithString;
 import static org.junit.Assert.assertEquals;
 
 public class NamePatternMatcherTest {
 
     /**
-     * Test pattern expansion.
-     */
-    @Test
-    public void testReplaceWildcardInStringWithString() throws Exception {
-        assertEquals(null, replaceWildcardInStringWithString("*", null, "Entity"));
-        assertEquals("*.java", replaceWildcardInStringWithString(null, "*.java", "Entity"));
-        assertEquals("Entity.java", replaceWildcardInStringWithString("*", "*.java", "Entity"));
-        assertEquals("java.Entity", replaceWildcardInStringWithString("*", "java.*", "Entity"));
-        assertEquals("Entity.Entity", replaceWildcardInStringWithString("*", "*.*", "Entity"));
-        assertEquals("EntityEntity", replaceWildcardInStringWithString("*", "**", "Entity"));
-        assertEquals("EditEntityReport.vm", replaceWildcardInStringWithString("*", "Edit*Report.vm", "Entity"));
-        assertEquals("Entity", replaceWildcardInStringWithString("*", "*", "Entity"));
-    }
-
-    /**
      * Test tokenizing
      */
     @Test

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-di/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-di/pom.xml b/cayenne-di/pom.xml
index 12fd6fd..1984dd3 100644
--- a/cayenne-di/pom.xml
+++ b/cayenne-di/pom.xml
@@ -29,7 +29,7 @@
 	</dependencies>
 	<build>
 		<plugins>
-			<!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-joda/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-joda/pom.xml b/cayenne-joda/pom.xml
index 7e969cf..18354ff 100644
--- a/cayenne-joda/pom.xml
+++ b/cayenne-joda/pom.xml
@@ -100,7 +100,7 @@
 	</dependencies>
 	<build>
 		<plugins>
-			<!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-lifecycle/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-lifecycle/pom.xml b/cayenne-lifecycle/pom.xml
index 04d62a1..b1172c7 100644
--- a/cayenne-lifecycle/pom.xml
+++ b/cayenne-lifecycle/pom.xml
@@ -68,7 +68,7 @@
 	</dependencies>
 	<build>
 		<plugins>
-			<!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-project/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-project/pom.xml b/cayenne-project/pom.xml
index 4c2174c..c426335 100644
--- a/cayenne-project/pom.xml
+++ b/cayenne-project/pom.xml
@@ -82,7 +82,7 @@
 
     <build>
         <plugins>
-            <!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+            <!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-protostuff/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-protostuff/pom.xml b/cayenne-protostuff/pom.xml
index 0328db7..185f446 100644
--- a/cayenne-protostuff/pom.xml
+++ b/cayenne-protostuff/pom.xml
@@ -90,7 +90,7 @@
 
     <build>
         <plugins>
-            <!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+            <!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-server/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/pom.xml b/cayenne-server/pom.xml
index 1e27e2f..88d9e7b 100644
--- a/cayenne-server/pom.xml
+++ b/cayenne-server/pom.xml
@@ -166,7 +166,7 @@
 			</resource>
 		</resources>
 		<plugins>
-			<!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/pom.xml b/cayenne-tools/pom.xml
deleted file mode 100644
index fb48cb3..0000000
--- a/cayenne-tools/pom.xml
+++ /dev/null
@@ -1,193 +0,0 @@
-<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-	<parent>
-		<artifactId>cayenne-parent</artifactId>
-		<groupId>org.apache.cayenne</groupId>
-		<version>4.0.M5-SNAPSHOT</version>
-	</parent>
-
-	<modelVersion>4.0.0</modelVersion>
-
-	<artifactId>cayenne-tools</artifactId>
-	<packaging>jar</packaging>
-	<name>cayenne-tools: Cayenne Tools</name>
-	<dependencies>
-        <!-- Compile Dependencies -->
-        <dependency>
-            <groupId>org.apache.ant</groupId>
-            <artifactId>ant</artifactId>
-            <scope>compile</scope>
-        </dependency>
-		<dependency>
-			<groupId>commons-collections</groupId>
-			<artifactId>commons-collections</artifactId>
-            <scope>compile</scope>
-		</dependency>
-		<dependency>
-			<groupId>commons-logging</groupId>
-			<artifactId>commons-logging</artifactId>
-            <scope>compile</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.velocity</groupId>
-			<artifactId>velocity</artifactId>
-            <scope>compile</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.cayenne</groupId>
-			<artifactId>cayenne-server</artifactId>
-			<version>${project.version}</version>
-            <scope>compile</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.cayenne</groupId>
-			<artifactId>cayenne-project</artifactId>
-			<version>${project.version}</version>
-            <scope>compile</scope>
-		</dependency>
-        <dependency>
-            <groupId>org.apache.cayenne</groupId>
-            <artifactId>cayenne-dbsync</artifactId>
-            <version>${project.version}</version>
-            <scope>compile</scope>
-        </dependency>
-		<dependency>
-			<groupId>foundrylogic.vpp</groupId>
-			<artifactId>vpp</artifactId>
-            <scope>compile</scope>
-		</dependency>
-
-        <!-- Test Dependencies -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cayenne</groupId>
-            <artifactId>cayenne-server</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-            <type>test-jar</type>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cayenne</groupId>
-            <artifactId>cayenne-dbsync</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-            <type>test-jar</type>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cayenne.build-tools</groupId>
-            <artifactId>cayenne-test-utilities</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.ant</groupId>
-            <artifactId>ant-testutil</artifactId>
-            <version>1.9.4</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.derby</groupId>
-            <artifactId>derby</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>xmlunit</groupId>
-            <artifactId>xmlunit</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-	</dependencies>
-	
-	<build>
-		<plugins>
-			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
-            <plugin>
-                <artifactId>maven-remote-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>process</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <artifactId>maven-jar-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>test-jar</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-	</build>
-    <profiles>
-        <profile>
-            <id>code-quality</id>
-
-            <activation>
-                <property>
-                    <name>!fast-and-dirty</name>
-                </property>
-            </activation>
-            <build>
-                <plugins>
-                    <plugin>
-                        <artifactId>maven-checkstyle-plugin</artifactId>
-                        <!--<configuration>
-                            <suppressionsLocation>${project.basedir}/cayenne-checkstyle-suppression.xml</suppressionsLocation>
-                        </configuration>-->
-                    </plugin>
-                    <plugin>
-                        <artifactId>maven-pmd-plugin</artifactId>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
-    </profiles>
-</project>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/Artifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/Artifact.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/Artifact.java
deleted file mode 100644
index fcd9118..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/Artifact.java
+++ /dev/null
@@ -1,65 +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.gen;
-
-import org.apache.velocity.VelocityContext;
-
-/**
- * Represents a class generation "artifact" which is a facade to a metadata object used
- * for a given single generation template run.
- * 
- * @since 3.0
- */
-public interface Artifact {
-
-    public static String STRING_UTILS_KEY = "stringUtils";
-    public static String IMPORT_UTILS_KEY = "importUtils";
-
-    /**
-     * Root object, such as ObjEntity or Embeddable, etc.
-     */
-    public static String OBJECT_KEY = "object";
-    public static String SUPER_CLASS_KEY = "superClassName";
-    public static String SUPER_PACKAGE_KEY = "superPackageName";
-    public static String SUB_CLASS_KEY = "subClassName";
-    public static String SUB_PACKAGE_KEY = "subPackageName";
-    public static String BASE_CLASS_KEY = "baseClassName";
-    public static String BASE_PACKAGE_KEY = "basePackageName";
-    public static String CREATE_PROPERTY_NAMES = "createPropertyNames";
-
-    TemplateType[] getTemplateTypes(ArtifactGenerationMode mode);
-
-    String getQualifiedBaseClassName();
-
-    String getQualifiedClassName();
-
-    /**
-     * Returns a mapping metadata object for this artifact.
-     */
-    Object getObject();
-
-    /**
-     * A callback method that allows each artifact to add its own special keys to the
-     * context. Invoked from
-     * {@link ClassGenerationAction#resetContextForArtifactTemplate(Artifact, TemplateType)},
-     * after the context is initialized by code generator, so this method can use
-     * predefined keys from the context.
-     */
-    void postInitContext(VelocityContext context);
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java
deleted file mode 100644
index b0c20cc..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java
+++ /dev/null
@@ -1,28 +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.gen;
-
-/**
- * Code generator execution mode for a single artifact.
- * 
- * @since 3.0
- */
-public enum ArtifactGenerationMode {
-    SINGLE_CLASS, GENERATION_GAP
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java
deleted file mode 100644
index e76c172..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java
+++ /dev/null
@@ -1,40 +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.gen;
-
-/**
- * Code generator execution mode for a collection of artifacts.
- * 
- * @since 3.0
- */
-public enum ArtifactsGenerationMode {
-
-    // TODO: andrus 12/9/2007 - label names are old... need to call it something else...
-    DATAMAP("datamap"), ENTITY("entity"), ALL("all");
-
-    private String label;
-
-    private ArtifactsGenerationMode(String label) {
-        this.label = label;
-    }
-
-    public String getLabel() {
-        return label;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
deleted file mode 100644
index 9c5c932..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
+++ /dev/null
@@ -1,584 +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.gen;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.Embeddable;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.commons.logging.Log;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.log.NullLogSystem;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-public class ClassGenerationAction {
-	static final String TEMPLATES_DIR_NAME = "templates/v1_2/";
-
-	public static final String SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "singleclass.vm";
-	public static final String SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "subclass.vm";
-	public static final String SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "superclass.vm";
-
-	public static final String EMBEDDABLE_SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "embeddable-singleclass.vm";
-	public static final String EMBEDDABLE_SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "embeddable-subclass.vm";
-	public static final String EMBEDDABLE_SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "embeddable-superclass.vm";
-
-	public static final String DATAMAP_SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "datamap-singleclass.vm";
-	public static final String DATAMAP_SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "datamap-subclass.vm";
-	public static final String DATAMAP_SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "datamap-superclass.vm";
-
-	public static final String SUPERCLASS_PREFIX = "_";
-	private static final String WILDCARD = "*";
-
-	protected Collection<Artifact> artifacts;
-
-	protected String superPkg;
-	protected DataMap dataMap;
-
-	protected ArtifactsGenerationMode artifactsGenerationMode;
-	protected boolean makePairs;
-
-	protected Log logger;
-	protected File destDir;
-	protected boolean overwrite;
-	protected boolean usePkgPath;
-
-	protected String template;
-	protected String superTemplate;
-	protected String embeddableTemplate;
-	protected String embeddableSuperTemplate;
-	protected String queryTemplate;
-	protected String querySuperTemplate;
-	protected long timestamp;
-	protected String outputPattern;
-	protected String encoding;
-	protected boolean createPropertyNames;
-
-	// runtime ivars
-	protected VelocityContext context;
-	protected Map<String, Template> templateCache;
-
-	public ClassGenerationAction() {
-		this.outputPattern = "*.java";
-		this.timestamp = System.currentTimeMillis();
-		this.usePkgPath = true;
-		this.makePairs = true;
-		this.context = new VelocityContext();
-		this.templateCache = new HashMap<>(5);
-
-		this.artifacts = new ArrayList<>();
-	}
-
-	protected String defaultTemplateName(TemplateType type) {
-		switch (type) {
-		case ENTITY_SINGLE_CLASS:
-			return ClassGenerationAction.SINGLE_CLASS_TEMPLATE;
-		case ENTITY_SUBCLASS:
-			return ClassGenerationAction.SUBCLASS_TEMPLATE;
-		case ENTITY_SUPERCLASS:
-			return ClassGenerationAction.SUPERCLASS_TEMPLATE;
-		case EMBEDDABLE_SUBCLASS:
-			return ClassGenerationAction.EMBEDDABLE_SUBCLASS_TEMPLATE;
-		case EMBEDDABLE_SUPERCLASS:
-			return ClassGenerationAction.EMBEDDABLE_SUPERCLASS_TEMPLATE;
-		case EMBEDDABLE_SINGLE_CLASS:
-			return ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE;
-		case DATAMAP_SINGLE_CLASS:
-			return ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE;
-		case DATAMAP_SUPERCLASS:
-			return ClassGenerationAction.DATAMAP_SUPERCLASS_TEMPLATE;
-		case DATAMAP_SUBCLASS:
-			return ClassGenerationAction.DATAMAP_SUBCLASS_TEMPLATE;
-		default:
-			throw new IllegalArgumentException("Invalid template type: " + type);
-		}
-	}
-
-	protected String customTemplateName(TemplateType type) {
-		switch (type) {
-		case ENTITY_SINGLE_CLASS:
-			return template;
-		case ENTITY_SUBCLASS:
-			return template;
-		case ENTITY_SUPERCLASS:
-			return superTemplate;
-		case EMBEDDABLE_SUBCLASS:
-			return embeddableTemplate;
-		case EMBEDDABLE_SUPERCLASS:
-			return embeddableSuperTemplate;
-		case DATAMAP_SINGLE_CLASS:
-			return queryTemplate;
-		case DATAMAP_SUPERCLASS:
-			return querySuperTemplate;
-		case DATAMAP_SUBCLASS:
-			return queryTemplate;
-		default:
-			throw new IllegalArgumentException("Invalid template type: " + type);
-		}
-	}
-
-	/**
-	 * Returns a String used to prefix class name to create a generated
-	 * superclass. Default value is "_".
-	 */
-	protected String getSuperclassPrefix() {
-		return ClassGenerationAction.SUPERCLASS_PREFIX;
-	}
-
-	/**
-	 * VelocityContext initialization method called once per artifact.
-	 */
-	protected void resetContextForArtifact(Artifact artifact) {
-		StringUtils stringUtils = StringUtils.getInstance();
-
-		String qualifiedClassName = artifact.getQualifiedClassName();
-		String packageName = stringUtils.stripClass(qualifiedClassName);
-		String className = stringUtils.stripPackageName(qualifiedClassName);
-
-		String qualifiedBaseClassName = artifact.getQualifiedBaseClassName();
-		String basePackageName = stringUtils.stripClass(qualifiedBaseClassName);
-		String baseClassName = stringUtils.stripPackageName(qualifiedBaseClassName);
-
-		String superClassName = getSuperclassPrefix() + stringUtils.stripPackageName(qualifiedClassName);
-
-		String superPackageName = this.superPkg;
-		if (superPackageName == null) {
-			superPackageName = packageName + ".auto";
-		}
-
-		context.put(Artifact.BASE_CLASS_KEY, baseClassName);
-		context.put(Artifact.BASE_PACKAGE_KEY, basePackageName);
-
-		context.put(Artifact.SUB_CLASS_KEY, className);
-		context.put(Artifact.SUB_PACKAGE_KEY, packageName);
-
-		context.put(Artifact.SUPER_CLASS_KEY, superClassName);
-		context.put(Artifact.SUPER_PACKAGE_KEY, superPackageName);
-
-		context.put(Artifact.OBJECT_KEY, artifact.getObject());
-		context.put(Artifact.STRING_UTILS_KEY, stringUtils);
-
-		context.put(Artifact.CREATE_PROPERTY_NAMES, createPropertyNames);
-	}
-
-	/**
-	 * VelocityContext initialization method called once per each artifact and
-	 * template type combination.
-	 */
-	protected void resetContextForArtifactTemplate(Artifact artifact, TemplateType templateType) {
-		context.put(Artifact.IMPORT_UTILS_KEY, new ImportUtils());
-		artifact.postInitContext(context);
-	}
-
-	/**
-	 * Executes class generation once per each artifact.
-	 */
-	public void execute() throws Exception {
-
-		validateAttributes();
-
-		try {
-			for (Artifact artifact : artifacts) {
-				execute(artifact);
-			}
-		} finally {
-			// must reset engine at the end of class generator run to avoid
-			// memory
-			// leaks and stale templates
-			this.templateCache.clear();
-		}
-	}
-
-	/**
-	 * Executes class generation for a single artifact.
-	 */
-	protected void execute(Artifact artifact) throws Exception {
-
-		resetContextForArtifact(artifact);
-
-		ArtifactGenerationMode artifactMode = makePairs ? ArtifactGenerationMode.GENERATION_GAP
-				: ArtifactGenerationMode.SINGLE_CLASS;
-
-		TemplateType[] templateTypes = artifact.getTemplateTypes(artifactMode);
-		for (TemplateType type : templateTypes) {
-
-			try (Writer out = openWriter(type);) {
-				if (out != null) {
-
-					resetContextForArtifactTemplate(artifact, type);
-					getTemplate(type).merge(context, out);
-				}
-			}
-		}
-	}
-
-	protected Template getTemplate(TemplateType type) throws Exception {
-
-		String templateName = customTemplateName(type);
-		if (templateName == null) {
-			templateName = defaultTemplateName(type);
-		}
-
-		// Velocity < 1.5 has some memory problems, so we will create a
-		// VelocityEngine
-		// every time, and store templates in an internal cache, to avoid
-		// uncontrolled
-		// memory leaks... Presumably 1.5 fixes it.
-
-		Template template = templateCache.get(templateName);
-
-		if (template == null) {
-
-			Properties props = new Properties();
-
-			// null logger that will prevent velocity.log from being generated
-			props.put(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, NullLogSystem.class.getName());
-			props.put("resource.loader", "cayenne");
-			props.put("cayenne.resource.loader.class", ClassGeneratorResourceLoader.class.getName());
-			props.put("cayenne.resource.loader.cache", "false");
-
-			VelocityEngine velocityEngine = new VelocityEngine();
-			velocityEngine.init(props);
-
-			template = velocityEngine.getTemplate(templateName);
-			templateCache.put(templateName, template);
-		}
-
-		return template;
-	}
-
-	/**
-	 * Validates the state of this class generator. Throws
-	 * CayenneRuntimeException if it is in an inconsistent state. Called
-	 * internally from "execute".
-	 */
-	protected void validateAttributes() {
-		if (destDir == null) {
-			throw new CayenneRuntimeException("'destDir' attribute is missing.");
-		}
-
-		if (!destDir.isDirectory()) {
-			throw new CayenneRuntimeException("'destDir' is not a directory.");
-		}
-
-		if (!destDir.canWrite()) {
-			throw new CayenneRuntimeException("Do not have write permissions for " + destDir);
-		}
-	}
-
-	/**
-	 * Sets the destDir.
-	 */
-	public void setDestDir(File destDir) {
-		this.destDir = destDir;
-	}
-
-	/**
-	 * Sets <code>overwrite</code> property.
-	 */
-	public void setOverwrite(boolean overwrite) {
-		this.overwrite = overwrite;
-	}
-
-	/**
-	 * Sets <code>makepairs</code> property.
-	 */
-	public void setMakePairs(boolean makePairs) {
-		this.makePairs = makePairs;
-	}
-
-	/**
-	 * Sets <code>template</code> property.
-	 */
-	public void setTemplate(String template) {
-		this.template = template;
-	}
-
-	/**
-	 * Sets <code>superTemplate</code> property.
-	 */
-	public void setSuperTemplate(String superTemplate) {
-		this.superTemplate = superTemplate;
-	}
-
-	public void setQueryTemplate(String queryTemplate) {
-		this.queryTemplate = queryTemplate;
-	}
-
-	public void setQuerySuperTemplate(String querySuperTemplate) {
-		this.querySuperTemplate = querySuperTemplate;
-	}
-
-	/**
-	 * Sets <code>usepkgpath</code> property.
-	 */
-	public void setUsePkgPath(boolean usePkgPath) {
-		this.usePkgPath = usePkgPath;
-	}
-
-	/**
-	 * Sets <code>outputPattern</code> property.
-	 */
-	public void setOutputPattern(String outputPattern) {
-		this.outputPattern = outputPattern;
-	}
-
-	/**
-	 * Sets <code>createPropertyNames</code> property.
-	 */
-	public void setCreatePropertyNames(boolean createPropertyNames) {
-		this.createPropertyNames = createPropertyNames;
-	}
-
-	/**
-	 * Opens a Writer to write generated output. Returned Writer is mapped to a
-	 * filesystem file (although subclasses may override that). File location is
-	 * determined from the current state of VelocityContext and the TemplateType
-	 * passed as a parameter. Writer encoding is determined from the value of
-	 * the "encoding" property.
-	 */
-	protected Writer openWriter(TemplateType templateType) throws Exception {
-
-		File outFile = (templateType.isSuperclass()) ? fileForSuperclass() : fileForClass();
-		if (outFile == null) {
-			return null;
-		}
-
-		if (logger != null) {
-			String label = templateType.isSuperclass() ? "superclass" : "class";
-			logger.info("Generating " + label + " file: " + outFile.getCanonicalPath());
-		}
-
-		// return writer with specified encoding
-		FileOutputStream out = new FileOutputStream(outFile);
-
-		return (encoding != null) ? new OutputStreamWriter(out, encoding) : new OutputStreamWriter(out);
-	}
-
-	/**
-	 * Returns a target file where a generated superclass must be saved. If null
-	 * is returned, class shouldn't be generated.
-	 */
-	protected File fileForSuperclass() throws Exception {
-
-		String packageName = (String) context.get(Artifact.SUPER_PACKAGE_KEY);
-		String className = (String) context.get(Artifact.SUPER_CLASS_KEY);
-
-		String filename = NamePatternMatcher.replaceWildcardInStringWithString(WILDCARD, outputPattern, className);
-		File dest = new File(mkpath(destDir, packageName), filename);
-
-		// Ignore if the destination is newer than the map
-		// (internal timestamp), i.e. has been generated after the map was
-		// last saved AND the template is older than the destination file
-		if (dest.exists() && !isOld(dest)) {
-
-			if (superTemplate == null) {
-				return null;
-			}
-
-			File superTemplateFile = new File(superTemplate);
-			if (superTemplateFile.lastModified() < dest.lastModified()) {
-				return null;
-			}
-		}
-
-		return dest;
-	}
-
-	/**
-	 * Returns a target file where a generated class must be saved. If null is
-	 * returned, class shouldn't be generated.
-	 */
-	protected File fileForClass() throws Exception {
-
-		String packageName = (String) context.get(Artifact.SUB_PACKAGE_KEY);
-		String className = (String) context.get(Artifact.SUB_CLASS_KEY);
-
-		String filename = NamePatternMatcher.replaceWildcardInStringWithString(WILDCARD, outputPattern, className);
-		File dest = new File(mkpath(destDir, packageName), filename);
-
-		if (dest.exists()) {
-			// no overwrite of subclasses
-			if (makePairs) {
-				return null;
-			}
-
-			// skip if said so
-			if (!overwrite) {
-				return null;
-			}
-
-			// Ignore if the destination is newer than the map
-			// (internal timestamp), i.e. has been generated after the map was
-			// last saved AND the template is older than the destination file
-			if (!isOld(dest)) {
-
-				if (template == null) {
-					return null;
-				}
-
-				File templateFile = new File(template);
-				if (templateFile.lastModified() < dest.lastModified()) {
-					return null;
-				}
-			}
-		}
-
-		return dest;
-	}
-
-	/**
-	 * Returns true if <code>file</code> parameter is older than internal
-	 * timestamp of this class generator.
-	 */
-	protected boolean isOld(File file) {
-		return file.lastModified() <= timestamp;
-	}
-
-	/**
-	 * Returns a File object corresponding to a directory where files that
-	 * belong to <code>pkgName</code> package should reside. Creates any missing
-	 * diectories below <code>dest</code>.
-	 */
-	protected File mkpath(File dest, String pkgName) throws Exception {
-
-		if (!usePkgPath || pkgName == null) {
-			return dest;
-		}
-
-		String path = pkgName.replace('.', File.separatorChar);
-		File fullPath = new File(dest, path);
-		if (!fullPath.isDirectory() && !fullPath.mkdirs()) {
-			throw new Exception("Error making path: " + fullPath);
-		}
-
-		return fullPath;
-	}
-
-	public void setTimestamp(long timestamp) {
-		this.timestamp = timestamp;
-	}
-
-	/**
-	 * Sets file encoding. If set to null, default system encoding will be used.
-	 */
-	public void setEncoding(String encoding) {
-		this.encoding = encoding;
-	}
-
-	/**
-	 * Sets "superPkg" property value.
-	 */
-	public void setSuperPkg(String superPkg) {
-		this.superPkg = superPkg;
-	}
-
-	/**
-	 * @param dataMap
-	 *            The dataMap to set.
-	 */
-	public void setDataMap(DataMap dataMap) {
-		this.dataMap = dataMap;
-	}
-
-	/**
-	 * Adds entities to the internal entity list.
-	 */
-	public void addEntities(Collection<ObjEntity> entities) {
-		if (artifactsGenerationMode == ArtifactsGenerationMode.ENTITY
-				|| artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
-			if (entities != null) {
-				for (ObjEntity entity : entities) {
-					artifacts.add(new EntityArtifact(entity));
-				}
-			}
-		}
-	}
-
-	public void addEmbeddables(Collection<Embeddable> embeddables) {
-		if (artifactsGenerationMode == ArtifactsGenerationMode.ENTITY
-				|| artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
-			if (embeddables != null) {
-				for (Embeddable embeddable : embeddables) {
-					artifacts.add(new EmbeddableArtifact(embeddable));
-				}
-			}
-		}
-	}
-
-	public void addQueries(Collection<QueryDescriptor> queries) {
-		if (artifactsGenerationMode == ArtifactsGenerationMode.DATAMAP
-				|| artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
-
-			// TODO: andrus 10.12.2010 - why not also check for empty query
-			// list?? Or
-			// create a better API for enabling DataMapArtifact
-			if (queries != null) {
-				artifacts.add(new DataMapArtifact(dataMap, queries));
-			}
-		}
-	}
-
-	/**
-	 * Sets an optional shared VelocityContext. Useful with tools like VPP that
-	 * can set custom values in the context, not known to Cayenne.
-	 */
-	public void setContext(VelocityContext context) {
-		this.context = context;
-	}
-
-	/**
-	 * Injects an optional logger that will be used to trace generated files at
-	 * the info level.
-	 */
-	public void setLogger(Log logger) {
-		this.logger = logger;
-	}
-
-	public void setEmbeddableTemplate(String embeddableTemplate) {
-		this.embeddableTemplate = embeddableTemplate;
-	}
-
-	public void setEmbeddableSuperTemplate(String embeddableSuperTemplate) {
-		this.embeddableSuperTemplate = embeddableSuperTemplate;
-	}
-
-	public void setArtifactsGenerationMode(String mode) {
-		if (ArtifactsGenerationMode.ENTITY.getLabel().equalsIgnoreCase(mode)) {
-			this.artifactsGenerationMode = ArtifactsGenerationMode.ENTITY;
-		} else if (ArtifactsGenerationMode.DATAMAP.getLabel().equalsIgnoreCase(mode)) {
-			this.artifactsGenerationMode = ArtifactsGenerationMode.DATAMAP;
-		} else {
-			this.artifactsGenerationMode = ArtifactsGenerationMode.ALL;
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
deleted file mode 100644
index 8e8a1ee..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
+++ /dev/null
@@ -1,102 +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.gen;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
-
-/**
- * Velocity template resource loader customized for Cayenne use. Supports loading
- * templates from the thread ClassLoader and from relative and absolute paths.
- * 
- * @since 1.2
- */
-// must be public top-level class as it is
-// instantiated via reflection by Velocity
-public class ClassGeneratorResourceLoader extends FileResourceLoader {
-
-    /**
-     * Returns resource as InputStream. First calls super implementation. If resource
-     * wasn't found, it attempts to load it from current directory or as an absolute path.
-     */
-    @Override
-    public synchronized InputStream getResourceStream(String name)
-            throws ResourceNotFoundException {
-
-        InputStream stream = loadFromRelativePath(name);
-        if (stream != null) {
-            return stream;
-        }
-
-        stream = loadFromAbsPath(name);
-        if (stream != null) {
-            return stream;
-        }
-
-        stream = loadFromThreadClassLoader(name);
-        if (stream != null) {
-            return stream;
-        }
-
-        stream = loadFromThisClassLoader(name);
-        if (stream != null) {
-            return stream;
-        }
-
-        throw new ResourceNotFoundException("Couldn't find resource '"
-                + name
-                + "'. Searched filesystem path and classpath");
-    }
-
-    protected InputStream loadFromRelativePath(String name) {
-        try {
-            return super.getResourceStream(name);
-        }
-        catch (ResourceNotFoundException rnfex) {
-            return null;
-        }
-    }
-
-    protected InputStream loadFromAbsPath(String name) {
-        try {
-            File file = new File(name);
-            return (file.canRead()) ? new BufferedInputStream(new FileInputStream(file
-                    .getAbsolutePath())) : null;
-
-        }
-        catch (FileNotFoundException fnfe) {
-            return null;
-        }
-    }
-
-    protected InputStream loadFromThreadClassLoader(String name) {
-        return Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
-    }
-
-    protected InputStream loadFromThisClassLoader(String name) {
-        return getClass().getClassLoader().getResourceAsStream(name);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
deleted file mode 100644
index f36fd68..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
+++ /dev/null
@@ -1,79 +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.gen;
-
-import java.util.Collection;
-
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.QueryDescriptor;
-
-/**
- * @since 3.0
- */
-public class ClientClassGenerationAction extends ClassGenerationAction {
-
-    public static final String SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-subclass.vm";
-    public static final String SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-superclass.vm";
-    
-    public static final String DMAP_SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-datamap-singleclass.vm";
-    public static final String DMAP_SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-datamap-subclass.vm";
-    public static final String DMAP_SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-datamap-superclass.vm";
-    
-    public static final String CLIENT_SUPERCLASS_PREFIX = "_Client";
-
-    @Override
-    protected String defaultTemplateName(TemplateType type) {
-        switch (type) {
-            case ENTITY_SUBCLASS:
-                return ClientClassGenerationAction.SUBCLASS_TEMPLATE;
-            case ENTITY_SUPERCLASS:
-                return ClientClassGenerationAction.SUPERCLASS_TEMPLATE;
-            case EMBEDDABLE_SUBCLASS:
-                return ClassGenerationAction.EMBEDDABLE_SUBCLASS_TEMPLATE;
-            case EMBEDDABLE_SUPERCLASS:
-                return ClassGenerationAction.EMBEDDABLE_SUPERCLASS_TEMPLATE;
-            
-            case DATAMAP_SUPERCLASS:
-                return ClientClassGenerationAction.DMAP_SUPERCLASS_TEMPLATE;
-            case DATAMAP_SUBCLASS:
-                return ClientClassGenerationAction.DMAP_SUBCLASS_TEMPLATE;
-            default:
-                throw new IllegalArgumentException("Unsupported template type: " + type);
-        }
-    }
-
-    @Override
-    public void addEntities(Collection<ObjEntity> entities) {
-        if (entities != null) {
-            for (ObjEntity entity : entities) {
-                artifacts.add(new ClientEntityArtifact(entity));
-            }
-        }
-    }
-
-    @Override
-    public void addQueries(Collection<QueryDescriptor> queries) {
-        if (artifactsGenerationMode == ArtifactsGenerationMode.DATAMAP
-                || artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
-            if (queries != null) {
-                artifacts.add(new ClientDataMapArtifact(dataMap, queries));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/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
deleted file mode 100644
index a9d1dfe..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
+++ /dev/null
@@ -1,50 +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.gen;
-
-import org.apache.cayenne.map.DataMap;
-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) {
-        super(dataMap, queries);
-
-    }
-
-    @Override
-    public String getQualifiedBaseClassName() {
-
-        return dataMap.getDefaultClientSuperclass();
-    }
-
-    @Override
-    public String getQualifiedClassName() {
-        String clientPrefix = "";
-        if (Util.nullSafeEquals(dataMap.getDefaultClientPackage(), dataMap.getDefaultPackage())) {
-            clientPrefix = "Client_";
-        }
-
-        return dataMap.getNameWithDefaultClientPackage(Util.underscoredToJava(clientPrefix + dataMap.getName(), true));
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java
deleted file mode 100644
index d20a2d4..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java
+++ /dev/null
@@ -1,45 +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.gen;
-
-import org.apache.cayenne.PersistentObject;
-import org.apache.cayenne.map.ObjEntity;
-
-/**
- * Client code generation artifact based on ObjEntity.
- * 
- * @since 3.0
- */
-public class ClientEntityArtifact extends EntityArtifact {
-
-    public ClientEntityArtifact(ObjEntity entity) {
-        super(entity);
-    }
-
-    @Override
-    public String getQualifiedBaseClassName() {
-        return (entity.getClientSuperClassName() != null) ? entity
-                .getClientSuperClassName() : PersistentObject.class.getName();
-    }
-
-    @Override
-    public String getQualifiedClassName() {
-        return entity.getClientClassName();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/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
deleted file mode 100644
index 8e60495..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
+++ /dev/null
@@ -1,137 +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.gen;
-
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.cayenne.util.Util;
-import org.apache.velocity.VelocityContext;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-/**
- * {@link Artifact} facade for a DataMap.
- * 
- * @since 3.0
- */
-public class DataMapArtifact implements Artifact {
-
-    public static final String DATAMAP_UTILS_KEY = "dataMapUtils";
-
-    protected DataMap dataMap;
-    protected Collection<QueryDescriptor> selectQueries;
-    protected Collection<QueryDescriptor> sqlTemplateQueries;
-    protected Collection<QueryDescriptor> procedureQueries;
-    protected Collection<QueryDescriptor> ejbqlQueries;
-    protected Collection<String> queryNames;
-
-    public DataMapArtifact(DataMap dataMap, Collection<QueryDescriptor> queries) {
-        this.dataMap = dataMap;
-        selectQueries = new LinkedList<>();
-        sqlTemplateQueries = new LinkedList<>();
-        procedureQueries = new LinkedList<>();
-        ejbqlQueries = new LinkedList<>();
-        queryNames = new LinkedList<>();
-        addQueries(queries);
-    }
-
-    public String getQualifiedBaseClassName() {
-        return Object.class.getName();
-    }
-
-    public String getQualifiedClassName() {
-        return dataMap.getNameWithDefaultPackage(Util.underscoredToJava(dataMap.getName(), true));
-    }
-
-    public Object getObject() {
-        return this;
-    }
-
-    public void postInitContext(VelocityContext context) {
-        DataMapUtils dataMapUtils = new DataMapUtils();
-        context.put(DATAMAP_UTILS_KEY, dataMapUtils);
-    }
-
-    public TemplateType[] getTemplateTypes(ArtifactGenerationMode mode) {
-        switch (mode) {
-            case SINGLE_CLASS:
-                return new TemplateType[] {
-                    TemplateType.DATAMAP_SINGLE_CLASS
-                };
-            case GENERATION_GAP:
-                return new TemplateType[] {
-                        TemplateType.DATAMAP_SUPERCLASS, TemplateType.DATAMAP_SUBCLASS
-                };
-            default:
-                return new TemplateType[0];
-        }
-    }
-
-    private void addQueries(Collection<QueryDescriptor> queries) {
-        if (queries != null) {
-            for (QueryDescriptor query : queries) {
-                addQuery(query);
-            }
-        }
-    }
-
-    private void addQuery(QueryDescriptor query) {
-
-        switch (query.getType()) {
-            case QueryDescriptor.SELECT_QUERY:
-                selectQueries.add(query);
-                break;
-            case QueryDescriptor.PROCEDURE_QUERY:
-                procedureQueries.add(query);
-                break;
-            case QueryDescriptor.SQL_TEMPLATE:
-                sqlTemplateQueries.add(query);
-                break;
-            case QueryDescriptor.EJBQL_QUERY:
-                ejbqlQueries.add(query);
-                break;
-        }
-
-        if (query.getName() != null && !"".equals(query.getName())) {
-            queryNames.add(query.getName());
-        }
-    }
-
-    public Collection<QueryDescriptor> getSelectQueries() {
-        return selectQueries;
-    }
-
-    public boolean hasSelectQueries() {
-        return selectQueries.size() > 0;
-    }
-
-    public boolean hasQueryNames() {
-        return !queryNames.isEmpty();
-    }
-
-    public Collection<String> getQueryNames() {
-        return queryNames;
-    }
-
-    public DataMap getDataMap() {
-    	return dataMap;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/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
deleted file mode 100644
index a0013cc..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
+++ /dev/null
@@ -1,219 +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.gen;
-
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionException;
-import org.apache.cayenne.exp.ExpressionParameter;
-import org.apache.cayenne.exp.parser.ASTList;
-import org.apache.cayenne.exp.parser.ASTObjPath;
-import org.apache.cayenne.map.Entity;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-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.query.Ordering;
-import org.apache.cayenne.util.CayenneMapEntry;
-import org.apache.cayenne.util.Util;
-import org.apache.commons.collections.set.ListOrderedSet;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Attributes and Methods for working with Queries.
- *
- * @since 3.0
- */
-public class DataMapUtils {
-
-	Map<String, Map<String, String>> queriesMap = new HashMap<>();
-
-	/**
-	 * Return valid method name based on query name (replace all illegal
-	 * characters with underscore '_').
-	 * 
-	 * @param query
-	 * @return Method name that perform query.
-	 */
-	public String getQueryMethodName(QueryDescriptor query) {
-		return Util.underscoredToJava(query.getName(), true);
-	}
-
-	/**
-	 * Get all parameter names that used in query qualifier.
-	 *
-	 * @param query
-	 * @return Parameter names.
-	 */
-	public Collection getParameterNames(SelectQueryDescriptor query) {
-
-		if (query.getQualifier() == null) {
-			return Collections.EMPTY_SET;
-		}
-
-		Map<String, String> queryParameters = queriesMap.get(query.getName());
-
-		if (queryParameters == null) {
-			queryParameters = getParameterNames(query.getQualifier(), query.getRoot());
-			queriesMap.put(query.getName(), queryParameters);
-		}
-
-		return parseQualifier(query.getQualifier().toString());
-	}
-
-	public Boolean isValidParameterNames(SelectQueryDescriptor query) {
-
-		if (query.getQualifier() == null) {
-			return true;
-		}
-
-		Map<String, String> queryParameters = queriesMap.get(query.getName());
-
-		if (queryParameters == null) {
-			try {
-				queryParameters = getParameterNames(query.getQualifier(), query.getRoot());
-			} catch (Exception e) {
-				// if we have wrong path in queryParameters return false.
-				return false;
-			}
-		}
-
-		for (Ordering ordering : query.getOrderings()) {
-			// validate paths in ordering
-			String path = ordering.getSortSpecString();
-			Iterator<CayenneMapEntry> it = ((ObjEntity) query.getRoot()).resolvePathComponents(path);
-			while (it.hasNext()) {
-				try {
-					it.next();
-				} catch (ExpressionException e) {
-					// if we have wrong path in orderings return false.
-					return false;
-				}
-			}
-		}
-
-		return true;
-	}
-
-	/**
-	 * Get list of parameter names in the same order as in qualifier.
-	 * 
-	 * @param qualifierString
-	 *            to be parsed
-	 * @return List of parameter names.
-	 */
-	private Set parseQualifier(String qualifierString) {
-		Set result = new ListOrderedSet();
-		Pattern pattern = Pattern.compile("\\$[\\w]+");
-		Matcher matcher = pattern.matcher(qualifierString);
-		while (matcher.find()) {
-			String name = matcher.group();
-			result.add(Util.underscoredToJava(name.substring(1), false));
-		}
-
-		return result;
-	}
-
-	public boolean hasParameters(SelectQueryDescriptor query) {
-		Map queryParameters = queriesMap.get(query.getName());
-
-		if (queryParameters == null) {
-			return false;
-		}
-
-		return queryParameters.keySet().size() > 0;
-
-	}
-
-	/**
-	 * Get type of parameter for given name.
-	 *
-	 * @param query
-	 * @param name
-	 * @return Parameter type.
-	 */
-	public String getParameterType(SelectQueryDescriptor query, String name) {
-		return queriesMap.get(query.getName()).get(name);
-	}
-
-	private Map<String, String> getParameterNames(Expression expression, Object root) {
-		if (expression != null) {
-			Map<String, String> types = new HashMap<>();
-			String typeName = "";
-			List<String> names = new LinkedList<String>();
-
-			for (int i = 0; i < expression.getOperandCount(); i++) {
-				Object operand = expression.getOperand(i);
-
-				if (operand instanceof Expression) {
-					types.putAll(getParameterNames((Expression) operand, root));
-				}
-
-				if (operand instanceof ASTObjPath) {
-					PathComponent<ObjAttribute, ObjRelationship> component = ((Entity) root).lastPathComponent(
-							(ASTObjPath) operand, null);
-					ObjAttribute attribute = component.getAttribute();
-					if (attribute != null) {
-						typeName = attribute.getType();
-					} else {
-						ObjRelationship relationship = component.getRelationship();
-						if (relationship != null) {
-							typeName = ((ObjEntity) relationship.getTargetEntity()).getClassName();
-						} else {
-							typeName = "Object";
-						}
-					}
-				}
-
-				if (operand instanceof ASTList) {
-					Object[] values = (Object[]) ((ASTList) operand).getOperand(0);
-					for (Object value : values) {
-						if (value instanceof ExpressionParameter) {
-							names.add(((ExpressionParameter) value).getName());
-						}
-					}
-				}
-
-				if (operand instanceof ExpressionParameter) {
-					names.add(((ExpressionParameter) operand).getName());
-				}
-
-			}
-
-			for (String name : names) {
-				types.put(Util.underscoredToJava(name, false), typeName);
-			}
-
-			return types;
-		}
-		return Collections.EMPTY_MAP;
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
deleted file mode 100644
index 8e6ea43..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
+++ /dev/null
@@ -1,68 +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.gen;
-
-import org.apache.cayenne.map.Embeddable;
-import org.apache.velocity.VelocityContext;
-
-/**
- * {@link Artifact} facade for an {@link Embeddable}.
- * 
- * @since 3.0
- */
-public class EmbeddableArtifact implements Artifact {
-
-    protected Embeddable embeddable;
-
-    public EmbeddableArtifact(Embeddable embeddable) {
-        this.embeddable = embeddable;
-    }
-
-    public Object getObject() {
-        return embeddable;
-    }
-
-    public String getQualifiedBaseClassName() {
-        return Object.class.getName();
-    }
-
-    public String getQualifiedClassName() {
-        return embeddable.getClassName();
-    }
-
-    public TemplateType[] getTemplateTypes(ArtifactGenerationMode mode) {
-        switch (mode) {
-            case SINGLE_CLASS:
-                return new TemplateType[] {
-                    TemplateType.EMBEDDABLE_SINGLE_CLASS
-                };
-            case GENERATION_GAP:
-                return new TemplateType[] {
-                        TemplateType.EMBEDDABLE_SUPERCLASS,
-                        TemplateType.EMBEDDABLE_SUBCLASS
-                };
-            default:
-                return new TemplateType[0];
-        }
-    }
-
-    public void postInitContext(VelocityContext context) {
-        // noop - no special keys...
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityArtifact.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
deleted file mode 100644
index 394304f..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
+++ /dev/null
@@ -1,98 +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.gen;
-
-import org.apache.cayenne.CayenneDataObject;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.velocity.VelocityContext;
-
-/**
- * {@link Artifact} facade for an ObjEntity.
- * 
- * @since 3.0
- */
-public class EntityArtifact implements Artifact {
-
-    public static String ENTITY_UTILS_KEY = "entityUtils";
-
-    protected ObjEntity entity;
-
-    public EntityArtifact(ObjEntity entity) {
-        this.entity = entity;
-    }
-
-    /**
-     * Returns ObjEntity.
-     */
-    public Object getObject() {
-        return entity;
-    }
-
-    public String getQualifiedBaseClassName() {
-        return (entity.getSuperClassName() != null)
-                ? entity.getSuperClassName()
-                : CayenneDataObject.class.getName();
-    }
-
-    public String getQualifiedClassName() {
-        return entity.getClassName();
-    }
-
-    public TemplateType getSingleClassType() {
-        return TemplateType.ENTITY_SINGLE_CLASS;
-    }
-
-    public TemplateType getSubclassType() {
-        return TemplateType.ENTITY_SUBCLASS;
-    }
-
-    public TemplateType getSuperClassType() {
-        return TemplateType.ENTITY_SUPERCLASS;
-    }
-
-    public TemplateType[] getTemplateTypes(ArtifactGenerationMode mode) {
-        switch (mode) {
-            case SINGLE_CLASS:
-                return new TemplateType[] {
-                    TemplateType.ENTITY_SINGLE_CLASS
-                };
-            case GENERATION_GAP:
-                return new TemplateType[] {
-                        TemplateType.ENTITY_SUPERCLASS, TemplateType.ENTITY_SUBCLASS
-                };
-            default:
-                return new TemplateType[0];
-        }
-    }
-
-    public void postInitContext(VelocityContext context) {
-        EntityUtils metadata = new EntityUtils(
-                entity.getDataMap(),
-                entity,
-                (String) context.get(BASE_CLASS_KEY),
-                (String) context.get(BASE_PACKAGE_KEY),
-                (String) context.get(SUPER_CLASS_KEY),
-                (String) context.get(SUPER_PACKAGE_KEY),
-                (String) context.get(SUB_CLASS_KEY),
-                (String) context.get(SUB_PACKAGE_KEY));
-
-        context.put(ENTITY_UTILS_KEY, metadata);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityUtils.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityUtils.java
deleted file mode 100644
index ecf2a3f..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityUtils.java
+++ /dev/null
@@ -1,274 +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.gen;
-
-import java.util.Collection;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.MappingNamespace;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.map.Relationship;
-
-/**
- * Attributes and Methods for working with ObjEntities.
- * 
- * @since 1.2
- */
-public class EntityUtils {
-
-    // template substitution values
-    protected String subClassName;
-    protected String superClassName;
-    protected String baseClassName;
-    protected String subPackageName;
-    protected String superPackageName;
-    protected String basePackageName;
-
-    protected DataMap primaryDataMap;
-    protected ObjEntity objEntity;
-
-    protected Collection<String> callbackNames;
-
-    public EntityUtils(DataMap dataMap, ObjEntity objEntity, String fqnBaseClass, String fqnSuperClass,
-            String fqnSubClass) {
-
-        StringUtils stringUtils = StringUtils.getInstance();
-
-        this.baseClassName = stringUtils.stripPackageName(fqnBaseClass);
-        this.basePackageName = stringUtils.stripClass(fqnBaseClass);
-        this.superClassName = stringUtils.stripPackageName(fqnSuperClass);
-        this.superPackageName = stringUtils.stripClass(fqnSuperClass);
-        this.subClassName = stringUtils.stripPackageName(fqnSubClass);
-        this.subPackageName = stringUtils.stripClass(fqnSubClass);
-
-        this.primaryDataMap = dataMap;
-
-        this.objEntity = objEntity;
-        this.callbackNames = objEntity.getCallbackMethods();
-    }
-
-    EntityUtils(DataMap dataMap, ObjEntity objEntity, String baseClassName, String basePackageName,
-            String superClassName, String superPackageName, String subClassName, String subPackageName) {
-
-        this.baseClassName = baseClassName;
-        this.basePackageName = basePackageName;
-        this.superClassName = superClassName;
-        this.superPackageName = superPackageName;
-        this.subClassName = subClassName;
-        this.subPackageName = subPackageName;
-
-        this.primaryDataMap = dataMap;
-
-        this.objEntity = objEntity;
-        this.callbackNames = objEntity.getCallbackMethods();
-    }
-
-    /**
-     * @return Returns the primary DataMap.
-     * @since 1.2
-     */
-    public DataMap getPrimaryDataMap() {
-        return primaryDataMap;
-    }
-
-    /**
-     * Returns the EntityResolver for this set of DataMaps.
-     * 
-     * @since 1.2
-     */
-    public MappingNamespace getEntityResolver() {
-        return primaryDataMap.getNamespace();
-    }
-
-    /**
-     * Returns true if current ObjEntity is defined as abstract.
-     */
-    public boolean isAbstract() {
-        return isAbstract(objEntity);
-    }
-
-    /**
-     * Returns true if current ObjEntity is defined as abstract.
-     */
-    public boolean isAbstract(ObjEntity anObjEntity) {
-        return anObjEntity != null && anObjEntity.isAbstract();
-    }
-
-    /**
-     * Returns true if current ObjEntity contains at least one toMany
-     * relationship.
-     */
-    public boolean hasToManyRelationships() {
-        return hasToManyRelationships(objEntity);
-    }
-
-    /**
-     * Returns true if an ObjEntity contains at least one toMany relationship.
-     */
-    public boolean hasToManyRelationships(ObjEntity anObjEntity) {
-        if (anObjEntity == null) {
-            return false;
-        }
-
-        for (Relationship r : anObjEntity.getRelationships()) {
-            if (r.isToMany()) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Returns true if current ObjEntity contains at least one toMany
-     * relationship, ignoring those declared in superentities.
-     * 
-     * @since 1.2
-     */
-    public boolean hasToManyDeclaredRelationships() {
-        return hasToManyDeclaredRelationships(objEntity);
-    }
-
-    /**
-     * Returns true if an ObjEntity contains at least one toMany relationship,
-     * ignoring those declared in superentities.
-     * 
-     * @since 1.2
-     */
-    public boolean hasToManyDeclaredRelationships(ObjEntity anObjEntity) {
-        if (anObjEntity == null) {
-            return false;
-        }
-
-        for (Relationship r : anObjEntity.getDeclaredRelationships()) {
-            if (r.isToMany()) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Returns true if current ObjEntity contains at least one toOne
-     * relationship.
-     */
-    public boolean hasToOneRelationships() {
-        return hasToOneRelationships(objEntity);
-    }
-
-    /**
-     * Returns true if an ObjEntity contains at least one toOne relationship.
-     */
-    public boolean hasToOneRelationships(ObjEntity anObjEntity) {
-        if (anObjEntity == null) {
-            return false;
-        }
-
-        for (Relationship r : anObjEntity.getRelationships()) {
-            if (!r.isToMany()) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Returns true if current ObjEntity contains at least one toOne
-     * relationship, ignoring those declared in superentities.
-     */
-    public boolean hasToOneDeclaredRelationships() {
-        return hasToOneDeclaredRelationships(objEntity);
-    }
-
-    /**
-     * Returns true if an ObjEntity contains at least one toOne relationship,
-     * ignoring those declared in superentities.
-     */
-    public boolean hasToOneDeclaredRelationships(ObjEntity anObjEntity) {
-        if (anObjEntity == null) {
-            return false;
-        }
-
-        for (Relationship r : anObjEntity.getDeclaredRelationships()) {
-            if (!r.isToMany()) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Returns the map key type for a collection relationship of type
-     * java.util.Map.
-     * 
-     * @param relationship
-     *            The relationship to look up type information for.
-     * @return The type of the attribute keyed on.
-     */
-    public String getMapKeyType(final ObjRelationship relationship) {
-
-        ObjEntity targetEntity = (ObjEntity) relationship.getTargetEntity();
-
-        // If the map key is null, then we're doing look-ups by actual object
-        // key.
-        if (relationship.getMapKey() == null) {
-
-            // If it's a multi-column key, then the return type is always
-            // ObjectId.
-            DbEntity dbEntity = targetEntity.getDbEntity();
-            if ((dbEntity != null) && (dbEntity.getPrimaryKeys().size() > 1)) {
-                return ObjectId.class.getName();
-            }
-
-            // If it's a single column key or no key exists at all, then we
-            // really don't
-            // know what the key type is,
-            // so default to Object.
-            return Object.class.getName();
-        }
-
-        // If the map key is a non-default attribute, then fetch the attribute
-        // and return
-        // its type.
-        ObjAttribute attribute = targetEntity.getAttribute(relationship.getMapKey());
-        if (attribute == null) {
-            throw new CayenneRuntimeException("Invalid map key '" + relationship.getMapKey()
-                    + "', no matching attribute found");
-        }
-
-        return attribute.getType();
-    }
-
-    /**
-     * @return the list of all callback names registered for the entity.
-     * @since 3.0
-     */
-    public Collection<String> getCallbackNames() {
-        return callbackNames;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ImportUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ImportUtils.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ImportUtils.java
deleted file mode 100644
index af40499..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ImportUtils.java
+++ /dev/null
@@ -1,266 +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.gen;
-
-import org.apache.cayenne.util.Util;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Methods for mangling strings.
- * 
- */
-public class ImportUtils {
-
-	public static final String importOrdering[] = new String[] { "java.", "javax.", "org.", "com." };
-
-	static final String primitives[] = new String[] { "long", "double", "byte", "boolean", "float", "short", "int",
-			"char" };
-
-	static final String primitiveClasses[] = new String[] { Long.class.getName(), Double.class.getName(),
-			Byte.class.getName(), Boolean.class.getName(), Float.class.getName(), Short.class.getName(),
-			Integer.class.getName(), Character.class.getName() };
-
-	static Map<String, String> classesForPrimitives = Util.toMap(primitives, primitiveClasses);
-	static Map<String, String> primitivesForClasses = Util.toMap(primitiveClasses, primitives);
-
-	protected Map<String, String> importTypesMap = new HashMap<>();
-
-	// Types forced to be FQN
-	protected Map<String, String> reservedImportTypesMap = new HashMap<>();
-
-	protected String packageName;
-
-	public ImportUtils() {
-		super();
-	}
-
-	protected boolean canRegisterType(String typeName) {
-		// Not sure why this would ever happen, but it did
-		if (null == typeName)
-			return false;
-
-		StringUtils stringUtils = StringUtils.getInstance();
-		String typeClassName = stringUtils.stripPackageName(typeName);
-		String typePackageName = stringUtils.stripClass(typeName);
-
-		if (typePackageName.length() == 0)
-			return false; // disallow non-packaged types (primitives, probably)
-		if ("java.lang".equals(typePackageName))
-			return false;
-
-		// Can only have one type -- rest must use fqn
-		if (reservedImportTypesMap.containsKey(typeClassName))
-			return false;
-		if (importTypesMap.containsKey(typeClassName))
-			return false;
-
-		return true;
-	}
-
-	/**
-	 * Reserve a fully-qualified data type class name so it cannot be used by
-	 * another class. No import statements will be generated for reserved types.
-	 * Typically, this is the fully-qualified class name of the class being
-	 * generated.
-	 * 
-	 * @param typeName
-	 *            FQ data type class name.
-	 */
-	public void addReservedType(String typeName) {
-		if (!canRegisterType(typeName))
-			return;
-
-		StringUtils stringUtils = StringUtils.getInstance();
-		String typeClassName = stringUtils.stripPackageName(typeName);
-
-		reservedImportTypesMap.put(typeClassName, typeName);
-	}
-
-	/**
-	 * Register a fully-qualified data type class name. For example,
-	 * org.apache.cayenne.CayenneDataObject.
-	 * 
-	 * @param typeName
-	 *            FQ data type class name.
-	 */
-	public void addType(String typeName) {
-		if (!canRegisterType(typeName))
-			return;
-
-		StringUtils stringUtils = StringUtils.getInstance();
-		String typePackageName = stringUtils.stripClass(typeName);
-		String typeClassName = stringUtils.stripPackageName(typeName);
-
-		if (typePackageName.equals(packageName))
-			return;
-
-		importTypesMap.put(typeClassName, typeName);
-	}
-
-	/**
-	 * Add the package name to use for this importUtil invocation.
-	 * 
-	 * @param packageName
-	 */
-	public void setPackage(String packageName) {
-		this.packageName = packageName;
-	}
-
-	/**
-	 * Performs processing similar to <code>formatJavaType(String)</code>, with
-	 * special handling of primitive types and their Java class counterparts.
-	 * This method allows users to make a decision whether to use primitives or
-	 * not, regardless of how type is mapped.
-	 */
-	public String formatJavaType(String typeName, boolean usePrimitives) {
-		if (usePrimitives) {
-			String primitive = primitivesForClasses.get(typeName);
-			return (primitive != null) ? primitive : formatJavaType(typeName);
-		} else {
-			String primitiveClass = classesForPrimitives.get(typeName);
-			return (primitiveClass != null) ? formatJavaType(primitiveClass) : formatJavaType(typeName);
-		}
-	}
-
-	/**
-	 * Removes registered package and non-reserved registered type name prefixes
-	 * from java types
-	 */
-	public String formatJavaType(String typeName) {
-		if (typeName != null) {
-			StringUtils stringUtils = StringUtils.getInstance();
-			String typeClassName = stringUtils.stripPackageName(typeName);
-
-			if (!reservedImportTypesMap.containsKey(typeClassName)) {
-				if (importTypesMap.containsKey(typeClassName)) {
-					if (typeName.equals(importTypesMap.get(typeClassName)))
-						return typeClassName;
-				}
-			}
-
-			String typePackageName = stringUtils.stripClass(typeName);
-			if ("java.lang".equals(typePackageName))
-				return typeClassName;
-			if ((null != packageName) && (packageName.equals(typePackageName)))
-				return typeClassName;
-		}
-
-		return typeName;
-	}
-
-	/**
-	 * @since 3.0
-	 */
-	public String formatJavaTypeAsNonBooleanPrimitive(String type) {
-		String value = ImportUtils.classesForPrimitives.get(type);
-		return formatJavaType(value != null ? value : type);
-	}
-
-	/**
-	 * @since 3.0
-	 */
-	public boolean isNonBooleanPrimitive(String type) {
-		return ImportUtils.classesForPrimitives.containsKey(type) && !isBoolean(type);
-	}
-
-	/**
-	 * @since 3.0
-	 */
-	public boolean isBoolean(String type) {
-		return "boolean".equals(type);
-	}
-
-	/**
-	 * Generate package and list of import statements based on the registered
-	 * types.
-	 */
-	public String generate() {
-		StringBuilder outputBuffer = new StringBuilder();
-
-		if (null != packageName) {
-			outputBuffer.append("package ");
-			outputBuffer.append(packageName);
-
-			// Using UNIX line endings intentionally - generated Java files
-			// should look
-			// the same regardless of platform to prevent developer teams
-			// working on
-			// multiple OS's to override each other's work
-			outputBuffer.append(";\n\n");
-		}
-
-		List<String> typesList = new ArrayList<>(importTypesMap.values());
-		Collections.sort(typesList, new Comparator<String>() {
-
-			public int compare(String s1, String s2) {
-
-				for (String ordering : importOrdering) {
-					if ((s1.startsWith(ordering)) && (!s2.startsWith(ordering))) {
-						return -1;
-					}
-					if ((!s1.startsWith(ordering)) && (s2.startsWith(ordering))) {
-						return 1;
-					}
-				}
-
-				return s1.compareTo(s2);
-			}
-		});
-
-		String lastStringPrefix = null;
-		boolean firstIteration = true;
-		for (String typeName : typesList) {
-
-			if (firstIteration) {
-				firstIteration = false;
-			} else {
-				outputBuffer.append('\n');
-			}
-			// Output another newline if we're in a different root package.
-			// Find root package
-			String thisStringPrefix = typeName;
-			int dotIndex = typeName.indexOf('.');
-			if (-1 != dotIndex) {
-				thisStringPrefix = typeName.substring(0, dotIndex);
-			}
-			// if this isn't the first import,
-			if (null != lastStringPrefix) {
-				// and it's different from the last import
-				if (false == thisStringPrefix.equals(lastStringPrefix)) {
-					// output a newline; force UNIX style per comment above
-					outputBuffer.append("\n");
-				}
-			}
-			lastStringPrefix = thisStringPrefix;
-
-			outputBuffer.append("import ");
-			outputBuffer.append(typeName);
-			outputBuffer.append(';');
-		}
-
-		return outputBuffer.toString();
-	}
-}


Mime
View raw message