Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.openbpm.control.view.processinstance.runtime;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.grid.GridSortOrder;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
Expand All @@ -14,6 +15,7 @@
import com.vaadin.flow.data.event.SortEvent;
import com.vaadin.flow.data.renderer.Renderer;
import com.vaadin.flow.data.renderer.TextRenderer;
import com.vaadin.flow.data.selection.SelectionEvent;
import com.vaadin.flow.theme.lumo.LumoUtility;
import io.jmix.core.DataLoadContext;
import io.jmix.core.LoadContext;
Expand All @@ -26,6 +28,7 @@
import io.jmix.flowui.component.grid.DataGrid;
import io.jmix.flowui.component.grid.TreeDataGrid;
import io.jmix.flowui.component.tabsheet.JmixTabSheet;
import io.jmix.flowui.download.Downloader;
import io.jmix.flowui.fragment.Fragment;
import io.jmix.flowui.fragment.FragmentDescriptor;
import io.jmix.flowui.kit.action.ActionPerformedEvent;
Expand All @@ -38,10 +41,11 @@
import io.openbpm.control.entity.filter.*;
import io.openbpm.control.entity.processinstance.ProcessInstanceData;
import io.openbpm.control.entity.processinstance.ProcessInstanceState;
import io.openbpm.control.entity.variable.CamundaVariableType;
import io.openbpm.control.entity.variable.ObjectTypeInfo;
import io.openbpm.control.entity.variable.VariableInstanceData;
import io.openbpm.control.entity.variable.VariableValueInfo;
import io.openbpm.control.service.activity.ActivityService;
import io.openbpm.control.exception.EngineResourceNotAvailableException;
import io.openbpm.control.service.externaltask.ExternalTaskService;
import io.openbpm.control.service.incident.IncidentService;
import io.openbpm.control.service.job.JobService;
Expand All @@ -54,8 +58,11 @@
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.List;
import java.util.Set;

