cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [22/32] cayenne git commit: Cgen task refactoring
Date Wed, 14 Nov 2018 14:27:53 GMT
Cgen task refactoring


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

Branch: refs/heads/master
Commit: b30e5eb5d9e22f7ff0c7d3e8763d9b990bd8cb4d
Parents: a5c2ceb
Author: Arseni Bulatski <ancarseni@gmail.com>
Authored: Fri Nov 9 15:23:06 2018 +0300
Committer: Arseni Bulatski <ancarseni@gmail.com>
Committed: Fri Nov 9 16:40:51 2018 +0300

----------------------------------------------------------------------
 RELEASE-NOTES.txt                               |   1 +
 .../cayenne/tools/CayenneGeneratorTask.java     |  42 +-
 .../cayenne/tools/CgenWithConfigTest.java       |   4 +-
 .../apache/cayenne/gen/CgenConfiguration.java   |  71 ++-
 .../cayenne/gen/ClassGenerationAction.java      |  24 +-
 .../apache/cayenne/gen/EmbeddableArtifact.java  |  12 +-
 .../org/apache/cayenne/gen/EntityArtifact.java  |  12 +-
 .../cayenne/gen/xml/CgenConfigHandler.java      |  14 +
 .../cayenne/gen/xml/CgenSaverDelegate.java      |   2 +-
 .../CayenneGeneratorEmbeddableFilterAction.java |   5 +
 .../CayenneGeneratorEntityFilterAction.java     |  13 -
 .../java/org/apache/cayenne/tools/CgenTask.java |  44 +-
 .../org/apache/cayenne/tools/BaseTaskIT.java    |  15 +
 .../org/apache/cayenne/tools/CgenTaskIT.java    |  12 +-
 .../apache/cayenne/tools/DbGenerateTaskIT.java  |   4 +-
 .../apache/cayenne/tools/GradlePluginIT.java    |   2 +-
 .../org/apache/cayenne/tools/cgenConfig.map.xml |  22 -
 .../cayenne/tools/cgen_with_config.map.xml      |  22 +
 .../cayenne/project/CompoundSaverDelegate.java  |  13 +-
 .../main/java/org/apache/cayenne/util/Util.java |  33 +-
 .../org/apache/cayenne/schema/10/cgen.xsd       |  47 ++
 .../cayenne/tools/CayenneGeneratorMojo.java     |  46 +-
 .../cayenne/tools/CayenneGeneratorMojoTest.java |   2 +-
 .../cayenne/modeler/CayenneModelerFrame.java    |  79 ++-
 .../dialog/codegen/ClassesTabController.java    | 203 -------
 .../modeler/dialog/codegen/ClassesTabPanel.java | 141 -----
 .../dialog/codegen/ClientModeController.java    |  81 ---
 .../dialog/codegen/CodeGeneratorController.java | 169 ------
 .../codegen/CodeGeneratorControllerBase.java    | 380 -------------
 .../dialog/codegen/CodeGeneratorDialog.java     |  99 ----
 .../dialog/codegen/CustomModeController.java    | 235 --------
 .../modeler/dialog/codegen/CustomModePanel.java | 137 -----
 .../codegen/CustomPreferencesUpdater.java       | 209 -------
 .../dialog/codegen/GeneratorController.java     | 561 -------------------
 .../codegen/GeneratorControllerPanel.java       |  55 --
 .../dialog/codegen/GeneratorTabController.java  | 115 ----
 .../dialog/codegen/GeneratorTabPanel.java       |  65 ---
 .../dialog/codegen/StandardModeController.java  |  82 ---
 .../dialog/codegen/StandardModePanel.java       |  42 --
 .../dialog/codegen/StandardPanelComponent.java  |  81 ---
 .../modeler/editor/DataDomainTabbedView.java    |   4 +-
 .../modeler/editor/DataMapTabbedView.java       |  40 +-
 .../editor/cgen/ClassesTabController.java       |  11 +-
 .../editor/cgen/ClientModeController.java       |   7 +-
 .../editor/cgen/CodeGeneratorController.java    |  21 +-
 .../cgen/CodeGeneratorControllerBase.java       |  82 +++
 .../editor/cgen/CustomModeController.java       |  28 +-
 .../modeler/editor/cgen/CustomModePanel.java    |  17 +-
 .../editor/cgen/GeneratorController.java        |  69 +--
 .../editor/cgen/GeneratorControllerPanel.java   |  10 +-
 .../editor/cgen/GeneratorTabController.java     |   7 +-
 .../modeler/editor/cgen/GeneratorTabPanel.java  |   1 +
 .../editor/cgen/StandardModeController.java     |   8 +-
 .../modeler/editor/cgen/StandardModePanel.java  |   4 +-
 .../editor/cgen/StandardPanelComponent.java     |  63 ---
 .../modeler/editor/cgen/domain/CgenPanel.java   |  19 +
 .../modeler/editor/cgen/domain/CgenTab.java     |  19 +
 .../editor/cgen/domain/CgenTabController.java   |  28 +-
 .../cayenne/modeler/util/ModelerUtil.java       |   3 +
 59 files changed, 592 insertions(+), 3045 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index fd08cdc..d701e29 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -25,6 +25,7 @@ CAY-2485 Compact Slf4j Logger
 CAY-2487 Removed usage of CayenneException.
 CAY-2489 Add validation to the case of not to PK relationships
 CAY-2491 Remaster Db Import View
+CAY-2493 Save cgen configuration with datamap XML
 
 Bug Fixes:
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
index 02cc0bf..6291a6d 100644
--- a/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
@@ -35,8 +35,6 @@ import org.apache.velocity.VelocityContext;
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Paths;
 
 /**
  * An Ant task to perform class generation based on CayenneDataMap.
@@ -47,12 +45,15 @@ public class CayenneGeneratorTask extends CayenneTask {
 
     protected String includeEntitiesPattern;
     protected String excludeEntitiesPattern;
+    /**
+     * @since 4.1
+     */
     protected String excludeEmbeddablesPattern;
     protected VPPConfig vppConfig;
 
     protected File map;
     protected File additionalMaps[];
-    protected boolean client;
+    protected Boolean client;
     protected File destDir;
     protected String encoding;
     protected Boolean makepairs;
