mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-12-16 05:12:00 +09:00
WIP
This commit is contained in:
@@ -20,6 +20,7 @@ import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.Lob;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
@@ -201,6 +202,7 @@ public class DbAdmin {
|
||||
ManyToMany manyToMany = f.getAnnotation(ManyToMany.class);
|
||||
ManyToOne manyToOne = f.getAnnotation(ManyToOne.class);
|
||||
OneToOne oneToOne = f.getAnnotation(OneToOne.class);
|
||||
Lob lob = f.getAnnotation(Lob.class);
|
||||
|
||||
String fieldName = determineFieldName(f);
|
||||
|
||||
@@ -212,6 +214,10 @@ public class DbAdmin {
|
||||
DbFieldType fieldType = null;
|
||||
try {
|
||||
fieldType = DbFieldType.fromClass(f.getType());
|
||||
|
||||
if (fieldType != null && lob != null && fieldType == DbFieldType.STRING) {
|
||||
fieldType = DbFieldType.TEXT;
|
||||
}
|
||||
} catch (DbAdminException e) {
|
||||
// If failure, we try to map a relationship on this field
|
||||
}
|
||||
|
||||
@@ -124,6 +124,10 @@ public class DbField {
|
||||
return format;
|
||||
}
|
||||
|
||||
public boolean isText() {
|
||||
return type == DbFieldType.TEXT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DbField [name=" + dbName + ", javaName=" + javaName + ", type=" + type + ", field=" + field
|
||||
|
||||
@@ -163,6 +163,28 @@ public enum DbFieldType {
|
||||
return List.of(CompareOperator.CONTAINS, CompareOperator.STRING_EQ);
|
||||
}
|
||||
},
|
||||
TEXT {
|
||||
@Override
|
||||
public String getHTMLName() {
|
||||
return "textarea";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object parseValue(Object value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getJavaClass() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompareOperator> getCompareOperators() {
|
||||
return List.of(CompareOperator.CONTAINS, CompareOperator.STRING_EQ);
|
||||
}
|
||||
|
||||
},
|
||||
BOOLEAN {
|
||||
@Override
|
||||
public String getHTMLName() {
|
||||
|
||||
Reference in New Issue
Block a user