You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2026/05/24 21:26:43 UTC
(cayenne) branch master updated (bdaf2e9e5 -> a596a6846)
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
from bdaf2e9e5 a more reliable MCP handshake read
new ce8b28fc1 CAY-2949 CayenneModeler MCP: dbimport_run tool
new ac2b74e94 CAY-2943 CayenneModeler MCP: open_project tool
new 8d43e8720 cleanup
new be41f444a CAY-2949 CayenneModeler MCP: dbimport_run tool
new 2ce7f826a Newly reverse-engineered entities are excluded from CGen | CAY-2951
new a596a6846 Newly reverse-engineered entities are excluded from CGen | CAY-2951
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
RELEASE-NOTES.txt | 1 +
.../org/apache/cayenne/gen/CgenConfiguration.java | 63 ++++++---------
.../mcp/tools/dbimport/DbImportRunTool.java | 92 +++++++++++-----------
.../mcp/tools/openproject/McpJarLocator.java | 41 +---------
.../mcp/tools/openproject/ModelerDiscovery.java | 92 ----------------------
.../mcp/tools/openproject/OpenProjectTool.java | 58 ++++++++++----
.../protocol/OpenProjectDistribution.java | 3 +-
.../tools/dbimport/DbImportRunValidationTest.java | 9 +--
.../tools/openproject/ModelerDiscoveryTest.java | 51 ++----------
.../org/apache/cayenne/project/ProjectModule.java | 4 +-
.../validation}/ValidationConfigHandler.java | 2 +-
.../extension/validation}/ValidationExtension.java | 2 +-
.../validation}/ValidationLoaderDelegate.java | 2 +-
.../validation}/ValidationSaverDelegate.java | 2 +-
.../org/apache/cayenne/modeler/ModelerModule.java | 2 +-
.../ui/project/editor/datamap/DataMapView.java | 1 -
.../ui/project/editor/datamap/cgen/CgenPanel.java | 46 ++++++++---
17 files changed, 167 insertions(+), 304 deletions(-)
rename {modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension => cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation}/ValidationConfigHandler.java (97%)
rename {modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension => cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation}/ValidationExtension.java (96%)
rename {modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension => cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation}/ValidationLoaderDelegate.java (96%)
rename {modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension => cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation}/ValidationSaverDelegate.java (97%)
(cayenne) 01/06: CAY-2949 CayenneModeler MCP: dbimport_run tool
Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit ce8b28fc15ac21fc9102eb9e796a56e5c454d760
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Sun May 24 15:10:43 2026 -0400
CAY-2949 CayenneModeler MCP: dbimport_run tool
1. fixing issues
2. Don't duplicate connection opening
---
.../mcp/tools/dbimport/DbImportRunTool.java | 85 +++++++++++-----------
1 file changed, 41 insertions(+), 44 deletions(-)
diff --git a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunTool.java b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunTool.java
index a73b10b40..0da88ca22 100644
--- a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunTool.java
+++ b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunTool.java
@@ -22,7 +22,6 @@ import io.modelcontextprotocol.json.McpJsonMapper;
import io.modelcontextprotocol.server.McpServerFeatures;
import io.modelcontextprotocol.spec.McpSchema;
import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.datasource.DriverDataSource;
import org.apache.cayenne.dbsync.DbSyncModule;
import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration;
@@ -55,8 +54,6 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.sql.Connection;
-import java.sql.Driver;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
@@ -211,44 +208,12 @@ public class DbImportRunTool {
connector.getDbAdapter()
);
- // Step 5 — JDBC driver loadable from Preferences → Classpath?
+ // Set the thread context classloader so DefaultClassLoaderManager (used by
+ // DriverDataSourceFactory → AdhocObjectFactory) picks up the driver JARs from preferences.
+ // Driver loading and connection failures surface as exceptions from action.execute() below.
ClassLoader driverCl = buildDriverClassLoader();
- Driver driver;
- try {
- driver = (Driver) driverCl.loadClass(connector.getJdbcDriver()).getDeclaredConstructor().newInstance();
- } catch (ClassNotFoundException e) {
- return validationFailed(DbImportErrorCode.jdbc_driver_not_loadable,
- "JDBC driver class '%s' could not be loaded. In CayenneModeler, open Preferences → Classpath, add the driver jar, then re-run — the MCP server reads the classpath fresh on each call."
- .formatted(connector.getJdbcDriver()),
- new DbImportValidation(true, true, true, false, null),
- resolved);
- } catch (Exception e) {
- return validationFailed(DbImportErrorCode.jdbc_driver_not_loadable,
- "JDBC driver class '%s' could not be instantiated: %s"
- .formatted(connector.getJdbcDriver(), e.getMessage()),
- new DbImportValidation(true, true, true, false, null),
- resolved);
- }
-
- // Step 6 — JDBC connection opens?
- Connection conn;
- try {
- conn = new DriverDataSource(
- driver,
- connector.getUrl(),
- connector.getUserName(),
- connector.getPassword()).getConnection();
-
- } catch (SQLException e) {
- String sqlState = e.getSQLState() != null ? " [SQLState: %s]".formatted(e.getSQLState()) : "";
- return validationFailed(DbImportErrorCode.jdbc_connection_failed,
- "Could not open JDBC connection to '%s' as '%s': %s%s."
- .formatted(connector.getUrl(), connector.getUserName(), e.getMessage(), sqlState),
- new DbImportValidation(true, true, true, true, false),
- resolved);
- }
-
- // All validation passed — run dbimport
+ ClassLoader previousCl = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(driverCl);
Supplier<List<String>> stopCapture = McpLoggingHandler.startCapture("org.apache.cayenne.dbsync");
List<String> warnings;
try {
@@ -263,16 +228,29 @@ public class DbImportRunTool {
return new DbImportRunResult(status, summary, resolved, warnings, DbImportValidation.ALL_PASSED, null);
} catch (Exception e) {
warnings = stopCapture.get();
+ if (hasCauseOfType(e, ClassNotFoundException.class)) {
+ return validationFailed(DbImportErrorCode.jdbc_driver_not_loadable,
+ "JDBC driver class '%s' could not be loaded. In CayenneModeler, open Preferences → Classpath, add the driver jar, then re-run."
+ .formatted(connector.getJdbcDriver()),
+ new DbImportValidation(true, true, true, false, null),
+ resolved);
+ }
+ if (hasCauseOfType(e, SQLException.class)) {
+ SQLException sqle = causeOfType(e, SQLException.class);
+ String sqlState = sqle.getSQLState() != null ? " [SQLState: %s]".formatted(sqle.getSQLState()) : "";
+ return validationFailed(DbImportErrorCode.jdbc_connection_failed,
+ "Could not open JDBC connection to '%s' as '%s': %s%s."
+ .formatted(connector.getUrl(), connector.getUserName(), sqle.getMessage(), sqlState),
+ new DbImportValidation(true, true, true, true, false),
+ resolved);
+ }
InstrumentedDbImportAction action = injector.getInstance(InstrumentedDbImportAction.class);
DbImportSummary partial = action.buildSummary(0);
String msg = e.getMessage() != null ? e.getMessage() : e.getClass().getName();
return new DbImportRunResult("error", partial, resolved, warnings, DbImportValidation.ALL_PASSED,
new DbImportError(DbImportErrorCode.dbimport_runtime_error, msg));
} finally {
- try {
- conn.close();
- } catch (SQLException ignored) {
- }
+ Thread.currentThread().setContextClassLoader(previousCl);
}
}
@@ -337,6 +315,25 @@ public class DbImportRunTool {
);
}
+ private static boolean hasCauseOfType(Throwable t, Class<? extends Throwable> type) {
+ for (Throwable c = t; c != null; c = c.getCause()) {
+ if (type.isInstance(c)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T extends Throwable> T causeOfType(Throwable t, Class<T> type) {
+ for (Throwable c = t; c != null; c = c.getCause()) {
+ if (type.isInstance(c)) {
+ return (T) c;
+ }
+ }
+ return null;
+ }
+
private record CachedClassLoader(List<String> entries, ClassLoader loader) {
}
}
(cayenne) 02/06: CAY-2943 CayenneModeler MCP: open_project tool
Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit ac2b74e9439b28d1654b03884992ec42ded43482
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Sun May 24 15:39:49 2026 -0400
CAY-2943 CayenneModeler MCP: open_project tool
do not attempt to deal with sourtce trees, only locate the Modeler within distributions
---
.../mcp/tools/openproject/McpJarLocator.java | 41 +---------
.../mcp/tools/openproject/ModelerDiscovery.java | 92 ----------------------
.../mcp/tools/openproject/OpenProjectTool.java | 58 ++++++++++----
.../protocol/OpenProjectDistribution.java | 3 +-
.../tools/openproject/ModelerDiscoveryTest.java | 51 ++----------
5 files changed, 51 insertions(+), 194 deletions(-)
diff --git a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/McpJarLocator.java b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/McpJarLocator.java
index 3d0902eac..4bdaa664b 100644
--- a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/McpJarLocator.java
+++ b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/McpJarLocator.java
@@ -25,7 +25,6 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.CodeSource;
import java.security.ProtectionDomain;
-import java.util.Optional;
/**
* Resolves the directory that contains the running MCP server jar. Used as the
@@ -35,46 +34,12 @@ import java.util.Optional;
*/
final class McpJarLocator {
- /** Canonical name of the MCP server jar in a distribution (outside of dev builds). */
- static final String MCP_JAR_NAME = "CayenneMCPServer.jar";
-
- record Located(Path dir, boolean isDistribution) {}
-
private McpJarLocator() {
}
/**
- * Locates the directory containing the jar (or class output dir) the given class
- * was loaded from, and whether that jar is the canonical distribution jar
- * ({@value #MCP_JAR_NAME}). Returns {@code Optional.empty()} in exotic launch
- * configurations where the protection domain has no resolvable location.
+ * Returns the directory containing the jar the given class was loaded from, or {@code null} in exotic launch configurations where the
+ * protection domain has no resolvable location.
*/
- static Optional<Located> locate(Class<?> anchor) {
- try {
- ProtectionDomain pd = anchor.getProtectionDomain();
- if (pd == null) {
- return Optional.empty();
- }
- CodeSource cs = pd.getCodeSource();
- if (cs == null) {
- return Optional.empty();
- }
- URL url = cs.getLocation();
- if (url == null) {
- return Optional.empty();
- }
- Path location = Paths.get(url.toURI());
- // For a jar: location is the jar itself; we want its parent directory.
- // For a class-file directory (IDE / surefire fork): location is the dir;
- // its parent is also a reasonable starting point (target/), but here we
- // want the dir that "would have been the jar's parent" — so use it directly.
- boolean isDistribution = Files.isRegularFile(location)
- && MCP_JAR_NAME.equals(location.getFileName() != null
- ? location.getFileName().toString() : "");
- Path dir = location.getParent() != null ? location.getParent() : location;
- return Optional.of(new Located(dir, isDistribution));
- } catch (URISyntaxException | RuntimeException e) {
- return Optional.empty();
- }
- }
+
}
diff --git a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/ModelerDiscovery.java b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/ModelerDiscovery.java
index 56a3b8590..c8ae42fe0 100644
--- a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/ModelerDiscovery.java
+++ b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/ModelerDiscovery.java
@@ -40,9 +40,6 @@ final class ModelerDiscovery {
static final String WINDOWS_EXE_NAME = "CayenneModeler.exe";
static final String GENERIC_JAR_NAME = "CayenneModeler.jar";
- /** Max levels to climb when locating the source-tree git root. */
- private static final int SOURCE_TREE_CLIMB_LIMIT = 8;
-
sealed interface DiscoveryResult permits Found, NotFound {}
record Found(OpenProjectDistribution distribution, LauncherKind launcherKind, Path launcher)
@@ -54,16 +51,6 @@ final class ModelerDiscovery {
}
static DiscoveryResult discover(Path mcpDir, OsKind osKind) {
- return discover(mcpDir, osKind, false);
- }
-
- /**
- * @param isDistributionJar {@code true} when the MCP server is running from
- * {@value McpJarLocator#MCP_JAR_NAME} — a distribution build. When {@code true},
- * the source-tree fallback is skipped: a production jar should not accidentally
- * pick up a developer Modeler build.
- */
- static DiscoveryResult discover(Path mcpDir, OsKind osKind, boolean isDistributionJar) {
List<String> notes = new ArrayList<>();
if (osKind == OsKind.MAC) {
@@ -88,16 +75,6 @@ final class ModelerDiscovery {
}
notes.add("generic: no " + GENERIC_JAR_NAME + " sibling of the MCP jar");
- if (!isDistributionJar) {
- Optional<Found> sourceTree = probeSourceTree(mcpDir, osKind);
- if (sourceTree.isPresent()) {
- return sourceTree.get();
- }
- notes.add("""
- source_tree: no built CayenneModeler under <gitRoot>/modeler/cayenne-modeler-{mac,win,generic}/target/classes/ \
- (run `mvn -pl modeler/cayenne-modeler-<kind> -am package -P<kind>`)""");
- }
-
return new NotFound(List.copyOf(notes));
}
@@ -151,73 +128,4 @@ final class ModelerDiscovery {
return Files.isRegularFile(candidate) ? Optional.of(candidate) : Optional.empty();
}
- /**
- * Source-tree probe — climbs to a {@code .git}-bearing root and looks under
- * {@code modeler/cayenne-modeler-{mac,win,generic}/target/classes/} for the
- * OS-appropriate launcher. The reported distribution is {@code source_tree}
- * so callers can see when dev-mode discovery kicked in; the launcher kind
- * still drives argv construction.
- */
- static Optional<Found> probeSourceTree(Path mcpDir, OsKind osKind) {
- Path gitRoot = findGitRoot(mcpDir);
- if (gitRoot == null) {
- return Optional.empty();
- }
-
- if (osKind == OsKind.MAC) {
- Path macClasses = gitRoot.resolve("modeler/cayenne-modeler-mac/target/classes");
- Optional<Path> bundle = findAppBundle(macClasses);
- if (bundle.isPresent()) {
- return Optional.of(new Found(
- OpenProjectDistribution.source_tree, LauncherKind.MAC_APP, bundle.get()));
- }
- }
-
- if (osKind == OsKind.WINDOWS) {
- Path winExe = gitRoot.resolve(
- "modeler/cayenne-modeler-win/target/classes/" + WINDOWS_EXE_NAME);
- if (Files.isRegularFile(winExe)) {
- return Optional.of(new Found(
- OpenProjectDistribution.source_tree, LauncherKind.WINDOWS_EXE, winExe));
- }
- }
-
- Path genericJar = gitRoot.resolve(
- "modeler/cayenne-modeler-generic/target/classes/" + GENERIC_JAR_NAME);
- if (Files.isRegularFile(genericJar)) {
- return Optional.of(new Found(
- OpenProjectDistribution.source_tree, LauncherKind.GENERIC_JAR, genericJar));
- }
-
- return Optional.empty();
- }
-
- private static Path findGitRoot(Path start) {
- if (start == null) {
- return null;
- }
- Path current = start;
- for (int i = 0; i < SOURCE_TREE_CLIMB_LIMIT && current != null; i++) {
- if (Files.isDirectory(current.resolve(".git"))) {
- return current;
- }
- current = current.getParent();
- }
- return null;
- }
-
- private static Optional<Path> findAppBundle(Path dir) {
- if (!Files.isDirectory(dir)) {
- return Optional.empty();
- }
- try (var stream = Files.list(dir)) {
- return stream
- .filter(p -> p.getFileName() != null
- && p.getFileName().toString().endsWith(".app"))
- .filter(p -> Files.isDirectory(p.resolve("Contents/MacOS")))
- .findFirst();
- } catch (java.io.IOException e) {
- return Optional.empty();
- }
- }
}
diff --git a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/OpenProjectTool.java b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/OpenProjectTool.java
index 82de61236..3f83620ba 100644
--- a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/OpenProjectTool.java
+++ b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/OpenProjectTool.java
@@ -37,12 +37,16 @@ import org.apache.cayenne.mcp.tools.openproject.protocol.OpenProjectValidation;
import org.apache.cayenne.modeler.pref.PrefsLocator;
import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.CodeSource;
+import java.security.ProtectionDomain;
import java.time.Duration;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
import java.util.UUID;
/**
@@ -131,22 +135,21 @@ public class OpenProjectTool {
}
// Step 2 — locate the MCP jar's directory.
- Optional<McpJarLocator.Located> mcpLocated = McpJarLocator.locate(OpenProjectTool.class);
- if (mcpLocated.isEmpty()) {
+ Path mcpDir = mcpJarDir();
+ if (mcpDir == null) {
return validationFailed(OpenProjectErrorCode.mcp_jar_location_unresolved,
"Could not resolve the running MCP server jar's location",
new OpenProjectValidation(true, false, null));
}
- McpJarLocator.Located mcp = mcpLocated.get();
// Step 3 — discover a Modeler installation.
OsKind osKind = OsKind.detect();
- DiscoveryResult discovery = ModelerDiscovery.discover(mcp.dir(), osKind, mcp.isDistribution());
+ DiscoveryResult discovery = ModelerDiscovery.discover(mcpDir, osKind);
return switch (discovery) {
case Found f -> launchAndAwait(f, projectFile);
case NotFound nf -> validationFailed(OpenProjectErrorCode.modeler_not_found,
"No CayenneModeler installation found relative to MCP jar at %s. Probes: %s"
- .formatted(mcp.dir(), String.join("; ", nf.probeNotes())),
+ .formatted(mcpDir, String.join("; ", nf.probeNotes())),
new OpenProjectValidation(true, true, false));
};
}
@@ -214,20 +217,20 @@ public class OpenProjectTool {
"Spawned Modeler process exited before reporting handshake (%s)"
.formatted(exit)));
}
- case TIMEOUT -> {
- yield new OpenProjectResult(
- "error",
- resolved,
- allPassed,
- null,
- new OpenProjectError(OpenProjectErrorCode.launch_not_confirmed,
- "Handshake did not appear within %ds".formatted(HANDSHAKE_TIMEOUT.toSeconds())));
- }
+ case TIMEOUT -> new OpenProjectResult(
+ "error",
+ resolved,
+ allPassed,
+ null,
+ new OpenProjectError(OpenProjectErrorCode.launch_not_confirmed,
+ "Handshake did not appear within %ds".formatted(HANDSHAKE_TIMEOUT.toSeconds())));
};
}
- private static OpenProjectResult validationFailed(OpenProjectErrorCode code, String message,
- OpenProjectValidation validation) {
+ private static OpenProjectResult validationFailed(
+ OpenProjectErrorCode code,
+ String message,
+ OpenProjectValidation validation) {
return new OpenProjectResult(
"validation_failed",
null,
@@ -236,4 +239,25 @@ public class OpenProjectTool {
new OpenProjectError(code, message)
);
}
+
+ static Path mcpJarDir() {
+ try {
+ ProtectionDomain pd = OpenProjectTool.class.getProtectionDomain();
+ if (pd == null) {
+ return null;
+ }
+ CodeSource cs = pd.getCodeSource();
+ if (cs == null) {
+ return null;
+ }
+ URL url = cs.getLocation();
+ if (url == null) {
+ return null;
+ }
+ Path location = Paths.get(url.toURI());
+ return Files.isRegularFile(location) && location.getParent() != null ? location.getParent() : location;
+ } catch (URISyntaxException | RuntimeException e) {
+ return null;
+ }
+ }
}
diff --git a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/protocol/OpenProjectDistribution.java b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/protocol/OpenProjectDistribution.java
index 3f3eb0f19..9985d8f16 100644
--- a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/protocol/OpenProjectDistribution.java
+++ b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/openproject/protocol/OpenProjectDistribution.java
@@ -26,6 +26,5 @@ package org.apache.cayenne.mcp.tools.openproject.protocol;
public enum OpenProjectDistribution {
mac,
windows,
- generic,
- source_tree
+ generic
}
diff --git a/cayenne-mcp-server/src/test/java/org/apache/cayenne/mcp/tools/openproject/ModelerDiscoveryTest.java b/cayenne-mcp-server/src/test/java/org/apache/cayenne/mcp/tools/openproject/ModelerDiscoveryTest.java
index e4b133414..2f680e196 100644
--- a/cayenne-mcp-server/src/test/java/org/apache/cayenne/mcp/tools/openproject/ModelerDiscoveryTest.java
+++ b/cayenne-mcp-server/src/test/java/org/apache/cayenne/mcp/tools/openproject/ModelerDiscoveryTest.java
@@ -174,8 +174,8 @@ public class ModelerDiscoveryTest {
DiscoveryResult result = ModelerDiscovery.discover(tmp, OsKind.MAC);
NotFound nf = assertInstanceOf(NotFound.class, result);
- // Mac eligible probes: mac, generic, source_tree (3)
- assertEquals(3, nf.probeNotes().size());
+ // Mac eligible probes: mac, generic (2)
+ assertEquals(2, nf.probeNotes().size());
// None of the notes should mention .exe (Windows probe wasn't eligible).
assertTrue(nf.probeNotes().stream().noneMatch(n -> n.contains(".exe")));
}
@@ -199,47 +199,8 @@ public class ModelerDiscoveryTest {
DiscoveryResult result = ModelerDiscovery.discover(tmp, OsKind.OTHER);
NotFound nf = assertInstanceOf(NotFound.class, result);
- // OTHER eligible probes: generic, source_tree (2)
- assertEquals(2, nf.probeNotes().size());
- }
-
- // -------- Source-tree fallback --------
-
- @Test
- public void sourceTreeMatchesGenericLauncher(@TempDir Path tmp) throws IOException {
- Path root = tmp.resolve("repo");
- Files.createDirectories(root.resolve(".git"));
- Path genericClasses = root.resolve("modeler/cayenne-modeler-generic/target/classes");
- Files.createDirectories(genericClasses);
- Files.createFile(genericClasses.resolve(ModelerDiscovery.GENERIC_JAR_NAME));
-
- Path mcpDir = root.resolve("cayenne-mcp-server/target");
- Files.createDirectories(mcpDir);
-
- DiscoveryResult result = ModelerDiscovery.discover(mcpDir, OsKind.OTHER);
-
- Found found = assertInstanceOf(Found.class, result);
- assertEquals(OpenProjectDistribution.source_tree, found.distribution());
- assertEquals(LauncherKind.GENERIC_JAR, found.launcherKind());
- }
-
- @Test
- public void sourceTreeMatchesMacBundle(@TempDir Path tmp) throws IOException {
- Path root = tmp.resolve("repo");
- Files.createDirectories(root.resolve(".git"));
- Path macClasses = root.resolve("modeler/cayenne-modeler-mac/target/classes");
- Path bundle = macClasses.resolve("CayenneModeler.app");
- Files.createDirectories(bundle.resolve("Contents/MacOS"));
-
- Path mcpDir = root.resolve("cayenne-mcp-server/target");
- Files.createDirectories(mcpDir);
-
- DiscoveryResult result = ModelerDiscovery.discover(mcpDir, OsKind.MAC);
-
- Found found = assertInstanceOf(Found.class, result);
- assertEquals(OpenProjectDistribution.source_tree, found.distribution());
- assertEquals(LauncherKind.MAC_APP, found.launcherKind());
- assertEquals(bundle, found.launcher());
+ // OTHER eligible probes: generic (1)
+ assertEquals(1, nf.probeNotes().size());
}
@Test
@@ -247,8 +208,8 @@ public class ModelerDiscoveryTest {
DiscoveryResult result = ModelerDiscovery.discover(tmp, OsKind.OTHER);
NotFound nf = assertInstanceOf(NotFound.class, result);
- assertEquals(2, nf.probeNotes().size(),
- "OTHER has 2 eligible probes: generic and source_tree");
+ assertEquals(1, nf.probeNotes().size(),
+ "OTHER has 1 eligible probe: generic");
}
// -------- Helpers --------
(cayenne) 06/06: Newly reverse-engineered entities are excluded from CGen | CAY-2951
Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit a596a68462914eef50ed25f8991afac48c2fd202
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Sun May 24 16:29:32 2026 -0400
Newly reverse-engineered entities are excluded from CGen | CAY-2951
post-cleanup
---
.../org/apache/cayenne/gen/CgenConfiguration.java | 47 ++++++++--------------
1 file changed, 16 insertions(+), 31 deletions(-)
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
index 3529859ab..2183201a3 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
@@ -58,11 +58,11 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
*/
private Path cgenOutputPath;
- private Collection<Artifact> artifacts;
+ private final Collection<Artifact> artifacts;
private Set<String> entityArtifacts;
- private Collection<String> excludedEntityArtifacts;
+ private final Collection<String> excludedEntityArtifacts;
private Set<String> embeddableArtifacts;
- private Collection<String> excludedEmbeddableArtifacts;
+ private final Collection<String> excludedEmbeddableArtifacts;
private String name;
private String superPkg;
@@ -102,9 +102,8 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
public CgenConfiguration() {
this.name = CgenConfigList.DEFAULT_CONFIG_NAME;
- /**
- * {@link #isDefault()} method should be in sync with the following values
- */
+
+ // isDefault() method should be in sync with the following values
this.outputPattern = "*.java";
this.timestamp = 0L;
this.usePkgPath = true;
@@ -195,6 +194,7 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
/**
* Method returns output path as is, without any processing.
+ *
* @return cgen output relative path
* @see #buildOutputPath()
* @since 5.0 renamed from {@code getRelPath()}
@@ -247,12 +247,12 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
return cgenOutputPath;
}
- if(cgenOutputPath == null) {
+ if (cgenOutputPath == null) {
// this case should be invalid, but let the caller deal with it
return null;
}
- if(cgenOutputPath.isAbsolute()) {
+ if (cgenOutputPath.isAbsolute()) {
return cgenOutputPath.normalize();
} else {
return rootProjectPath.resolve(cgenOutputPath).toAbsolutePath().normalize();
@@ -524,28 +524,13 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
}
public CgenTemplate getTemplateByType(TemplateType type) {
- switch (type) {
- case ENTITY_SINGLE_CLASS:
- case ENTITY_SUBCLASS:
- return getTemplate();
-
- case ENTITY_SUPERCLASS:
- return getSuperTemplate();
-
- case EMBEDDABLE_SINGLE_CLASS:
- case EMBEDDABLE_SUBCLASS:
- return getEmbeddableTemplate();
-
- case EMBEDDABLE_SUPERCLASS:
- return getEmbeddableSuperTemplate();
-
- case DATAMAP_SINGLE_CLASS:
- case DATAMAP_SUBCLASS:
- return getDataMapTemplate();
-
- case DATAMAP_SUPERCLASS:
- return getDataMapSuperTemplate();
- }
- return null;
+ return switch (type) {
+ case ENTITY_SINGLE_CLASS, ENTITY_SUBCLASS -> getTemplate();
+ case ENTITY_SUPERCLASS -> getSuperTemplate();
+ case EMBEDDABLE_SINGLE_CLASS, EMBEDDABLE_SUBCLASS -> getEmbeddableTemplate();
+ case EMBEDDABLE_SUPERCLASS -> getEmbeddableSuperTemplate();
+ case DATAMAP_SINGLE_CLASS, DATAMAP_SUBCLASS -> getDataMapTemplate();
+ case DATAMAP_SUPERCLASS -> getDataMapSuperTemplate();
+ };
}
}
(cayenne) 04/06: CAY-2949 CayenneModeler MCP: dbimport_run tool
Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit be41f444ad24cd27ae0332cccce32c9af6bfb8f8
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Sun May 24 16:09:49 2026 -0400
CAY-2949 CayenneModeler MCP: dbimport_run tool
make sure we do not lose extensions on save
---
.../org/apache/cayenne/mcp/tools/dbimport/DbImportRunTool.java | 7 ++++++-
.../src/main/java/org/apache/cayenne/project/ProjectModule.java | 4 ++--
.../project/extension/validation}/ValidationConfigHandler.java | 2 +-
.../cayenne/project/extension/validation}/ValidationExtension.java | 2 +-
.../project/extension/validation}/ValidationLoaderDelegate.java | 2 +-
.../project/extension/validation}/ValidationSaverDelegate.java | 2 +-
.../src/main/java/org/apache/cayenne/modeler/ModelerModule.java | 2 +-
7 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunTool.java b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunTool.java
index 0da88ca22..e9ab9609d 100644
--- a/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunTool.java
+++ b/cayenne-mcp-server/src/main/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunTool.java
@@ -28,6 +28,7 @@ import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration;
import org.apache.cayenne.dbsync.reverse.dbimport.DbImportModule;
import org.apache.cayenne.di.DIBootstrap;
import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.gen.xml.CgenExtension;
import org.apache.cayenne.map.DataMap;
import org.apache.cayenne.modeler.pref.PreferenceNodeIds;
import org.apache.cayenne.modeler.pref.PrefsLocator;
@@ -45,6 +46,7 @@ import org.apache.cayenne.mcp.tools.dbimport.protocol.DbImportValidation;
import org.apache.cayenne.project.Project;
import org.apache.cayenne.project.ProjectLoader;
import org.apache.cayenne.project.ProjectModule;
+import org.apache.cayenne.project.extension.validation.ValidationExtension;
import org.apache.cayenne.resource.URLResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -84,13 +86,16 @@ public class DbImportRunTool {
public DbImportRunTool(PrefsLocator prefsLocator) {
this.prefsLocator = prefsLocator;
+ // TODO CAY-2950: unknown extensions should be preserved via blob roundtrip instead of
+ // requiring each extension to be explicitly registered here
this.injector = DIBootstrap.createInjector(
new DbSyncModule(),
new ToolsModule(LOGGER),
new DbImportModule(),
new ProjectModule(),
new McpProjectLoaderModule(),
- binder -> binder.bind(InstrumentedDbImportAction.class).to(InstrumentedDbImportAction.class)
+ b -> ProjectModule.extend(b).addExtension(CgenExtension.class).addExtension(ValidationExtension.class),
+ b -> b.bind(InstrumentedDbImportAction.class).to(InstrumentedDbImportAction.class)
);
}
diff --git a/cayenne-project/src/main/java/org/apache/cayenne/project/ProjectModule.java b/cayenne-project/src/main/java/org/apache/cayenne/project/ProjectModule.java
index 0b9ede4dc..9e1ee3687 100644
--- a/cayenne-project/src/main/java/org/apache/cayenne/project/ProjectModule.java
+++ b/cayenne-project/src/main/java/org/apache/cayenne/project/ProjectModule.java
@@ -37,8 +37,8 @@ import org.apache.cayenne.project.validation.DefaultProjectValidator;
import org.apache.cayenne.project.validation.ProjectValidator;
/**
- * A dependency injection (DI) module contributing configuration related
- * to Cayenne mapping project manipulation to a DI container.
+ * A dependency injection (DI) module contributing configuration related to Cayenne mapping project manipulation to a
+ * DI container.
*
* @since 4.0
*/
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationConfigHandler.java b/cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationConfigHandler.java
similarity index 97%
rename from modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationConfigHandler.java
rename to cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationConfigHandler.java
index 898cf4e57..3dc63f17e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationConfigHandler.java
+++ b/cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationConfigHandler.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
****************************************************************/
-package org.apache.cayenne.modeler.service.validator.extension;
+package org.apache.cayenne.project.extension.validation;
import org.apache.cayenne.configuration.xml.DataChannelMetaData;
import org.apache.cayenne.configuration.xml.NamespaceAwareNestedTagHandler;
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationExtension.java b/cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationExtension.java
similarity index 96%
rename from modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationExtension.java
rename to cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationExtension.java
index 4445c5c27..ac816df91 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationExtension.java
+++ b/cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationExtension.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
****************************************************************/
-package org.apache.cayenne.modeler.service.validator.extension;
+package org.apache.cayenne.project.extension.validation;
import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.configuration.xml.DataChannelMetaData;
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationLoaderDelegate.java b/cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationLoaderDelegate.java
similarity index 96%
rename from modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationLoaderDelegate.java
rename to cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationLoaderDelegate.java
index 2e864289c..ac83a331c 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationLoaderDelegate.java
+++ b/cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationLoaderDelegate.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
****************************************************************/
-package org.apache.cayenne.modeler.service.validator.extension;
+package org.apache.cayenne.project.extension.validation;
import org.apache.cayenne.configuration.xml.DataChannelMetaData;
import org.apache.cayenne.configuration.xml.NamespaceAwareNestedTagHandler;
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationSaverDelegate.java b/cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationSaverDelegate.java
similarity index 97%
rename from modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationSaverDelegate.java
rename to cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationSaverDelegate.java
index d28cd66ff..8b0db1ebf 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/service/validator/extension/ValidationSaverDelegate.java
+++ b/cayenne-project/src/main/java/org/apache/cayenne/project/extension/validation/ValidationSaverDelegate.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
****************************************************************/
-package org.apache.cayenne.modeler.service.validator.extension;
+package org.apache.cayenne.project.extension.validation;
import org.apache.cayenne.configuration.DataChannelDescriptor;
import org.apache.cayenne.configuration.xml.DataChannelMetaData;
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerModule.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerModule.java
index efe30d2f3..c3258e3dd 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerModule.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerModule.java
@@ -26,10 +26,10 @@ import org.apache.cayenne.dbsync.xml.DbImportExtension;
import org.apache.cayenne.di.Binder;
import org.apache.cayenne.di.Module;
import org.apache.cayenne.gen.xml.CgenExtension;
-import org.apache.cayenne.modeler.service.validator.extension.ValidationExtension;
import org.apache.cayenne.project.ProjectModule;
import org.apache.cayenne.project.extension.ExtensionAwareHandlerFactory;
import org.apache.cayenne.project.extension.info.InfoExtension;
+import org.apache.cayenne.project.extension.validation.ValidationExtension;
import org.xml.sax.XMLReader;
/**
(cayenne) 05/06: Newly reverse-engineered entities are excluded from CGen | CAY-2951
Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 2ce7f826a40894332a6e7ffe813e7ec09df80abb
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Sun May 24 16:29:32 2026 -0400
Newly reverse-engineered entities are excluded from CGen | CAY-2951
---
RELEASE-NOTES.txt | 1 +
.../org/apache/cayenne/gen/CgenConfiguration.java | 16 ++++----
.../ui/project/editor/datamap/DataMapView.java | 1 -
.../ui/project/editor/datamap/cgen/CgenPanel.java | 46 ++++++++++++++++------
4 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 03c7bba2c..c94bd087c 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -77,6 +77,7 @@ CAY-2926 Modeler: renaming an ObjEntity adds it to cgen excludeEntities
CAY-2931 Modeler: default encoding detected as UTF8, should be UTF-8
CAY-2934 Modeler: dropdown data trunction
CAY-2944 MergerTokenFactoryProvider does not resolve adapter subclasses
+CAY-2951 Newly reverse-engineered entities are excluded from CGen
----------------------------------
Release: 5.0-M1
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
index a5d763fa0..3529859ab 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
@@ -414,10 +414,10 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
}
private String getExcludedEntities() {
- return dataMap.getObjEntities()
- .stream()
- .map(ObjEntity::getName)
- .filter(name -> !entityArtifacts.contains(name))
+ Set<String> existing = dataMap.getObjEntityMap().keySet();
+ return excludedEntityArtifacts.stream()
+ .filter(existing::contains)
+ .sorted()
.collect(Collectors.joining(","));
}
@@ -430,10 +430,10 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
}
private String getExcludedEmbeddables() {
- return dataMap.getEmbeddables()
- .stream()
- .map(Embeddable::getClassName)
- .filter(className -> !embeddableArtifacts.contains(className))
+ Set<String> existing = dataMap.getEmbeddableMap().keySet();
+ return excludedEmbeddableArtifacts.stream()
+ .filter(existing::contains)
+ .sorted()
.collect(Collectors.joining(","));
}
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/datamap/DataMapView.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/datamap/DataMapView.java
index fc21c1b4a..3559a7924 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/datamap/DataMapView.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/datamap/DataMapView.java
@@ -48,7 +48,6 @@ public class DataMapView extends ProjectTabbedPane {
}
private void currentDataMapChanged(DataMapDisplayEvent e) {
-
if (e.isMainTabFocus()) {
setSelectedIndex(0);
}
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/datamap/cgen/CgenPanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/datamap/cgen/CgenPanel.java
index 6551f19de..b1b147830 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/datamap/cgen/CgenPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/project/editor/datamap/cgen/CgenPanel.java
@@ -48,7 +48,6 @@ import org.apache.cayenne.modeler.project.CgenOps;
import org.apache.cayenne.modeler.project.ProjectSession;
import org.apache.cayenne.modeler.toolkit.ProjectPanel;
import org.apache.cayenne.modeler.toolkit.icon.IconFactory;
-import org.apache.cayenne.modeler.ui.project.editor.datamap.dbimport.DbImportResultDialog;
import org.apache.cayenne.tools.ToolsInjectorBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -68,8 +67,7 @@ import java.util.stream.Collectors;
* the body splits into the per-class artefact selector (left) and the cgen options form (right).
* Subscribes to project events to keep its model snapshot in sync with mapping edits.
*/
-public class CgenPanel extends ProjectPanel
- implements ObjEntityListener, EmbeddableListener, DataMapListener {
+public class CgenPanel extends ProjectPanel implements ObjEntityListener, EmbeddableListener, DataMapListener {
private static final Logger LOGGER = LoggerFactory.getLogger(CgenPanel.class);
@@ -246,6 +244,10 @@ public class CgenPanel extends ProjectPanel
private void setConfiguration(String selectedConfig) {
cgenConfiguration = cgenConfigList.getByName(selectedConfig);
if (cgenConfiguration != null) {
+ // Refresh entityArtifacts from the DataMap so any entities added since the config
+ // was last loaded (e.g. by a dbimport run) are treated as included by default.
+ cgenConfiguration.resolveExcludedEntities();
+ cgenConfiguration.resolveExcludedEmbeddables();
addToSelectedEntities(cgenConfiguration.getEntities());
addToSelectedEmbeddables(cgenConfiguration.getEmbeddables());
cgenConfiguration.setForce(true);
@@ -462,6 +464,17 @@ public class CgenPanel extends ProjectPanel
for (ObjEntity entity : selectionModel.getSelectedEntities(classes)) {
cgenConfiguration.loadEntity(entity);
}
+ // Keep excludedEntityArtifacts in sync so XML serialization stays correct
+ Collection<String> excluded = cgenConfiguration.getExcludedEntityArtifacts();
+ excluded.clear();
+ DataMap dataMap = cgenConfiguration.getDataMap();
+ if (dataMap != null) {
+ Set<String> selected = cgenConfiguration.getEntities();
+ dataMap.getObjEntities().stream()
+ .map(ObjEntity::getName)
+ .filter(name -> !selected.contains(name))
+ .forEach(excluded::add);
+ }
}
checkCgenConfigDirty();
}
@@ -472,6 +485,17 @@ public class CgenPanel extends ProjectPanel
for (Embeddable embeddable : selectionModel.getSelectedEmbeddables(classes)) {
cgenConfiguration.loadEmbeddable(embeddable);
}
+ // Keep excludedEmbeddableArtifacts in sync so XML serialization stays correct
+ Collection<String> excluded = cgenConfiguration.getExcludedEmbeddableArtifacts();
+ excluded.clear();
+ DataMap dataMap = cgenConfiguration.getDataMap();
+ if (dataMap != null) {
+ Set<String> selected = cgenConfiguration.getEmbeddables();
+ dataMap.getEmbeddables().stream()
+ .map(Embeddable::getClassName)
+ .filter(name -> !selected.contains(name))
+ .forEach(excluded::add);
+ }
}
checkCgenConfigDirty();
}
@@ -565,20 +589,16 @@ public class CgenPanel extends ProjectPanel
@Override
public void dataMapChanged(DataMapEvent e) {
- if (e.getSource() instanceof DbImportResultDialog) {
- if (cgenConfiguration != null) {
- for (ObjEntity objEntity : e.getDataMap().getObjEntities()) {
- if (!cgenConfiguration.getExcludedEntityArtifacts().contains(objEntity.getName())) {
- addEntity(cgenConfiguration.getDataMap(), objEntity);
- }
- }
- }
- checkCgenConfigDirty();
- }
}
@Override
public void dataMapAdded(DataMapEvent e) {
+ // DbImportProjectSaver fires a pair of REMOVE / ADD events after merging new entities into a DataMap.
+ // Re-initialize the panel so newly imported entities appear as included.
+ DataMap map = e.getDataMap();
+ if (map != null && cgenConfiguration != null && map == cgenConfiguration.getDataMap()) {
+ initFromModel(map);
+ }
}
@Override
(cayenne) 03/06: cleanup
Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 8d43e8720d7c61b16fbd117dc866846aeb48feed
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Sun May 24 15:47:24 2026 -0400
cleanup
---
.../cayenne/mcp/tools/dbimport/DbImportRunValidationTest.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/cayenne-mcp-server/src/test/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunValidationTest.java b/cayenne-mcp-server/src/test/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunValidationTest.java
index 0c13205f7..0bcc07269 100644
--- a/cayenne-mcp-server/src/test/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunValidationTest.java
+++ b/cayenne-mcp-server/src/test/java/org/apache/cayenne/mcp/tools/dbimport/DbImportRunValidationTest.java
@@ -44,13 +44,12 @@ import static org.junit.jupiter.api.Assertions.*;
public class DbImportRunValidationTest {
private static DbImportRunTool tool;
- private static PrefsLocator prefsLocator;
private Preferences testPrefsRoot;
@BeforeAll
public static void setUpClass() {
- prefsLocator = new PrefsLocator(Preferences.userRoot().node("cayenne-test/dbimport-validation"));
+ PrefsLocator prefsLocator = new PrefsLocator(Preferences.userRoot().node("cayenne-test/dbimport-validation"));
tool = new DbImportRunTool(prefsLocator);
}
@@ -96,7 +95,7 @@ public class DbImportRunValidationTest {
@Test
public void dataMapNotFound() throws URISyntaxException {
- String projectPath = fixtureProject("no-dbimport");
+ String projectPath = fixtureProject();
DbImportRunResult result = tool.run(projectPath, "NoSuchMap");
@@ -213,9 +212,9 @@ public class DbImportRunValidationTest {
assertNoCredentialsInResult(result);
}
- private static String fixtureProject(String fixture) throws URISyntaxException {
+ private static String fixtureProject() throws URISyntaxException {
return Paths.get(DbImportRunValidationTest.class
- .getResource("/dbimport-fixtures/" + fixture + "/cayenne-project.xml")
+ .getResource("/dbimport-fixtures/no-dbimport/cayenne-project.xml")
.toURI()).toString();
}