You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2017/02/01 13:23:52 UTC
[04/10] cayenne git commit: CAY-2215 split cayenne-tools into
cayenne-cgen and cayenne-ant
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java
deleted file mode 100644
index cc27627..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java
+++ /dev/null
@@ -1,189 +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.project.validation.NameValidationHelper;
-import org.apache.cayenne.util.Util;
-
-/**
- * Methods for mangling strings.
- */
-public class StringUtils {
-
- private static StringUtils sharedInstance;
-
- public static StringUtils getInstance() {
- if (null == sharedInstance) {
- sharedInstance = new StringUtils();
- }
-
- return sharedInstance;
- }
-
- /**
- * Prepends underscore to variable name if necessary to remove conflict with reserved
- * keywords.
- */
- public String formatVariableName(String variableName) {
- if (NameValidationHelper.getInstance().isReservedJavaKeyword(variableName)) {
- return "_" + variableName;
- }
- else {
- return variableName;
- }
- }
-
- /**
- * Removes package name, leaving base name.
- *
- * @since 1.2
- */
- public String stripPackageName(String fullyQualifiedClassName) {
- return Util.stripPackageName(fullyQualifiedClassName);
- }
-
- /**
- * Removes base name, leaving package name.
- *
- * @since 1.2
- */
- public String stripClass(String aString) {
- if (aString == null || aString.length() == 0)
- return aString;
-
- int lastDot = aString.lastIndexOf('.');
-
- if (-1 == lastDot)
- return "";
-
- return aString.substring(0, lastDot);
- }
-
- /**
- * Capitalizes the first letter of the property name.
- *
- * @since 1.1
- */
- public String capitalized(String name) {
- if (name == null || name.length() == 0)
- return name;
-
- char c = Character.toUpperCase(name.charAt(0));
- return (name.length() == 1) ? Character.toString(c) : c + name.substring(1);
- }
-
- /**
- * Returns string with lowercased first letter
- *
- * @since 1.2
- */
- public static String uncapitalized(String aString) {
- if (aString == null || aString.length() == 0)
- return aString;
-
- char c = Character.toLowerCase(aString.charAt(0));
- return (aString.length() == 1) ? Character.toString(c) : c + aString.substring(1);
- }
-
- /**
- * Converts property name to Java constants naming convention.
- *
- * @since 1.1
- */
- public String capitalizedAsConstant(String name) {
- if (name == null || name.length() == 0)
- return name;
-
- // clear of non-java chars. While the method name implies that a passed identifier
- // is pure Java, it is used to build pk columns names and such, so extra safety
- // check is a good idea
- name = Util.specialCharsToJava(name);
-
- char charArray[] = name.toCharArray();
- StringBuilder buffer = new StringBuilder();
-
- for (int i = 0; i < charArray.length; i++) {
- if ((Character.isUpperCase(charArray[i])) && (i != 0)) {
-
- char prevChar = charArray[i - 1];
- if ((Character.isLowerCase(prevChar))) {
- buffer.append("_");
- }
- }
-
- buffer.append(Character.toUpperCase(charArray[i]));
- }
-
- return buffer.toString();
- }
-
- /**
- * Converts entity or property name to a plural form. For example:
- * <ul>
- * <li>pluralize("Word") == "Words"</li>
- * <li>pluralize("Status") == "Statuses"</li>
- * <li>pluralize("Index") == "Indexes"</li>
- * <li>pluralize("Factory") == "Factories"</li>
- * </ul>
- * <p>
- * As of 3.1 this method is not used in bundled templates, and is present here for
- * user templates convenience.
- *
- * @since 3.1
- */
- public String pluralize(String str) {
- if (str == null || str.length() == 0) {
- return str;
- }
- else if (str.endsWith("s") || str.endsWith("x")) {
- return str + "es";
- }
- else if (str.endsWith("y")) {
- return str.substring(0, str.length() - 1) + "ies";
- }
- else {
- return str + "s";
- }
- }
-
- /**
- * <p>
- * Strip generic definition from string
- * </p>
- * <p>For example: List>Integer< == List</p>
- * @since 4.0
- */
- public String stripGeneric(String str) {
- if(str == null) {
- return null;
- }
- int start = str.indexOf('<');
- if(start == -1) {
- return str;
- }
- int end = str.lastIndexOf('>');
- if(end == -1) {
- return str;
- } else if(end == str.length() - 1) {
- return str.substring(0, start);
- }
- return str.substring(0, start) + str.substring(end+1);
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/TemplateType.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/TemplateType.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/TemplateType.java
deleted file mode 100644
index 109627e..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/TemplateType.java
+++ /dev/null
@@ -1,55 +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;
-
-/**
- * Defines class generation template types.
- *
- * @since 3.0
- */
-public enum TemplateType {
-
- ENTITY_SINGLE_CLASS(false),
-
- ENTITY_SUPERCLASS(true),
-
- ENTITY_SUBCLASS(false),
-
- EMBEDDABLE_SINGLE_CLASS(false),
-
- EMBEDDABLE_SUPERCLASS(true),
-
- EMBEDDABLE_SUBCLASS(false),
-
- DATAMAP_SINGLE_CLASS(false),
-
- DATAMAP_SUPERCLASS(true),
-
- DATAMAP_SUBCLASS(false);
-
- private boolean superclass;
-
- private TemplateType(boolean superclass) {
- this.superclass = superclass;
- }
-
- public boolean isSuperclass() {
- return superclass;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/package.html
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/package.html b/cayenne-tools/src/main/java/org/apache/cayenne/gen/package.html
deleted file mode 100644
index 69b8b7d..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/package.html
+++ /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.
--->
-<html>
-<body>
-Contains classes that provide Java source generation facility.
-Source creation is based on a set of templates parsed
-during generation process, using Jakarta Velocity template engine.
-
-<p><i>For more information see <a href="../../../../../../index.html"
-target="_top">Cayenne User Guide.</a></i></p>
-</body>
-</html>
\ 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/tools/AntDataPortDelegate.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java
deleted file mode 100644
index de001bd..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java
+++ /dev/null
@@ -1,170 +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.tools;
-
-import org.apache.cayenne.access.DataPort;
-import org.apache.cayenne.access.DataPortDelegate;
-import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.query.Query;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Pattern;
-
-/**
- * DataPortDelegate implementation that works in the context of Ant DataPortTask
- * task execution, performing entity filtering and logging functions.
- *
- * @since 1.2: Prior to 1.2 DataPort classes were a part of cayenne-examples
- * package.
- * @deprecated since 4.0
- */
-@Deprecated
-class AntDataPortDelegate implements DataPortDelegate {
-
- protected Task parentTask;
-
- protected Pattern[] mapFilters;
-
- protected long timestamp;
- protected DbEntity lastEntity;
-
- protected NamePatternMatcher namePatternMatcher;
-
- // exists for testing and such
- AntDataPortDelegate() {
- mapFilters = new Pattern[] {};
- }
-
- AntDataPortDelegate(Task parentTask, String mapsPattern,
- String includeEntitiesPattern, String excludeEntitiesPattern) {
- this.parentTask = parentTask;
-
- AntLogger logger = new AntLogger(parentTask);
-
- this.namePatternMatcher = NamePatternMatcher.build(logger, includeEntitiesPattern, excludeEntitiesPattern);
- this.mapFilters = NamePatternMatcher.createPatterns(logger, mapsPattern);
- }
-
- /**
- * Applies preconfigured list of filters to the list, removing entities that
- * do not pass the filter.
- */
- protected List filterEntities(List entities) {
- if (entities == null || entities.isEmpty()) {
- return entities;
- }
-
- Iterator it = entities.iterator();
- while (it.hasNext()) {
- DbEntity entity = (DbEntity) it.next();
-
- if (!passedDataMapFilter(entity.getDataMap())) {
- it.remove();
- }
- }
-
- namePatternMatcher.filter(entities);
-
- return entities;
- }
-
- /**
- * Returns true if the DataMap passes a set of DataMap filters or if there
- * is no DataMap filters.
- */
- protected boolean passedDataMapFilter(DataMap map) {
- if (mapFilters.length == 0) {
- return true;
- }
-
- if (map == null) {
- return true;
- }
-
- String mapName = map.getName();
- for (Pattern mapFilter : mapFilters) {
- if (mapFilter.matcher(mapName).find()) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Implements the delegate method to filter the list of entities applying
- * filtering rules encapsulated by this object.
- */
- public List willPortEntities(DataPort portTool, List entities) {
- return filterEntities(entities);
- }
-
- /**
- * Logs entity porting event using Ant logger.
- */
- public Query willPortEntity(DataPort portTool, DbEntity entity, Query query) {
- parentTask.log("Porting '" + entity.getName() + "'");
- lastEntity = entity;
- timestamp = System.currentTimeMillis();
- return query;
- }
-
- public void didPortEntity(DataPort portTool, DbEntity entity, int rowCount) {
- String timestampLabel = "";
- if (lastEntity == entity) {
- timestampLabel = " in " + (System.currentTimeMillis() - timestamp)
- + " ms.";
- }
-
- String label = (rowCount == 1) ? "1 row transferred" : rowCount
- + " rows transferred";
- parentTask.log("Done porting " + entity.getName() + ", " + label
- + timestampLabel, Project.MSG_VERBOSE);
- }
-
- public List willCleanData(DataPort portTool, List entities) {
- return filterEntities(entities);
- }
-
- public Query willCleanData(DataPort portTool, DbEntity entity, Query query) {
- parentTask.log("Deleting " + entity.getName(), Project.MSG_VERBOSE);
- lastEntity = entity;
- timestamp = System.currentTimeMillis();
- return query;
- }
-
- public void didCleanData(DataPort portTool, DbEntity entity, int rowCount) {
- String timestampLabel = "";
- if (lastEntity == entity) {
- timestampLabel = " in " + (System.currentTimeMillis() - timestamp)
- + " ms.";
- }
-
- String label = (rowCount == 1) ? "1 row deleted" : rowCount
- + " rows deleted";
- parentTask.log("Done deleting " + entity.getName() + ", " + label
- + timestampLabel, Project.MSG_VERBOSE);
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntLogger.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntLogger.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntLogger.java
deleted file mode 100644
index 5ef9166..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntLogger.java
+++ /dev/null
@@ -1,108 +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.tools;
-
-import org.apache.commons.logging.Log;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-
-/**
- * @since 3.0
- */
-class AntLogger implements Log {
-
- private Task parentTask;
-
- public AntLogger(Task parentTask) {
- this.parentTask = parentTask;
- }
-
- public void debug(Object message, Throwable th) {
- parentTask.log(String.valueOf(message), Project.MSG_DEBUG);
- }
-
- public void debug(Object message) {
- parentTask.log(String.valueOf(message), Project.MSG_DEBUG);
- }
-
- public void error(Object message, Throwable th) {
- parentTask.log(String.valueOf(message), Project.MSG_ERR);
- }
-
- public void error(Object message) {
- parentTask.log(String.valueOf(message), Project.MSG_ERR);
- }
-
- public void fatal(Object message, Throwable th) {
- parentTask.log(String.valueOf(message), Project.MSG_ERR);
- }
-
- public void fatal(Object message) {
- parentTask.log(String.valueOf(message), Project.MSG_ERR);
- }
-
- public void info(Object message, Throwable th) {
- parentTask.log(String.valueOf(message), Project.MSG_INFO);
- }
-
- public void info(Object message) {
- parentTask.log(String.valueOf(message), Project.MSG_INFO);
- }
-
- public void trace(Object message, Throwable th) {
- parentTask.log(String.valueOf(message), Project.MSG_VERBOSE);
- }
-
- public void trace(Object message) {
- parentTask.log(String.valueOf(message), Project.MSG_VERBOSE);
- }
-
- public void warn(Object message, Throwable th) {
- parentTask.log(String.valueOf(message), Project.MSG_WARN);
- }
-
- public void warn(Object message) {
- parentTask.log(String.valueOf(message), Project.MSG_WARN);
- }
-
- public boolean isWarnEnabled() {
- return true;
- }
-
- public boolean isDebugEnabled() {
- return true;
- }
-
- public boolean isErrorEnabled() {
- return true;
- }
-
- public boolean isFatalEnabled() {
- return true;
- }
-
- public boolean isInfoEnabled() {
- return true;
- }
-
- public boolean isTraceEnabled() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java
deleted file mode 100644
index d195f9a..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java
+++ /dev/null
@@ -1,35 +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.tools;
-
-public class AntTableType {
- private String name;
-
- public void addText(String string) {
- setName(string);
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
deleted file mode 100644
index 4d068d8..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
+++ /dev/null
@@ -1,85 +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.tools;
-
-import org.apache.cayenne.dbsync.filter.NameFilter;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.Embeddable;
-import org.apache.cayenne.map.ObjEntity;
-
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * Performs entity filtering to build a collection of entities that should be used in
- * class generation.
- *
- * @since 3.0
- */
-class CayenneGeneratorEntityFilterAction {
-
- private NameFilter nameFilter;
- private boolean client;
-
- Collection<Embeddable> getFilteredEmbeddables(DataMap mainDataMap) {
- Collection<Embeddable> embeddables = new ArrayList<>(mainDataMap.getEmbeddables());
-
- // filter out excluded entities...
- Iterator<Embeddable> it = embeddables.iterator();
-
- while (it.hasNext()) {
- Embeddable e = it.next();
-
- // note that unlike entity, embeddable is matched by class name as it doesn't
- // have a symbolic name...
- if (!nameFilter.isIncluded(e.getClassName())) {
- it.remove();
- }
- }
-
- return embeddables;
- }
-
- Collection<ObjEntity> getFilteredEntities(DataMap mainDataMap)
- throws MalformedURLException {
-
- Collection<ObjEntity> entities = new ArrayList<>(mainDataMap.getObjEntities());
-
- // filter out excluded entities...
- Iterator<ObjEntity> it = entities.iterator();
- while (it.hasNext()) {
- ObjEntity e = it.next();
- if (e.isGeneric() || client && !e.isClientAllowed() || !nameFilter.isIncluded(e.getName())) {
- it.remove();
- }
- }
-
- return entities;
- }
-
- void setClient(boolean client) {
- this.client = client;
- }
-
- public void setNameFilter(NameFilter nameFilter) {
- this.nameFilter = nameFilter;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
deleted file mode 100644
index 819a0e2..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.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.tools;
-
-import java.io.File;
-import java.net.MalformedURLException;
-
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.MapLoader;
-import org.xml.sax.InputSource;
-
-/**
- * Loads a DataMap and a shared entity namespace.
- *
- * @since 3.0
- */
-class CayenneGeneratorMapLoaderAction {
-
- private File mainDataMapFile;
- private File[] additionalDataMapFiles;
- private DataMap mainDataMap;
-
- DataMap getMainDataMap() throws MalformedURLException {
- if (mainDataMap == null) {
- MapLoader mapLoader = new MapLoader();
-
- DataMap mainDataMap = loadDataMap(mapLoader, mainDataMapFile);
-
- if (additionalDataMapFiles != null) {
-
- EntityResolver entityResolver = new EntityResolver();
- entityResolver.addDataMap(mainDataMap);
- mainDataMap.setNamespace(entityResolver);
-
- for (File additionalDataMapFile : additionalDataMapFiles) {
-
- DataMap dataMap = loadDataMap(mapLoader, additionalDataMapFile);
- entityResolver.addDataMap(dataMap);
- dataMap.setNamespace(entityResolver);
- }
- }
-
- this.mainDataMap = mainDataMap;
- }
-
- return mainDataMap;
- }
-
- protected DataMap loadDataMap(MapLoader mapLoader, File dataMapFile)
- throws MalformedURLException {
- InputSource in = new InputSource(dataMapFile.toURI().toURL().toString());
- return mapLoader.loadDataMap(in);
- }
-
- void setMainDataMapFile(File mainDataMapFile) {
- this.mainDataMapFile = mainDataMapFile;
- }
-
- void setAdditionalDataMapFiles(File[] additionalDataMapFiles) {
- this.additionalDataMapFiles = additionalDataMapFiles;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
deleted file mode 100644
index d57b350..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
+++ /dev/null
@@ -1,304 +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.tools;
-
-import foundrylogic.vpp.VPPConfig;
-import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
-import org.apache.cayenne.gen.ArtifactsGenerationMode;
-import org.apache.cayenne.gen.ClassGenerationAction;
-import org.apache.cayenne.gen.ClientClassGenerationAction;
-import org.apache.cayenne.map.DataMap;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.Path;
-import org.apache.velocity.VelocityContext;
-
-import java.io.File;
-
-/**
- * An Ant task to perform class generation based on CayenneDataMap.
- *
- * @since 3.0
- */
-public class CayenneGeneratorTask extends CayenneTask {
-
- protected String includeEntitiesPattern;
- protected String excludeEntitiesPattern;
- protected VPPConfig vppConfig;
-
- protected File map;
- protected File additionalMaps[];
- protected boolean client;
- protected File destDir;
- protected String encoding;
- protected boolean makepairs;
- protected String mode;
- protected String outputPattern;
- protected boolean overwrite;
- protected String superpkg;
- protected String supertemplate;
- protected String template;
- protected String embeddabletemplate;
- protected String embeddablesupertemplate;
- protected String querytemplate;
- protected String querysupertemplate;
- protected boolean usepkgpath;
- protected boolean createpropertynames;
-
- public CayenneGeneratorTask() {
- this.makepairs = true;
- this.mode = ArtifactsGenerationMode.ENTITY.getLabel();
- this.outputPattern = "*.java";
- this.usepkgpath = true;
- }
-
- protected VelocityContext getVppContext() {
- initializeVppConfig();
- return vppConfig.getVelocityContext();
- }
-
- protected ClassGenerationAction createGeneratorAction() {
- ClassGenerationAction action = client ? new ClientClassGenerationAction() : new ClassGenerationAction();
-
- action.setContext(getVppContext());
- action.setDestDir(destDir);
- action.setEncoding(encoding);
- action.setMakePairs(makepairs);
- action.setArtifactsGenerationMode(mode);
- action.setOutputPattern(outputPattern);
- action.setOverwrite(overwrite);
- action.setSuperPkg(superpkg);
- action.setSuperTemplate(supertemplate);
- action.setTemplate(template);
- action.setEmbeddableSuperTemplate(embeddablesupertemplate);
- action.setEmbeddableTemplate(embeddabletemplate);
- action.setQueryTemplate(querytemplate);
- action.setQuerySuperTemplate(querysupertemplate);
- action.setUsePkgPath(usepkgpath);
- action.setCreatePropertyNames(createpropertynames);
-
- return action;
- }
-
- /**
- * Executes the task. It will be called by ant framework.
- */
- @Override
- public void execute() throws BuildException {
- validateAttributes();
-
- AntLogger logger = new AntLogger(this);
- CayenneGeneratorMapLoaderAction loadAction = new CayenneGeneratorMapLoaderAction();
-
- loadAction.setMainDataMapFile(map);
- loadAction.setAdditionalDataMapFiles(additionalMaps);
-
- CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();
- filterAction.setClient(client);
- filterAction.setNameFilter(NamePatternMatcher.build(logger, includeEntitiesPattern, excludeEntitiesPattern));
-
- try {
-
- DataMap dataMap = loadAction.getMainDataMap();
-
- ClassGenerationAction generatorAction = createGeneratorAction();
- generatorAction.setLogger(logger);
- generatorAction.setTimestamp(map.lastModified());
- generatorAction.setDataMap(dataMap);
- generatorAction.addEntities(filterAction.getFilteredEntities(dataMap));
- generatorAction.addEmbeddables(filterAction.getFilteredEmbeddables(dataMap));
- generatorAction.addQueries(dataMap.getQueryDescriptors());
- generatorAction.execute();
- }
- catch (Exception e) {
- throw new BuildException(e);
- }
- }
-
- /**
- * Validates attributes that are not related to internal DefaultClassGenerator. Throws
- * BuildException if attributes are invalid.
- */
- protected void validateAttributes() throws BuildException {
- if (map == null && this.getProject() == null) {
- throw new BuildException("either 'map' or 'project' is required.");
- }
- }
-
- /**
- * Sets the map.
- *
- * @param map The map to set
- */
- public void setMap(File map) {
- this.map = map;
- }
-
- /**
- * Sets the additional DataMaps.
- *
- * @param additionalMapsPath The additional DataMaps to set
- */
- public void setAdditionalMaps(Path additionalMapsPath) {
- String additionalMapFilenames[] = additionalMapsPath.list();
- this.additionalMaps = new File[additionalMapFilenames.length];
-
- for (int i = 0; i < additionalMapFilenames.length; i++) {
- additionalMaps[i] = new File(additionalMapFilenames[i]);
- }
- }
-
- /**
- * 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;
- }
-
- /**
- * Sets <code>querytemplate</code> property.
- */
- public void setQueryTemplate(String querytemplate) {
- this.querytemplate = querytemplate;
- }
-
- /**
- * Sets <code>querysupertemplate</code> property.
- */
- public void setQuerySupertemplate(String querysupertemplate) {
- this.querysupertemplate = querysupertemplate;
- }
-
- /**
- * Sets <code>usepkgpath</code> property.
- */
- public void setUsepkgpath(boolean usepkgpath) {
- this.usepkgpath = usepkgpath;
- }
-
- /**
- * Sets <code>superpkg</code> property.
- */
- public void setSuperpkg(String superpkg) {
- this.superpkg = superpkg;
- }
-
- /**
- * Sets <code>client</code> property.
- */
- public void setClient(boolean client) {
- this.client = client;
- }
-
- /**
- * Sets <code>encoding</code> property that allows to generate files using non-default
- * encoding.
- */
- public void setEncoding(String encoding) {
- this.encoding = encoding;
- }
-
- /**
- * Sets <code>excludeEntitiesPattern</code> property.
- */
- public void setExcludeEntities(String excludeEntitiesPattern) {
- this.excludeEntitiesPattern = excludeEntitiesPattern;
- }
-
- /**
- * Sets <code>includeEntitiesPattern</code> property.
- */
- public void setIncludeEntities(String includeEntitiesPattern) {
- this.includeEntitiesPattern = includeEntitiesPattern;
- }
-
- /**
- * Sets <code>outputPattern</code> property.
- */
- public void setOutputPattern(String outputPattern) {
- this.outputPattern = outputPattern;
- }
-
- /**
- * Sets <code>mode</code> property.
- */
- public void setMode(String mode) {
- this.mode = mode;
- }
-
- /**
- * Sets <code>createpropertynames</code> property.
- */
- public void setCreatepropertynames(boolean createpropertynames) {
- this.createpropertynames = createpropertynames;
- }
-
- public void setEmbeddabletemplate(String embeddabletemplate) {
- this.embeddabletemplate = embeddabletemplate;
- }
-
- public void setEmbeddablesupertemplate(String embeddablesupertemplate) {
- this.embeddablesupertemplate = embeddablesupertemplate;
- }
-
- /**
- * Provides a <code>VPPConfig</code> object to configure. (Written with createConfig()
- * instead of addConfig() to avoid run-time dependency on VPP).
- */
- public Object createConfig() {
- this.vppConfig = new VPPConfig();
- return this.vppConfig;
- }
-
- /**
- * If no VppConfig element specified, use the default one.
- */
- private void initializeVppConfig() {
- if (vppConfig == null) {
- vppConfig = VPPConfig.getDefaultConfig(getProject());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneTask.java
deleted file mode 100644
index 2bff0e3..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneTask.java
+++ /dev/null
@@ -1,161 +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.tools;
-
-import java.io.File;
-
-import javax.sql.DataSource;
-
-import org.apache.cayenne.configuration.DataNodeDescriptor;
-import org.apache.cayenne.configuration.server.DbAdapterFactory;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.di.Injector;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.MapLoader;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Reference;
-import org.xml.sax.InputSource;
-
-/**
- * Base task for all Cayenne ant tasks, providing support for common
- * configuration items.
- *
- * @since 1.2
- */
-public abstract class CayenneTask extends Task {
- protected Path classpath;
-
- protected String adapter;
- protected File map;
- protected String driver;
- protected String url;
- protected String userName;
- protected String password;
-
- /**
- * Sets the classpath used by the task.
- *
- * @param path
- * The classpath to set.
- */
- public void setClasspath(Path path) {
- createClasspath().append(path);
- }
-
- /**
- * Sets the classpath reference used by the task.
- *
- * @param reference
- * The classpath reference to set.
- */
- public void setClasspathRef(Reference reference) {
- createClasspath().setRefid(reference);
- }
-
- /**
- * Convenience method for creating a classpath instance to be used for the
- * task.
- *
- * @return The new classpath.
- */
- private Path createClasspath() {
- if (null == classpath) {
- classpath = new Path(getProject());
- }
-
- return classpath.createPath();
- }
-
- /**
- * Sets the map.
- *
- * @param map
- * The map to set
- */
- public void setMap(File map) {
- this.map = map;
- }
-
- /**
- * Sets the db adapter.
- *
- * @param adapter
- * The db adapter to set.
- */
- public void setAdapter(String adapter) {
- this.adapter = adapter;
- }
-
- /**
- * Sets the JDBC driver used to connect to the database server.
- *
- * @param driver
- * The driver to set.
- */
- public void setDriver(String driver) {
- this.driver = driver;
- }
-
- /**
- * Sets the JDBC URL used to connect to the database server.
- *
- * @param url
- * The url to set.
- */
- public void setUrl(String url) {
- this.url = url;
- }
-
- /**
- * Sets the username used to connect to the database server.
- */
- public void setUserName(String username) {
- this.userName = username;
- }
-
- /**
- * Sets the password used to connect to the database server.
- *
- * @param password
- * The password to set.
- */
- public void setPassword(String password) {
- this.password = password;
- }
-
- /** Loads and returns DataMap based on <code>map</code> attribute. */
- protected DataMap loadDataMap() throws Exception {
- InputSource in = new InputSource(map.getCanonicalPath());
- return new MapLoader().loadDataMap(in);
- }
-
- protected DbAdapter getAdapter(Injector injector, DataSource dataSource)
- throws Exception {
-
- DbAdapterFactory adapterFactory = injector
- .getInstance(DbAdapterFactory.class);
-
- DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
- nodeDescriptor.setAdapterType(adapter);
-
- return adapterFactory.createAdapter(nodeDescriptor, dataSource);
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/DataPortTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DataPortTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DataPortTask.java
deleted file mode 100644
index 4b24035..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DataPortTask.java
+++ /dev/null
@@ -1,213 +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.tools;
-
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.DataPort;
-import org.apache.cayenne.configuration.Constants;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Binder;
-import org.apache.cayenne.di.Key;
-import org.apache.cayenne.di.Module;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.resource.FilesystemResourceLocator;
-import org.apache.cayenne.resource.ResourceLocator;
-import org.apache.cayenne.util.Util;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.HashSet;
-
-/**
- * A "cdataport" Ant task implementing a frontend to DataPort allowing porting
- * database data using Ant build scripts.
- *
- * @since 1.2: Prior to 1.2 DataPort classes were a part of cayenne-examples
- * package.
- * @deprecated since 4.0
- */
-@Deprecated
-public class DataPortTask extends CayenneTask {
-
- protected File projectFile;
- protected String maps;
- protected String srcNode;
- protected String destNode;
- protected String includeTables;
- protected String excludeTables;
- protected boolean cleanDest = true;
-
- public DataPortTask() {
- // set defaults
- this.cleanDest = true;
- }
-
- @Override
- public void execute() throws BuildException {
-
- log("*** 'cdataport' task is deprecated and will be removed after 4.0",
- Project.MSG_WARN);
-
- validateParameters();
-
- String projectFileLocation = projectFile.getName();
- Module dataPortModule = new Module() {
-
- public void configure(Binder binder) {
- FilesystemResourceLocator filesystemResourceLocator = new FilesystemResourceLocator(projectFile);
- binder.bind(ResourceLocator.class).toInstance(filesystemResourceLocator);
- binder.bind(Key.get(ResourceLocator.class, Constants.SERVER_RESOURCE_LOCATOR))
- .toInstance(filesystemResourceLocator);
- }
- };
-
- ServerRuntime runtime = new ServerRuntime(projectFileLocation,
- dataPortModule);
- DataDomain domain;
-
- ClassLoader threadContextClassLoader = Thread.currentThread()
- .getContextClassLoader();
- try {
- // need to set context class loader so that cayenne can find jdbc
- // driver and
- // PasswordEncoder
- // TODO: andrus 04/11/2010 is this still relevant in 3.1?
- Thread.currentThread().setContextClassLoader(
- getClass().getClassLoader());
-
- domain = runtime.getDataDomain();
- } catch (Exception ex) {
- throw new BuildException(
- "Error loading Cayenne configuration from " + projectFile,
- ex);
- } finally {
- // set back to original ClassLoader
- Thread.currentThread().setContextClassLoader(
- threadContextClassLoader);
- }
-
- // perform project validation
- DataNode source = domain.getDataNode(srcNode);
- if (source == null) {
- throw new BuildException("srcNode not found in the project: "
- + srcNode);
- }
-
- DataNode destination = domain.getDataNode(destNode);
- if (destination == null) {
- throw new BuildException("destNode not found in the project: "
- + destNode);
- }
-
- log("Porting from '" + srcNode + "' to '" + destNode + "'.");
-
- AntDataPortDelegate portDelegate = new AntDataPortDelegate(this, maps,
- includeTables, excludeTables);
- DataPort dataPort = new DataPort(portDelegate);
- dataPort.setEntities(getAllEntities(source, destination));
- dataPort.setCleaningDestination(cleanDest);
- dataPort.setSourceNode(source);
- dataPort.setDestinationNode(destination);
-
- try {
- dataPort.execute();
- } catch (Exception e) {
- Throwable topOfStack = Util.unwindException(e);
- throw new BuildException("Error porting data: "
- + topOfStack.getMessage(), topOfStack);
- }
- }
-
- protected Collection<DbEntity> getAllEntities(DataNode source,
- DataNode target) {
- // use a set to exclude duplicates, though a valid project will probably
- // have
- // none...
- Collection<DbEntity> allEntities = new HashSet<DbEntity>();
-
- for (DataMap map : source.getDataMaps()) {
- allEntities.addAll(map.getDbEntities());
- }
-
- for (DataMap map : target.getDataMaps()) {
- allEntities.addAll(map.getDbEntities());
- }
-
- log("Number of entities: " + allEntities.size(), Project.MSG_VERBOSE);
-
- if (allEntities.size() == 0) {
- log("No entities found for either source or target.");
- }
- return allEntities;
- }
-
- protected void validateParameters() throws BuildException {
- if (projectFile == null) {
- throw new BuildException(
- "Required 'projectFile' parameter is missing.");
- }
-
- if (!projectFile.exists()) {
- throw new BuildException("'projectFile' does not exist: "
- + projectFile);
- }
-
- if (srcNode == null) {
- throw new BuildException("Required 'srcNode' parameter is missing.");
- }
-
- if (destNode == null) {
- throw new BuildException(
- "Required 'destNode' parameter is missing.");
- }
- }
-
- public void setDestNode(String destNode) {
- this.destNode = destNode;
- }
-
- public void setExcludeTables(String excludeTables) {
- this.excludeTables = excludeTables;
- }
-
- public void setIncludeTables(String includeTables) {
- this.includeTables = includeTables;
- }
-
- public void setMaps(String maps) {
- this.maps = maps;
- }
-
- public void setProjectFile(File projectFile) {
- this.projectFile = projectFile;
- }
-
- public void setSrcNode(String srcNode) {
- this.srcNode = srcNode;
- }
-
- public void setCleanDest(boolean flag) {
- this.cleanDest = flag;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
deleted file mode 100644
index ce2e574..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
+++ /dev/null
@@ -1,155 +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.tools;
-
-import org.apache.cayenne.access.DbGenerator;
-import org.apache.cayenne.datasource.DriverDataSource;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dbsync.DbSyncModule;
-import org.apache.cayenne.di.DIBootstrap;
-import org.apache.cayenne.di.Injector;
-import org.apache.cayenne.log.NoopJdbcEventLogger;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
-import org.apache.cayenne.util.Util;
-import org.apache.commons.logging.Log;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-
-import java.sql.Driver;
-import java.util.Collections;
-
-/**
- * An Ant Task that is a frontend to Cayenne DbGenerator allowing schema
- * generation from DataMap using Ant.
- *
- * @since 1.2
- */
-// TODO: support classpath attribute for loading the driver
-public class DbGeneratorTask extends CayenneTask {
-
- // DbGenerator options... setup defaults similar to DbGenerator itself:
- // all DROP set to false, all CREATE - to true
- protected boolean dropTables;
- protected boolean dropPK;
- protected boolean createTables = true;
- protected boolean createPK = true;
- protected boolean createFK = true;
-
- @Override
- public void execute() {
-
- Log logger = new AntLogger(this);
-
- log(String.format("connection settings - [driver: %s, url: %s, username: %s]", driver, url, userName),
- Project.MSG_VERBOSE);
-
- log(String.format(
- "generator options - [dropTables: %s, dropPK: %s, createTables: %s, createPK: %s, createFK: %s]",
- dropTables, dropPK, createTables, createPK, createFK), Project.MSG_VERBOSE);
-
- validateAttributes();
-
- ClassLoader loader = null;
- Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger));
- try {
- loader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(DbGeneratorTask.class.getClassLoader());
-
- // Load the data map and run the db generator.
- DataMap dataMap = loadDataMap();
-
- // load driver taking custom CLASSPATH into account...
- DriverDataSource dataSource = new DriverDataSource((Driver) Class.forName(driver).newInstance(), url,
- userName, password);
-
- DbAdapter adapter = getAdapter(injector, dataSource);
-
- DbGenerator generator = new DbGenerator(adapter, dataMap, Collections.<DbEntity> emptyList(), null,
- NoopJdbcEventLogger.getInstance());
- generator.setShouldCreateFKConstraints(createFK);
- generator.setShouldCreatePKSupport(createPK);
- generator.setShouldCreateTables(createTables);
- generator.setShouldDropPKSupport(dropPK);
- generator.setShouldDropTables(dropTables);
-
- generator.runGenerator(dataSource);
- } catch (Exception ex) {
- Throwable th = Util.unwindException(ex);
-
- String message = "Error generating database";
-
- if (th.getLocalizedMessage() != null) {
- message += ": " + th.getLocalizedMessage();
- }
-
- log(message, Project.MSG_ERR);
- throw new BuildException(message, th);
- } finally {
- Thread.currentThread().setContextClassLoader(loader);
- injector.shutdown();
- }
- }
-
- /**
- * Validates attributes that are not related to internal
- * DefaultClassGenerator. Throws BuildException if attributes are invalid.
- */
- protected void validateAttributes() throws BuildException {
- StringBuilder error = new StringBuilder("");
-
- if (map == null) {
- error.append("The 'map' attribute must be set.\n");
- }
-
- if (driver == null) {
- error.append("The 'driver' attribute must be set.\n");
- }
-
- if (url == null) {
- error.append("The 'adapter' attribute must be set.\n");
- }
-
- if (error.length() > 0) {
- throw new BuildException(error.toString());
- }
- }
-
- public void setCreateFK(boolean createFK) {
- this.createFK = createFK;
- }
-
- public void setCreatePK(boolean createPK) {
- this.createPK = createPK;
- }
-
- public void setCreateTables(boolean createTables) {
- this.createTables = createTables;
- }
-
- public void setDropPK(boolean dropPK) {
- this.dropPK = dropPK;
- }
-
- public void setDropTables(boolean dropTables) {
- this.dropTables = dropTables;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
deleted file mode 100644
index 6c939c1..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
+++ /dev/null
@@ -1,241 +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.tools;
-
-import org.apache.cayenne.conn.DataSourceInfo;
-import org.apache.cayenne.dbsync.DbSyncModule;
-import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
-import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
-import org.apache.cayenne.dbsync.reverse.dbimport.Catalog;
-import org.apache.cayenne.dbsync.reverse.dbimport.DbImportAction;
-import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfigurationValidator;
-import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration;
-import org.apache.cayenne.dbsync.reverse.dbimport.DbImportModule;
-import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn;
-import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure;
-import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable;
-import org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn;
-import org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure;
-import org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable;
-import org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering;
-import org.apache.cayenne.dbsync.reverse.dbimport.Schema;
-import org.apache.cayenne.dbsync.reverse.filters.FiltersConfigBuilder;
-import org.apache.cayenne.di.DIBootstrap;
-import org.apache.cayenne.di.Injector;
-import org.apache.cayenne.util.Util;
-import org.apache.commons.logging.Log;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-
-import java.io.File;
-
-public class DbImporterTask extends Task {
-
- private final DbImportConfiguration config;
- private ReverseEngineering reverseEngineering;
-
- public DbImporterTask() {
- this.config = new DbImportConfiguration();
- this.config.setUsePrimitives(true);
- this.config.setNamingStrategy(DefaultObjectNameGenerator.class.getName());
-
- // reverse engineering config is flattened into task...
- this.reverseEngineering = new ReverseEngineering();
- }
-
- public void addIncludeColumn(IncludeColumn includeColumn) {
- reverseEngineering.addIncludeColumn(includeColumn);
- }
-
- public void addExcludeColumn(ExcludeColumn excludeColumn) {
- reverseEngineering.addExcludeColumn(excludeColumn);
- }
-
- public void addIncludeTable(IncludeTable includeTable) {
- reverseEngineering.addIncludeTable(includeTable);
- }
-
- public void addExcludeTable(ExcludeTable excludeTable) {
- reverseEngineering.addExcludeTable(excludeTable);
- }
-
- public void addIncludeProcedure(IncludeProcedure includeProcedure) {
- reverseEngineering.addIncludeProcedure(includeProcedure);
- }
-
- public void addExcludeProcedure(ExcludeProcedure excludeProcedure) {
- reverseEngineering.addExcludeProcedure(excludeProcedure);
- }
-
- public void setSkipRelationshipsLoading(boolean skipRelationshipsLoading) {
- reverseEngineering.setSkipRelationshipsLoading(skipRelationshipsLoading);
- }
-
- public void setSkipPrimaryKeyLoading(boolean skipPrimaryKeyLoading) {
- reverseEngineering.setSkipPrimaryKeyLoading(skipPrimaryKeyLoading);
- }
-
- public void addConfiguredTableType(AntTableType type) {
- reverseEngineering.addTableType(type.getName());
- }
-
- public void addConfiguredSchema(Schema schema) {
- reverseEngineering.addSchema(schema);
- }
-
- public void addCatalog(Catalog catalog) {
- reverseEngineering.addCatalog(catalog);
- }
-
- @Override
- public void execute() {
- config.setFiltersConfig(new FiltersConfigBuilder(reverseEngineering).build());
- validateAttributes();
-
- Log logger = new AntLogger(this);
- config.setLogger(logger);
- config.setSkipRelationshipsLoading(reverseEngineering.getSkipRelationshipsLoading());
- config.setSkipPrimaryKeyLoading(reverseEngineering.getSkipPrimaryKeyLoading());
- config.setTableTypes(reverseEngineering.getTableTypes());
-
- Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger), new DbImportModule());
- DbImportConfigurationValidator validator = new DbImportConfigurationValidator(reverseEngineering, config, injector);
- try {
- validator.validate();
- } catch (Exception ex) {
- throw new BuildException(ex.getMessage(), ex);
- }
-
- try {
- injector.getInstance(DbImportAction.class).execute(config);
- } catch (Exception ex) {
- Throwable th = Util.unwindException(ex);
-
- String message = "Error importing database schema";
-
- if (th.getLocalizedMessage() != null) {
- message += ": " + th.getLocalizedMessage();
- }
-
- log(message, Project.MSG_ERR);
- throw new BuildException(message, th);
- } finally {
- injector.shutdown();
- }
- }
-
- /**
- * Validates attributes that are not related to internal
- * DefaultClassGenerator. Throws BuildException if attributes are invalid.
- */
- protected void validateAttributes() throws BuildException {
- StringBuilder error = new StringBuilder("");
-
- if (config.getTargetDataMap() == null) {
- error.append("The 'map' attribute must be set.\n");
- }
-
- DataSourceInfo dataSourceInfo = config.getDataSourceInfo();
- if (dataSourceInfo.getJdbcDriver() == null) {
- error.append("The 'driver' attribute must be set.\n");
- }
-
- if (dataSourceInfo.getDataSourceUrl() == null) {
- error.append("The 'url' attribute must be set.\n");
- }
-
- if (error.length() > 0) {
- throw new BuildException(error.toString());
- }
- }
-
- /**
- * @since 4.0
- */
- public void setDefaultPackage(String defaultPackage) {
- config.setDefaultPackage(defaultPackage);
- }
-
- /**
- * @since 4.0
- */
- public void setMeaningfulPkTables(String meaningfulPkTables) {
- config.setMeaningfulPkTables(meaningfulPkTables);
- }
-
- public void setNamingStrategy(String namingStrategy) {
- config.setNamingStrategy(namingStrategy);
- }
-
- /**
- * @since 4.0
- */
- public void setStripFromTableNames(String pattern) {
- config.setStripFromTableNames(pattern);
- }
-
- public void setAdapter(String adapter) {
- config.setAdapter(adapter);
- }
-
- public void setDriver(String driver) {
- config.setDriver(driver);
- }
-
- public void setPassword(String password) {
- config.setPassword(password);
- }
-
- public void setUrl(String url) {
- config.setUrl(url);
- }
-
- public void setUserName(String username) {
- config.setUsername(username);
- }
-
- public void setUsePrimitives(boolean flag) {
- config.setUsePrimitives(flag);
- }
-
- public void setForceDataMapCatalog(boolean flag) {
- config.setForceDataMapCatalog(flag);
- }
-
- public void setForceDataMapSchema(boolean flag) {
- config.setForceDataMapSchema(flag);
- }
-
- public ReverseEngineering getReverseEngineering() {
- return reverseEngineering;
- }
-
- public File getMap() {
- return config.getTargetDataMap();
- }
-
- public void setMap(File map) {
- config.setTargetDataMap(map);
- }
-
- public DbImportConfiguration toParameters() {
- return config;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/package.html
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/package.html b/cayenne-tools/src/main/java/org/apache/cayenne/tools/package.html
deleted file mode 100644
index f25bcbe..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/package.html
+++ /dev/null
@@ -1,23 +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.
--->
-<html>
-<body>
-Command line tools and Ant tasks.
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/org/apache/cayenne/tools/antlib.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/org/apache/cayenne/tools/antlib.xml b/cayenne-tools/src/main/resources/org/apache/cayenne/tools/antlib.xml
deleted file mode 100644
index bfebaf6..0000000
--- a/cayenne-tools/src/main/resources/org/apache/cayenne/tools/antlib.xml
+++ /dev/null
@@ -1,25 +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.
--->
-
-<antlib>
- <taskdef name="cgen" classname="org.apache.cayenne.tools.CayenneGeneratorTask"/>
- <taskdef name="cdbgen" classname="org.apache.cayenne.tools.DbGeneratorTask"/>
- <taskdef name="cdataport" classname="org.apache.cayenne.tools.DataPortTask"/>
- <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask"/>
-</antlib>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-singleclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-singleclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-singleclass.vm
deleted file mode 100644
index d0c7f6c..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-singleclass.vm
+++ /dev/null
@@ -1,96 +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.
-##
-##Terminology:
-## Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-## Super class - superclass of entity, ie, org.apache.cayenne.art.auto._Artist
-## Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-## Classes available in template
-## object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
-## stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-## dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.DataMapUtils
-## importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-## superClassName
-## superPackageName
-## subClassName
-## subPackageName
-## baseClassName
-## basePackageName
-##
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
-${importUtils.addType("${basePackageName}.${baseClassName}")}##
-${importUtils.addType('java.util.List')}
-${importUtils.addType('java.util.Map')}
-${importUtils.addType('java.util.HashMap')}
-${importUtils.addType('org.apache.cayenne.ObjectContext')}
-#foreach( $selectQuery in ${object.SelectQueries})
-${importUtils.addType(${selectQuery.Root.ClassName})}
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-${importUtils.addType(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})}
-#end
-#end
-${importUtils.generate()}
-
-/**
- * This class was generated by Cayenne.
- * It is probably a good idea to avoid changing this class manually,
- * since it may be overwritten next time code is regenerated.
- * If you need to make any customizations, please use subclass.
- */
-public class ${subClassName} {
-#if( ${object.hasQueryNames()})
-#foreach( $qname in ${object.QueryNames})
-
- public static final String ${stringUtils.capitalizedAsConstant($qname)}_QUERYNAME = "$qname";
-#end
-#end
-
-private static ${subClassName} instance;
-
- private ${subClassName}() {}
-
- public ${subClassName} getInstance() {
- if( instance == null) {
- instance = new ${subClassName}();
- }
- return instance;
- }
-
-#foreach( $selectQuery in ${object.SelectQueries})
- public List<${stringUtils.stripPackageName($selectQuery.Root.ClassName)}> perform${dataMapUtils.getQueryMethodName(${selectQuery})}(ObjectContext context #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}), ${stringUtils.stripPackageName(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})} ${parameter} #end) {
- #if(${dataMapUtils.hasParameters($selectQuery)})
- String[] parameters = new String[] {
- #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
- "${parameter}",
- #end
- };
-
- Object[] values = new Object[] {
- #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
- ${parameter},
- #end
- };
- #end
-
- NamedQuery query = new NamedQuery("${selectQuery.Name}"#if(${dataMapUtils.hasParameters($selectQuery)}), parameters, values#end);
- return context.performQuery(query);
- }
-#end
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-subclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-subclass.vm
deleted file mode 100644
index f5e0474..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-subclass.vm
+++ /dev/null
@@ -1,47 +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.
-##
-##Terminology:
-## Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-## Super class - superclass of entity, ie, org.apache.cayenne.art.auto._Artist
-## Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-## Classes available in template
-## stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-## dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.dataMapUtils
-## importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
-${importUtils.addType("${superPackageName}.${superClassName}")}##
-${importUtils.generate()}
-
-public class ${subClassName} extends ${superClassName} {
-
- private static ${subClassName} instance;
-
- private ${subClassName}() {}
-
- public static ${subClassName} getInstance() {
- if(instance == null) {
- instance = new ${subClassName}();
- }
-
- return instance;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-superclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-superclass.vm
deleted file mode 100644
index c196301..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-superclass.vm
+++ /dev/null
@@ -1,83 +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.
-##
-##Terminology:
-## Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-## Super class - superclass of entity, ie, org.apache.cayenne.art.auto._Artist
-## Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-## Classes available in template
-## stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-## dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.DataMapUtils
-## importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-## superClassName
-## superPackageName
-## subClassName
-## subPackageName
-## baseClassName
-## basePackageName
-##
-${importUtils.setPackage($superPackageName)}##
-#if(${superPackageName})${importUtils.addReservedType("${superPackageName}.${superClassName}")}#end##
-#if(${basePackageName})${importUtils.addType("${basePackageName}.${baseClassName}")}#end##
-#if( ${object.hasSelectQueries()} )
-${importUtils.addType('java.util.List')}##
-${importUtils.addType('org.apache.cayenne.ObjectContext')}##
-${importUtils.addType('org.apache.cayenne.query.NamedQuery')}##
-#foreach( $selectQuery in ${object.SelectQueries})
-${importUtils.addType(${selectQuery.Root.ClientClassName})}##
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-${importUtils.addType(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})}##
-#end
-#end
-#end
-${importUtils.generate()}
-
-/**
- * This class was generated by Cayenne.
- * It is probably a good idea to avoid changing this class manually,
- * since it may be overwritten next time code is regenerated.
- * If you need to make any customizations, please use subclass.
- */
-public class ${superClassName} {
-#if( ${object.hasQueryNames()})
-#foreach( $qname in ${object.QueryNames})
-
- public static final String ${stringUtils.capitalizedAsConstant($qname)}_QUERYNAME = "$qname";
-#end
-#end
-#foreach( $selectQuery in ${object.SelectQueries})
-
- public List<${stringUtils.stripPackageName($selectQuery.Root.ClientClassName)}> perform${dataMapUtils.getQueryMethodName(${selectQuery})}(ObjectContext context #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}), ${stringUtils.stripPackageName(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})} ${parameter}#end) {
-#if(${dataMapUtils.hasParameters($selectQuery)})
- String[] parameters = {
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
- "${parameter}",
-#end
- };
-
- Object[] values = {
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
- ${parameter},
-#end
- };
-
-#end
- return context.performQuery(new NamedQuery("${selectQuery.Name}"#if(${dataMapUtils.hasParameters($selectQuery)}), parameters, values#end));
- }
-#end
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/client-subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/client-subclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/client-subclass.vm
deleted file mode 100644
index d28de85..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/client-subclass.vm
+++ /dev/null
@@ -1,57 +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.
-##
-## A default Cayenne template for a client-side subclass in a generated subclass/superclass pair.
-##
-## Terminology:
-## Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-## Super class - superclass of entity, ie, org.apache.cayenne.art.auto._Artist
-## Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-## Classes available in template
-## object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
-## stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-## entityUtils - class for entity "helper" functions: See org.apache.cayenne.gen.EntityUtils
-## importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-## superClassName
-## superPackageName
-## subClassName
-## subPackageName
-## baseClassName
-## basePackageName
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${$subPackageName}.${subClassName}")}##
-${importUtils.addType("${superPackageName}.${superClassName}")}##
-${importUtils.generate()}
-
-/**
- * A persistent class mapped as "${object.name}" Cayenne entity.
- */
-public#if("true" == "${object.getIsAbstract()}") abstract#end class ${subClassName} extends ${superClassName} {
-
- private static final long serialVersionUID = 1L;
-
-##callback methods
-#foreach( $cbname in ${entityUtils.callbackNames})
- @Override
- protected void ${cbname}() {
- //TODO: Implement ${cbname}
- }
-
-#end
-}