cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/3] cayenne git commit: CAY-2161 Fixed class generation with 'Not for client use' parameter
Date Fri, 07 Apr 2017 14:15:41 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master a2c5210de -> c56019336


CAY-2161 Fixed class generation with 'Not for client use' parameter

+ exception throw on discrepancy of code generation parameters


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

Branch: refs/heads/master
Commit: 7215827bc3eb4677caa283dec946ccfdca70a53b
Parents: ba4ff30
Author: Maxim Petrusevich <maks1464@gmail.com>
Authored: Thu Apr 6 13:49:42 2017 +0300
Committer: Maxim Petrusevich <maks1464@gmail.com>
Committed: Thu Apr 6 13:49:42 2017 +0300

----------------------------------------------------------------------
 .../cayenne/gen/ClassGenerationAction.java      |  8 ++--
 .../gen/ClientClassGenerationAction.java        | 17 ++++++-
 docs/doc/src/main/resources/RELEASE-NOTES.txt   |  1 +
 .../dialog/codegen/GeneratorController.java     | 50 +++++++++++---------
 4 files changed, 47 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/7215827b/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 c07a3cb..1e37be9 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
@@ -19,11 +19,9 @@
 
 package org.apache.cayenne.gen;
 
+import org.apache.cayenne.CayenneException;
 import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.Embeddable;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.QueryDescriptor;
+import org.apache.cayenne.map.*;
 import org.apache.commons.logging.Log;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
@@ -513,7 +511,7 @@ public class ClassGenerationAction {
 	/**
 	 * Adds entities to the internal entity list.
 	 */
-	public void addEntities(Collection<ObjEntity> entities) {
+	public void addEntities(Collection<ObjEntity> entities) throws CayenneException {
 		if (artifactsGenerationMode == ArtifactsGenerationMode.ENTITY
 				|| artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
 			if (entities != null) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/7215827b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
index c89b1eb..5386c96 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.gen;
 
 import java.util.Collection;
 
+import org.apache.cayenne.CayenneException;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.QueryDescriptor;
 
@@ -59,11 +60,23 @@ public class ClientClassGenerationAction extends ClassGenerationAction
{
         }
     }
 
+    /**
+     *
+     * @param entities
+     * @throws CayenneException
+     *
+     * @since 4.0 throws exception
+     */
     @Override
-    public void addEntities(Collection<ObjEntity> entities) {
+    public void addEntities(Collection<ObjEntity> entities) throws CayenneException
{
+        if (!dataMap.isClientSupported()) {
+            throw new CayenneException("Can't create client classes. Check client supported
option on DataMap configuration.");
+        }
         if (entities != null) {
             for (ObjEntity entity : entities) {
-                artifacts.add(new ClientEntityArtifact(entity));
+                if (!entity.isServerOnly()) {
+                    artifacts.add(new ClientEntityArtifact(entity));
+                }
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/7215827b/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index 22fc18a..04c5b75 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -71,6 +71,7 @@ Bug Fixes:
 
 CAY-2032 SelectAction: DistinctResultIterator ignores flattened relationships
 CAY-2137 When generating SQL from EJBQL, use "AND" to separate multiple join conditions
+CAY-2161 'Not for Client Use' option is ignored at Class Generation
 CAY-2174 Change FK attribute name cause ObjAttribute appear after Reverse Engineering
 CAY-2175 AliasName used in EJBQLQuery is not working if it contains mixed case
 CAY-2183 Newly created DbRelationship is unexpectedly renamed by the Modeler

http://git-wip-us.apache.org/repos/asf/cayenne/blob/7215827b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/GeneratorController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/GeneratorController.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/GeneratorController.java
index 92a75ec..6d3452b 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/GeneratorController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/GeneratorController.java
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.modeler.dialog.codegen;
 
+import org.apache.cayenne.CayenneException;
 import org.apache.cayenne.gen.ArtifactsGenerationMode;
 import org.apache.cayenne.gen.ClassGenerationAction;
 import org.apache.cayenne.map.DataMap;
@@ -169,38 +170,43 @@ public abstract class GeneratorController extends CayenneController
{
         Collection<ClassGenerationAction> generators = new ArrayList<>();
         Collection<StandardPanelComponent> dataMapLines = ((GeneratorControllerPanel)
getView()).getDataMapLines();
         for (DataMap map : getParentController().getDataMaps()) {
-            ClassGenerationAction generator = newGenerator();
-            generator.setArtifactsGenerationMode(mode);
-            generator.setDataMap(map);
+            try {
+                ClassGenerationAction generator = newGenerator();
+                generator.setArtifactsGenerationMode(mode);
+                generator.setDataMap(map);
 
-            LinkedList<ObjEntity> objEntities = new LinkedList<>(map.getObjEntities());
-            objEntities.retainAll(selectedEntities);
-            generator.addEntities(objEntities);
+                LinkedList<ObjEntity> objEntities = new LinkedList<>(map.getObjEntities());
+                objEntities.retainAll(selectedEntities);
+                generator.addEntities(objEntities);
 
-            LinkedList<Embeddable> embeddables = new LinkedList<>(map.getEmbeddables());
-            embeddables.retainAll(getParentController().getSelectedEmbeddables());
-            generator.addEmbeddables(embeddables);
+                LinkedList<Embeddable> embeddables = new LinkedList<>(map.getEmbeddables());
+                embeddables.retainAll(getParentController().getSelectedEmbeddables());
+                generator.addEmbeddables(embeddables);
 
-            generator.addQueries(map.getQueryDescriptors());
+                generator.addQueries(map.getQueryDescriptors());
 
-            Preferences preferences = application.getPreferencesNode(GeneralPreferences.class,
"");
+                Preferences preferences = application.getPreferencesNode(GeneralPreferences.class,
"");
 
-            if (preferences != null) {
-                generator.setEncoding(preferences.get(GeneralPreferences.ENCODING_PREFERENCE,
null));
+                if (preferences != null) {
+                    generator.setEncoding(preferences.get(GeneralPreferences.ENCODING_PREFERENCE,
null));
 
-            }
+                }
 
-            generator.setDestDir(outputDir);
-            generator.setMakePairs(true);
+                generator.setDestDir(outputDir);
+                generator.setMakePairs(true);
 
-            for (StandardPanelComponent dataMapLine : dataMapLines) {
-                if(dataMapLine.getDataMap() == map && !Util.isEmptyString(dataMapLine.getSuperclassPackage().getText()))
{
-                    generator.setSuperPkg(dataMapLine.getSuperclassPackage().getText());
-                    break;
+                for (StandardPanelComponent dataMapLine : dataMapLines) {
+                    if (dataMapLine.getDataMap() == map && !Util.isEmptyString(dataMapLine.getSuperclassPackage().getText()))
{
+                        generator.setSuperPkg(dataMapLine.getSuperclassPackage().getText());
+                        break;
+                    }
                 }
-            }
 
-            generators.add(generator);
+                generators.add(generator);
+            } catch (CayenneException exception) {
+                JOptionPane.showMessageDialog(this.getView(), exception.getUnlabeledMessage());
+                return null;
+            }
         }
 
         return generators;


Mime
View raw message