
com.xlrit.gears.engine.facade.SubmitTaskCmd Maven / Gradle / Ivy
package com.xlrit.gears.engine.facade;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.databind.JsonNode;
import com.xlrit.gears.engine.security.AuthManagerSession;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.cmd.NeedsActiveTaskCmd;
import org.flowable.engine.impl.form.TaskFormHandler;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.TaskHelper;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.springframework.web.multipart.MultipartFile;
import static com.xlrit.gears.engine.util.EngineUtils.createSubmitVars;
public class SubmitTaskCmd extends NeedsActiveTaskCmd {
private final JsonNode formValues;
private final List files;
public SubmitTaskCmd(String taskId, JsonNode formValues, List files) {
super(taskId);
this.formValues = formValues;
this.files = files;
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
protected ProcessInstance execute(CommandContext commandContext, TaskEntity task) {
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
ExecutionEntity executionEntity = CommandContextUtil.getExecutionEntityManager().findById(task.getExecutionId());
Map properties = createSubmitVars(formValues, files);
CommandContextUtil.getHistoryManager(commandContext)
.recordFormPropertiesSubmitted(executionEntity, properties, taskId, processEngineConfiguration.getClock().getCurrentTime());
TaskFormHandler taskFormHandler = processEngineConfiguration.getFormHandlerHelper().getTaskFormHandlder(task);
if (taskFormHandler != null) {
taskFormHandler.submitFormProperties(properties, executionEntity);
String userId = commandContext.getSession(AuthManagerSession.class).getCurrentUserId();
TaskHelper.completeTask(task, userId, null, null, null, null, commandContext);
}
return executionEntity.getRootProcessInstance();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy