Open MaxPostema opened 1 year ago
Traced to the backend. On a 'clone' of the record the same information is send to the server as is send when a record is updated. I am pretty sure the frontend does wat it needs to do.
In org/molgenis/emx2/web/GraphqlApi.java:102 is file info
private static String executeQuery(GraphQL g, Request request) throws IOException {
mutation update($value:[UserInput]){update(User:$value){message}}
in org/molgenis/emx2/sql/SqlTable.java:139 file name is lost
public int update(Iterable<Row> rows) {
Code flow goes through BinaryFileWrapper
which has no property to store fileName
.
public BinaryFileWrapper(String contentType, String fileName, byte[] contents) {
this.contents = contents;
this.mimetype = contentType;
this.extension = deriveExtension(fileName);
}
So we need to add fileName to org.molgenis.emx2.Binary
to even store the name.
When we have a File
object we can use getName()
.
getName()
to BinaryFile
and BinaryFileWrapper
setBinary()
replacing this.values.put(name, UUID.randomUUID().toString().replace("-", ""));
by the filename
?We discussed this and supposed a File has also a ~*_labelcolumn .. "Pet store". "User" table has
picture` but there is none according SQL DDL
...
picture character varying COLLATE pg_catalog."default",
picture_mimetype character varying COLLATE pg_catalog."default",
picture_extension character varying COLLATE pg_catalog."default",
picture_size integer,
picture_contents bytea,
In Java I like to access the picture
value too:
Can s()
call provide this as I need the column value as well
.select(s(columnName, s("contents"), s("mimetype"), s("extension")))
results into data like
Probably the solution is to recognize during insert that file metadata is included (but not the byte stream of course). See screenshot below of an example clone. You can see that it is a clone because file metadata is included
See
What version of EMX2 are you using (see footer) Software version: 8.114.11-SNAPSHOT Database version: 5.
Describe the bug Cloning a record removed the uploaded file
To Reproduce Steps to reproduce the behavior:
Expected behavior I Expect the clone to keep the uploaded file or to have a cloned file