use of org.flowable.variable.api.history.HistoricVariableInstance in project zaakafhandelcomponent by NL-AMS-LOCGOV.
the class FlowableService method readTaakdata.
public Map<String, String> readTaakdata(final String taskId) {
final Map<String, String> taakdata;
if (isOpenTask(taskId)) {
taakdata = (Map<String, String>) cmmnTaskService.getVariableLocal(taskId, VAR_TASK_TAAKDATA);
} else {
final HistoricVariableInstance historicVariableInstance = cmmnHistoryService.createHistoricVariableInstanceQuery().taskId(taskId).variableName(VAR_TASK_TAAKDATA).singleResult();
taakdata = historicVariableInstance != null ? (Map<String, String>) historicVariableInstance.getValue() : null;
}
return taakdata != null ? taakdata : Collections.emptyMap();
}
use of org.flowable.variable.api.history.HistoricVariableInstance in project plumdo-work by wengwh.
the class RestResponseFactory method createRestVariables.
public List<RestVariable> createRestVariables(List<HistoricVariableInstance> historicVariableInstances) {
List<RestVariable> result = new ArrayList<>();
RestVariableConverter converter = null;
for (HistoricVariableInstance pair : historicVariableInstances) {
for (RestVariableConverter c : variableConverters) {
if (c.getRestTypeName().equals(pair.getVariableTypeName())) {
converter = c;
break;
}
}
RestVariable restVariable = new RestVariable();
restVariable.setName(pair.getVariableName());
if (converter != null) {
restVariable.setType(converter.getRestTypeName());
converter.convertVariableValue(pair.getValue(), restVariable);
} else {
restVariable.setType(pair.getVariableTypeName());
restVariable.setValue(pair.getValue());
}
result.add(restVariable);
}
return result;
}
use of org.flowable.variable.api.history.HistoricVariableInstance in project syncope by apache.
the class FlowableUserRequestHandler method submitForm.
@Override
@SuppressWarnings("unchecked")
public UserWorkflowResult<UserUR> submitForm(final UserRequestForm form) {
Pair<Task, TaskFormData> parsed = parseTask(form.getTaskId());
String authUser = AuthContextUtils.getUsername();
if (!parsed.getLeft().getAssignee().equals(authUser)) {
throw new WorkflowException(new IllegalArgumentException("Task " + form.getTaskId() + " assigned to " + parsed.getLeft().getAssignee() + " but submitted by " + authUser));
}
String procInstID = parsed.getLeft().getProcessInstanceId();
User user = userDAO.find(getUserKey(procInstID));
if (user == null) {
throw new NotFoundException("User with key " + getUserKey(procInstID));
}
Set<String> preTasks = FlowableRuntimeUtils.getPerformedTasks(engine, procInstID);
engine.getRuntimeService().setVariable(procInstID, FlowableRuntimeUtils.TASK, "submit");
engine.getRuntimeService().setVariable(procInstID, FlowableRuntimeUtils.FORM_SUBMITTER, authUser);
engine.getRuntimeService().setVariable(procInstID, FlowableRuntimeUtils.USER, lazyLoad(user));
try {
engine.getFormService().submitTaskFormData(form.getTaskId(), getPropertiesForSubmit(form));
} catch (FlowableException e) {
FlowableRuntimeUtils.throwException(e, "While submitting form for task " + form.getTaskId());
}
Set<String> postTasks = FlowableRuntimeUtils.getPerformedTasks(engine, procInstID);
postTasks.removeAll(preTasks);
postTasks.add(form.getTaskId());
if (procInstID.equals(FlowableRuntimeUtils.getWFProcInstID(engine, user.getKey()))) {
FlowableRuntimeUtils.updateStatus(engine, procInstID, user);
}
user = userDAO.save(user);
PropagationByResource<String> propByRes;
PropagationByResource<Pair<String, String>> propByLinkedAccount;
String clearPassword = null;
UserUR userUR;
if (engine.getRuntimeService().createProcessInstanceQuery().processInstanceId(procInstID).singleResult() == null) {
List<HistoricVariableInstance> historicVariables = engine.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(procInstID).list();
// see if there is any propagation to be done
propByRes = getHistoricVariable(historicVariables, FlowableRuntimeUtils.PROP_BY_RESOURCE, PropagationByResource.class);
propByLinkedAccount = getHistoricVariable(historicVariables, FlowableRuntimeUtils.PROP_BY_LINKEDACCOUNT, PropagationByResource.class);
// fetch - if available - the encrypted password
String encryptedPwd = getHistoricVariable(historicVariables, FlowableRuntimeUtils.ENCRYPTED_PWD, String.class);
if (StringUtils.isNotBlank(encryptedPwd)) {
clearPassword = FlowableRuntimeUtils.decrypt(encryptedPwd);
}
userUR = getHistoricVariable(historicVariables, FlowableRuntimeUtils.USER_UR, UserUR.class);
} else {
engine.getRuntimeService().removeVariable(procInstID, FlowableRuntimeUtils.TASK);
engine.getRuntimeService().removeVariable(procInstID, FlowableRuntimeUtils.FORM_SUBMITTER);
engine.getRuntimeService().removeVariable(procInstID, FlowableRuntimeUtils.USER);
engine.getRuntimeService().removeVariable(procInstID, FlowableRuntimeUtils.USER_TO);
// see if there is any propagation to be done
propByRes = engine.getRuntimeService().getVariable(procInstID, FlowableRuntimeUtils.PROP_BY_RESOURCE, PropagationByResource.class);
engine.getRuntimeService().removeVariable(procInstID, FlowableRuntimeUtils.PROP_BY_RESOURCE);
propByLinkedAccount = engine.getRuntimeService().getVariable(procInstID, FlowableRuntimeUtils.PROP_BY_LINKEDACCOUNT, PropagationByResource.class);
engine.getRuntimeService().removeVariable(procInstID, FlowableRuntimeUtils.PROP_BY_LINKEDACCOUNT);
// fetch - if available - the encrypted password
String encryptedPwd = engine.getRuntimeService().getVariable(procInstID, FlowableRuntimeUtils.ENCRYPTED_PWD, String.class);
engine.getRuntimeService().removeVariable(procInstID, FlowableRuntimeUtils.ENCRYPTED_PWD);
if (StringUtils.isNotBlank(encryptedPwd)) {
clearPassword = FlowableRuntimeUtils.decrypt(encryptedPwd);
}
Boolean enabled = engine.getRuntimeService().getVariable(procInstID, FlowableRuntimeUtils.ENABLED, Boolean.class);
engine.getRuntimeService().removeVariable(procInstID, FlowableRuntimeUtils.ENABLED);
// supports approval chains
FlowableRuntimeUtils.saveForFormSubmit(engine, procInstID, dataBinder.getUserTO(user, true), clearPassword, enabled, propByRes, propByLinkedAccount);
userUR = engine.getRuntimeService().getVariable(procInstID, FlowableRuntimeUtils.USER_UR, UserUR.class);
engine.getRuntimeService().removeVariable(procInstID, FlowableRuntimeUtils.USER_UR);
}
if (userUR == null) {
userUR = new UserUR();
userUR.setKey(user.getKey());
userUR.setPassword(new PasswordPatch.Builder().onSyncope(true).value(clearPassword).build());
Set<String> pwdResources = new HashSet<>();
if (propByRes != null) {
pwdResources.addAll(propByRes.get(ResourceOperation.CREATE));
}
if (propByLinkedAccount != null) {
pwdResources.addAll(propByLinkedAccount.get(ResourceOperation.CREATE).stream().map(Pair::getLeft).collect(Collectors.toList()));
}
userUR.getPassword().getResources().addAll(pwdResources);
}
return new UserWorkflowResult<>(userUR, propByRes, propByLinkedAccount, postTasks);
}
Aggregations