Search in sources :

Example 1 with FormType

use of org.activiti.engine.form.FormType 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

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 SecurityService (eu.bcvsolutions.idm.core.security.api.service.SecurityService)1 AbstractComponentFormType (eu.bcvsolutions.idm.core.workflow.domain.formtype.AbstractComponentFormType)1 DecisionFormType (eu.bcvsolutions.idm.core.workflow.domain.formtype.DecisionFormType)1 TaskHistoryFormType (eu.bcvsolutions.idm.core.workflow.domain.formtype.TaskHistoryFormType)1 DecisionFormTypeDto (eu.bcvsolutions.idm.core.workflow.model.dto.DecisionFormTypeDto)1