Search in sources :

Example 6 with WorkflowProcessDefinitionDto

use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto in project CzechIdMng by bcvsolutions.

the class WorkflowDefinitionController method getDiagram.

/**
 * Generate process definition diagram image
 *
 * @param definitionKey
 * @return
 */
@RequestMapping(value = "/{backendId}/diagram", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.WORKFLOW_DEFINITION_READ + "')")
@ApiOperation(value = "Workflow definition diagram", nickname = "getWorkflowDefinitionDiagram", tags = { WorkflowDefinitionController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_READ, description = "") }) }, notes = "Returns input stream to definition's diagram.")
public ResponseEntity<InputStreamResource> getDiagram(@ApiParam(value = "Workflow definition key.", required = true) @PathVariable String backendId) {
    // check rights
    WorkflowProcessDefinitionDto result = definitionService.getByName(backendId);
    if (result == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
    }
    InputStream is = definitionService.getDiagramByKey(backendId);
    try {
        return ResponseEntity.ok().contentLength(is.available()).contentType(MediaType.IMAGE_PNG).body(new InputStreamResource(is));
    } catch (IOException e) {
        throw new ResultCodeException(CoreResultCode.INTERNAL_SERVER_ERROR, e);
    }
}
Also used : InputStream(java.io.InputStream) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IOException(java.io.IOException) WorkflowProcessDefinitionDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto) InputStreamResource(org.springframework.core.io.InputStreamResource) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with WorkflowProcessDefinitionDto

use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto in project CzechIdMng by bcvsolutions.

the class DefaultWorkflowHistoricTaskInstanceService method toResource.

private WorkflowHistoricTaskInstanceDto toResource(HistoricTaskInstance instance) {
    if (instance == null) {
        return null;
    }
    WorkflowHistoricTaskInstanceDto dto = new WorkflowHistoricTaskInstanceDto();
    // Not working ... variables are not local but global in process scope
    // ... may be logged level?
    // if(instance.getTaskLocalVariables() != null &&
    // instance.getTaskLocalVariables().containsKey(WorkflowHistoricTaskInstanceService.TASK_COMPLETE_DECISION)){
    // dto.setCompleteTaskDecision((String)
    // instance.getTaskLocalVariables().get(WorkflowHistoricTaskInstanceService.TASK_COMPLETE_DECISION));
    // }
    dto.setId(instance.getId());
    dto.setName(instance.getName());
    dto.setProcessDefinitionId(instance.getProcessDefinitionId());
    dto.setTaskVariables(instance.getTaskLocalVariables());
    dto.setDeleteReason(instance.getDeleteReason());
    dto.setDurationInMillis(instance.getDurationInMillis());
    dto.setEndTime(instance.getEndTime());
    dto.setStartTime(instance.getStartTime());
    dto.setPriority(instance.getPriority());
    dto.setAssignee(instance.getAssignee());
    dto.setCreateTime(instance.getCreateTime());
    dto.setDueDate(instance.getDueDate());
    List<HistoricIdentityLink> identityLinks = historyService.getHistoricIdentityLinksForTask(instance.getId());
    if (identityLinks != null && !identityLinks.isEmpty()) {
        List<String> candicateUsers = new ArrayList<>();
        for (HistoricIdentityLink identity : identityLinks) {
            if (IdentityLinkType.CANDIDATE.equals(identity.getType())) {
                candicateUsers.add(identity.getUserId());
            }
        }
        dto.setCandicateUsers(candicateUsers);
    }
    dto.setDefinition(workflowTaskDefinitionService.searchTaskDefinitionById(dto.getProcessDefinitionId(), instance.getTaskDefinitionKey()));
    if (!Strings.isNullOrEmpty(dto.getProcessDefinitionId())) {
        WorkflowProcessDefinitionDto processDefinition = workflowProcessDefinitionService.get(dto.getProcessDefinitionId());
        if (processDefinition != null) {
            dto.setProcessDefinitionKey(processDefinition.getKey());
        }
    }
    return dto;
}
Also used : HistoricIdentityLink(org.activiti.engine.history.HistoricIdentityLink) ArrayList(java.util.ArrayList) WorkflowProcessDefinitionDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto) WorkflowHistoricTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto)

Example 8 with WorkflowProcessDefinitionDto

