This commit is contained in:
Francesco 2023-11-11 11:07:43 +01:00
parent 6eacecdef3
commit 32751552d4
2 changed files with 12 additions and 1 deletions

View File

@ -26,6 +26,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -182,6 +183,14 @@ public class SnapAdmin {
return findSchemaByClassName(klass.getName()); return findSchemaByClassName(klass.getName());
} }
/**
* Returns whether this class is managed by SnapAdmin
*/
public boolean isManagedClass(Class<?> klass) {
Optional<DbObjectSchema> hasSchema =
schemas.stream().filter(s -> s.getClassName().equals(klass.getName())).findFirst();
return hasSchema.isPresent();
}
/** /**
* This method processes a BeanDefinition into a DbObjectSchema object, * This method processes a BeanDefinition into a DbObjectSchema object,

View File

@ -287,7 +287,9 @@ public class DbObjectSchema {
List<DbField> res = getFields().stream().filter(f -> { List<DbField> res = getFields().stream().filter(f -> {
return f.getPrimitiveField().getAnnotation(OneToMany.class) != null return f.getPrimitiveField().getAnnotation(OneToMany.class) != null
|| f.getPrimitiveField().getAnnotation(ManyToMany.class) != null; || f.getPrimitiveField().getAnnotation(ManyToMany.class) != null;
}).collect(Collectors.toList()); })
.filter(f -> snapAdmin.isManagedClass(f.getConnectedType()))
.collect(Collectors.toList());
return res; return res;
} }