mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-09 05:48:20 +00:00
WIP
This commit is contained in:
parent
82311fd23e
commit
00a3ff53f0
@ -195,6 +195,12 @@ public class DbAdminRepository {
|
|||||||
Map<String, Object> allValues = new HashMap<>();
|
Map<String, Object> allValues = new HashMap<>();
|
||||||
allValues.putAll(values);
|
allValues.putAll(values);
|
||||||
|
|
||||||
|
values.keySet().forEach(fieldName -> {
|
||||||
|
if (values.get(fieldName).isBlank()) {
|
||||||
|
allValues.put(fieldName, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
files.keySet().forEach(f -> {
|
files.keySet().forEach(f -> {
|
||||||
try {
|
try {
|
||||||
allValues.put(f, files.get(f).getBytes());
|
allValues.put(f, files.get(f).getBytes());
|
||||||
|
@ -21,6 +21,9 @@ public class DbObject {
|
|||||||
private DbObjectSchema schema;
|
private DbObjectSchema schema;
|
||||||
|
|
||||||
public DbObject(Object instance, DbObjectSchema schema) {
|
public DbObject(Object instance, DbObjectSchema schema) {
|
||||||
|
if (instance == null)
|
||||||
|
throw new DbAdminException("Trying to build object with instance == null");
|
||||||
|
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
this.schema = schema;
|
this.schema = schema;
|
||||||
}
|
}
|
||||||
@ -54,6 +57,8 @@ public class DbObject {
|
|||||||
OneToOne oneToOne = field.getPrimitiveField().getAnnotation(OneToOne.class);
|
OneToOne oneToOne = field.getPrimitiveField().getAnnotation(OneToOne.class);
|
||||||
if (oneToOne != null || manyToOne != null) {
|
if (oneToOne != null || manyToOne != null) {
|
||||||
Object linkedObject = get(field.getJavaName()).getValue();
|
Object linkedObject = get(field.getJavaName()).getValue();
|
||||||
|
if (linkedObject == null) return null;
|
||||||
|
|
||||||
DbObject linkedDbObject = new DbObject(linkedObject, field.getConnectedSchema());
|
DbObject linkedDbObject = new DbObject(linkedObject, field.getConnectedSchema());
|
||||||
return linkedDbObject;
|
return linkedDbObject;
|
||||||
} else {
|
} else {
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
<!-- data-row-field fragment -->
|
<!-- data-row-field fragment -->
|
||||||
<th:block th:fragment="data_row_field(field, object)">
|
<th:block th:fragment="data_row_field(field, object)">
|
||||||
<th:block th:if="${field.getConnectedType() != null}">
|
<th:block th:if="${field.getConnectedType() != null && object.traverse(field) != null}">
|
||||||
<a th:href="|/dbadmin/model/${field.getConnectedType().getName()}/show/${object.traverse(field).getPrimaryKeyValue()}|">
|
<a th:href="|/dbadmin/model/${field.getConnectedType().getName()}/show/${object.traverse(field).getPrimaryKeyValue()}|">
|
||||||
<span th:text="${object.has(field) ? object.traverse(field).getPrimaryKeyValue() : 'NULL'}"></span>
|
<span th:text="${object.has(field) ? object.traverse(field).getPrimaryKeyValue() : 'NULL'}"></span>
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user