Search in sources :

Example 1 with AbstractFormType

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);
    }
}
Also used : ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) Expression(org.activiti.engine.delegate.Expression) AbstractFormType(org.activiti.engine.form.AbstractFormType)

Example 2 with AbstractFormType

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;
}
Also used : MonthFormType(org.activiti.explorer.form.MonthFormType) ProcessDefinitionFormType(org.activiti.explorer.form.ProcessDefinitionFormType) SpringProcessEngineConfiguration(org.activiti.spring.SpringProcessEngineConfiguration) ArrayList(java.util.ArrayList) UserFormType(org.activiti.explorer.form.UserFormType) AbstractFormType(org.activiti.engine.form.AbstractFormType) ProcessEngineFactoryBean(org.activiti.spring.ProcessEngineFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with AbstractFormType

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;
}
Also used : MonthFormType(org.activiti.rest.form.MonthFormType) ProcessDefinitionFormType(org.activiti.rest.form.ProcessDefinitionFormType) SpringProcessEngineConfiguration(org.activiti.spring.SpringProcessEngineConfiguration) ArrayList(java.util.ArrayList) UserFormType(org.activiti.rest.form.UserFormType) AbstractFormType(org.activiti.engine.form.AbstractFormType) ProcessEngineFactoryBean(org.activiti.spring.ProcessEngineFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with AbstractFormType

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);
        }
    }
}
Also used : FormTypes(org.activiti.engine.impl.form.FormTypes) StringFormType(org.activiti.engine.impl.form.StringFormType) DoubleFormType(org.activiti.engine.impl.form.DoubleFormType) DateFormType(org.activiti.engine.impl.form.DateFormType) AbstractFormType(org.activiti.engine.form.AbstractFormType) LongFormType(org.activiti.engine.impl.form.LongFormType) BooleanFormType(org.activiti.engine.impl.form.BooleanFormType)

Example 5 with AbstractFormType

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));
        }
    }
}
Also used : DecisionFormType(eu.bcvsolutions.idm.core.workflow.domain.formtype.DecisionFormType) Date(java.util.Date) FormDataDto(eu.bcvsolutions.idm.core.workflow.model.dto.FormDataDto) Autowired(org.springframework.beans.factory.annotation.Autowired) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) AbstractComponentFormType(eu.bcvsolutions.idm.core.workflow.domain.formtype.AbstractComponentFormType) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) SecurityService(eu.bcvsolutions.idm.core.security.api.service.SecurityService) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) AbstractBaseDtoService(eu.bcvsolutions.idm.core.rest.AbstractBaseDtoService) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) BasePermission(eu.bcvsolutions.idm.core.security.api.domain.BasePermission) WorkflowTaskInstanceService(eu.bcvsolutions.idm.core.workflow.service.WorkflowTaskInstanceService) Pageable(org.springframework.data.domain.Pageable) TaskQuery(org.activiti.engine.task.TaskQuery) IdentityLink(org.activiti.engine.task.IdentityLink) ImmutableMap(com.google.common.collect.ImmutableMap) FormType(org.activiti.engine.form.FormType) Set(java.util.Set) PageRequest(org.springframework.data.domain.PageRequest) TaskHistoryFormType(eu.bcvsolutions.idm.core.workflow.domain.formtype.TaskHistoryFormType) UUID(java.util.UUID) TaskInfo(org.activiti.engine.task.TaskInfo) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) AbstractFormType(org.activiti.engine.form.AbstractFormType) List(java.util.List) PageImpl(org.springframework.data.domain.PageImpl) WorkflowProcessDefinitionService(eu.bcvsolutions.idm.core.workflow.service.WorkflowProcessDefinitionService) TaskService(org.activiti.engine.TaskService) HashMap(java.util.HashMap) IdentityLinkType(org.activiti.engine.task.IdentityLinkType) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Strings(com.google.common.base.Strings) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) Service(org.springframework.stereotype.Service) WorkflowProcessInstanceService(eu.bcvsolutions.idm.core.workflow.service.WorkflowProcessInstanceService) TaskFormData(org.activiti.engine.form.TaskFormData) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowHistoricTaskInstanceService(eu.bcvsolutions.idm.core.workflow.service.WorkflowHistoricTaskInstanceService) IdentityLinkDto(eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto) Task(org.activiti.engine.task.Task) FormService(org.activiti.engine.FormService) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) FormProperty(org.activiti.engine.form.FormProperty) WorkflowTaskDefinitionService(eu.bcvsolutions.idm.core.workflow.service.WorkflowTaskDefinitionService) WorkflowHistoricTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) WorkflowProcessDefinitionDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto) DecisionFormTypeDto(eu.bcvsolutions.idm.core.workflow.model.dto.DecisionFormTypeDto) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) Assert(org.springframework.util.Assert) AbstractComponentFormType(eu.bcvsolutions.idm.core.workflow.domain.formtype.AbstractComponentFormType) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) TaskHistoryFormType(eu.bcvsolutions.idm.core.workflow.domain.formtype.TaskHistoryFormType) DecisionFormType(eu.bcvsolutions.idm.core.workflow.domain.formtype.DecisionFormType) AbstractComponentFormType(eu.bcvsolutions.idm.core.workflow.domain.formtype.AbstractComponentFormType) FormType(org.activiti.engine.form.FormType) TaskHistoryFormType(eu.bcvsolutions.idm.core.workflow.domain.formtype.TaskHistoryFormType) AbstractFormType(org.activiti.engine.form.AbstractFormType) DecisionFormType(eu.bcvsolutions.idm.core.workflow.domain.formtype.DecisionFormType) List(java.util.List) ArrayList(java.util.ArrayList) AbstractFormType(org.activiti.engine.form.AbstractFormType) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) DecisionFormTypeDto(eu.bcvsolutions.idm.core.workflow.model.dto.DecisionFormTypeDto)

Aggregations

AbstractFormType (org.activiti.engine.form.AbstractFormType)5 ArrayList (java.util.ArrayList)3 ProcessEngineFactoryBean (org.activiti.spring.ProcessEngineFactoryBean)2 SpringProcessEngineConfiguration (org.activiti.spring.SpringProcessEngineConfiguration)2 Bean (org.springframework.context.annotation.Bean)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Strings (com.google.common.base.Strings)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)1 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 ConfigurationService (eu.bcvsolutions.idm.core.api.service.ConfigurationService)1 LookupService (eu.bcvsolutions.idm.core.api.service.LookupService)1 CoreGroupPermission (eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission)1 AbstractBaseDtoService (eu.bcvsolutions.idm.core.rest.AbstractBaseDtoService)1 BasePermission (eu.bcvsolutions.idm.core.security.api.domain.BasePermission)1 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)1