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 2018/11/14 14:27:48 UTC
[17/32] cayenne git commit: Cgen tab, cgen configuration,
cgen in maven, ant, gradle.
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/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 384d366..3b339df 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
@@ -20,15 +20,18 @@
package org.apache.cayenne.tools;
import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Set;
-import com.sun.org.apache.xpath.internal.operations.Bool;
import groovy.lang.Reference;
import org.apache.cayenne.configuration.xml.DataChannelMetaData;
import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
import org.apache.cayenne.di.DIBootstrap;
import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.gen.CgenConfiguration;
import org.apache.cayenne.gen.CgenModule;
import org.apache.cayenne.gen.ClassGenerationAction;
import org.apache.cayenne.gen.ClientClassGenerationAction;
@@ -74,6 +77,10 @@ public class CgenTask extends BaseCayenneTask {
@Input
@Optional
+ private String excludeEmbeddables;
+
+ @Input
+ @Optional
private String makePairs;
@Input
@@ -142,6 +149,8 @@ public class CgenTask extends BaseCayenneTask {
private DataChannelMetaData metaData;
+ private boolean useConfigFromDataMap;
+
@TaskAction
public void generate() {
File dataMapFile = getDataMapFile();
@@ -152,9 +161,12 @@ public class CgenTask extends BaseCayenneTask {
CayenneGeneratorMapLoaderAction loaderAction = new CayenneGeneratorMapLoaderAction(injector);
loaderAction.setMainDataMapFile(dataMapFile);
- CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();
- filterAction.setClient(client);
- filterAction.setNameFilter(NamePatternMatcher.build(getLogger(), includeEntities, excludeEntities));
+ CayenneGeneratorEntityFilterAction filterEntityAction = new CayenneGeneratorEntityFilterAction();
+ filterEntityAction.setClient(client);
+ filterEntityAction.setNameFilter(NamePatternMatcher.build(getLogger(), includeEntities, excludeEntities));
+
+ CayenneGeneratorEmbeddableFilterAction filterEmbeddableAction = new CayenneGeneratorEmbeddableFilterAction();
+ filterEmbeddableAction.setNameFilter(NamePatternMatcher.build(getLogger(), null, excludeEmbeddables));
try {
loaderAction.setAdditionalDataMapFiles(convertAdditionalDataMaps());
@@ -165,16 +177,18 @@ public class CgenTask extends BaseCayenneTask {
generator.setLogger(getLogger());
if(this.force || getProject().hasProperty("force")) {
- generator.setForce(true);
+ generator.getCgenConfiguration().setForce(true);
}
- generator.setTimestamp(dataMapFile.lastModified());
- generator.setDataMap(dataMap);
- if(generator.getEntities().isEmpty() && generator.getEmbeddables().isEmpty()) {
- generator.addEntities(filterAction.getFilteredEntities(dataMap));
- generator.addEmbeddables(dataMap.getEmbeddables());
- generator.addQueries(dataMap.getQueryDescriptors());
- } else {
+ generator.getCgenConfiguration().setTimestamp(dataMapFile.lastModified());
+
+ 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));
+ generator.addQueries(dataMap.getQueryDescriptors());
}
generator.execute();
} catch (Exception exception) {
@@ -196,35 +210,74 @@ public class CgenTask extends BaseCayenneTask {
);
}
- ClassGenerationAction newGeneratorInstance() {
- return client ? new ClientClassGenerationAction() : new ClassGenerationAction();
- }
-
ClassGenerationAction createGenerator(DataMap dataMap) {
- ClassGenerationAction action = this.newGeneratorInstance();
-
- if(metaData != null && metaData.get(dataMap, ClassGenerationAction.class) != null){
- action = metaData.get(dataMap, ClassGenerationAction.class);
+ CgenConfiguration cgenConfiguration = buildConfiguration(dataMap);
+ return cgenConfiguration.isClient() ? new ClientClassGenerationAction(cgenConfiguration) :
+ new ClassGenerationAction(cgenConfiguration);
+ }
+
+ CgenConfiguration buildConfiguration(DataMap dataMap) {
+ CgenConfiguration cgenConfiguration;
+ if(hasConfig()) {
+ return cgenConfigFromPom(dataMap);
+ } 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();
+ cgenConfiguration.setRelPath(getDestDirFile().getPath());
+ cgenConfiguration.setDataMap(dataMap);
+ return cgenConfiguration;
}
+ }
- action.setDestDir(getDestDirFile());
- action.setEncoding(encoding != null ? encoding : action.getEncoding());
- action.setMakePairs(makePairs != null ? Boolean.valueOf(makePairs) : action.isMakePairs());
- action.setArtifactsGenerationMode(mode != null ? mode : action.getArtifactsGenerationMode());
- action.setOutputPattern(outputPattern != null ? outputPattern : action.getOutputPattern());
- action.setOverwrite(overwrite != null ? Boolean.valueOf(overwrite) : action.isOverwrite());
- action.setSuperPkg(superPkg != null ? superPkg : action.getSuperPkg());
- action.setSuperTemplate(superTemplate != null ? superTemplate : action.getSuperclassTemplate());
- action.setTemplate(template != null ? template : action.getTemplate());
- action.setEmbeddableSuperTemplate(embeddableSuperTemplate != null ? embeddableSuperTemplate : action.getEmbeddableSuperTemplate());
- action.setEmbeddableTemplate(embeddableTemplate != null ? embeddableTemplate : action.getEmbeddableTemplate());
- action.setUsePkgPath(usePkgPath != null ? Boolean.valueOf(usePkgPath) : action.isUsePkgPath());
- action.setCreatePropertyNames(createPropertyNames != null ? Boolean.valueOf(createPropertyNames) : action.isCreatePropertyNames());
- action.setQueryTemplate(queryTemplate != null ? queryTemplate : action.getQueryTemplate());
- action.setQuerySuperTemplate(querySuperTemplate != null ? querySuperTemplate : action.getQuerySuperTemplate());
- return action;
+ private CgenConfiguration cgenConfigFromPom(DataMap dataMap){
+ CgenConfiguration cgenConfiguration = new CgenConfiguration();
+ cgenConfiguration.setDataMap(dataMap);
+ cgenConfiguration.setRelPath(getDestDirFile() != null ? getDestDirFile().getPath() : 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());
+ cgenConfiguration.setOutputPattern(outputPattern != null ? outputPattern : cgenConfiguration.getOutputPattern());
+ cgenConfiguration.setOverwrite(overwrite != null ? Boolean.valueOf(overwrite) : cgenConfiguration.isOverwrite());
+ cgenConfiguration.setSuperPkg(superPkg != null ? superPkg : cgenConfiguration.getSuperPkg());
+ cgenConfiguration.setSuperTemplate(superTemplate != null ? superTemplate : cgenConfiguration.getSuperTemplate());
+ cgenConfiguration.setTemplate(template != null ? template : cgenConfiguration.getTemplate());
+ cgenConfiguration.setEmbeddableSuperTemplate(embeddableSuperTemplate != null ? embeddableSuperTemplate : cgenConfiguration.getEmbeddableSuperTemplate());
+ cgenConfiguration.setEmbeddableTemplate(embeddableTemplate != null ? embeddableTemplate : cgenConfiguration.getEmbeddableTemplate());
+ cgenConfiguration.setUsePkgPath(usePkgPath != null ? Boolean.valueOf(usePkgPath) : cgenConfiguration.isUsePkgPath());
+ 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);
+ if(!cgenConfiguration.isMakePairs()) {
+ if(template == null) {
+ cgenConfiguration.setTemplate(client ? 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);
+ }
+ }
+ return cgenConfiguration;
}
+ private boolean hasConfig() {
+ return destDir != null || destDirName != null || encoding != null || client || 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;
+ }
@OutputDirectory
protected File getDestDirFile() {
@@ -358,6 +411,18 @@ public class CgenTask extends BaseCayenneTask {
setIncludeEntities(includeEntities);
}
+ public String getExcludeEmbeddables() {
+ return excludeEmbeddables;
+ }
+
+ public void setExcludeEmbeddables(String excludeEmbeddables) {
+ this.excludeEmbeddables = excludeEmbeddables;
+ }
+
+ public void excludeEmbeddables(String excludeEmbeddables) {
+ setExcludeEmbeddables(excludeEmbeddables);
+ }
+
public boolean isMakePairs() {
return Boolean.valueOf(makePairs);
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/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 132320c..b41c1d2 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
@@ -24,11 +24,14 @@ import org.gradle.testkit.runner.GradleRunner;
import org.gradle.testkit.runner.TaskOutcome;
import org.junit.Test;
-
import java.io.File;
import java.net.URLDecoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
@@ -88,4 +91,59 @@ public class CgenTaskIT extends BaseTaskIT {
assertEquals(TaskOutcome.SUCCESS, result.task(":cgen").getOutcome());
}
+ @Test
+ public void cgenWithConfig() throws Exception {
+ GradleRunner runner = createRunner(
+ "cgen_with_config",
+ "cgen",
+ "-PdataMap=" + URLDecoder.decode(getClass().getResource("cgenConfig.map.xml").getFile(), "UTF-8")
+ );
+
+ BuildResult result = runner.forwardOutput().build();
+
+ String generatedDirectoryPath = projectDir.getAbsolutePath() + "/customDirectory1/";
+
+ String generatedClassPath = generatedDirectoryPath + "ObjEntity1.txt";
+ String datamap = generatedDirectoryPath + "CgenMap.txt";
+ String notIncludedEntity = generatedDirectoryPath + "ObjEntity.txt";
+ String notIncludedEmbeddable = generatedDirectoryPath + "Embeddable.txt";
+
+ Path generatedClass = Paths.get(generatedClassPath);
+ Path generatedDataMap = Paths.get(datamap);
+ Path generatedNotIncludedEntity = Paths.get(notIncludedEntity);
+ Path generatedNotIncludedEmbeddable = Paths.get(notIncludedEmbeddable);
+
+ assertTrue(Files.exists(generatedClass));
+ assertFalse(Files.exists(generatedDataMap));
+ assertFalse(Files.exists(generatedNotIncludedEmbeddable));
+ assertFalse(Files.exists(generatedNotIncludedEntity));
+ assertEquals(TaskOutcome.SUCCESS, result.task(":cgen").getOutcome());
+ }
+
+ @Test
+ public void testWithConfigs() throws Exception {
+ GradleRunner runner = createRunner(
+ "cgen_with_configs",
+ "cgen",
+ "-PdataMap=" + URLDecoder.decode(getClass().getResource("cgenMap.map.xml").getFile(), "UTF-8")
+ );
+
+ BuildResult result = runner.forwardOutput().build();
+
+ String generatedDirectoryPath = projectDir.getAbsolutePath() + "/customDirectory/";
+
+ String generatedClassPath = generatedDirectoryPath + "ObjEntity.groovy";
+ Path generatedClass = Paths.get(generatedClassPath);
+ assertTrue(Files.exists(generatedClass));
+
+ String notIncludedEntity = generatedDirectoryPath + "ObjEntity1.groovy";
+ Path generatedNotIncludedEntity = Paths.get(notIncludedEntity);
+ assertFalse(Files.exists(generatedNotIncludedEntity));
+
+ String includedDataMap = generatedDirectoryPath + "CgenMap.groovy";
+ Path generatedIncludedDataMap = Paths.get(includedDataMap);
+ assertTrue(Files.exists(generatedIncludedDataMap));
+
+ assertEquals(TaskOutcome.SUCCESS, result.task(":cgen").getOutcome());
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskTest.java b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskTest.java
index 478ac5c..e2fa3ca 100644
--- a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskTest.java
+++ b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskTest.java
@@ -19,6 +19,7 @@
package org.apache.cayenne.tools;
+import org.apache.cayenne.gen.CgenConfiguration;
import org.apache.cayenne.gen.ClassGenerationAction;
import org.apache.cayenne.map.DataMap;
import org.junit.Rule;
@@ -27,7 +28,8 @@ import org.junit.rules.TemporaryFolder;
import java.io.File;
-import static junit.framework.TestCase.assertSame;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.*;
/**
@@ -40,7 +42,7 @@ public class CgenTaskTest {
DataMap dataMap = new DataMap();
- private CgenTask createCgenTaskMock(ClassGenerationAction action) {
+ private CgenTask createCgenTaskMock() {
CgenTask mock = mock(CgenTask.class);
doCallRealMethod().when(mock).setClient(anyBoolean());
@@ -59,7 +61,7 @@ public class CgenTaskTest {
doCallRealMethod().when(mock).setOverwrite(anyBoolean());
doCallRealMethod().when(mock).setUsePkgPath(anyBoolean());
doCallRealMethod().when(mock).setTemplate(anyString());
- when(mock.newGeneratorInstance()).thenReturn(action);
+ when(mock.buildConfiguration(dataMap)).thenCallRealMethod();
when(mock.createGenerator(dataMap)).thenCallRealMethod();
return mock;
@@ -67,9 +69,7 @@ public class CgenTaskTest {
@Test
public void testGeneratorCreation() {
- ClassGenerationAction action = mock(ClassGenerationAction.class);
- CgenTask task = createCgenTaskMock(action);
-
+ CgenTask task = createCgenTaskMock();
task.setEmbeddableSuperTemplate("superTemplate");
task.setEmbeddableTemplate("template");
task.setEncoding("UTF-8");
@@ -78,28 +78,29 @@ public class CgenTaskTest {
task.setMode("entity");
task.setOutputPattern("pattern");
task.setSuperPkg("org.example.model.auto");
- task.setSuperTemplate("*.java");
- task.setTemplate("*.java");
+ task.setSuperTemplate("superTemplate");
+ task.setTemplate("template");
task.setMakePairs(true);
task.setCreatePropertyNames(true);
task.setOverwrite(true);
task.setUsePkgPath(true);
ClassGenerationAction createdAction = task.createGenerator(dataMap);
- assertSame(action, createdAction);
- verify(action).setCreatePropertyNames(true);
- verify(action).setMakePairs(true);
- verify(action).setOverwrite(true);
- verify(action).setUsePkgPath(true);
- verify(action).setArtifactsGenerationMode("entity");
- verify(action).setEncoding("UTF-8");
- verify(action).setEmbeddableSuperTemplate("superTemplate");
- verify(action).setEmbeddableTemplate("template");
- verify(action).setOutputPattern("pattern");
- verify(action).setSuperPkg("org.example.model.auto");
- verify(action).setSuperTemplate("*.java");
- verify(action).setTemplate("*.java");
+ CgenConfiguration cgenConfiguration = createdAction.getCgenConfiguration();
+ assertEquals(cgenConfiguration.getEmbeddableSuperTemplate(), "superTemplate");
+ assertEquals(cgenConfiguration.getEmbeddableTemplate(), "template");
+ assertEquals(cgenConfiguration.getEncoding(), "UTF-8");
+ assertEquals(cgenConfiguration.getArtifactsGenerationMode(), "entity");
+ assertEquals(cgenConfiguration.getOutputPattern(), "pattern");
+ assertEquals(cgenConfiguration.getSuperPkg(), "org.example.model.auto");
+ assertEquals(cgenConfiguration.getSuperTemplate(), "superTemplate");
+ assertEquals(cgenConfiguration.getTemplate(), "template");
+ assertTrue(cgenConfiguration.isMakePairs());
+ assertTrue(cgenConfiguration.isCreatePropertyNames());
+ assertTrue(cgenConfiguration.isOverwrite());
+ assertTrue(cgenConfiguration.isUsePkgPath());
+
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskWithConfigIT.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskWithConfigIT.java b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskWithConfigIT.java
deleted file mode 100644
index bf981ec..0000000
--- a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskWithConfigIT.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-package org.apache.cayenne.tools;
-
-import org.gradle.testkit.runner.BuildResult;
-import org.gradle.testkit.runner.GradleRunner;
-import org.gradle.testkit.runner.TaskOutcome;
-import org.junit.Test;
-
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @since 4.1
- */
-public class CgenTaskWithConfigIT extends BaseTaskIT{
-
- @Test
- public void cgenWithConfig() throws Exception {
- GradleRunner runner = createRunner(
- "cgen_with_config",
- "cgen",
- "-PdataMap=" + URLDecoder.decode(getClass().getResource("cgenMap.map.xml").getFile(), "UTF-8")
- );
-
- BuildResult result = runner.forwardOutput().build();
-
- String generatedDirectoryPath = projectDir.getAbsolutePath() + "/customDirectory/";
-
- String generatedClassPath = generatedDirectoryPath + "ObjEntity1.txt";
- String datamap = generatedDirectoryPath + "TestCgenMap.txt";
- String notIncludedEntity = generatedDirectoryPath + "ObjEntity.txt";
- String notIncludedSuperDatamap = generatedDirectoryPath + "_TestCgenMap.txt";
-
- File notIncludeSuperDatamap = new File("_TestCgenMap.txt");
- assertFalse(notIncludeSuperDatamap.exists());
-
- File generatedClass = new File(generatedClassPath);
- File generatedDatamap = new File(datamap);
- File generatedNotIncludedEntity = new File(notIncludedEntity);
- File generatedNotIncludedSuperDatamap = new File(notIncludedSuperDatamap);
-
- assertTrue(generatedClass.exists());
- assertFalse(generatedDatamap.exists());
- assertFalse(generatedNotIncludedEntity.exists());
- assertFalse(generatedNotIncludedSuperDatamap.exists());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/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
new file mode 100644
index 0000000..e3bfe55
--- /dev/null
+++ b/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgenConfig.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/52ea45b5/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgenMap.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgenMap.map.xml b/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgenMap.map.xml
index 930acbc..78da7cd 100644
--- a/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgenMap.map.xml
+++ b/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgenMap.map.xml
@@ -7,21 +7,16 @@
<obj-entity name="ObjEntity" className="ObjEntity"/>
<obj-entity name="ObjEntity1" className="ObjEntity1"/>
<cgen xmlns="http://cayenne.apache.org/schema/10/cgen">
- <objEntity>
- <name>ObjEntity1</name>
- </objEntity>
- <generationMode>all</generationMode>
- <dataMapTemplate>templates/v4_1/datamap-subclass.vm</dataMapTemplate>
- <dataMapSuperclassTemplate>templates/v4_1/datamap-superclass.vm</dataMapSuperclassTemplate>
- <subclassTemplate>templates/v4_1/subclass.vm</subclassTemplate>
- <superclassTemplate>templates/v4_1/superclass.vm</superclassTemplate>
- <embeddableTemplate>templates/v4_1/embeddable-subclass.vm</embeddableTemplate>
- <embeddableSuperclassTemplate>templates/v4_1/embeddable-superclass.vm</embeddableSuperclassTemplate>
+ <destDir>./customDirectory</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>
- <overwriteSubclasses>false</overwriteSubclasses>
+ <overwrite>false</overwrite>
<createPropertyNames>false</createPropertyNames>
- <encoding>UTF-8</encoding>
</cgen>
</data-map>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_config.gradle
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_config.gradle b/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_config.gradle
index 3cad46e..94de25f 100644
--- a/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_config.gradle
+++ b/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_config.gradle
@@ -19,10 +19,9 @@
plugins {
id 'org.apache.cayenne'
+ id 'java'
}
cgen {
map dataMap
- destDir = './customDirectory'
- mode = 'entity'
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_configs.gradle
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_configs.gradle b/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_configs.gradle
new file mode 100644
index 0000000..9299033
--- /dev/null
+++ b/cayenne-gradle-plugin/src/test/resources/org/apache/cayenne/tools/cgen_with_configs.gradle
@@ -0,0 +1,32 @@
+/*****************************************************************
+ * 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.
+ ****************************************************************/
+
+plugins {
+ id 'org.apache.cayenne'
+}
+
+cgen {
+ map dataMap
+ destDir = './customDirectory'
+ makePairs false
+ outputPattern = '*.groovy'
+ excludeEntities = 'ObjEntity1'
+ overwrite = false
+ mode = 'all'
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/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 1ab9f96..e936024 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
@@ -24,6 +24,7 @@ import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
import org.apache.cayenne.di.DIBootstrap;
import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.gen.CgenConfiguration;
import org.apache.cayenne.gen.CgenModule;
import org.apache.cayenne.gen.ClassGenerationAction;
import org.apache.cayenne.gen.ClientClassGenerationAction;
@@ -38,9 +39,13 @@ 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 map. This class is an Maven
+ * Maven mojo to perform class generation from data cgenConfiguration. This class is an Maven
* adapter to DefaultClassGenerator class.
*
* @since 3.0
@@ -94,6 +99,13 @@ public class CayenneGeneratorMojo extends AbstractMojo {
private String includeEntities;
/**
+ * Embeddables (expressed as a perl5 regex) to exclude from template
+ * generation. (Default is to include all embeddables in the DataMap).
+ */
+ @Parameter
+ private String excludeEmbeddables;
+
+ /**
* If set to <code>true</code>, will generate subclass/superclass pairs,
* with all generated code included in superclass (default is
* <code>true</code>).
@@ -207,30 +219,31 @@ public class CayenneGeneratorMojo extends AbstractMojo {
* @since 4.1
*/
@Parameter(defaultValue = "false")
- private Boolean createPKProperties;
+ private boolean createPKProperties;
private transient Injector injector;
private static final Logger logger = LoggerFactory.getLogger(CayenneGeneratorMojo.class);
+ private boolean useConfigFromDataMap;
+
public void execute() throws MojoExecutionException, MojoFailureException {
// Create the destination directory if necessary.
// TODO: (KJM 11/2/06) The destDir really should be added as a
// compilation resource for maven.
- if (!destDir.exists()) {
- destDir.mkdirs();
- }
-
injector = DIBootstrap.createInjector(new CgenModule(), new ToolsModule(LoggerFactory.getLogger(CayenneGeneratorMojo.class)));
Logger logger = new MavenLogger(this);
CayenneGeneratorMapLoaderAction loaderAction = new CayenneGeneratorMapLoaderAction(injector);
loaderAction.setMainDataMapFile(map);
- CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();
- filterAction.setClient(client);
- filterAction.setNameFilter(NamePatternMatcher.build(logger, includeEntities, excludeEntities));
+ CayenneGeneratorEntityFilterAction filterEntityAction = new CayenneGeneratorEntityFilterAction();
+ filterEntityAction.setClient(client);
+ filterEntityAction.setNameFilter(NamePatternMatcher.build(logger, includeEntities, excludeEntities));
+
+ CayenneGeneratorEmbeddableFilterAction filterEmbeddableAction = new CayenneGeneratorEmbeddableFilterAction();
+ filterEmbeddableAction.setNameFilter(NamePatternMatcher.build(logger, null, excludeEmbeddables));
try {
loaderAction.setAdditionalDataMapFiles(convertAdditionalDataMaps());
@@ -242,17 +255,17 @@ public class CayenneGeneratorMojo extends AbstractMojo {
if(force) {
// will (re-)generate all files
- generator.setForce(true);
+ generator.getCgenConfiguration().setForce(true);
}
- generator.setTimestamp(map.lastModified());
- generator.setDataMap(dataMap);
- if(!generator.getEntities().isEmpty() || !generator.getEmbeddables().isEmpty()){
+ generator.getCgenConfiguration().setTimestamp(map.lastModified());
+ if(!hasConfig() && useConfigFromDataMap) {
generator.prepareArtifacts();
} else {
- generator.addEntities(filterAction.getFilteredEntities(dataMap));
- generator.addEmbeddables(dataMap.getEmbeddables());
+ generator.addEntities(filterEntityAction.getFilteredEntities(dataMap));
+ 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);
@@ -260,7 +273,7 @@ public class CayenneGeneratorMojo extends AbstractMojo {
}
/**
- * Loads and returns DataMap based on <code>map</code> attribute.
+ * Loads and returns DataMap based on <code>cgenConfiguration</code> attribute.
*/
protected File[] convertAdditionalDataMaps() throws Exception {
@@ -277,40 +290,78 @@ public class CayenneGeneratorMojo extends AbstractMojo {
);
}
+ private boolean hasConfig() {
+ return encoding != null || client || 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;
+ }
+
/**
* Factory method to create internal class generator. Called from
* constructor.
*/
- protected ClassGenerationAction createGenerator(DataMap dataMap) {
+ private ClassGenerationAction createGenerator(DataMap dataMap) {
+ CgenConfiguration cgenConfiguration = buildConfiguration(dataMap);
+ ClassGenerationAction classGenerationAction = cgenConfiguration.isClient() ? new ClientClassGenerationAction(cgenConfiguration) :
+ new ClassGenerationAction(cgenConfiguration);
+ injector.injectMembers(classGenerationAction);
- ClassGenerationAction action = injector.getInstance(DataChannelMetaData.class).get(dataMap, ClassGenerationAction.class);
+ return classGenerationAction;
+ }
- if (client) {
- action = new ClientClassGenerationAction();
+ private CgenConfiguration buildConfiguration(DataMap dataMap) {
+ CgenConfiguration cgenConfiguration = injector.getInstance(DataChannelMetaData.class).get(dataMap, CgenConfiguration.class);
+ if(hasConfig()) {
+ 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 {
- if(action == null) {
- action = new ClassGenerationAction();
- }
+ cgenConfiguration = new CgenConfiguration();
+ cgenConfiguration.setDataMap(dataMap);
+ cgenConfiguration.setRelPath(destDir.getPath());
+ return cgenConfiguration;
}
+ }
- injector.injectMembers(action);
-
-// action.setDestDir(destDir.toPath());
- action.setEncoding(encoding != null ? encoding : action.getEncoding());
- action.setMakePairs(makePairs != null ? makePairs : action.isMakePairs());
- action.setArtifactsGenerationMode(mode != null ? mode : action.getArtifactsGenerationMode());
- action.setOutputPattern(outputPattern != null ? outputPattern : action.getOutputPattern());
- action.setOverwrite(overwrite != null ? overwrite : action.isOverwrite());
- action.setSuperPkg(superPkg != null ? superPkg : action.getSuperPkg());
- action.setSuperTemplate(superTemplate != null ? superTemplate : action.getSuperclassTemplate());
- action.setTemplate(template != null ? template : action.getTemplate());
- action.setEmbeddableSuperTemplate(embeddableSuperTemplate != null ? embeddableSuperTemplate : action.getEmbeddableSuperTemplate());
- action.setEmbeddableTemplate(embeddableTemplate != null ? embeddableTemplate : action.getEmbeddableTemplate());
- action.setUsePkgPath(usePkgPath != null ? usePkgPath : action.isUsePkgPath());
- action.setCreatePropertyNames(createPropertyNames != null ? createPropertyNames : action.isCreatePropertyNames());
- action.setQueryTemplate(queryTemplate != null ? queryTemplate : action.getQueryTemplate());
- action.setQuerySuperTemplate(querySuperTemplate != null ? querySuperTemplate : action.getQuerySuperTemplate());
- action.setCreatePKProperties(createPKProperties != null ? createPKProperties : action.isCreatePropertyNames());
- return action;
+ private CgenConfiguration cgenConfigFromPom(DataMap dataMap){
+ CgenConfiguration cgenConfiguration = new CgenConfiguration();
+ cgenConfiguration.setDataMap(dataMap);
+ cgenConfiguration.setRelPath(destDir != null ? destDir.getPath() : cgenConfiguration.getRelPath());
+ cgenConfiguration.setEncoding(encoding != null ? encoding : cgenConfiguration.getEncoding());
+ cgenConfiguration.setMakePairs(makePairs != null ? makePairs : cgenConfiguration.isMakePairs());
+ cgenConfiguration.setArtifactsGenerationMode(mode != null ? mode : cgenConfiguration.getArtifactsGenerationMode());
+ cgenConfiguration.setOutputPattern(outputPattern != null ? outputPattern : cgenConfiguration.getOutputPattern());
+ cgenConfiguration.setOverwrite(overwrite != null ? overwrite : cgenConfiguration.isOverwrite());
+ cgenConfiguration.setSuperPkg(superPkg != null ? superPkg : cgenConfiguration.getSuperPkg());
+ cgenConfiguration.setSuperTemplate(superTemplate != null ? superTemplate : cgenConfiguration.getSuperTemplate());
+ cgenConfiguration.setTemplate(template != null ? template : cgenConfiguration.getTemplate());
+ cgenConfiguration.setEmbeddableSuperTemplate(embeddableSuperTemplate != null ? embeddableSuperTemplate : cgenConfiguration.getEmbeddableSuperTemplate());
+ 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.setCreatePKProperties(createPKProperties);
+ cgenConfiguration.setClient(client);
+ if(!cgenConfiguration.isMakePairs()) {
+ if(template == null) {
+ cgenConfiguration.setTemplate(client ? 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);
+ }
+ }
+ return cgenConfiguration;
}
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/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 40338fb..edad490 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
@@ -65,4 +65,52 @@ public class CayenneGeneratorMojoTest extends AbstractMojoTestCase {
assertTrue(content.contains("public void addToAdditionalRel(TestRelEntity obj)"));
assertTrue(content.contains("public void removeFromAdditionalRel(TestRelEntity obj)"));
}
+
+ public void testCgenDataMapConfig() throws Exception {
+ File pom = getTestFile("src/test/resources/cgen/project-to-test/cgen-pom.xml");
+ assertNotNull(pom);
+ assertTrue(pom.exists());
+
+ CayenneGeneratorMojo myMojo = (CayenneGeneratorMojo) lookupMojo("cgen", pom);
+ assertNotNull(myMojo);
+ myMojo.execute();
+
+ File testEntity = new File("target/cgenClasses/ObjEntity1.txt");
+ File notIncludedDataMapEntity = new File("target/cgenClasses/TestCgenMap.txt");
+
+ File notIncludedEntity = new File("target/cgenClasses/ObjEntity.txt");
+ File notIncludedEmbeddable = new File("target/cgenClasses/Embeddable.txt");
+ File notIncludedSuperDataMap = new File("target/cgenClasses/_TestCgenMap.txt");
+
+ assertTrue(testEntity.exists());
+ assertFalse(notIncludedDataMapEntity.exists());
+
+ assertFalse(notIncludedEntity.exists());
+ assertFalse(notIncludedSuperDataMap.exists());
+ assertFalse(notIncludedEmbeddable.exists());
+ }
+
+ public void testDataMapPomCgen() throws Exception {
+ File pom = getTestFile("src/test/resources/cgen/project-to-test/datamap-and-pom.xml");
+ assertNotNull(pom);
+ assertTrue(pom.exists());
+
+ CayenneGeneratorMojo myMojo = (CayenneGeneratorMojo) lookupMojo("cgen", pom);
+ assertNotNull(myMojo);
+ myMojo.execute();
+
+ File objEntity1 = new File("target/resultClasses/ObjEntity1.txt");
+ assertTrue(objEntity1.exists());
+ File embeddable = new File("target/resultClasses/Embeddable.txt");
+ assertTrue(embeddable.exists());
+ File dataMap = new File("target/resultClasses/TestCgen.txt");
+ assertTrue(dataMap.exists());
+
+ File objEntity = new File("target/resultClasses/ObjEntity.txt");
+ assertFalse(objEntity.exists());
+ File superObjEntity1 = new File("target/resultClasses/superPkg/_ObjEntity.txt");
+ assertFalse(superObjEntity1.exists());
+ File superDataMap = new File("target/resultClasses/superPkg/_TestCgen.txt");
+ assertFalse(superDataMap.exists());
+ }
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/maven-plugins/cayenne-maven-plugin/src/test/java/org/apache/cayenne/tools/CgenWithConfigMojoTest.java
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/test/java/org/apache/cayenne/tools/CgenWithConfigMojoTest.java b/maven-plugins/cayenne-maven-plugin/src/test/java/org/apache/cayenne/tools/CgenWithConfigMojoTest.java
deleted file mode 100644
index 2532db5..0000000
--- a/maven-plugins/cayenne-maven-plugin/src/test/java/org/apache/cayenne/tools/CgenWithConfigMojoTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-package org.apache.cayenne.tools;
-
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-
-import java.io.File;
-
-/**
- * @since 4.1
- */
-public class CgenWithConfigMojoTest extends AbstractMojoTestCase {
-
- public void testCgen() throws Exception {
- File pom = getTestFile("src/test/resources/cgen/project-to-test/cgen-pom.xml");
- assertNotNull(pom);
- assertTrue(pom.exists());
-
- CayenneGeneratorMojo myMojo = (CayenneGeneratorMojo) lookupMojo("cgen", pom);
- assertNotNull(myMojo);
- myMojo.execute();
-
- File testEntity = new File("target/cgenClasses/ObjEntity1.txt");
- File notIncludedDataMapEntity = new File("target/cgenClasses/TestCgenMap.txt");
-
- File notIncludedEntity = new File("target/cgenClasses/ObjEntity.txt");
- File notIncludedSuperDataMap = new File("target/cgenClasses/_TestCgenMap.txt");
-
- assertTrue(testEntity.exists());
- assertFalse(notIncludedDataMapEntity.exists());
-
- assertFalse(notIncludedEntity.exists());
- assertFalse(notIncludedSuperDataMap.exists());
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/project-to-test/cgen-pom.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/project-to-test/cgen-pom.xml b/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/project-to-test/cgen-pom.xml
index eadddc6..f72e2db 100644
--- a/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/project-to-test/cgen-pom.xml
+++ b/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/project-to-test/cgen-pom.xml
@@ -38,8 +38,6 @@
<artifactId>cayenne-maven-plugin</artifactId>
<configuration>
<map>src/test/resources/cgen/testCgenMap.map.xml</map>
- <destDir>target/cgenClasses</destDir>
- <mode>entity</mode>
</configuration>
</plugin>
</plugins>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/project-to-test/datamap-and-pom.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/project-to-test/datamap-and-pom.xml b/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/project-to-test/datamap-and-pom.xml
new file mode 100644
index 0000000..620a6d0
--- /dev/null
+++ b/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/project-to-test/datamap-and-pom.xml
@@ -0,0 +1,54 @@
+<?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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <name>Test CayenneGeneratorMojo</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>cayenne-maven-plugin</artifactId>
+ <configuration>
+ <map>src/test/resources/cgen/testCgen.map.xml</map>
+ <destDir>target/resultClasses</destDir>
+ <outputPattern>*.txt</outputPattern>
+ <makePairs>false</makePairs>
+ <usePkgPath>true</usePkgPath>
+ <superPkg>superPkg</superPkg>
+ <encoding>UTF-8</encoding>
+ <excludeEntities>ObjEntity</excludeEntities>
+ <mode>all</mode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/testCgen.map.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/testCgen.map.xml b/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/testCgen.map.xml
new file mode 100644
index 0000000..6986022
--- /dev/null
+++ b/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/testCgen.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>../../../../target/cgenClasses</destDir>
+ <mode>entity</mode>
+ <excludeEntities>ObjEntity1</excludeEntities>
+ <excludeEmbeddables>Embeddable</excludeEmbeddables>
+ <template>templates/v4_1/subclass.vm</template>
+ <superTemplate>templates/v4_1/superclass.vm</superTemplate>
+ <outputPattern>*.txt</outputPattern>
+ <makePairs>true</makePairs>
+ <usePkgPath>true</usePkgPath>
+ <overwrite>false</overwrite>
+ <createPropertyNames>false</createPropertyNames>
+ </cgen>
+</data-map>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/testCgenMap.map.xml
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/testCgenMap.map.xml b/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/testCgenMap.map.xml
index 930acbc..e320b07 100644
--- a/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/testCgenMap.map.xml
+++ b/maven-plugins/cayenne-maven-plugin/src/test/resources/cgen/testCgenMap.map.xml
@@ -7,21 +7,16 @@
<obj-entity name="ObjEntity" className="ObjEntity"/>
<obj-entity name="ObjEntity1" className="ObjEntity1"/>
<cgen xmlns="http://cayenne.apache.org/schema/10/cgen">
- <objEntity>
- <name>ObjEntity1</name>
- </objEntity>
- <generationMode>all</generationMode>
- <dataMapTemplate>templates/v4_1/datamap-subclass.vm</dataMapTemplate>
- <dataMapSuperclassTemplate>templates/v4_1/datamap-superclass.vm</dataMapSuperclassTemplate>
- <subclassTemplate>templates/v4_1/subclass.vm</subclassTemplate>
- <superclassTemplate>templates/v4_1/superclass.vm</superclassTemplate>
- <embeddableTemplate>templates/v4_1/embeddable-subclass.vm</embeddableTemplate>
- <embeddableSuperclassTemplate>templates/v4_1/embeddable-superclass.vm</embeddableSuperclassTemplate>
+ <destDir>../../../../target/cgenClasses</destDir>
+ <mode>entity</mode>
+ <excludeEntities>ObjEntity</excludeEntities>
+ <excludeEmbeddables>Embeddable</excludeEmbeddables>
+ <template>templates/v4_1/subclass.vm</template>
+ <superTemplate>templates/v4_1/superclass.vm</superTemplate>
<outputPattern>*.txt</outputPattern>
<makePairs>false</makePairs>
<usePkgPath>true</usePkgPath>
- <overwriteSubclasses>false</overwriteSubclasses>
+ <overwrite>false</overwrite>
<createPropertyNames>false</createPropertyNames>
- <encoding>UTF-8</encoding>
</cgen>
</data-map>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/GenerateCodeAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/GenerateCodeAction.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/GenerateCodeAction.java
index bdb2e15..6861916 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/GenerateCodeAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/GenerateCodeAction.java
@@ -19,15 +19,14 @@
package org.apache.cayenne.modeler.action;
+
import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.map.DataMap;
import org.apache.cayenne.modeler.Application;
-import org.apache.cayenne.modeler.dialog.codegen.CodeGeneratorController;
+import org.apache.cayenne.modeler.event.DomainDisplayEvent;
import org.apache.cayenne.modeler.util.CayenneAction;
-import org.apache.cayenne.project.Project;
import java.awt.event.ActionEvent;
-import java.util.Collection;
+
public class GenerateCodeAction extends CayenneAction {
@@ -44,9 +43,6 @@ public class GenerateCodeAction extends CayenneAction {
}
public void performAction(ActionEvent e) {
- Collection<DataMap> dataMaps;
- Project project = getProjectController().getProject();
- dataMaps = ((DataChannelDescriptor) project.getRootNode()).getDataMaps();
- new CodeGeneratorController(getApplication().getFrameController(), dataMaps).startup();
+ getProjectController().fireDomainDisplayEvent(new DomainDisplayEvent(this, (DataChannelDescriptor) getProjectController().getProject().getRootNode()));
}
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/52ea45b5/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
index b9d1c5b..8df07df 100644
--- 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
@@ -1,203 +1,203 @@
-/*****************************************************************
- * 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
+///*****************************************************************
+// * 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/52ea45b5/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
index b1d3bd9..5d7e895 100644
--- 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
@@ -1,141 +1,141 @@
-/*****************************************************************
- * 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
+///*****************************************************************
+// * 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