mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-08 21:38:21 +00:00
@Disable annotation to ignore entity (#24)
This commit is contained in:
parent
9422b55341
commit
61051ed2b8
@ -47,6 +47,7 @@ import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import tech.ailef.dbadmin.external.annotations.Disable;
|
||||
import tech.ailef.dbadmin.external.annotations.DisplayFormat;
|
||||
import tech.ailef.dbadmin.external.dbmapping.CustomJpaRepository;
|
||||
import tech.ailef.dbadmin.external.dbmapping.DbField;
|
||||
@ -107,7 +108,10 @@ public class DbAdmin {
|
||||
logger.debug("Found " + beanDefs.size() + " candidate @Entity classes");
|
||||
|
||||
for (BeanDefinition bd : beanDefs) {
|
||||
schemas.add(processBeanDefinition(bd));
|
||||
// This can return null if the Entity has the @Disable annotation
|
||||
DbObjectSchema schema = processBeanDefinition(bd);
|
||||
if (schema != null)
|
||||
schemas.add(schema);
|
||||
}
|
||||
|
||||
logger.info("Scanned package '" + currentPackage + "'. Loaded " + beanDefs.size() + " schemas.");
|
||||
@ -185,6 +189,11 @@ public class DbAdmin {
|
||||
|
||||
try {
|
||||
Class<?> klass = Class.forName(fullClassName);
|
||||
|
||||
Disable disabled = klass.getAnnotation(Disable.class);
|
||||
if (disabled != null)
|
||||
return null;
|
||||
|
||||
DbObjectSchema schema = new DbObjectSchema(klass, this);
|
||||
CustomJpaRepository simpleJpaRepository = new CustomJpaRepository(schema, entityManager);
|
||||
schema.setJpaRepository(simpleJpaRepository);
|
||||
|
35
src/main/java/tech/ailef/dbadmin/external/annotations/Disable.java
vendored
Normal file
35
src/main/java/tech/ailef/dbadmin/external/annotations/Disable.java
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Spring Boot Database Admin - An automatically generated CRUD admin UI for Spring Boot apps
|
||||
* Copyright (C) 2023 Ailef (http://ailef.tech)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package tech.ailef.dbadmin.external.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Disables Spring Boot Database Admin on this table.
|
||||
* This means it is ignored during the initialization phase and not analyzed
|
||||
* at all.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Disable {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user