This is an automated email from the ASF dual-hosted git repository. thurka pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new fc9e5178f8 do not create repository and entity classes from template if project was not configured with databse support new 9b91eba3ef Merge pull request #6529 from thurka/GCN-3474 fc9e5178f8 is described below commit fc9e5178f822f61cc194ed259505ecf7d37efc00 Author: Tomas Hurka <tomas.hu...@gmail.com> AuthorDate: Wed Oct 4 14:04:59 2023 +0200 do not create repository and entity classes from template if project was not configured with databse support --- .../org/netbeans/modules/micronaut/db/MicronautEntity.java | 5 +++++ .../netbeans/modules/micronaut/db/MicronautRepository.java | 4 ++++ .../src/org/netbeans/modules/micronaut/db/Utils.java | 11 +++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/MicronautEntity.java b/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/MicronautEntity.java index 7e83726708..76d072c548 100644 --- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/MicronautEntity.java +++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/MicronautEntity.java @@ -105,6 +105,7 @@ public class MicronautEntity extends RelatedCMPWizard { @NbBundle.Messages({ "MSG_NoDbConn=No database connection found", + "MSG_NoDdSupport=No database support libraries found for {0}", "MSG_NoProject=No project found for {0}", "MSG_NoSourceGroup=No source group found for {0}", "MSG_SelectTables=Select Database Tables", @@ -137,6 +138,10 @@ public class MicronautEntity extends RelatedCMPWizard { DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(Bundle.MSG_NoSourceGroup(folder.getPath()), NotifyDescriptor.ERROR_MESSAGE)); return Collections.emptyList(); } + if (!Utils.isDBSupported(sourceGroup) && !Utils.isJPASupported(sourceGroup)) { + DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(Bundle.MSG_NoDdSupport(folder.getPath()), NotifyDescriptor.ERROR_MESSAGE)); + return Collections.emptyList(); + } DatabaseConnection connection = ConnectionManager.getDefault().getPreferredConnection(true); if (connection == null) { DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(Bundle.MSG_NoDbConn(), NotifyDescriptor.ERROR_MESSAGE)); diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/MicronautRepository.java b/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/MicronautRepository.java index 4f3c6b6797..1bb29e08ec 100644 --- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/MicronautRepository.java +++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/MicronautRepository.java @@ -113,6 +113,10 @@ public class MicronautRepository implements TemplateWizard.Iterator { DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(Bundle.MSG_NoSourceGroup(folder.getPath()), NotifyDescriptor.ERROR_MESSAGE)); return Collections.emptyList(); } + if (!Utils.isDBSupported(sourceGroup) && !Utils.isJPASupported(sourceGroup)) { + DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(Bundle.MSG_NoDdSupport(folder.getPath()), NotifyDescriptor.ERROR_MESSAGE)); + return Collections.emptyList(); + } final boolean jpaSupported = Utils.isJPASupported(sourceGroup); final Map<String, String> entity2idTypes = getEntityClasses(sourceGroup, jpaSupported); final List<NotifyDescriptor.QuickPick.Item> entities = new ArrayList<>(); diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/Utils.java b/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/Utils.java index 4e3e08fbd7..c0e5897dea 100644 --- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/Utils.java +++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/db/Utils.java @@ -28,6 +28,14 @@ import org.netbeans.api.project.SourceGroup; public class Utils { public static boolean isJPASupported(SourceGroup sg) { + return resolveClassName(sg, "io.micronaut.data.jpa.repository.JpaRepository"); //NOI18N + } + + public static boolean isDBSupported(SourceGroup sg) { + return resolveClassName(sg, "io.micronaut.data.annotation.Id"); //NOI18N + } + + private static boolean resolveClassName(SourceGroup sg, String fqn) { if (sg == null) { return false; } @@ -35,7 +43,6 @@ public class Utils { if (compile == null) { return false; } - final String notNullAnnotation = "io.micronaut.data.jpa.repository.JpaRepository"; //NOI18N - return compile.findResource(notNullAnnotation.replace('.', '/') + ".class") != null; //NOI18N + return compile.findResource(fqn.replace('.', '/') + ".class") != null; //NOI18N } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists