use of org.apache.syncope.common.lib.to.UserRequestFormProperty in project syncope by apache.
the class FlowableUserRequestHandler method getForm.
@SuppressWarnings("unchecked")
protected UserRequestForm getForm(final String procInstId, final String taskId, final String formKey, final List<FormProperty> props) {
UserRequestForm formTO = new UserRequestForm();
formTO.setBpmnProcess(engine.getRuntimeService().createProcessInstanceQuery().processInstanceId(procInstId).singleResult().getProcessDefinitionKey());
User user = userDAO.find(getUserKey(procInstId));
if (user == null) {
throw new NotFoundException("User for process instance id " + procInstId);
}
formTO.setUsername(user.getUsername());
formTO.setTaskId(taskId);
formTO.setFormKey(formKey);
formTO.setUserTO(engine.getRuntimeService().getVariable(procInstId, FlowableRuntimeUtils.USER_TO, UserTO.class));
formTO.setUserUR(engine.getRuntimeService().getVariable(procInstId, FlowableRuntimeUtils.USER_UR, UserUR.class));
formTO.getProperties().addAll(props.stream().map(fProp -> {
UserRequestFormProperty propertyTO = new UserRequestFormProperty();
propertyTO.setId(fProp.getId());
propertyTO.setName(fProp.getName());
propertyTO.setReadable(fProp.isReadable());
propertyTO.setRequired(fProp.isRequired());
propertyTO.setWritable(fProp.isWritable());
propertyTO.setValue(fProp.getValue());
propertyTO.setType(fromFlowableFormType(fProp.getType()));
switch(propertyTO.getType()) {
case Date:
propertyTO.setDatePattern((String) fProp.getType().getInformation("datePattern"));
break;
case Enum:
((Map<String, String>) fProp.getType().getInformation("values")).forEach((key, value) -> {
propertyTO.getEnumValues().add(new UserRequestFormPropertyValue(key, value));
});
break;
case Dropdown:
String valueProviderBean = (String) fProp.getType().getInformation(DropdownValueProvider.NAME);
try {
DropdownValueProvider valueProvider = ApplicationContextProvider.getApplicationContext().getBean(valueProviderBean, DropdownValueProvider.class);
valueProvider.getValues().forEach((key, value) -> {
propertyTO.getDropdownValues().add(new UserRequestFormPropertyValue(key, value));
});
} catch (Exception e) {
LOG.error("Could not find bean {} of type {} for form property {}", valueProviderBean, DropdownValueProvider.class.getName(), propertyTO.getId(), e);
}
break;
default:
}
return propertyTO;
}).collect(Collectors.toList()));
return formTO;
}
use of org.apache.syncope.common.lib.to.UserRequestFormProperty in project syncope by apache.
the class FlowableUserRequestHandler method getHistoricFormTO.
protected UserRequestForm getHistoricFormTO(final String procInstId, final String taskId, final String formKey, final List<HistoricFormPropertyEntity> props) {
UserRequestForm formTO = new UserRequestForm();
formTO.setBpmnProcess(engine.getRuntimeService().createProcessInstanceQuery().processInstanceId(procInstId).singleResult().getProcessDefinitionKey());
User user = userDAO.find(getUserKey(procInstId));
if (user == null) {
throw new NotFoundException("User for process instance id " + procInstId);
}
formTO.setUsername(user.getUsername());
formTO.setTaskId(taskId);
formTO.setFormKey(formKey);
formTO.setUserTO(engine.getRuntimeService().getVariable(procInstId, FlowableRuntimeUtils.USER_TO, UserTO.class));
formTO.setUserUR(engine.getRuntimeService().getVariable(procInstId, FlowableRuntimeUtils.USER_UR, UserUR.class));
formTO.getProperties().addAll(props.stream().map(prop -> {
UserRequestFormProperty propertyTO = new UserRequestFormProperty();
propertyTO.setId(prop.getPropertyId());
propertyTO.setName(prop.getPropertyId());
propertyTO.setValue(prop.getPropertyValue());
return propertyTO;
}).collect(Collectors.toList()));
return formTO;
}
Aggregations