Search in sources :

Example 1 with WorkflowDeploymentDto

use of eu.bcvsolutions.idm.core.workflow.api.dto.WorkflowDeploymentDto in project CzechIdMng by bcvsolutions.

the class BasicEmailTest method testSendEmailFromWorkflow.

/**
 * Send email through {@link EmailNotificationSender}
 */
@Test
public void testSendEmailFromWorkflow() {
    // Deploy process - annotation @Deployment can't be used - we need custom behavior to work
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("eu/bcvsolutions/idm/workflow/deploy/testEmailer.bpmn20.xml");
    WorkflowDeploymentDto deploymentDto = processDeploymentService.create(PROCESS_KEY, "testEmailer.bpmn20.xml", is);
    IdmNotificationFilter filter = new IdmNotificationFilter();
    // 
    Assert.assertNotNull(deploymentDto);
    filter.setText(EMAIL_TEXT);
    filter.setRecipient(EMAIL_RECIPIENT);
    Assert.assertEquals(0, emailLogService.find(filter, null).getTotalElements());
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_KEY);
    // 
    Assert.assertTrue(instance.isEnded());
    long count = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_KEY).count();
    Assert.assertEquals(0, count);
    Assert.assertEquals(1, emailLogService.find(filter, null).getTotalElements());
}
Also used : RuntimeService(org.activiti.engine.RuntimeService) InputStream(java.io.InputStream) WorkflowDeploymentDto(eu.bcvsolutions.idm.core.workflow.api.dto.WorkflowDeploymentDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Test(org.junit.Test) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)

Example 2 with WorkflowDeploymentDto

use of eu.bcvsolutions.idm.core.workflow.api.dto.WorkflowDeploymentDto in project CzechIdMng by bcvsolutions.

the class WorkflowDefinitionController method post.

/**
 * Upload new deployment to Activiti engine
 *
 * @param name
 * @param fileName
 * @param data
 * @return
 * @throws IOException
 */
@ResponseBody
@RequestMapping(method = RequestMethod.POST)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.WORKFLOW_DEFINITION_CREATE + "') or hasAuthority('" + CoreGroupPermission.WORKFLOW_DEFINITION_UPDATE + "')")
@ApiOperation(value = "Create / update workflow definition", nickname = "postWorkflowDefinition", response = WorkflowDeploymentDto.class, tags = { WorkflowDefinitionController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_CREATE, description = ""), @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_CREATE, description = ""), @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_UPDATE, description = "") }) }, notes = "Upload new deployment to Activiti engine." + " If definition with iven key exists, new deployment version is added." + " All running task instances process with their deployment version." + " Newly added version will be used for new instances.")
public Resource<WorkflowDeploymentDto> post(String name, String fileName, MultipartFile data) throws IOException {
    WorkflowDeploymentDto deployment = deploymentService.create(name, fileName, data.getInputStream());
    Link selfLink = ControllerLinkBuilder.linkTo(this.getClass()).slash(deployment.getId()).withSelfRel();
    return new Resource<WorkflowDeploymentDto>(deployment, selfLink);
}
Also used : InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.hateoas.Resource) WorkflowDeploymentDto(eu.bcvsolutions.idm.core.workflow.api.dto.WorkflowDeploymentDto) Link(org.springframework.hateoas.Link) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

WorkflowDeploymentDto (eu.bcvsolutions.idm.core.workflow.api.dto.WorkflowDeploymentDto)2 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)1 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)1 ApiOperation (io.swagger.annotations.ApiOperation)1 InputStream (java.io.InputStream)1 RuntimeService (org.activiti.engine.RuntimeService)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 Test (org.junit.Test)1 InputStreamResource (org.springframework.core.io.InputStreamResource)1 Link (org.springframework.hateoas.Link)1 Resource (org.springframework.hateoas.Resource)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1