use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto in project CzechIdMng by bcvsolutions.

the class DefaultWorkflowTaskInstanceService method toResource.

private WorkflowTaskInstanceDto toResource(Task task) {
    if (task == null) {
        return null;
    }
    WorkflowTaskInstanceDto dto = new WorkflowTaskInstanceDto();
    dto.setId(task.getId());
    dto.setCreated(task.getCreateTime());
    dto.setFormKey(task.getFormKey());
    dto.setAssignee(task.getAssignee());
    dto.setName(task.getName());
    dto.setDescription(task.getDescription());
    dto.setProcessInstanceId(task.getProcessInstanceId());
    Map<String, Object> taksVariables = task.getTaskLocalVariables();
    Map<String, Object> processVariables = task.getProcessVariables();
    // Add applicant username to task dto (for easier work)
    if (processVariables != null && processVariables.containsKey(WorkflowProcessInstanceService.APPLICANT_IDENTIFIER)) {
        dto.setApplicant((String) processVariables.get(WorkflowProcessInstanceService.APPLICANT_IDENTIFIER).toString());
    }
    dto.setVariables(processVariables);
    convertToDtoVariables(dto, taksVariables);
    dto.setDefinition(workflowTaskDefinitionService.searchTaskDefinitionById(task.getProcessDefinitionId(), task.getTaskDefinitionKey()));
    if (!Strings.isNullOrEmpty(task.getProcessDefinitionId())) {
        WorkflowProcessDefinitionDto processDefinition = workflowProcessDefinitionService.get(task.getProcessDefinitionId());
        if (processDefinition != null) {
            dto.setProcessDefinitionKey(processDefinition.getKey());
        }
    }
    TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    // Add form data (it means form properties and value from WF)
    List<FormProperty> formProperties = taskFormData.getFormProperties();
    // Search and add identity links to dto (It means all user
    // (assigned/candidates/group) for this task)
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
    if (identityLinks != null) {
        List<IdentityLinkDto> identityLinksDtos = new ArrayList<>();
        for (IdentityLink il : identityLinks) {
            identityLinksDtos.add(toResource(il));
        }
        dto.getIdentityLinks().addAll(identityLinksDtos);
    }
    // Check if the logged user can complete this task
    boolean canExecute = this.canExecute(dto);
    if (formProperties != null && !formProperties.isEmpty()) {
        for (FormProperty property : formProperties) {
            resovleFormProperty(property, dto, canExecute);
        }
    }
    return dto;
}
Also used : FormProperty(org.activiti.engine.form.FormProperty) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) ArrayList(java.util.ArrayList) TaskFormData(org.activiti.engine.form.TaskFormData) IdentityLink(org.activiti.engine.task.IdentityLink) IdentityLinkDto(eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto) WorkflowProcessDefinitionDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto)

Example 9 with WorkflowProcessDefinitionDto

use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto in project CzechIdMng by bcvsolutions.

the class DeployAndRunProcessTest method testMultipleAutoDeployDefinitionLocations.

@Test
public void testMultipleAutoDeployDefinitionLocations() {
    WorkflowProcessDefinitionDto definitionTwo = definitionService.getByName(TEST_PROCESS_KEY_TWO);
    // 
    Assert.assertNotNull(definitionTwo);
}
Also used : WorkflowProcessDefinitionDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Aggregations

WorkflowProcessDefinitionDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto)9 ArrayList (java.util.ArrayList)4 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)2 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)2 ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)2 Test (org.junit.Test)2 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 ResourceWrapper (eu.bcvsolutions.idm.core.api.rest.domain.ResourceWrapper)1 IdentityLinkDto (eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto)1 WorkflowHistoricTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto)1 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)1 WorkflowDefinitionController (eu.bcvsolutions.idm.core.workflow.rest.WorkflowDefinitionController)1 ApiOperation (io.swagger.annotations.ApiOperation)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 FormProperty (org.activiti.engine.form.FormProperty)1 TaskFormData (org.activiti.engine.form.TaskFormData)1 HistoricIdentityLink (org.activiti.engine.history.HistoricIdentityLink)1 IdentityLink (org.activiti.engine.task.IdentityLink)1 InputStreamResource (org.springframework.core.io.InputStreamResource)1