This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git

commit 011051ef3624d969bfef059de1ce71ae939274d0
Author: Nikita Timofeev <stari...@gmail.com>
AuthorDate: Wed Jul 20 14:51:51 2022 +0300

    CAY-2752 Rename queryTemplate to dataMapTemplate in the cgen config
     - rename CgenConfiguration fields
     - minor code cleanup
---
 .../apache/cayenne/tools/CayenneGeneratorTask.java |  6 +--
 .../org/apache/cayenne/gen/CgenConfiguration.java  | 48 +++++++++++++---------
 .../apache/cayenne/gen/ClassGenerationAction.java  |  6 +--
 .../apache/cayenne/gen/xml/CgenConfigHandler.java  |  4 +-
 .../apache/cayenne/project/FileProjectSaver.java   |  2 +-
 .../apache/cayenne/tools/CayenneGeneratorMojo.java |  6 +--
 .../editor/cgen/CodeGeneratorController.java       |  6 +--
 .../modeler/editor/cgen/CustomModeController.java  |  8 ++--
 .../modeler/editor/cgen/CustomModePanel.java       |  4 +-
 9 files changed, 48 insertions(+), 42 deletions(-)

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 9970ad902..4c75bb484 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
@@ -200,8 +200,8 @@ public class CayenneGeneratorTask extends CayenneTask {
         cgenConfiguration.setEmbeddableTemplate(embeddabletemplate != null ? 
embeddabletemplate : cgenConfiguration.getEmbeddableTemplate());
         cgenConfiguration.setUsePkgPath(usepkgpath != null ? usepkgpath : 
cgenConfiguration.isUsePkgPath());
         cgenConfiguration.setCreatePropertyNames(createpropertynames != null ? 
createpropertynames : cgenConfiguration.isCreatePropertyNames());
-        cgenConfiguration.setQueryTemplate(querytemplate != null ? 
querytemplate : cgenConfiguration.getQueryTemplate());
-        cgenConfiguration.setQuerySuperTemplate(querysupertemplate != null ? 
querysupertemplate : cgenConfiguration.getQuerySuperTemplate());
+        cgenConfiguration.setDataMapTemplate(querytemplate != null ? 
querytemplate : cgenConfiguration.getDataMapTemplate());
+        cgenConfiguration.setDataMapSuperTemplate(querysupertemplate != null ? 
querysupertemplate : cgenConfiguration.getDataMapSuperTemplate());
         cgenConfiguration.setCreatePKProperties(createpkproperties != null ? 
createpkproperties : cgenConfiguration.isCreatePKProperties());
         cgenConfiguration.setExternalToolConfig(externaltoolconfig != null ? 
externaltoolconfig : cgenConfiguration.getExternalToolConfig());
         if(!cgenConfiguration.isMakePairs()) {
@@ -212,7 +212,7 @@ public class CayenneGeneratorTask extends CayenneTask {
                 
cgenConfiguration.setEmbeddableTemplate(ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE);
             }
             if(querytemplate == null) {
-                
cgenConfiguration.setQueryTemplate(ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
+                
cgenConfiguration.setDataMapTemplate(ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
             }
         }
         return cgenConfiguration;
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 9f39edc8f..8731b1a8a 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
@@ -39,10 +39,8 @@ import org.apache.cayenne.util.XMLSerializable;
 import org.apache.cayenne.validation.ValidationException;
 
 /**
- * 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.
+ * Stores configuration for the code generation tool.
+ * CgenConfiguration is stored in the dataMap xml file and used by Modeler and 
CLI tools (Maven, Gradle and Ant).
  *
  * @since 4.1
  */
@@ -69,8 +67,14 @@ public class CgenConfiguration implements Serializable, 
XMLSerializable {
     private String superTemplate;
     private String embeddableTemplate;
     private String embeddableSuperTemplate;
-    private String queryTemplate;
-    private String querySuperTemplate;
+    /**
+     * @since 4.3 renamed from queryTemplate
+     */
+    private String dataMapTemplate;
+    /**
+     * @since 4.3 renamed from querySuperTemplate
+     */
+    private String dataMapSuperTemplate;
     private long timestamp;
     private String outputPattern;
     private String encoding;
@@ -105,8 +109,8 @@ public class CgenConfiguration implements Serializable, 
XMLSerializable {
 
         this.template = ClassGenerationAction.SUBCLASS_TEMPLATE;
         this.superTemplate = ClassGenerationAction.SUPERCLASS_TEMPLATE;
-        this.queryTemplate = ClassGenerationAction.DATAMAP_SUBCLASS_TEMPLATE;
-        this.querySuperTemplate = 
ClassGenerationAction.DATAMAP_SUPERCLASS_TEMPLATE;
+        this.dataMapTemplate = ClassGenerationAction.DATAMAP_SUBCLASS_TEMPLATE;
+        this.dataMapSuperTemplate = 
ClassGenerationAction.DATAMAP_SUPERCLASS_TEMPLATE;
 
         this.embeddableTemplate = 
ClassGenerationAction.EMBEDDABLE_SUBCLASS_TEMPLATE;
         this.embeddableSuperTemplate = 
ClassGenerationAction.EMBEDDABLE_SUPERCLASS_TEMPLATE;
@@ -231,20 +235,20 @@ public class CgenConfiguration implements Serializable, 
XMLSerializable {
         this.embeddableSuperTemplate = embeddableSuperTemplate;
     }
 
-    public String getQueryTemplate() {
-        return queryTemplate;
+    public String getDataMapTemplate() {
+        return dataMapTemplate;
     }
 
-    public void setQueryTemplate(String queryTemplate) {
-        this.queryTemplate = queryTemplate;
+    public void setDataMapTemplate(String dataMapTemplate) {
+        this.dataMapTemplate = dataMapTemplate;
     }
 
-    public String getQuerySuperTemplate() {
-        return querySuperTemplate;
+    public String getDataMapSuperTemplate() {
+        return dataMapSuperTemplate;
     }
 
-    public void setQuerySuperTemplate(String querySuperTemplate) {
-        this.querySuperTemplate = querySuperTemplate;
+    public void setDataMapSuperTemplate(String dataMapSuperTemplate) {
+        this.dataMapSuperTemplate = dataMapSuperTemplate;
     }
 
     public long getTimestamp() {
@@ -331,7 +335,13 @@ public class CgenConfiguration implements Serializable, 
XMLSerializable {
     }
 
     public Path buildPath() {
-        return rootPath != null ? relPath != null ? 
rootPath.resolve(relPath).toAbsolutePath().normalize() : rootPath : relPath;
+        if(rootPath == null) {
+            return relPath;
+        }
+        if(relPath == null) {
+            return rootPath;
+        }
+        return rootPath.resolve(relPath).toAbsolutePath().normalize();
     }
 
     public void loadEntity(ObjEntity entity) {
@@ -406,8 +416,8 @@ public class CgenConfiguration implements Serializable, 
XMLSerializable {
                 .simpleTag("superTemplate", 
separatorsToUnix(this.superTemplate))
                 .simpleTag("embeddableTemplate", 
separatorsToUnix(this.embeddableTemplate))
                 .simpleTag("embeddableSuperTemplate", 
separatorsToUnix(this.embeddableSuperTemplate))
-                .simpleTag("queryTemplate", 
separatorsToUnix(this.queryTemplate))
-                .simpleTag("querySuperTemplate", 
separatorsToUnix(this.querySuperTemplate))
+                .simpleTag("queryTemplate", 
separatorsToUnix(this.dataMapTemplate))
+                .simpleTag("querySuperTemplate", 
separatorsToUnix(this.dataMapSuperTemplate))
                 .simpleTag("outputPattern", this.outputPattern)
                 .simpleTag("makePairs", Boolean.toString(this.makePairs))
                 .simpleTag("usePkgPath", Boolean.toString(this.usePkgPath))
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 cebaab17d..c497153eb 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
@@ -39,7 +39,6 @@ import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.QueryDescriptor;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.context.Context;
 import org.apache.velocity.tools.ToolManager;
@@ -65,7 +64,6 @@ public class ClassGenerationAction {
 
        public static final String SUPERCLASS_PREFIX = "_";
        private static final String WILDCARD = "*";
-       private static final String CGEN_ROOT_PATH = "cayenne.cgen.rootpath";
 
        /**
         * @since 4.1
@@ -147,9 +145,9 @@ public class ClassGenerationAction {
                                return 
cgenConfiguration.getEmbeddableSuperTemplate();
                        case DATAMAP_SINGLE_CLASS:
                        case DATAMAP_SUBCLASS:
-                               return cgenConfiguration.getQueryTemplate();
+                               return cgenConfiguration.getDataMapTemplate();
                        case DATAMAP_SUPERCLASS:
-                               return 
cgenConfiguration.getQuerySuperTemplate();
+                               return 
cgenConfiguration.getDataMapSuperTemplate();
                        default:
                                throw new IllegalArgumentException("Invalid 
template type: " + type);
                }
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 a60f8faab..3dea5e115 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
@@ -195,14 +195,14 @@ public class CgenConfigHandler extends 
NamespaceAwareNestedTagHandler{
        if(template.trim().length() == 0) {
                return;
        }
-       configuration.setQueryTemplate(template);
+       configuration.setDataMapTemplate(template);
     }
     
     private void createQuerySuperTemplate(String template) {
        if(template.trim().length() == 0) {
                return;
        }
-       configuration.setQuerySuperTemplate(template);
+       configuration.setDataMapSuperTemplate(template);
     }
 
     private void createOutputPattern(String pattern) {
diff --git 
a/cayenne-project/src/main/java/org/apache/cayenne/project/FileProjectSaver.java
 
b/cayenne-project/src/main/java/org/apache/cayenne/project/FileProjectSaver.java
index 95f1132b0..a83cf7693 100644
--- 
a/cayenne-project/src/main/java/org/apache/cayenne/project/FileProjectSaver.java
+++ 
b/cayenne-project/src/main/java/org/apache/cayenne/project/FileProjectSaver.java
@@ -356,7 +356,7 @@ public class FileProjectSaver implements ProjectSaver {
                }
        }
 
-       class SaveUnit {
+       static class SaveUnit {
 
                private ConfigurationNode node;
                private SaverDelegate delegate;
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 03eac5a66..846e23ad1 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
@@ -344,8 +344,8 @@ public class CayenneGeneratorMojo extends AbstractMojo {
                cgenConfiguration.setEmbeddableTemplate(embeddableTemplate != 
null ? embeddableTemplate : cgenConfiguration.getEmbeddableTemplate());
                cgenConfiguration.setUsePkgPath(usePkgPath != null ? usePkgPath 
: cgenConfiguration.isUsePkgPath());
                cgenConfiguration.setCreatePropertyNames(createPropertyNames != 
null ? createPropertyNames : cgenConfiguration.isCreatePropertyNames());
-               cgenConfiguration.setQueryTemplate(queryTemplate != null ? 
queryTemplate : cgenConfiguration.getQueryTemplate());
-               cgenConfiguration.setQuerySuperTemplate(querySuperTemplate != 
null ? querySuperTemplate : cgenConfiguration.getQuerySuperTemplate());
+               cgenConfiguration.setDataMapTemplate(queryTemplate != null ? 
queryTemplate : cgenConfiguration.getDataMapTemplate());
+               cgenConfiguration.setDataMapSuperTemplate(querySuperTemplate != 
null ? querySuperTemplate : cgenConfiguration.getDataMapSuperTemplate());
                cgenConfiguration.setCreatePKProperties(createPKProperties != 
null ? createPKProperties : cgenConfiguration.isCreatePKProperties());
                cgenConfiguration.setExternalToolConfig(externalToolConfig != 
null ? externalToolConfig : cgenConfiguration.getExternalToolConfig());
                if(!cgenConfiguration.isMakePairs()) {
@@ -356,7 +356,7 @@ public class CayenneGeneratorMojo extends AbstractMojo {
                                
cgenConfiguration.setEmbeddableTemplate(ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE);
                        }
                        if(queryTemplate == null) {
-                               
cgenConfiguration.setQueryTemplate(ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
+                               
cgenConfiguration.setDataMapTemplate(ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
                        }
                }
                return cgenConfiguration;
diff --git 
a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorController.java
 
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorController.java
index 2b336798c..624eb6e55 100644
--- 
a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorController.java
+++ 
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorController.java
@@ -36,9 +36,6 @@ import java.util.stream.Collectors;
 import org.apache.cayenne.configuration.event.DataMapEvent;
 import org.apache.cayenne.configuration.event.DataMapListener;
 import org.apache.cayenne.configuration.xml.DataChannelMetaData;
-import org.apache.cayenne.di.DIBootstrap;
-import org.apache.cayenne.di.Module;
-import org.apache.cayenne.di.spi.ModuleLoader;
 import org.apache.cayenne.gen.CgenConfiguration;
 import org.apache.cayenne.gen.ClassGenerationAction;
 import org.apache.cayenne.gen.ClassGenerationActionFactory;
@@ -62,8 +59,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
+ * Main controller for the code generation UI.
+ *
  * @since 4.1
- * A controller for the class generator dialog.
  */
 public class CodeGeneratorController extends CayenneController implements 
ObjEntityListener, EmbeddableListener, DataMapListener {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(ErrorDebugDialog.class);
diff --git 
a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModeController.java
 
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModeController.java
index 28d8f3c55..97ecb39a6 100644
--- 
a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModeController.java
+++ 
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModeController.java
@@ -119,9 +119,9 @@ public class CustomModeController extends 
GeneratorController {
         String embeddableSuperTemplateName = 
getApplication().getCodeTemplateManager().getNameByPath(
                 cgenConfiguration.getEmbeddableSuperTemplate(), 
cgenConfiguration.getRootPath());
         String queryTemplateName = 
getApplication().getCodeTemplateManager().getNameByPath(
-                cgenConfiguration.getQueryTemplate(), 
cgenConfiguration.getRootPath());
+                cgenConfiguration.getDataMapTemplate(), 
cgenConfiguration.getRootPath());
         String querySuperTemplateName = 
getApplication().getCodeTemplateManager().getNameByPath(
-                cgenConfiguration.getQuerySuperTemplate(), 
cgenConfiguration.getRootPath());
+                cgenConfiguration.getDataMapSuperTemplate(), 
cgenConfiguration.getRootPath());
 
         view.getSubclassTemplate().setItem(templateName);
         view.getSuperclassTemplate().setItem(superTemplateName);
@@ -141,11 +141,11 @@ public class CustomModeController extends 
GeneratorController {
             if (!view.getPairs().isSelected()) {
                 
cgenConfiguration.setTemplate(ClassGenerationAction.SINGLE_CLASS_TEMPLATE);
                 
cgenConfiguration.setEmbeddableTemplate(ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE);
-                
cgenConfiguration.setQueryTemplate(ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
+                
cgenConfiguration.setDataMapTemplate(ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
             } else {
                 
cgenConfiguration.setTemplate(ClassGenerationAction.SUBCLASS_TEMPLATE);
                 
cgenConfiguration.setEmbeddableTemplate(ClassGenerationAction.EMBEDDABLE_SUBCLASS_TEMPLATE);
-                
cgenConfiguration.setQueryTemplate(ClassGenerationAction.DATAMAP_SUBCLASS_TEMPLATE);
+                
cgenConfiguration.setDataMapTemplate(ClassGenerationAction.DATAMAP_SUBCLASS_TEMPLATE);
             }
             initForm(cgenConfiguration);
             getParentController().checkCgenConfigDirty();
diff --git 
a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModePanel.java
 
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModePanel.java
index 32909ef5d..598ddad35 100644
--- 
a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModePanel.java
+++ 
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModePanel.java
@@ -110,7 +110,7 @@ public class CustomModePanel extends 
GeneratorControllerPanel {
                @Override
                protected void updateModel(String item) throws 
ValidationException {
                        CgenConfiguration cgenConfiguration = getCgenConfig();
-                       
cgenConfiguration.setQueryTemplate(Application.getInstance().getCodeTemplateManager().getTemplatePath(item,
+                       
cgenConfiguration.setDataMapTemplate(Application.getInstance().getCodeTemplateManager().getTemplatePath(item,
                                        
cgenConfiguration.getDataMap().getConfigurationSource()));
                 checkConfigDirty();
                }
@@ -121,7 +121,7 @@ public class CustomModePanel extends 
GeneratorControllerPanel {
                @Override
                protected void updateModel(String item) throws 
ValidationException {
                        CgenConfiguration cgenConfiguration = getCgenConfig();
-                       
cgenConfiguration.setQuerySuperTemplate(Application.getInstance().getCodeTemplateManager().getTemplatePath(item,
+                       
cgenConfiguration.setDataMapSuperTemplate(Application.getInstance().getCodeTemplateManager().getTemplatePath(item,
                                        
cgenConfiguration.getDataMap().getConfigurationSource()));
                 checkConfigDirty();
                }

Reply via email to