Expand Down Expand Up @@ -95,7 +102,8 @@ public class RuntimeTabFragment extends Fragment<HorizontalLayout> {
private Dialogs dialogs;
@Autowired
private Messages messages;

@Autowired
protected Downloader downloader;

@ViewComponent
protected MessageBundle messageBundle;
Expand All @@ -113,6 +121,8 @@ public class RuntimeTabFragment extends Fragment<HorizontalLayout> {
protected JmixTabSheet runtimeTabsheet;
@ViewComponent
protected VerticalLayout activityTreeContainer;
@ViewComponent
protected Button downloadButton;

protected VariableFilter variableFilter;

Expand Down Expand Up @@ -320,6 +330,27 @@ protected List<VariableInstanceData> runtimeVariablesDlLoadDelegate(final LoadCo
return variableService.findRuntimeVariables(context);
}

@Subscribe("runtimeVariablesGrid")
public void onRuntimeVariablesGridSelection(final SelectionEvent<DataGrid<VariableInstanceData>, VariableInstanceData> event) {
VariableInstanceData selectedItem = runtimeVariablesGrid.getSingleSelectedItem();
boolean isFileType = selectedItem != null &&
CamundaVariableType.FILE.getId().equals(selectedItem.getType())
&& selectedItem.getValueInfo() != null;
downloadButton.setEnabled(isFileType);
}

@Subscribe("runtimeVariablesGrid.download")
public void onRuntimeVariablesGridDownload(final ActionPerformedEvent event) {
VariableInstanceData selectedItem = runtimeVariablesGrid.getSingleSelectedItem();
if (selectedItem != null) {
Resource fileResource = variableService.getVariableInstanceBinary(selectedItem.getVariableInstanceId());
byte[] byteArrayContent = getByteArrayContent(fileResource);
if (fileResource.getFilename() != null) {
downloader.download(() -> new ByteArrayInputStream(byteArrayContent), fileResource.getFilename());
} downloader.download(() -> new ByteArrayInputStream(byteArrayContent), selectedItem.getValueInfo().getFilename());
}
}


@Install(to = "runtimeVariablesPagination", subject = "totalCountDelegate")
protected Integer runtimeVariablesPaginationTotalCountDelegate(final DataLoadContext dataLoadContext) {
Expand Down Expand Up @@ -481,6 +512,9 @@ protected String getVariableValueColumnText(VariableInstanceData variableInstanc
if (variableInstance.getValue() != null) {
return variableInstance.getValue().toString();
}
if (variableInstance.getType().equals(CamundaVariableType.FILE.getId())) {
return variableInstance.getValueInfo().getFilename();
}
return null;
}

Expand All @@ -507,4 +541,14 @@ protected Component getTabContent(Tab tab) {
: null;
}

private static byte[] getByteArrayContent(Resource deploymentResourceData) {
byte[] byteArray;
try {
byteArray = deploymentResourceData.getContentAsByteArray();
} catch (IOException e) {
throw new EngineResourceNotAvailableException(deploymentResourceData.getFilename());
}
return byteArray;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ protected FileUploadField createFileField() {
}

fileUploadField.addFileUploadSucceededListener(this::handleFileUpload);
fileUploadField.setHelperText(messageBundle.getMessage("variableNameFileTypeMaxSize"));

byte[] binaryValue = loadBinaryValue(variableInstanceData);
fileUploadField.setValue(binaryValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ io.openbpm.control.view.processvariable/variableInstanceData.detail.title=Variab
io.openbpm.control.view.processvariable/variableInstanceDataEdit.value=Wert
io.openbpm.control.view.processvariable/variableNameAlreadyExistsError=Variablenname existiert bereits
io.openbpm.control.view.processvariable/variableValueUpdated=Variablenwert aktualisiert
io.openbpm.control.view.processvariable/variableNameFileTypeMaxSize=Maximale Dateigröße: 1024 kB

io.openbpm.control.view.startprocess/processDefinitionIdLabel=ID
io.openbpm.control.view.startprocess/startProcess=Starten
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ io.openbpm.control.view.processvariable/variableInstanceData.detail.title=Variab
io.openbpm.control.view.processvariable/variableInstanceDataEdit.value=Value
io.openbpm.control.view.processvariable/variableNameAlreadyExistsError=Variable name already exists
io.openbpm.control.view.processvariable/variableValueUpdated=Variable value updated
io.openbpm.control.view.processvariable/variableNameFileTypeMaxSize=Maximum file size: 1024 kB


io.openbpm.control.view.startprocess/processDefinitionIdLabel=Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ io.openbpm.control.view.processvariable/variableInstanceData.detail.title=Detall
io.openbpm.control.view.processvariable/variableInstanceDataEdit.value=Valor
io.openbpm.control.view.processvariable/variableNameAlreadyExistsError=El nombre de la variable ya existe
io.openbpm.control.view.processvariable/variableValueUpdated=Valor de variable actualizado
io.openbpm.control.view.processvariable/variableNameFileTypeMaxSize=Tamaño máximo del archivo: 1024 kB

io.openbpm.control.view.startprocess/processDefinitionIdLabel=Id
io.openbpm.control.view.startprocess/startProcess=Iniciar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ io.openbpm.control.view.processvariable/variableInstanceData.detail.title=Экз
io.openbpm.control.view.processvariable/variableInstanceDataEdit.value=Значение
io.openbpm.control.view.processvariable/variableNameAlreadyExistsError=Имя переменной уже существует
io.openbpm.control.view.processvariable/variableValueUpdated=Значение переменной обновлено
io.openbpm.control.view.processvariable/variableNameFileTypeMaxSize=Максимальный размер файла: 1024 кб


io.openbpm.control.view.startprocess/processDefinitionIdLabel=Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<button action="runtimeVariablesGrid.create" themeNames="primary small"/>
<button action="runtimeVariablesGrid.edit" themeNames="small"/>
<button action="runtimeVariablesGrid.remove" themeNames="small"/>
<button id="downloadButton" text="msg:///actions.Download" icon="DOWNLOAD_ALT" action="runtimeVariablesGrid.download" themeNames="small" enabled="false"/>
<simplePagination id="runtimeVariablesPagination" dataLoader="runtimeVariablesDl"/>
</hbox>
<dataGrid id="runtimeVariablesGrid"
Expand All @@ -51,6 +52,7 @@
<action id="create" type="list_create"/>
<action id="edit" type="list_edit"/>
<action id="remove" type="list_remove"/>
<action id="download" type="list_itemTracking"/>
</actions>
<columns resizable="true">
<column property="name" flexGrow="1"/>
Expand Down