You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2022/07/20 15:30:12 UTC

[cayenne] 03/03: CAY-2752 Rename queryTemplate to dataMapTemplate in the cgen config - update build tools configs

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 c39d93244c9d47fc2a8c37fd59211e43d73469ef
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Wed Jul 20 18:29:59 2022 +0300

    CAY-2752 Rename queryTemplate to dataMapTemplate in the cgen config
     - update build tools configs
---
 .../apache/cayenne/tools/CayenneGeneratorTask.java | 28 ++++++-----
 .../java/org/apache/cayenne/tools/CgenTask.java    | 55 +++++++++++++++++-----
 .../apache/cayenne/tools/CayenneGeneratorMojo.java | 36 ++++++++++----
 3 files changed, 85 insertions(+), 34 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 4c75bb484..e720c66de 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
@@ -65,8 +65,8 @@ public class CayenneGeneratorTask extends CayenneTask {
     protected String template;
     protected String embeddabletemplate;
     protected String embeddablesupertemplate;
-    protected String querytemplate;
-    protected String querysupertemplate;
+    protected String datamaptemplate;
+    protected String datamapsupertemplate;
     protected Boolean usepkgpath;
     protected Boolean createpropertynames;
 
@@ -160,8 +160,8 @@ public class CayenneGeneratorTask extends CayenneTask {
         return destDir != null || encoding != 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 != null || querytemplate != null ||
-                querysupertemplate != null || createpkproperties != null || force || externaltoolconfig != null;
+                usepkgpath != null || createpropertynames != null || datamaptemplate != null ||
+                datamapsupertemplate != null || createpkproperties != null || force || externaltoolconfig != null;
     }
 
     private CgenConfiguration buildConfiguration(DataMap dataMap) {
@@ -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.setDataMapTemplate(querytemplate != null ? querytemplate : cgenConfiguration.getDataMapTemplate());
-        cgenConfiguration.setDataMapSuperTemplate(querysupertemplate != null ? querysupertemplate : cgenConfiguration.getDataMapSuperTemplate());
+        cgenConfiguration.setDataMapTemplate(datamaptemplate != null ? datamaptemplate : cgenConfiguration.getDataMapTemplate());
+        cgenConfiguration.setDataMapSuperTemplate(datamapsupertemplate != null ? datamapsupertemplate : cgenConfiguration.getDataMapSuperTemplate());
         cgenConfiguration.setCreatePKProperties(createpkproperties != null ? createpkproperties : cgenConfiguration.isCreatePKProperties());
         cgenConfiguration.setExternalToolConfig(externaltoolconfig != null ? externaltoolconfig : cgenConfiguration.getExternalToolConfig());
         if(!cgenConfiguration.isMakePairs()) {
@@ -211,7 +211,7 @@ public class CayenneGeneratorTask extends CayenneTask {
             if(embeddabletemplate == null) {
                 cgenConfiguration.setEmbeddableTemplate(ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE);
             }
-            if(querytemplate == null) {
+            if(datamaptemplate == null) {
                 cgenConfiguration.setDataMapTemplate(ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
             }
         }
@@ -294,17 +294,19 @@ public class CayenneGeneratorTask extends CayenneTask {
     }
 
     /**
-     * Sets <code>querytemplate</code> property.
+     * Sets <code>datamaptemplate</code> property.
+     * @since 4.3 querytemplate renamed to datamaptemplate
      */
-    public void setQueryTemplate(String querytemplate) {
-        this.querytemplate = querytemplate;
+    public void setDataMapTemplate(String datamaptemplate) {
+        this.datamaptemplate = datamaptemplate;
     }
 
     /**
-     * Sets <code>querysupertemplate</code> property.
+     * Sets <code>datamapsupertemplate</code> property.
+     * @since 4.3 querysupertemplate renamed to datamapsupertemplate
      */
-    public void setQuerySupertemplate(String querysupertemplate) {
-        this.querysupertemplate = querysupertemplate;
+    public void setDataMapSupertemplate(String datamapsupertemplate) {
+        this.datamapsupertemplate = datamapsupertemplate;
     }
 
     /**
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 7328662dd..f30ee36ce 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
@@ -120,13 +120,28 @@ public class CgenTask extends BaseCayenneTask {
     @Input
     private boolean force;
 
+    /**
+     * Location of Velocity template file for DataMap class generation.
+     * DataMap class provides utilities for usage of the Cayenne queries stored in the DataMap.
+     * If omitted, default template is used.
+     *
+     * @since 4.3 renamed from queryTemplate
+     */
     @Input
     @Optional
-    private String queryTemplate;
+    private String dataMapTemplate;
 
+    /**
+     * Location of Velocity template file for DataMap superclass generation.
+     * DataMap class provides utilities for usage of the Cayenne queries stored in the DataMap.
+     * If omitted, default template is used.
+     * Ignored unless <code>makepairs</code> set to <code>true</code>.
+     *
+     * @since 4.3 renamed from querySuperTemplate
+     */
     @Input
     @Optional
-    private String querySuperTemplate;
+    private String dataMapSuperTemplate;
 
     /**
      * If set to <code>true</code>, will generate PK attributes as Properties.
@@ -252,8 +267,8 @@ public class CgenTask extends BaseCayenneTask {
         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(dataMapTemplate != null ? dataMapTemplate : cgenConfiguration.getDataMapTemplate());
+        cgenConfiguration.setDataMapSuperTemplate(dataMapSuperTemplate != null ? dataMapSuperTemplate : cgenConfiguration.getDataMapSuperTemplate());
         cgenConfiguration.setCreatePKProperties(createPKProperties != null ? createPKProperties : cgenConfiguration.isCreatePKProperties());
         cgenConfiguration.setExternalToolConfig(externalToolConfig != null ? externalToolConfig : cgenConfiguration.getExternalToolConfig());
         if(!cgenConfiguration.isMakePairs()) {
@@ -263,8 +278,8 @@ public class CgenTask extends BaseCayenneTask {
             if(embeddableTemplate == null) {
                 cgenConfiguration.setEmbeddableTemplate(ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE);
             }
-            if(queryTemplate == null) {
-                cgenConfiguration.setQueryTemplate(ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
+            if(dataMapTemplate == null) {
+                cgenConfiguration.setDataMapTemplate(ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
             }
         }
         return cgenConfiguration;
@@ -281,8 +296,8 @@ public class CgenTask extends BaseCayenneTask {
         return destDir != null || destDirName != null || encoding != 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 != null || externalToolConfig != null;
+                usePkgPath != null || createPropertyNames != null || force || dataMapTemplate != null ||
+                dataMapSuperTemplate != null || createPKProperties != null || externalToolConfig != null;
     }
 
     @OutputDirectory
@@ -421,12 +436,28 @@ public class CgenTask extends BaseCayenneTask {
         return externalToolConfig;
     }
 
-    public String getQueryTemplate() {
-        return queryTemplate;
+    public void setDataMapTemplate(String dataMapTemplate) {
+        this.dataMapTemplate = dataMapTemplate;
+    }
+
+    public void dataMapTemplate(String dataMapTemplate) {
+        this.dataMapTemplate = dataMapTemplate;
+    }
+
+    public String getDataMapTemplate() {
+        return dataMapTemplate;
+    }
+
+    public void setDataMapSuperTemplate(String dataMapSuperTemplate) {
+        this.dataMapSuperTemplate = dataMapSuperTemplate;
+    }
+
+    public void dataMapSuperTemplate(String dataMapSuperTemplate) {
+        this.dataMapSuperTemplate = dataMapSuperTemplate;
     }
 
-    public String getQuerySuperTemplate() {
-        return querySuperTemplate;
+    public String getDataMapSuperTemplate() {
+        return dataMapSuperTemplate;
     }
 
     /**
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 846e23ad1..68283dfd9 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
@@ -118,7 +118,8 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 	 * Specifies generator iteration target. &quot;entity&quot; performs one
 	 * iteration for each selected entity. &quot;datamap&quot; performs one
 	 * iteration per datamap (This is always one iteration since cgen currently
-	 * supports specifying one-and-only-one datamap). (Default is &quot;entity&quot;)
+	 * supports specifying one-and-only-one datamap).
+	 * (Default is &quot;entity&quot;)
 	 */
 	@Parameter
 	private String mode;
@@ -202,15 +203,32 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 	@Parameter(defaultValue = "false", property = "force")
 	private boolean force;
 
+	/**
+	 * Location of Velocity template file for DataMap class generation.
+	 * DataMap class provides utilities for usage of the Cayenne queries stored in the DataMap.
+	 * If omitted, default template is used.
+	 *
+	 * @since 4.3 renamed from queryTemplate
+	 */
 	@Parameter
-	private String queryTemplate;
+	private String dataMapTemplate;
 
+	/**
+	 * Location of Velocity template file for DataMap superclass generation.
+	 * DataMap class provides utilities for usage of the Cayenne queries stored in the DataMap.
+	 * If omitted, default template is used.
+	 * Ignored unless <code>makepairs</code> set to <code>true</code>.
+	 *
+	 * @since 4.3 renamed from querySuperTemplate
+	 */
 	@Parameter
-	private String querySuperTemplate;
+	private String dataMapSuperTemplate;
 
     /**
-     * If set to <code>true</code>, will generate PK attributes as Properties.
+     * If set to <code>true</code>, will generate Properties for PK attributes.
      * Default is <code>false</code>.
+	 *
+	 * @see org.apache.cayenne.exp.property.IdProperty and its implementations
      * @since 4.1
      */
     @Parameter
@@ -294,8 +312,8 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 		return destDir != null || encoding != 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 != null || externalToolConfig != null;
+				usePkgPath != null || createPropertyNames != null || force || dataMapTemplate != null ||
+				dataMapSuperTemplate != null || createPKProperties != null || externalToolConfig != null;
 	}
 
 	/**
@@ -344,8 +362,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.setDataMapTemplate(queryTemplate != null ? queryTemplate : cgenConfiguration.getDataMapTemplate());
-		cgenConfiguration.setDataMapSuperTemplate(querySuperTemplate != null ? querySuperTemplate : cgenConfiguration.getDataMapSuperTemplate());
+		cgenConfiguration.setDataMapTemplate(dataMapTemplate != null ? dataMapTemplate : cgenConfiguration.getDataMapTemplate());
+		cgenConfiguration.setDataMapSuperTemplate(dataMapSuperTemplate != null ? dataMapSuperTemplate : cgenConfiguration.getDataMapSuperTemplate());
 		cgenConfiguration.setCreatePKProperties(createPKProperties != null ? createPKProperties : cgenConfiguration.isCreatePKProperties());
 		cgenConfiguration.setExternalToolConfig(externalToolConfig != null ? externalToolConfig : cgenConfiguration.getExternalToolConfig());
 		if(!cgenConfiguration.isMakePairs()) {
@@ -355,7 +373,7 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 			if(embeddableTemplate == null) {
 				cgenConfiguration.setEmbeddableTemplate(ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE);
 			}
-			if(queryTemplate == null) {
+			if(dataMapTemplate == null) {
 				cgenConfiguration.setDataMapTemplate(ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE);
 			}
 		}