@@ -67,8 +68,11 @@ public class CayenneGeneratorTask extends CayenneTask {
     protected String querytemplate;
     protected String querysupertemplate;
     protected Boolean usepkgpath;
-    protected boolean createpropertynames;
+    protected Boolean createpropertynames;
 
+    /**
+     * @since 4.1
+     */
     private boolean force;
 
     private boolean useConfigFromDataMap;
@@ -80,7 +84,7 @@ public class CayenneGeneratorTask extends CayenneTask {
      *
      * @since 4.1
      */
-    protected boolean createpkproperties;
+    protected Boolean createpkproperties;
 
     public CayenneGeneratorTask() {
     }
@@ -106,7 +110,6 @@ public class CayenneGeneratorTask extends CayenneTask {
         loadAction.setAdditionalDataMapFiles(additionalMaps);
 
         CayenneGeneratorEntityFilterAction filterEntityAction = new CayenneGeneratorEntityFilterAction();
-        filterEntityAction.setClient(client);
         filterEntityAction.setNameFilter(NamePatternMatcher.build(logger, includeEntitiesPattern, excludeEntitiesPattern));
 
         CayenneGeneratorEmbeddableFilterAction filterEmbeddableAction = new CayenneGeneratorEmbeddableFilterAction();
@@ -116,6 +119,7 @@ public class CayenneGeneratorTask extends CayenneTask {
             DataMap dataMap = loadAction.getMainDataMap();
 
             ClassGenerationAction generatorAction = createGenerator(dataMap);
+            filterEntityAction.setClient(generatorAction.getCgenConfiguration().isClient());
             generatorAction.setLogger(logger);
             if(force) {
                 // will (re-)generate all files
@@ -146,11 +150,11 @@ public class CayenneGeneratorTask extends CayenneTask {
     }
 
     private boolean hasConfig() {
-        return destDir != null || encoding != null || client || excludeEntitiesPattern != null || excludeEmbeddablesPattern != null || includeEntitiesPattern != null ||
+        return destDir != null || encoding != null || client != null || excludeEntitiesPattern != null || excludeEmbeddablesPattern != null || includeEntitiesPattern != null ||
                 makepairs != null || mode != null || outputPattern != null || overwrite != null || superpkg != null ||
                 supertemplate != null || template != null || embeddabletemplate != null || embeddablesupertemplate != null ||
-                usepkgpath != null || createpropertynames || querytemplate != null ||
-                querysupertemplate != null || createpkproperties || force;
+                usepkgpath != null || createpropertynames != null || querytemplate != null ||
+                querysupertemplate != null || createpkproperties != null || force;
     }
 
     private CgenConfiguration buildConfiguration(DataMap dataMap) {
@@ -159,11 +163,6 @@ public class CayenneGeneratorTask extends CayenneTask {
             return cgenConfigFromPom(dataMap);
         } else if(cgenConfiguration != null) {
             useConfigFromDataMap = true;
-            java.nio.file.Path resourcePath = Paths.get(map.getPath());
-            if(Files.isRegularFile(resourcePath)) {
-                resourcePath = resourcePath.getParent();
-            }
-            cgenConfiguration.setRelPath(resourcePath.resolve(cgenConfiguration.getRelPath()));
             return cgenConfiguration;
         } else {
             cgenConfiguration = new CgenConfiguration();
@@ -175,7 +174,7 @@ public class CayenneGeneratorTask extends CayenneTask {
     private CgenConfiguration cgenConfigFromPom(DataMap dataMap){
         CgenConfiguration cgenConfiguration = new CgenConfiguration();
         cgenConfiguration.setDataMap(dataMap);
-        cgenConfiguration.setRelPath(destDir != null ? destDir.getPath() : cgenConfiguration.getRelPath());
+        cgenConfiguration.setRelPath(destDir != null ? destDir.toPath() : cgenConfiguration.getRelPath());
         cgenConfiguration.setEncoding(encoding != null ? encoding : cgenConfiguration.getEncoding());
         cgenConfiguration.setMakePairs(makepairs != null ? makepairs : cgenConfiguration.isMakePairs());
         cgenConfiguration.setArtifactsGenerationMode(mode != null ? mode : cgenConfiguration.getArtifactsGenerationMode());
@@ -187,20 +186,20 @@ public class CayenneGeneratorTask extends CayenneTask {
         cgenConfiguration.setEmbeddableSuperTemplate(embeddablesupertemplate != null ? embeddablesupertemplate : cgenConfiguration.getEmbeddableSuperTemplate());
         cgenConfiguration.setEmbeddableTemplate(embeddabletemplate != null ? embeddabletemplate : cgenConfiguration.getEmbeddableTemplate());
         cgenConfiguration.setUsePkgPath(usepkgpath != null ? usepkgpath : cgenConfiguration.isUsePkgPath());
-        cgenConfiguration.setCreatePropertyNames(createpropertynames);
+        cgenConfiguration.setCreatePropertyNames(createpropertynames != null ? createpropertynames : cgenConfiguration.isCreatePropertyNames());
         cgenConfiguration.setQueryTemplate(querytemplate != null ? querytemplate : cgenConfiguration.getQueryTemplate());
         cgenConfiguration.setQuerySuperTemplate(querysupertemplate != null ? querysupertemplate : cgenConfiguration.getQuerySuperTemplate());
-        cgenConfiguration.setCreatePKProperties(createpkproperties);
-        cgenConfiguration.setClient(client);
+        cgenConfiguration.setCreatePKProperties(createpkproperties != null ? createpkproperties : cgenConfiguration.isCreatePKProperties());
+        cgenConfiguration.setClient(client != null ? client : cgenConfiguration.isClient());
         if(!cgenConfiguration.isMakePairs()) {
             if(template == null) {
-                cgenConfiguration.setTemplate(client ? ClientClassGenerationAction.SINGLE_CLASS_TEMPLATE : ClassGenerationAction.SINGLE_CLASS_TEMPLATE);
+                cgenConfiguration.setTemplate(cgenConfiguration.isClient() ? ClientClassGenerationAction.SINGLE_CLASS_TEMPLATE : ClassGenerationAction.SINGLE_CLASS_TEMPLATE);
             }
             if(embeddabletemplate == null) {
                 cgenConfiguration.setEmbeddableTemplate(ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE);
             }
             if(querytemplate == null) {
-                cgenConfiguration.setQueryTemplate(client ? ClientClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE : ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
+                cgenConfiguration.setQueryTemplate(cgenConfiguration.isClient() ? ClientClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE : ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
             }
         }
         return cgenConfiguration;
@@ -331,6 +330,9 @@ public class CayenneGeneratorTask extends CayenneTask {
         this.includeEntitiesPattern = includeEntitiesPattern;
     }
 
+    /**
+     * Sets <code>excludeEmbeddablesPattern</code> property.
+     */
     public void setExcludeEmbeddablesPattern(String excludeEmbeddablesPattern) {
         this.excludeEmbeddablesPattern = excludeEmbeddablesPattern;
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-ant/src/test/java/org/apache/cayenne/tools/CgenWithConfigTest.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/java/org/apache/cayenne/tools/CgenWithConfigTest.java b/cayenne-ant/src/test/java/org/apache/cayenne/tools/CgenWithConfigTest.java
index 4241105..b51a1e0 100644
--- a/cayenne-ant/src/test/java/org/apache/cayenne/tools/CgenWithConfigTest.java
+++ b/cayenne-ant/src/test/java/org/apache/cayenne/tools/CgenWithConfigTest.java
@@ -60,7 +60,7 @@ public class CgenWithConfigTest {
     }
 
     @Test
-    public void testCgen() throws Exception {
+    public void testCgenWithDmConfig() {
         File mapDir = new File(baseDir, "cgenConfigTest");
         assertTrue(mapDir.mkdirs());
 
@@ -84,7 +84,7 @@ public class CgenWithConfigTest {
     }
 
     @Test
-    public void testCgenWithDmAndPomConfigs() throws Exception {
+    public void testCgenWithDmAndPomConfigs() {
         File mapDir = new File(baseDir, "cgenDmPomTest");
         assertTrue(mapDir.mkdirs());
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
index 8d4157d..15bc435 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
@@ -1,3 +1,22 @@
+/*****************************************************************
+ *   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.configuration.ConfigurationNodeVisitor;
@@ -16,6 +35,13 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.stream.Collectors;
 
+/**
+ * Used to keep config of class generation action.
+ * Previously was the part of ClassGeneretionAction class.
+ * Now CgenConfiguration is saved in dataMap file.
+ * You can reuse it in next cgen actions.
+ * @since 4.1
+ */
 public class CgenConfiguration implements Serializable, XMLSerializable {
 
     private Collection<Artifact> artifacts;
@@ -58,6 +84,7 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
         this.timestamp = 0L;
         this.usePkgPath = true;
         this.makePairs = true;
+        setArtifactsGenerationMode("entity");
 
         this.artifacts = new ArrayList<>();
         this.entityArtifacts = new ArrayList<>();
@@ -244,18 +271,18 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
         this.createPKProperties = createPKProperties;
     }
 
-    public String getRelPath() {
+    public Path getRelPath() {
+        return relPath;
+    }
+
+    public String buildRelPath() {
         if(relPath == null || relPath.toString().isEmpty()) {
             return ".";
         }
         return relPath.toString();
     }
 
-    public String getDir(){
-        return rootPath != null ? relPath != null ? rootPath.resolve(relPath).toAbsolutePath().normalize().toString() : rootPath.toString() : null;
-    }
-
-    public Collection<Artifact> getArtifacts() {
+    Collection<Artifact> getArtifacts() {
         return artifacts;
     }
 
@@ -267,20 +294,26 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
         return embeddableArtifacts;
     }
 
+    public boolean isClient() {
+        return client;
+    }
+
+    public void setClient(boolean client) {
+        this.client = client;
+    }
+
+    void addArtifact(Artifact artifact) {
+        artifacts.add(artifact);
+    }
+
     public Path buildPath() {
 		return rootPath != null ? relPath != null ? rootPath.resolve(relPath).toAbsolutePath().normalize() : rootPath : relPath;
 	}
 
-    /**
-     * @since 4.1
-     */
     public void loadEntity(String name) {
         entityArtifacts.add(name);
     }
 
-    /**
-     * @since 4.1
-     */
     public void loadEmbeddable(String name) {
         embeddableArtifacts.add(name);
     }
@@ -327,25 +360,13 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
 				.collect(Collectors.toList());
 	}
 
-    public boolean isClient() {
-        return client;
-    }
-
-    public void setClient(boolean client) {
-        this.client = client;
-    }
-
-    public void addArtifact(Artifact artifact) {
-        artifacts.add(artifact);
-    }
-
     @Override
     public void encodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate) {
         encoder.start("cgen")
                 .attribute("xmlns", CgenExtension.NAMESPACE)
                 .simpleTag("excludeEntities", getExcludeEntites())
                 .simpleTag("excludeEmbeddables",getExcludeEmbeddables())
-                .simpleTag("destDir", getRelPath())
+                .simpleTag("destDir", buildRelPath())
                 .simpleTag("mode", this.artifactsGenerationMode.getLabel())
                 .simpleTag("template", this.template)
                 .simpleTag("superTemplate", this.superTemplate)

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
index 36ba514..68897ef 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
@@ -28,10 +28,18 @@ import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
 import org.slf4j.Logger;
 
-import java.io.*;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
 import java.util.stream.Collectors;
 
 public class ClassGenerationAction {
@@ -53,6 +61,9 @@ public class ClassGenerationAction {
 	public static final String SUPERCLASS_PREFIX = "_";
 	private static final String WILDCARD = "*";
 
+	/**
+	 * @since 4.1
+	 */
 	protected CgenConfiguration cgenConfiguration;
 	protected Logger logger;
 
@@ -197,6 +208,9 @@ public class ClassGenerationAction {
 		}
 	}
 
+	/**
+	 * @since 4.1
+	 */
 	public void prepareArtifacts() {
 		cgenConfiguration.getArtifacts().clear();
 		addEntities(cgenConfiguration.getEntities().stream()
@@ -439,6 +453,9 @@ public class ClassGenerationAction {
 		this.logger = logger;
 	}
 
+	/**
+	 * @since 4.1
+	 */
 	public CgenConfiguration getCgenConfiguration() {
 		return cgenConfiguration;
 	}
@@ -451,6 +468,9 @@ public class ClassGenerationAction {
 		this.context = context;
 	}
 
+	/**
+	 * @since 4.1
+	 */
 	public void setCgenConfiguration(CgenConfiguration cgenConfiguration) {
 		this.cgenConfiguration = cgenConfiguration;
 	}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
index fec8dae..8e6ea43 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
@@ -18,10 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.gen;
 
-import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
 import org.apache.cayenne.map.Embeddable;
-import org.apache.cayenne.util.XMLEncoder;
-import org.apache.cayenne.util.XMLSerializable;
 import org.apache.velocity.VelocityContext;
 
 /**
@@ -29,7 +26,7 @@ import org.apache.velocity.VelocityContext;
  * 
  * @since 3.0
  */
-public class EmbeddableArtifact implements Artifact, XMLSerializable {
+public class EmbeddableArtifact implements Artifact {
 
     protected Embeddable embeddable;
 
@@ -68,11 +65,4 @@ public class EmbeddableArtifact implements Artifact, XMLSerializable {
     public void postInitContext(VelocityContext context) {
         // noop - no special keys...
     }
-
-    @Override
-    public void encodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate) {
-        encoder.start("embeddable")
-                .simpleTag("name", embeddable.getClassName())
-                .end();
-    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityArtifact.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
index b53ee46..3f70f53 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
@@ -19,10 +19,7 @@
 package org.apache.cayenne.gen;
 
 import org.apache.cayenne.BaseDataObject;
-import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
 import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.util.XMLEncoder;
-import org.apache.cayenne.util.XMLSerializable;
 import org.apache.velocity.VelocityContext;
 
 /**
@@ -30,7 +27,7 @@ import org.apache.velocity.VelocityContext;
  * 
  * @since 3.0
  */
-public class EntityArtifact implements Artifact, XMLSerializable {
+public class EntityArtifact implements Artifact {
 
     public static String ENTITY_UTILS_KEY = "entityUtils";
 
@@ -97,11 +94,4 @@ public class EntityArtifact implements Artifact, XMLSerializable {
 
         context.put(ENTITY_UTILS_KEY, metadata);
     }
-
-    @Override
-    public void encodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate) {
-        encoder.start("objEntity")
-                .simpleTag("name", entity.getName())
-                .end();
-    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
index 1f4dd5e..754aac6 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
@@ -21,9 +21,13 @@ package org.apache.cayenne.gen.xml;
 import org.apache.cayenne.configuration.xml.DataChannelMetaData;
 import org.apache.cayenne.configuration.xml.NamespaceAwareNestedTagHandler;
 import org.apache.cayenne.gen.CgenConfiguration;
+import org.apache.cayenne.map.DataMap;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.Paths;
 
 /**
@@ -271,9 +275,19 @@ public class CgenConfigHandler extends NamespaceAwareNestedTagHandler{
         configuration = new CgenConfiguration();
         loaderContext.addDataMapListener(dataMap -> {
             configuration.setDataMap(dataMap);
+            configuration.setRootPath(buildRootPath(dataMap));
             configuration.resolveExcludeEntities();
             configuration.resolveExcludeEmbeddables();
             CgenConfigHandler.this.metaData.add(dataMap, configuration);
         });
     }
+
+    private Path buildRootPath(DataMap dataMap) {
+        URL url = dataMap.getConfigurationSource().getURL();
+        Path resourcePath = Paths.get(url.getPath());
+        if(Files.isRegularFile(resourcePath)) {
+            resourcePath = resourcePath.getParent();
+        }
+        return resourcePath;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenSaverDelegate.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenSaverDelegate.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenSaverDelegate.java
index aa008b1..b31a8b0 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenSaverDelegate.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenSaverDelegate.java
@@ -60,7 +60,7 @@ public class CgenSaverDelegate extends BaseSaverDelegate{
             if(Files.isRegularFile(resourcePath)) {
                 resourcePath = resourcePath.getParent();
             }
-
+            cgenConfiguration.setRootPath(resourcePath);
             if(prevPath != null && resourcePath.compareTo(prevPath) != 0) {
                 Path relPath = resourcePath.relativize(prevPath);
                 cgenConfiguration.setRelPath(relPath);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEmbeddableFilterAction.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEmbeddableFilterAction.java b/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEmbeddableFilterAction.java
index 00ab16a..dba3ab7 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEmbeddableFilterAction.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEmbeddableFilterAction.java
@@ -7,6 +7,11 @@ import org.apache.cayenne.map.Embeddable;
 import java.util.ArrayList;
 import java.util.Collection;
 
+/**
+ *  Performs embeddable filtering to build a collection of embedables that should be used in
+ *  class generation.
+ * @since 4.1
+ */
 class CayenneGeneratorEmbeddableFilterAction {
 
     private NameFilter nameFilter;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java b/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
index 7d53536..64a11e8 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
@@ -20,7 +20,6 @@ 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;
@@ -38,18 +37,6 @@ class CayenneGeneratorEntityFilterAction {
     private NameFilter nameFilter;
     private boolean client;
 
-    Collection<Embeddable> getFilteredEmbeddables(DataMap mainDataMap) {
-        Collection<Embeddable> embeddables = new ArrayList<>(mainDataMap.getEmbeddables());
-
-        // filter out excluded entities...
-
-        // note that unlike entity, embeddable is matched by class name as it doesn't
-        // have a symbolic name...
-        embeddables.removeIf(e -> !nameFilter.isIncluded(e.getClassName()));
-
-        return embeddables;
-    }
-
     Collection<ObjEntity> getFilteredEntities(DataMap mainDataMap)
             throws MalformedURLException {
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
index 3b339df..bfafc1f 100644
--- a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
@@ -59,7 +59,8 @@ public class CgenTask extends BaseCayenneTask {
     private File additionalMaps;
 
     @Input
-    private boolean client;
+    @Optional
+    private String client;
 
     private File destDir;
 
@@ -75,6 +76,9 @@ public class CgenTask extends BaseCayenneTask {
     @Optional
     private String includeEntities;
 
+    /**
+     * @since 4.1
+     */
     @Input
     @Optional
     private String excludeEmbeddables;
@@ -143,7 +147,9 @@ public class CgenTask extends BaseCayenneTask {
      * Default is <code>false</code>.
      * @since 4.1
      */
-    private boolean createPKProperties;
+    @Input
+    @Optional
+    private String createPKProperties;
 
     private String destDirName;
 
@@ -162,7 +168,6 @@ public class CgenTask extends BaseCayenneTask {
         loaderAction.setMainDataMapFile(dataMapFile);
 
         CayenneGeneratorEntityFilterAction filterEntityAction = new CayenneGeneratorEntityFilterAction();
-        filterEntityAction.setClient(client);
         filterEntityAction.setNameFilter(NamePatternMatcher.build(getLogger(), includeEntities, excludeEntities));
 
         CayenneGeneratorEmbeddableFilterAction filterEmbeddableAction = new CayenneGeneratorEmbeddableFilterAction();
@@ -173,7 +178,7 @@ public class CgenTask extends BaseCayenneTask {
 
             DataMap dataMap = loaderAction.getMainDataMap();
             ClassGenerationAction generator = this.createGenerator(dataMap);
-
+            filterEntityAction.setClient(generator.getCgenConfiguration().isClient());
             generator.setLogger(getLogger());
 
             if(this.force || getProject().hasProperty("force")) {
@@ -183,8 +188,6 @@ public class CgenTask extends BaseCayenneTask {
 
             if(!hasConfig() && useConfigFromDataMap) {
                 generator.prepareArtifacts();
-                setDestDir(generator.getCgenConfiguration().getRelPath());
-                generator.getCgenConfiguration().setRelPath(getDestDirFile().toPath());
             } else {
                 generator.addEntities(filterEntityAction.getFilteredEntities(dataMap));
                 generator.addEmbeddables(filterEmbeddableAction.getFilteredEmbeddables(dataMap));
@@ -223,11 +226,6 @@ public class CgenTask extends BaseCayenneTask {
         } else if(metaData != null && metaData.get(dataMap, CgenConfiguration.class) != null) {
             useConfigFromDataMap = true;
             cgenConfiguration = metaData.get(dataMap, CgenConfiguration.class);
-            Path resourcePath = Paths.get(getDataMapFile().getPath());
-            if(Files.isRegularFile(resourcePath)) {
-                resourcePath = resourcePath.getParent();
-            }
-            cgenConfiguration.setRelPath(resourcePath.resolve(cgenConfiguration.getRelPath()));
             return cgenConfiguration;
         } else {
             cgenConfiguration = new CgenConfiguration();
@@ -240,7 +238,7 @@ public class CgenTask extends BaseCayenneTask {
     private CgenConfiguration cgenConfigFromPom(DataMap dataMap){
         CgenConfiguration cgenConfiguration = new CgenConfiguration();
         cgenConfiguration.setDataMap(dataMap);
-        cgenConfiguration.setRelPath(getDestDirFile() != null ? getDestDirFile().getPath() : cgenConfiguration.getRelPath());
+        cgenConfiguration.setRelPath(getDestDirFile() != null ? getDestDirFile().toPath() : cgenConfiguration.getRelPath());
         cgenConfiguration.setEncoding(encoding != null ? encoding : cgenConfiguration.getEncoding());
         cgenConfiguration.setMakePairs(makePairs != null ? Boolean.valueOf(makePairs) : cgenConfiguration.isMakePairs());
         cgenConfiguration.setArtifactsGenerationMode(mode != null ? mode : cgenConfiguration.getArtifactsGenerationMode());
@@ -255,28 +253,28 @@ public class CgenTask extends BaseCayenneTask {
         cgenConfiguration.setCreatePropertyNames(createPropertyNames != null ? Boolean.valueOf(createPropertyNames) : cgenConfiguration.isCreatePropertyNames());
         cgenConfiguration.setQueryTemplate(queryTemplate != null ? queryTemplate : cgenConfiguration.getQueryTemplate());
         cgenConfiguration.setQuerySuperTemplate(querySuperTemplate != null ? querySuperTemplate : cgenConfiguration.getQuerySuperTemplate());
-        cgenConfiguration.setCreatePKProperties(createPKProperties);
-        cgenConfiguration.setClient(client);
+        cgenConfiguration.setCreatePKProperties(createPKProperties != null ? Boolean.valueOf(createPKProperties) : cgenConfiguration.isCreatePKProperties());
+        cgenConfiguration.setClient(client != null ? Boolean.valueOf(client) : cgenConfiguration.isClient());
         if(!cgenConfiguration.isMakePairs()) {
             if(template == null) {
-                cgenConfiguration.setTemplate(client ? ClientClassGenerationAction.SINGLE_CLASS_TEMPLATE : ClassGenerationAction.SINGLE_CLASS_TEMPLATE);
+                cgenConfiguration.setTemplate(cgenConfiguration.isClient() ? ClientClassGenerationAction.SINGLE_CLASS_TEMPLATE : ClassGenerationAction.SINGLE_CLASS_TEMPLATE);
             }
             if(embeddableTemplate == null) {
                 cgenConfiguration.setEmbeddableTemplate(ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE);
             }
             if(queryTemplate == null) {
-                cgenConfiguration.setQueryTemplate(client ? ClientClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE : ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
+                cgenConfiguration.setQueryTemplate(cgenConfiguration.isClient() ? ClientClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE : ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
             }
         }
         return cgenConfiguration;
     }
 
     private boolean hasConfig() {
-        return destDir != null || destDirName != null || encoding != null || client || excludeEntities != null || excludeEmbeddables != null || includeEntities != null ||
+        return destDir != null || destDirName != null || encoding != null || client != null || excludeEntities != null || excludeEmbeddables != null || includeEntities != null ||
                 makePairs != null || mode != null || outputPattern != null || overwrite != null || superPkg != null ||
                 superTemplate != null || template != null || embeddableTemplate != null || embeddableSuperTemplate != null ||
                 usePkgPath != null || createPropertyNames != null || force || queryTemplate != null ||
-                querySuperTemplate != null || createPKProperties;
+                querySuperTemplate != null || createPKProperties != null;
     }
 
     @OutputDirectory
@@ -364,11 +362,11 @@ public class CgenTask extends BaseCayenneTask {
     }
 
     public boolean isClient() {
-        return client;
+        return Boolean.valueOf(client);
     }
 
     public void setClient(boolean client) {
-        this.client = client;
+        this.client = String.valueOf(client);
     }
 
     public void client(boolean client) {
@@ -419,6 +417,10 @@ public class CgenTask extends BaseCayenneTask {
         this.excludeEmbeddables = excludeEmbeddables;
     }
 
+    /**
+     * @since 4.1
+     * @param excludeEmbeddables
+     */
     public void excludeEmbeddables(String excludeEmbeddables) {
         setExcludeEmbeddables(excludeEmbeddables);
     }
@@ -568,7 +570,7 @@ public class CgenTask extends BaseCayenneTask {
     }
 
     public void setCreatePKProperties(boolean createPKProperties) {
-        this.createPKProperties = createPKProperties;
+        this.createPKProperties = String.valueOf(createPKProperties);
     }
 
     public void createPKProperties(boolean createPKProperties) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/BaseTaskIT.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/BaseTaskIT.java b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/BaseTaskIT.java
index 91118ca..b5c4a08 100644
--- a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/BaseTaskIT.java
+++ b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/BaseTaskIT.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.tools;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.nio.file.FileSystems;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -51,6 +52,7 @@ public class BaseTaskIT {
 
     protected GradleRunner createRunner(String projectName, String... args) throws Exception {
         prepareBuildScript(projectName);
+        prepareDataMap(args);
 
         List<String> gradleArguments = new ArrayList<>();
         gradleArguments.addAll(Arrays.asList(args));
@@ -67,4 +69,17 @@ public class BaseTaskIT {
         Path dst = FileSystems.getDefault().getPath(projectDir.getAbsolutePath(), "build.gradle");
         Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);
     }
+
+    private void prepareDataMap(String... args) throws Exception {
+        String pattern = "-PdataMap=";
+        for(String arg : args) {
+            if(arg.startsWith(pattern)) {
+                String path = arg.substring(pattern.length());
+                Path src = new File(getClass().getResource(path).toURI()).toPath();
+                Path dst = FileSystems.getDefault().getPath(projectDir.getAbsolutePath(), path);
+                Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);
+            }
+        }
+
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskIT.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskIT.java b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskIT.java
index b41c1d2..c3879ac 100644
--- a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskIT.java
+++ b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskIT.java
@@ -45,7 +45,7 @@ public class CgenTaskIT extends BaseTaskIT {
         GradleRunner runner = createRunner(
                 "cgen_default_config",
                 "cgen",
-                "-PdataMap=" + URLDecoder.decode(getClass().getResource("test_datamap.map.xml").getFile(), "UTF-8")
+                "-PdataMap=test_datamap.map.xml"
         );
 
         BuildResult result = runner.forwardOutput().build();
@@ -68,7 +68,7 @@ public class CgenTaskIT extends BaseTaskIT {
         GradleRunner runner = createRunner(
                 "cgen_custom_config",
                 "cgen",
-                "-PdataMap=" + URLDecoder.decode(getClass().getResource("test_datamap.map.xml").getFile(), "UTF-8")
+                "-PdataMap=test_datamap.map.xml"
         );
         BuildResult result = runner.build();
 
@@ -92,11 +92,11 @@ public class CgenTaskIT extends BaseTaskIT {
     }
 
     @Test
-    public void cgenWithConfig() throws Exception {
+    public void cgenWithConfigInDm() throws Exception {
         GradleRunner runner = createRunner(
                 "cgen_with_config",
                 "cgen",
-                "-PdataMap=" + URLDecoder.decode(getClass().getResource("cgenConfig.map.xml").getFile(), "UTF-8")
+                "-PdataMap=cgen_with_config.map.xml"
         );
 
         BuildResult result = runner.forwardOutput().build();
@@ -121,11 +121,11 @@ public class CgenTaskIT extends BaseTaskIT {
     }
 
     @Test
-    public void testWithConfigs() throws Exception {
+    public void testWithConfigsInDmAndPom() throws Exception {
         GradleRunner runner = createRunner(
                 "cgen_with_configs",
                 "cgen",
-                "-PdataMap=" + URLDecoder.decode(getClass().getResource("cgenMap.map.xml").getFile(), "UTF-8")
+                "-PdataMap=cgenMap.map.xml"
         );
 
         BuildResult result = runner.forwardOutput().build();

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/DbGenerateTaskIT.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/DbGenerateTaskIT.java b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/DbGenerateTaskIT.java
index 87c1194..c88f1f7 100644
--- a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/DbGenerateTaskIT.java
+++ b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/DbGenerateTaskIT.java
@@ -58,7 +58,7 @@ public class DbGenerateTaskIT extends BaseTaskIT {
                 "cdbgen_simple",
                 "cdbgen",
                 "-PdbUrl=" + dbUrl,
-                "-PdataMap=" + URLDecoder.decode(getClass().getResource("test_datamap.map.xml").getFile(), "UTF-8"),
+                "-PdataMap=test_datamap.map.xml",
                 "--info"
         );
 
@@ -84,7 +84,7 @@ public class DbGenerateTaskIT extends BaseTaskIT {
         GradleRunner runner = createRunner(
                 "cdbgen_custom",
                 "customCdbgen",
-                "-PdataMap=" + URLDecoder.decode(getClass().getResource("test_datamap.map.xml").getFile(), "UTF-8"),
+                "-PdataMap=test_datamap.map.xml",
                 "--info"
         );
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/GradlePluginIT.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/GradlePluginIT.java b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/GradlePluginIT.java
index 199c0a6..60f5749 100644
--- a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/GradlePluginIT.java
+++ b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/GradlePluginIT.java
@@ -43,7 +43,7 @@ public class GradlePluginIT extends BaseTaskIT {
         GradleRunner runner = createRunner(
                 "cgen_default_config",
                 "cgen",
-                "-PdataMap=" + URLDecoder.decode(getClass().getResource("test_datamap.map.xml").getFile(), "UTF-8")
+                "-PdataMap=test_datamap.map.xml"
         );
         runner.withGradleVersion(version);
         runner.build();

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgenConfig.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgenConfig.map.xml b/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgenConfig.map.xml
deleted file mode 100644
index e3bfe55..0000000
--- a/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgenConfig.map.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<data-map xmlns="http://cayenne.apache.org/schema/10/modelMap"
-          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-          xsi:schemaLocation="http://cayenne.apache.org/schema/10/modelMap http://cayenne.apache.org/schema/10/modelMap.xsd"
-          project-version="10">
-    <embeddable className="Embeddable"/>
-    <obj-entity name="ObjEntity" className="ObjEntity"/>
-    <obj-entity name="ObjEntity1" className="ObjEntity1"/>
-    <cgen xmlns="http://cayenne.apache.org/schema/10/cgen">
-        <destDir>./customDirectory1</destDir>
-        <excludeEntities>ObjEntity</excludeEntities>
-        <excludeEmbeddables>Embeddable</excludeEmbeddables>
-        <mode>entity</mode>
-        <template>templates/v4_1/subclass.vm</template>
-        <superTemplate>templates/v4_1/superclass.vm</superTemplate>
-        <outputPattern>*.txt</outputPattern>
-        <makePairs>false</makePairs>
-        <usePkgPath>true</usePkgPath>
-        <overwrite>false</overwrite>
-        <createPropertyNames>false</createPropertyNames>
-    </cgen>
-</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_config.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_config.map.xml b/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_config.map.xml
new file mode 100644
index 0000000..e3bfe55
--- /dev/null
+++ b/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_config.map.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/10/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/10/modelMap http://cayenne.apache.org/schema/10/modelMap.xsd"
+          project-version="10">
+    <embeddable className="Embeddable"/>
+    <obj-entity name="ObjEntity" className="ObjEntity"/>
+    <obj-entity name="ObjEntity1" className="ObjEntity1"/>
+    <cgen xmlns="http://cayenne.apache.org/schema/10/cgen">
+        <destDir>./customDirectory1</destDir>
+        <excludeEntities>ObjEntity</excludeEntities>
+        <excludeEmbeddables>Embeddable</excludeEmbeddables>
+        <mode>entity</mode>
+        <template>templates/v4_1/subclass.vm</template>
+        <superTemplate>templates/v4_1/superclass.vm</superTemplate>
+        <outputPattern>*.txt</outputPattern>
+        <makePairs>false</makePairs>
+        <usePkgPath>true</usePkgPath>
+        <overwrite>false</overwrite>
+        <createPropertyNames>false</createPropertyNames>
+    </cgen>
+</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-project/src/main/java/org/apache/cayenne/project/CompoundSaverDelegate.java
----------------------------------------------------------------------
diff --git a/cayenne-project/src/main/java/org/apache/cayenne/project/CompoundSaverDelegate.java b/cayenne-project/src/main/java/org/apache/cayenne/project/CompoundSaverDelegate.java
index 4745e38..7d446e3 100644
--- a/cayenne-project/src/main/java/org/apache/cayenne/project/CompoundSaverDelegate.java
+++ b/cayenne-project/src/main/java/org/apache/cayenne/project/CompoundSaverDelegate.java
@@ -21,7 +21,18 @@ package org.apache.cayenne.project;
 
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
-import org.apache.cayenne.map.*;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.EmbeddableAttribute;
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.map.ProcedureParameter;
+import org.apache.cayenne.map.QueryDescriptor;
 import org.apache.cayenne.project.extension.SaverDelegate;
 import org.apache.cayenne.resource.Resource;
 import org.apache.cayenne.util.XMLEncoder;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-server/src/main/java/org/apache/cayenne/util/Util.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/util/Util.java b/cayenne-server/src/main/java/org/apache/cayenne/util/Util.java
index de280b4..08941b8 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/util/Util.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/util/Util.java
@@ -26,20 +26,45 @@ import org.apache.cayenne.Persistent;
 import org.apache.cayenne.di.AdhocObjectFactory;
 import org.apache.cayenne.di.spi.DefaultAdhocObjectFactory;
 import org.apache.cayenne.di.spi.DefaultClassLoaderManager;
-import org.apache.cayenne.reflect.*;
+import org.apache.cayenne.reflect.ArcProperty;
+import org.apache.cayenne.reflect.AttributeProperty;
+import org.apache.cayenne.reflect.PropertyVisitor;
+import org.apache.cayenne.reflect.ToManyProperty;
+import org.apache.cayenne.reflect.ToOneProperty;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 
-import javax.xml.parsers.*;
-import java.io.*;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.lang.reflect.Member;
 import java.lang.reflect.Modifier;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.sql.SQLException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
 import java.util.regex.Pattern;
 
 /**

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/cayenne-server/src/main/resources/org/apache/cayenne/schema/10/cgen.xsd
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/resources/org/apache/cayenne/schema/10/cgen.xsd b/cayenne-server/src/main/resources/org/apache/cayenne/schema/10/cgen.xsd
new file mode 100644
index 0000000..7b26e92
--- /dev/null
+++ b/cayenne-server/src/main/resources/org/apache/cayenne/schema/10/cgen.xsd
@@ -0,0 +1,47 @@
+<?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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<xs:schema targetNamespace="http://cayenne.apache.org/schema/10/cgen"
+           elementFormDefault="qualified" version="10"
+           xmlns:cay="http://cayenne.apache.org/schema/10/cgen"
+           xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+    <xs:element name="cgen">
+        <xs:complexType>
+                <xs:sequence>
+                    <xs:element name="excludeEntities" minOccurs="0" type="xs:string"/>
+                    <xs:element name="excludeEmbeddables" minOccurs="0" type="xs:string"/>
+                    <xs:element name="destDir" minOccurs="0" type="xs:string"/>
+                    <xs:element name="mode" minOccurs="0" type="xs:string"/>
+                    <xs:element name="template" minOccurs="0" type="xs:string"/>
+                    <xs:element name="superTemplate" minOccurs="0" type="xs:string"/>
+                    <xs:element name="outputPattern" minOccurs="0" type="xs:string"/>
+                    <xs:element name="makePairs" minOccurs="0" type="xs:boolean"/>
+                    <xs:element name="skipRelationshipsLoading" minOccurs="0" type="xs:boolean"/>
+                    <xs:element name="usePkgPath" minOccurs="0" type="xs:boolean"/>
+                    <xs:element name="overwrite" minOccurs="0" type="xs:boolean"/>
+                    <xs:element name="createPropertyNames" minOccurs="0" type="xs:boolean"/>
+                    <xs:element name="createPKProperties" minOccurs="0" type="xs:boolean"/>
+                    <xs:element name="client" minOccurs="0" type="xs:boolean"/>
+                </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+
+</xs:schema>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
index e936024..647f363 100644
--- a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
+++ b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
@@ -39,10 +39,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 
 /**
  * Maven mojo to perform class generation from data cgenConfiguration. This class is an Maven
@@ -65,13 +61,19 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 	 * Whether we are generating classes for the client tier in a Remote Object
 	 * Persistence application. Default is <code>false</code>.
 	 */
-	@Parameter(defaultValue = "false")
-	private boolean client;
+	@Parameter
+	private Boolean client;
 
 	/**
-	 * Destination directory for Java classes (ignoring their package names).
+	 * Default destination directory for Java classes (ignoring their package names).
 	 */
 	@Parameter(defaultValue = "${project.build.sourceDirectory}")
+	private File defaultDir;
+
+	/**
+	 * Destination directory for Java classes (ignoring their package names).
+	 */
+	@Parameter
 	private File destDir;
 
 	/**
@@ -99,6 +101,7 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 	private String includeEntities;
 
 	/**
+	 * @since 4.1
 	 * Embeddables (expressed as a perl5 regex) to exclude from template
 	 * generation. (Default is to include all embeddables in the DataMap).
 	 */
@@ -218,8 +221,8 @@ public class CayenneGeneratorMojo extends AbstractMojo {
      * Default is <code>false</code>.
      * @since 4.1
      */
-    @Parameter(defaultValue = "false")
-    private boolean createPKProperties;
+    @Parameter
+    private Boolean createPKProperties;
 
     private transient Injector injector;
 
@@ -239,7 +242,6 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 		loaderAction.setMainDataMapFile(map);
 
 		CayenneGeneratorEntityFilterAction filterEntityAction = new CayenneGeneratorEntityFilterAction();
-		filterEntityAction.setClient(client);
 		filterEntityAction.setNameFilter(NamePatternMatcher.build(logger, includeEntities, excludeEntities));
 
 		CayenneGeneratorEmbeddableFilterAction filterEmbeddableAction = new CayenneGeneratorEmbeddableFilterAction();
@@ -249,8 +251,8 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 			loaderAction.setAdditionalDataMapFiles(convertAdditionalDataMaps());
 
 			DataMap dataMap = loaderAction.getMainDataMap();
-
 			ClassGenerationAction generator = createGenerator(dataMap);
+			filterEntityAction.setClient(generator.getCgenConfiguration().isClient());
 			generator.setLogger(logger);
 
 			if(force) {
@@ -265,7 +267,6 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 				generator.addEmbeddables(filterEmbeddableAction.getFilteredEmbeddables(dataMap));
 				generator.addQueries(dataMap.getQueryDescriptors());
 			}
-			URL dataName = dataMap.getConfigurationSource().getURL();
 			generator.execute();
 		} catch (Exception e) {
 			throw new MojoExecutionException("Error generating classes: ", e);
@@ -291,11 +292,11 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 	}
 
 	private boolean hasConfig() {
-		return encoding != null || client || excludeEntities != null || excludeEmbeddables != null || includeEntities != null ||
+		return destDir != null || encoding != null || client != null || excludeEntities != null || excludeEmbeddables != null || includeEntities != null ||
 				makePairs != null || mode != null || outputPattern != null || overwrite != null || superPkg != null ||
 				superTemplate != null || template != null || embeddableTemplate != null || embeddableSuperTemplate != null ||
 				usePkgPath != null || createPropertyNames != null || force || queryTemplate != null ||
-				querySuperTemplate != null || createPKProperties;
+				querySuperTemplate != null || createPKProperties != null;
 	}
 
 	/**
@@ -317,16 +318,11 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 			return cgenConfigFromPom(dataMap);
 		} else if(cgenConfiguration != null) {
 			useConfigFromDataMap = true;
-			Path resourcePath = Paths.get(map.getPath());
-			if(Files.isRegularFile(resourcePath)) {
-				resourcePath = resourcePath.getParent();
-			}
-			cgenConfiguration.setRelPath(resourcePath.resolve(cgenConfiguration.getRelPath()));
 			return cgenConfiguration;
 		} else {
 			cgenConfiguration = new CgenConfiguration();
 			cgenConfiguration.setDataMap(dataMap);
-			cgenConfiguration.setRelPath(destDir.getPath());
+			cgenConfiguration.setRelPath(defaultDir.getPath());
 			return cgenConfiguration;
 		}
 	}
@@ -334,7 +330,7 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 	private CgenConfiguration cgenConfigFromPom(DataMap dataMap){
 		CgenConfiguration cgenConfiguration = new CgenConfiguration();
 		cgenConfiguration.setDataMap(dataMap);
-		cgenConfiguration.setRelPath(destDir != null ? destDir.getPath() : cgenConfiguration.getRelPath());
+		cgenConfiguration.setRelPath(destDir != null ? destDir.getPath() : defaultDir.getPath());
 		cgenConfiguration.setEncoding(encoding != null ? encoding : cgenConfiguration.getEncoding());
 		cgenConfiguration.setMakePairs(makePairs != null ? makePairs : cgenConfiguration.isMakePairs());
 		cgenConfiguration.setArtifactsGenerationMode(mode != null ? mode : cgenConfiguration.getArtifactsGenerationMode());
@@ -349,17 +345,17 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 		cgenConfiguration.setCreatePropertyNames(createPropertyNames != null ? createPropertyNames : cgenConfiguration.isCreatePropertyNames());
 		cgenConfiguration.setQueryTemplate(queryTemplate != null ? queryTemplate : cgenConfiguration.getQueryTemplate());
 		cgenConfiguration.setQuerySuperTemplate(querySuperTemplate != null ? querySuperTemplate : cgenConfiguration.getQuerySuperTemplate());
-		cgenConfiguration.setCreatePKProperties(createPKProperties);
-		cgenConfiguration.setClient(client);
+		cgenConfiguration.setCreatePKProperties(createPKProperties != null ? createPKProperties : cgenConfiguration.isCreatePKProperties());
+		cgenConfiguration.setClient(client != null ? client : cgenConfiguration.isClient());
 		if(!cgenConfiguration.isMakePairs()) {
 			if(template == null) {
-				cgenConfiguration.setTemplate(client ? ClientClassGenerationAction.SINGLE_CLASS_TEMPLATE : ClassGenerationAction.SINGLE_CLASS_TEMPLATE);
+				cgenConfiguration.setTemplate(cgenConfiguration.isClient() ? ClientClassGenerationAction.SINGLE_CLASS_TEMPLATE : ClassGenerationAction.SINGLE_CLASS_TEMPLATE);
 			}
 			if(embeddableTemplate == null) {
 				cgenConfiguration.setEmbeddableTemplate(ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE);
 			}
 			if(queryTemplate == null) {
-				cgenConfiguration.setQueryTemplate(client ? ClientClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE : ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
+				cgenConfiguration.setQueryTemplate(cgenConfiguration.isClient() ? ClientClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE : ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
 			}
 		}
 		return cgenConfiguration;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/maven-plugins/cayenne-maven-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorMojoTest.java b/maven-plugins/cayenne-maven-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorMojoTest.java
index edad490..8454c32 100644
--- a/maven-plugins/cayenne-maven-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorMojoTest.java
+++ b/maven-plugins/cayenne-maven-plugin/src/test/java/org/apache/cayenne/tools/CayenneGeneratorMojoTest.java
@@ -90,7 +90,7 @@ public class CayenneGeneratorMojoTest extends AbstractMojoTestCase {
         assertFalse(notIncludedEmbeddable.exists());
     }
 
-    public void testDataMapPomCgen() throws Exception {
+    public void testCgenWithDmAndPomConfigs() throws Exception {
         File pom = getTestFile("src/test/resources/cgen/project-to-test/datamap-and-pom.xml");
         assertNotNull(pom);
         assertTrue(pom.exists());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
index 1af72ba..4ca815b 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
@@ -19,12 +19,63 @@
 
 package org.apache.cayenne.modeler;
 
-import org.apache.cayenne.modeler.action.*;
+import org.apache.cayenne.modeler.action.AboutAction;
+import org.apache.cayenne.modeler.action.ActionManager;
+import org.apache.cayenne.modeler.action.ConfigurePreferencesAction;
+import org.apache.cayenne.modeler.action.CopyAction;
+import org.apache.cayenne.modeler.action.CreateDataMapAction;
+import org.apache.cayenne.modeler.action.CreateDbEntityAction;
+import org.apache.cayenne.modeler.action.CreateEmbeddableAction;
+import org.apache.cayenne.modeler.action.CreateNodeAction;
+import org.apache.cayenne.modeler.action.CreateObjEntityAction;
+import org.apache.cayenne.modeler.action.CreateProcedureAction;
+import org.apache.cayenne.modeler.action.CreateQueryAction;
+import org.apache.cayenne.modeler.action.CutAction;
+import org.apache.cayenne.modeler.action.DbEntitySyncAction;
+import org.apache.cayenne.modeler.action.DocumentationAction;
+import org.apache.cayenne.modeler.action.ExitAction;
+import org.apache.cayenne.modeler.action.FindAction;
+import org.apache.cayenne.modeler.action.GenerateCodeAction;
+import org.apache.cayenne.modeler.action.GenerateDBAction;
+import org.apache.cayenne.modeler.action.ImportDataMapAction;
+import org.apache.cayenne.modeler.action.ImportEOModelAction;
+import org.apache.cayenne.modeler.action.InferRelationshipsAction;
+import org.apache.cayenne.modeler.action.MigrateAction;
+import org.apache.cayenne.modeler.action.NavigateBackwardAction;
+import org.apache.cayenne.modeler.action.NavigateForwardAction;
+import org.apache.cayenne.modeler.action.NewProjectAction;
+import org.apache.cayenne.modeler.action.ObjEntitySyncAction;
+import org.apache.cayenne.modeler.action.OpenProjectAction;
+import org.apache.cayenne.modeler.action.PasteAction;
+import org.apache.cayenne.modeler.action.ProjectAction;
+import org.apache.cayenne.modeler.action.RedoAction;
+import org.apache.cayenne.modeler.action.RemoveAction;
+import org.apache.cayenne.modeler.action.RevertAction;
+import org.apache.cayenne.modeler.action.SaveAction;
+import org.apache.cayenne.modeler.action.SaveAsAction;
+import org.apache.cayenne.modeler.action.ShowLogConsoleAction;
+import org.apache.cayenne.modeler.action.UndoAction;
+import org.apache.cayenne.modeler.action.ValidateAction;
 import org.apache.cayenne.modeler.action.dbimport.ReverseEngineeringToolMenuAction;
 import org.apache.cayenne.modeler.dialog.LogConsole;
 import org.apache.cayenne.modeler.dialog.welcome.WelcomeScreen;
 import org.apache.cayenne.modeler.editor.EditorView;
-import org.apache.cayenne.modeler.event.*;
+import org.apache.cayenne.modeler.event.DataMapDisplayEvent;
+import org.apache.cayenne.modeler.event.DataMapDisplayListener;
+import org.apache.cayenne.modeler.event.DataNodeDisplayEvent;
+import org.apache.cayenne.modeler.event.DataNodeDisplayListener;
+import org.apache.cayenne.modeler.event.DbEntityDisplayListener;
+import org.apache.cayenne.modeler.event.EmbeddableDisplayEvent;
+import org.apache.cayenne.modeler.event.EmbeddableDisplayListener;
+import org.apache.cayenne.modeler.event.EntityDisplayEvent;
+import org.apache.cayenne.modeler.event.MultipleObjectsDisplayEvent;
+import org.apache.cayenne.modeler.event.MultipleObjectsDisplayListener;
+import org.apache.cayenne.modeler.event.ObjEntityDisplayListener;
+import org.apache.cayenne.modeler.event.ProcedureDisplayEvent;
+import org.apache.cayenne.modeler.event.ProcedureDisplayListener;
+import org.apache.cayenne.modeler.event.QueryDisplayEvent;
+import org.apache.cayenne.modeler.event.QueryDisplayListener;
+import org.apache.cayenne.modeler.event.RecentFileListListener;
 import org.apache.cayenne.modeler.pref.ComponentGeometry;
 import org.apache.cayenne.modeler.util.ModelerUtil;
 import org.apache.cayenne.modeler.util.RecentFileMenu;
@@ -32,8 +83,28 @@ import org.apache.cayenne.swing.components.MainToolBar;
 import org.apache.cayenne.swing.components.TopBorder;
 import org.slf4j.LoggerFactory;
 
-import javax.swing.*;
-import java.awt.*;
+import javax.swing.Action;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JPanel;
+import javax.swing.JSplitPane;
+import javax.swing.JTextField;
+import javax.swing.JToolBar;
+import java.awt.AWTEvent;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.Toolkit;
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
 import java.awt.event.KeyEvent;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClassesTabController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClassesTabController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClassesTabController.java
deleted file mode 100644
index 8df07df..0000000
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClassesTabController.java
+++ /dev/null
@@ -1,203 +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.modeler.dialog.codegen;
-//
-//import org.apache.cayenne.map.DataMap;
-//import org.apache.cayenne.modeler.util.CayenneController;
-//import org.apache.cayenne.swing.BindingBuilder;
-//import org.apache.cayenne.swing.ImageRendererColumn;
-//import org.apache.cayenne.swing.ObjectBinding;
-//import org.apache.cayenne.swing.TableBindingBuilder;
-//
-//import javax.swing.JCheckBox;
-//import javax.swing.JLabel;
-//import javax.swing.JTable;
-//import java.awt.Component;
-//import java.util.ArrayList;
-//import java.util.Collection;
-//import java.util.HashMap;
-//import java.util.Map;
-//import java.util.List;
-//
-//public class ClassesTabController extends CayenneController {
-//
-//    public static final String GENERATE_PROPERTY = "generate";
-//
-//    protected ClassesTabPanel view;
-//
-//    private Map<DataMap, ObjectBinding> objectBindings;
-//
-//    protected Collection<DataMap> dataMaps;
-//
-//    protected Map<DataMap, List<Object>> objectList;
-//
-//    private List<Object> currentCollection;
-//
-//    public ClassesTabController(CodeGeneratorControllerBase parent, Collection<DataMap> dataMaps) {
-//        super(parent);
-//
-//        currentCollection = new ArrayList<>();
-//
-//        this.objectList = new HashMap<>();
-//        for(DataMap dataMap : dataMaps) {
-//            List<Object> list = new ArrayList<>();
-//            list.add(dataMap);
-//            list.addAll(dataMap.getObjEntities());
-//            list.addAll(dataMap.getEmbeddables());
-//            objectList.put(dataMap, list);
-//        }
-//
-//        this.objectBindings = new HashMap<>();
-//        this.dataMaps = dataMaps;
-//        this.view = new ClassesTabPanel(dataMaps);
-//
-//        initBindings();
-//    }
-//
-//    protected CodeGeneratorControllerBase getParentController() {
-//        return (CodeGeneratorControllerBase) getParent();
-//    }
-//
-//    public Component getView() {
-//        return view;
-//    }
-//
-//    protected void initBindings() {
-//
-//        BindingBuilder builder = new BindingBuilder(
-//                getApplication().getBindingFactory(),
-//                this);
-//
-//        builder.bindToAction(view.getCheckAll(), "checkAllAction()");
-//
-//        TableBindingBuilder tableBuilder = new TableBindingBuilder(builder);
-//
-//        tableBuilder.addColumn(
-//                "",
-//                "parent.setCurrentClass(#item), selected",
-//                Boolean.class,
-//                true,
-//                Boolean.TRUE);
-//
-//        tableBuilder.addColumn(
-//                "Class",
-//                "parent.getItemName(#item)",
-//                JLabel.class,
-//                false,
-//                "XXXXXXXXXXXXXX");
-//
-//        tableBuilder.addColumn(
-//                "Comments, Warnings",
-//                "parent.getProblem(#item)",
-//                String.class,
-//                false,
-//                "XXXXXXXXXXXXXXXXXXXXXXXXXXX");
-//
-//        for(DataMap dataMap : dataMaps) {
-//            JTable table = view.getDataMapTables().get(dataMap);
-//            if(table != null) {
-//                currentCollection = objectList.get(dataMap);
-//                objectBindings.put(dataMap, tableBuilder.bindToTable(table, "currentCollection"));
-//                table.getColumnModel().getColumn(1).setCellRenderer(new ImageRendererColumn());
-//            }
-//            JCheckBox checkBox = view.getDataMapJCheckBoxMap().get(dataMap);
-//            if(checkBox != null) {
-//                checkBox.addActionListener(val -> checkDataMap(dataMap, ((JCheckBox)val.getSource()).isSelected()));
-//            }
-//        }
-//    }
-//
-//    public List<Object> getCurrentCollection() {
-//        return currentCollection;
-//    }
-//
-//    public boolean isSelected() {
-//        return getParentController().isSelected();
-//    }
-//
-//    public void setSelected(boolean selected) {
-//        getParentController().setSelected(selected);
-//        classSelectedAction();
-//
-//        for(DataMap dataMap : dataMaps) {
-//            if(view.isAllCheckBoxesFromDataMapSelected(dataMap)) {
-//                view.getDataMapJCheckBoxMap().get(dataMap).setSelected(true);
-//            } else {
-//                view.getDataMapJCheckBoxMap().get(dataMap).setSelected(false);
-//            }
-//        }
-//    }
-//
-//    /**
-//     * A callback action that updates the state of Select All checkbox.
-//     */
-//    public void classSelectedAction() {
-//        int selectedCount = getParentController().getSelectedEntitiesSize()
-//                + getParentController().getSelectedEmbeddablesSize()
-//                + getParentController().getSelectedDataMapsSize();
-//
-//        if (selectedCount == 0) {
-//            view.getCheckAll().setSelected(false);
-//        }
-//        else if (selectedCount == getParentController().getClasses().size()) {
-//            view.getCheckAll().setSelected(true);
-//        }
-//    }
-//
-//    /**
-//     * An action that updates entity check boxes in response to the Select All state
-//     * change.
-//     */
-//    public void checkAllAction() {
-//        if (getParentController().updateSelection(view.getCheckAll().isSelected() ? o -> true : o -> false)) {
-//            dataMaps.forEach(dataMap -> {
-//                ObjectBinding binding = objectBindings.get(dataMap);
-//                if(binding != null) {
-//                    currentCollection = objectList.get(dataMap);
-//                    binding.updateView();
-//                }
-//            });
-//        }
-//    }
-//
-//    private void checkDataMap(DataMap dataMap, boolean selected) {
-//        if (getParentController().updateDataMapSelection(selected ? o -> true : o -> false, dataMap)){
-//            ObjectBinding binding = objectBindings.get(dataMap);
-//            if(binding != null) {
-//                currentCollection = objectList.get(dataMap);
-//                binding.updateView();
-//            }
-//            if(isAllMapsSelected()) {
-//                view.getCheckAll().setSelected(true);
-//            }
-//        }
-//    }
-//
-//    private boolean isAllMapsSelected() {
-//        for(DataMap dataMap : dataMaps) {
-//            if(view.getDataMapJCheckBoxMap().get(dataMap) != null) {
-//                if(!view.getDataMapJCheckBoxMap().get(dataMap).isSelected()) {
-//                    return false;
-//                }
-//            }
-//        }
-//        return true;
-//    }
-//}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClassesTabPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClassesTabPanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClassesTabPanel.java
deleted file mode 100644
index 5d7e895..0000000
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClassesTabPanel.java
+++ /dev/null
@@ -1,141 +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.modeler.dialog.codegen;
-//
-//import org.apache.cayenne.map.DataMap;
-//
-//import javax.swing.BoxLayout;
-//import javax.swing.JCheckBox;
-//import javax.swing.JLabel;
-//import javax.swing.JPanel;
-//import javax.swing.JScrollPane;
-//import javax.swing.JTable;
-//import javax.swing.ScrollPaneConstants;
-//import javax.swing.UIManager;
-//import javax.swing.border.EmptyBorder;
-//import java.awt.BorderLayout;
-//import java.awt.Component;
-//import java.awt.Dimension;
-//import java.awt.FlowLayout;
-//import java.util.Collection;
-//import java.util.HashMap;
-//import java.util.Map;
-//
-///**
-// */
-//public class ClassesTabPanel extends JPanel {
-//
-//    protected JCheckBox checkAll;
-//    protected JLabel checkAllLabel;
-//
-//    private Map<DataMap, JTable> dataMapTables;
-//
-//    private Map<DataMap, JCheckBox> dataMapJCheckBoxMap;
-//
-//    public ClassesTabPanel(Collection<DataMap> dataMaps) {
-//        dataMapTables = new HashMap<>();
-//        dataMapJCheckBoxMap = new HashMap<>();
-//
-//        // TODO: andrus 04/07/2006 - is there an easy way to stick that checkbox in the
-//        // table header????
-//        this.checkAll = new JCheckBox();
-//        this.checkAllLabel = new JLabel("Check All Classes");
-//
-//        checkAll.addItemListener(event -> {
-//            if (checkAll.isSelected()) {
-//                checkAllLabel.setText("Uncheck All Classess");
-//                dataMapJCheckBoxMap.keySet().forEach(val -> dataMapJCheckBoxMap.get(val).setSelected(true));
-//            }
-//            else {
-//                checkAllLabel.setText("Check All Classes");
-//                dataMapJCheckBoxMap.keySet().forEach(val -> dataMapJCheckBoxMap.get(val).setSelected(false));
-//            }
-//        });
-//
-//        // assemble
-//        JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
-//        topPanel.setBorder(UIManager.getBorder("ToolBar.border"));
-//        topPanel.add(checkAll);
-//        topPanel.add(checkAllLabel);
-//
-//        JPanel panel = new JPanel();
-//        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
-//        for(DataMap dataMap : dataMaps) {
-//            JTable table = new JTable();
-//            table.setRowHeight(22);
-//            dataMapTables.put(dataMap, table);
-//            JPanel scrollTable = new JPanel(new BorderLayout());
-//            scrollTable.add(dataMapTables.get(dataMap).getTableHeader(), BorderLayout.NORTH);
-//            scrollTable.add(dataMapTables.get(dataMap), BorderLayout.CENTER);
-//            scrollTable.setPreferredSize(new Dimension(dataMapTables.get(dataMap).getPreferredSize().width,
-//                    (dataMap.getEmbeddables().size() + dataMap.getObjEntities().size()) * dataMapTables.get(dataMap).getRowHeight() + 45));
-//            JPanel labelPanel = new JPanel(new BorderLayout());
-//            labelPanel.setPreferredSize(new Dimension(dataMapTables.get(dataMap).getPreferredSize().width, 20));
-//            JLabel dataMapLabel = new JLabel(dataMap.getName());
-//            dataMapLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
-//            dataMapLabel.setBorder(new EmptyBorder(8, 8, 8, 0));
-//            labelPanel.add(dataMapLabel, BorderLayout.CENTER);
-//
-//            JCheckBox dataMapCheckBox = new JCheckBox();
-//            dataMapJCheckBoxMap.put(dataMap, dataMapCheckBox);
-//            labelPanel.add(dataMapCheckBox, BorderLayout.WEST);
-//
-//            JPanel currPanel = new JPanel(new BorderLayout());
-//            currPanel.add(labelPanel, BorderLayout.NORTH);
-//            currPanel.add(scrollTable, BorderLayout.CENTER);
-//
-//            panel.add(currPanel);
-//        }
-//
-//        JScrollPane tablePanel = new JScrollPane(
-//                panel,
-//                ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
-//                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
-//
-//        // set some minimal preferred size, so that it is smaller than other forms used in
-//        // the dialog... this way we get the right automated overall size
-//        tablePanel.setPreferredSize(new Dimension(450, 400));
-//        setLayout(new BorderLayout());
-//        add(topPanel, BorderLayout.NORTH);
-//        add(tablePanel, BorderLayout.CENTER);
-//    }
-//
-//    public boolean isAllCheckBoxesFromDataMapSelected(DataMap dataMap) {
-//        JTable table = dataMapTables.get(dataMap);
-//        for(int i = 0; i < table.getRowCount(); i++) {
-//            if(!(Boolean)table.getModel().getValueAt(i, 0)) {
-//                return false;
-//            }
-//        }
-//        return true;
-//    }
-//
-//    public Map<DataMap, JTable> getDataMapTables() {
-//        return dataMapTables;
-//    }
-//
-//    public Map<DataMap, JCheckBox> getDataMapJCheckBoxMap() {
-//        return dataMapJCheckBoxMap;
-//    }
-//
-//    public JCheckBox getCheckAll() {
-//        return checkAll;
-//    }
-//}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClientModeController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClientModeController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClientModeController.java
deleted file mode 100644
index 0225d3b..0000000
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/ClientModeController.java
+++ /dev/null
@@ -1,81 +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.modeler.dialog.codegen;
-//
-//import org.apache.cayenne.gen.ClassGenerationAction;
-//import org.apache.cayenne.gen.ClientClassGenerationAction;
-//import org.apache.cayenne.map.DataMap;
-//import org.apache.cayenne.map.ObjEntity;
-//import org.apache.cayenne.modeler.pref.DataMapDefaults;
-//import org.apache.cayenne.validation.BeanValidationFailure;
-//import org.apache.cayenne.validation.ValidationResult;
-//
-//import java.util.ArrayList;
-//import java.util.TreeMap;
-//
-//public class ClientModeController extends StandardModeController {
-//
-//    public ClientModeController(CodeGeneratorControllerBase parent) {
-//        super(parent);
-//    }
-//
-//    public void validateEntity(ValidationResult validationBuffer, ObjEntity entity) {
-//        if (!entity.isClientAllowed()) {
-//            validationBuffer.addFailure(new BeanValidationFailure(
-//                    entity.getName(),
-//                    "clientAllowed",
-//                    "Not a client entity"));
-//        } else {
-//            super.validateEntity(validationBuffer, entity, true);
-//        }
-//    }
-//
-//    protected void createDefaults() {
-//        TreeMap<DataMap, DataMapDefaults> map = new TreeMap<DataMap, DataMapDefaults>();
-//        ArrayList<DataMap> dataMaps = (ArrayList<DataMap>) getParentController().getDataMaps();
-//        for (DataMap dataMap : dataMaps) {
-//            DataMapDefaults preferences = getApplication()
-//                    .getFrameController()
-//                    .getProjectController()
-//                    .getDataMapPreferences(this.getClass().getName().replace(".", "/"), dataMap);
-//
-//            preferences.setSuperclassPackage("");
-//            preferences.updateSuperclassPackage(dataMap, true);
-//
-//            map.put(dataMap, preferences);
-//
-//            if (getOutputPath() == null) {
-//                setOutputPath(preferences.getOutputPath());
-//            }
-//        }
-//
-//        setMapPreferences(map);
-//    }
-//
-//    protected GeneratorControllerPanel createView() {
-//        this.view = new StandardModePanel();
-//        return view;
-//    }
-//
-//    @Override
-//    protected ClassGenerationAction newGenerator() {
-//        return new ClientClassGenerationAction();
-//    }
-//}
\ No newline at end of file


Mime
View raw message