use of org.activiti.engine.form.AbstractFormType in project Activiti by Activiti.
the class DefaultFormHandler method parseConfiguration.
public void parseConfiguration(List<org.activiti.bpmn.model.FormProperty> formProperties, String formKey, DeploymentEntity deployment, ProcessDefinitionEntity processDefinition) {
this.deploymentId = deployment.getId();
ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
if (StringUtils.isNotEmpty(formKey)) {
this.formKey = expressionManager.createExpression(formKey);
}
FormTypes formTypes = Context.getProcessEngineConfiguration().getFormTypes();
for (org.activiti.bpmn.model.FormProperty formProperty : formProperties) {
FormPropertyHandler formPropertyHandler = new FormPropertyHandler();
formPropertyHandler.setId(formProperty.getId());
formPropertyHandler.setName(formProperty.getName());
AbstractFormType type = formTypes.parseFormPropertyType(formProperty);
formPropertyHandler.setType(type);
formPropertyHandler.setRequired(formProperty.isRequired());
formPropertyHandler.setReadable(formProperty.isReadable());
formPropertyHandler.setWritable(formProperty.isWriteable());
formPropertyHandler.setVariableName(formProperty.getVariable());
if (StringUtils.isNotEmpty(formProperty.getExpression())) {
Expression expression = expressionManager.createExpression(formProperty.getExpression());
formPropertyHandler.setVariableExpression(expression);
}
if (StringUtils.isNotEmpty(formProperty.getDefaultExpression())) {
Expression defaultExpression = expressionManager.createExpression(formProperty.getDefaultExpression());
formPropertyHandler.setDefaultExpression(defaultExpression);
}
formPropertyHandlers.add(formPropertyHandler);
}
}
use of org.activiti.engine.form.AbstractFormType in project Activiti by Activiti.
the class ActivitiEngineConfiguration method processEngineConfiguration.
@Bean(name = "processEngineConfiguration")
public ProcessEngineConfigurationImpl processEngineConfiguration() {
SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();
processEngineConfiguration.setDataSource(dataSource());
processEngineConfiguration.setDatabaseSchemaUpdate(environment.getProperty("engine.schema.update", "true"));
processEngineConfiguration.setTransactionManager(annotationDrivenTransactionManager());
processEngineConfiguration.setJobExecutorActivate(Boolean.valueOf(environment.getProperty("engine.activate.jobexecutor", "false")));
processEngineConfiguration.setAsyncExecutorEnabled(Boolean.valueOf(environment.getProperty("engine.asyncexecutor.enabled", "true")));
processEngineConfiguration.setAsyncExecutorActivate(Boolean.valueOf(environment.getProperty("engine.asyncexecutor.activate", "true")));
processEngineConfiguration.setHistory(environment.getProperty("engine.history.level", "full"));
String mailEnabled = environment.getProperty("engine.email.enabled");
if ("true".equals(mailEnabled)) {
processEngineConfiguration.setMailServerHost(environment.getProperty("engine.email.host"));
int emailPort = 1025;
String emailPortProperty = environment.getProperty("engine.email.port");
if (StringUtils.isNotEmpty(emailPortProperty)) {
emailPort = Integer.valueOf(emailPortProperty);
}
processEngineConfiguration.setMailServerPort(emailPort);
String emailUsernameProperty = environment.getProperty("engine.email.username");
if (StringUtils.isNotEmpty(emailUsernameProperty)) {
processEngineConfiguration.setMailServerUsername(emailUsernameProperty);
}
String emailPasswordProperty = environment.getProperty("engine.email.password");
if (StringUtils.isNotEmpty(emailPasswordProperty)) {
processEngineConfiguration.setMailServerPassword(emailPasswordProperty);
}
}
List<AbstractFormType> formTypes = new ArrayList<AbstractFormType>();
formTypes.add(new UserFormType());
formTypes.add(new ProcessDefinitionFormType());
formTypes.add(new MonthFormType());
processEngineConfiguration.setCustomFormTypes(formTypes);
return processEngineConfiguration;
}
use of org.activiti.engine.form.AbstractFormType in project Activiti by Activiti.
the class ActivitiEngineConfiguration method processEngineConfiguration.
@Bean(name = "processEngineConfiguration")
public ProcessEngineConfigurationImpl processEngineConfiguration() {
SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();
processEngineConfiguration.setDataSource(dataSource());
processEngineConfiguration.setDatabaseSchemaUpdate(environment.getProperty("engine.schema.update", "true"));
processEngineConfiguration.setTransactionManager(annotationDrivenTransactionManager());
processEngineConfiguration.setJobExecutorActivate(Boolean.valueOf(environment.getProperty("engine.activate.jobexecutor", "false")));
processEngineConfiguration.setAsyncExecutorEnabled(Boolean.valueOf(environment.getProperty("engine.asyncexecutor.enabled", "true")));
processEngineConfiguration.setAsyncExecutorActivate(Boolean.valueOf(environment.getProperty("engine.asyncexecutor.activate", "true")));
processEngineConfiguration.setHistory(environment.getProperty("engine.history.level", "full"));
List<AbstractFormType> formTypes = new ArrayList<AbstractFormType>();
formTypes.add(new UserFormType());
formTypes.add(new ProcessDefinitionFormType());
formTypes.add(new MonthFormType());
processEngineConfiguration.setCustomFormTypes(formTypes);
return processEngineConfiguration;
}
use of org.activiti.engine.form.AbstractFormType in project Activiti by Activiti.
the class ProcessEngineConfigurationImpl method initFormTypes.
protected void initFormTypes() {
if (formTypes == null) {
formTypes = new FormTypes();
formTypes.addFormType(new StringFormType());
formTypes.addFormType(new LongFormType());
formTypes.addFormType(new DateFormType("dd/MM/yyyy"));
formTypes.addFormType(new BooleanFormType());
formTypes.addFormType(new DoubleFormType());
}
if (customFormTypes != null) {
for (AbstractFormType customFormType : customFormTypes) {
formTypes.addFormType(customFormType);
}
}
}
use of org.activiti.engine.form.AbstractFormType in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowTaskInstanceService method resovleFormProperty.
/**
* Convert form property and add to result dto
*
* @param property
* @param dto
* @param canExecute
*/
@SuppressWarnings("unchecked")
private void resovleFormProperty(FormProperty property, WorkflowTaskInstanceDto dto, boolean canExecute) {
FormType formType = property.getType();
if (formType instanceof DecisionFormType) {
// task
if (!canExecute) {
return;
}
DecisionFormTypeDto decisionDto = (DecisionFormTypeDto) ((DecisionFormType) formType).convertFormValueToModelValue(property.getValue());
if (decisionDto != null) {
decisionDto.setId(property.getId());
setDecisionReasonRequired(decisionDto);
dto.getDecisions().add(decisionDto);
}
} else if (formType instanceof TaskHistoryFormType) {
WorkflowFilterDto filterDto = new WorkflowFilterDto();
filterDto.setProcessInstanceId(dto.getProcessInstanceId());
List<WorkflowHistoricTaskInstanceDto> tasks = historicTaskInstanceService.find(filterDto, PageRequest.of(0, 50)).getContent();
List<WorkflowHistoricTaskInstanceDto> history = tasks.stream().filter(workflowHistoricTaskInstanceDto -> workflowHistoricTaskInstanceDto.getEndTime() != null).sorted((o1, o2) -> {
if (o1.getEndTime().before(o2.getEndTime())) {
return -1;
} else if (o1.getEndTime().after(o2.getEndTime())) {
return 1;
}
return 0;
}).collect(Collectors.toList());
dto.getFormData().add(historyToResource(property, history));
} else if (formType instanceof AbstractFormType) {
// To rest will be add only component form type marked as "exportable to rest".
if (formType instanceof AbstractComponentFormType && !((AbstractComponentFormType) formType).isExportableToRest()) {
return;
}
Object values = formType.getInformation("values");
if (values instanceof Map<?, ?>) {
dto.getFormData().add(toResource(property, (Map<String, String>) values));
} else {
dto.getFormData().add(toResource(property, null));
}
}
}
Aggregations