BPM: Setting the value of io.jmix.core.FileRef from io.jmix.bpm.entity.FileDescription

On JMIX v 1.5.4:

When using an Entity Data Task to create a new record/item there is a parameter (io.jmix.bpm.entity.FileDescription) with the needed FileRef data for the Data Entity (io.jmix.core.FileRef), but when setting it directly it gives an error:

ClassCastException: class io.jmix.bpm.entity.FileDescription cannot be cast to class io.jmix.core.FileRef (io.jmix.bpm.entity.FileDescription and io.jmix.core.FileRef are in unnamed module of loader ‘app’)

Could you please help me to transform the value appropriately or use whatever other solution you could offer please?

Hello,
Can you describe your data model with more detail and explane what ?
Like Entity A with field FileRef named fileRefField, we put FileDescription into process variables, etc
Or create demo project.
I cannot catch whole your problem, but seems like you trying to assigne some entity’s FileRef field from FileDescription, but without details i cant suggest you a solution.

As i understood you

  1. You have EntityA, which should be created inside EntityDataTask.
  2. Created entity EntityA has FileRef field, i will name it “fileRefField”, probably is required
  3. You trying to fill fileRefField from processVariable??
  4. But when you trying to fill fileRefField from bpm, it throws exceptions because processVariable has type FileDescription, but your entity’s field has type FileRef?

But i have no details further

Regards, Dmitry

UPD:
If your problem still not solved, i can offer you check this topic. In short, you need just transform FileDescription into FileRef as i said before.
Steps:

  1. Add service task with SpringBean type before EntityDataTask
  2. Extract your FileDescription and transform it inside spring bean
    image
    import io.jmix.bpm.entity.FileDescription;
    import io.jmix.core.FileRef;
    import io.jmix.core.FileStorage;
    import org.springframework.stereotype.Component;
    
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    
    @Component
     public class ProcessFileManager {
    
        private FileStorage fileStorage;
    
        public ProcessFileManager(FileStorage fileStorage) {
            this.fileStorage = fileStorage;
        }
    
        public FileRef saveFileToFileStorage2(FileDescription fileDescription) throws IOException {
             try (InputStream is = new ByteArrayInputStream(fileDescription.getFileContent())) {
                FileRef fileRef = fileStorage.saveStream(fileDescription.getFileName(), is);
                return fileRef;
            }
        }
    }
    
  3. Put into service task’s method argument your FileDescription (named fileVar and marked as process variable)
  4. Publish ServiceTask result as process variable (named fileRefVar in screenshot)
    As i said, you just need to transform FileDescription into FileRef.
  5. Use your new FileRef by process variable named fileRefVar

Otherwise, you can use ServiceTask inside of EntityDataTask and taransoform and create necessary Entity insidea SpringBean manually to prevent bpmn schema complication.

If you need more detail explanation/demo, attach your demo project.

Regard, Dmitry