use of org.apache.syncope.common.lib.to.WorkflowFormTO in project syncope by apache.
the class FlowableUserWorkflowAdapter method getForm.
@Override
public WorkflowFormTO getForm(final String workflowId) {
Task task;
try {
task = engine.getTaskService().createTaskQuery().processInstanceId(workflowId).singleResult();
} catch (FlowableException e) {
throw new WorkflowException("While reading form for workflow instance " + workflowId, e);
}
TaskFormData formData;
try {
formData = engine.getFormService().getTaskFormData(task.getId());
} catch (FlowableException e) {
LOG.debug("No form found for task {}", task.getId(), e);
formData = null;
}
WorkflowFormTO result = null;
if (formData != null && !formData.getFormProperties().isEmpty()) {
result = getFormTO(task);
}
return result;
}
use of org.apache.syncope.common.lib.to.WorkflowFormTO in project syncope by apache.
the class FlowableUserWorkflowAdapter method getHistoricFormTO.
protected WorkflowFormTO getHistoricFormTO(final String processInstanceId, final String taskId, final String formKey, final List<HistoricFormPropertyEntity> props) {
WorkflowFormTO formTO = new WorkflowFormTO();
User user = userDAO.findByWorkflowId(processInstanceId);
if (user == null) {
throw new NotFoundException("User with workflow id " + processInstanceId);
}
formTO.setUsername(user.getUsername());
formTO.setTaskId(taskId);
formTO.setKey(formKey);
formTO.setUserTO(engine.getRuntimeService().getVariable(processInstanceId, USER_TO, UserTO.class));
formTO.setUserPatch(engine.getRuntimeService().getVariable(processInstanceId, USER_PATCH, UserPatch.class));
props.stream().map(prop -> {
WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
propertyTO.setId(prop.getPropertyId());
propertyTO.setName(prop.getPropertyId());
propertyTO.setValue(prop.getPropertyValue());
return propertyTO;
}).forEachOrdered(propertyTO -> {
formTO.getProperties().add(propertyTO);
});
return formTO;
}
use of org.apache.syncope.common.lib.to.WorkflowFormTO in project syncope by apache.
the class FlowableUserWorkflowAdapter method getForms.
protected <T extends Query<?, ?>, U extends Object> List<WorkflowFormTO> getForms(final Query<T, U> query) {
List<WorkflowFormTO> forms = new ArrayList<>();
query.list().forEach(obj -> {
try {
if (obj instanceof HistoricTaskInstance) {
forms.add(getFormTO((HistoricTaskInstance) obj));
} else if (obj instanceof Task) {
forms.add(getFormTO((Task) obj));
} else {
throw new FlowableException("Failure retrieving form", new IllegalArgumentException("Invalid task type"));
}
} catch (FlowableException e) {
LOG.debug("No form found for task {}", obj, e);
}
});
return forms;
}
use of org.apache.syncope.common.lib.to.WorkflowFormTO in project syncope by apache.
the class FlowableUserWorkflowAdapter method getFormTO.
protected WorkflowFormTO getFormTO(final HistoricTaskInstance task) {
final List<HistoricFormPropertyEntity> props = new ArrayList<>();
engine.getHistoryService().createHistoricDetailQuery().taskId(task.getId()).list().stream().filter(historicDetail -> (historicDetail instanceof HistoricFormPropertyEntity)).forEachOrdered(historicDetail -> {
props.add((HistoricFormPropertyEntity) historicDetail);
});
WorkflowFormTO formTO = getHistoricFormTO(task.getProcessInstanceId(), task.getId(), task.getFormKey(), props);
BeanUtils.copyProperties(task, formTO);
HistoricActivityInstance historicActivityInstance = engine.getHistoryService().createHistoricActivityInstanceQuery().executionId(task.getExecutionId()).activityType("userTask").activityName(task.getName()).singleResult();
if (historicActivityInstance != null) {
formTO.setCreateTime(historicActivityInstance.getStartTime());
formTO.setDueDate(historicActivityInstance.getEndTime());
}
return formTO;
}
use of org.apache.syncope.common.lib.to.WorkflowFormTO in project syncope by apache.
the class FlowableUserWorkflowAdapter method getFormTO.
protected WorkflowFormTO getFormTO(final Task task, final TaskFormData fd) {
WorkflowFormTO formTO = getFormTO(task.getProcessInstanceId(), task.getId(), fd.getFormKey(), fd.getFormProperties());
BeanUtils.copyProperties(task, formTO);
return formTO;
}
Aggregations