Package org.activiti.engine.delegate.event

Examples of org.activiti.engine.delegate.event.ActivitiEntityEvent


    // Add candidate user and group
    repositoryService.addCandidateStarterUser(processDefinition.getId(), "kermit");
    repositoryService.addCandidateStarterGroup(processDefinition.getId(), "sales");
    assertEquals(4, listener.getEventsReceived().size());

    ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
    assertTrue(event.getEntity() instanceof IdentityLink);
    assertEquals(processDefinition.getId(), event.getProcessDefinitionId());
    assertNull(event.getProcessInstanceId());
    assertNull(event.getExecutionId());
   
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
    assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
   
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(2);
    assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
    assertTrue(event.getEntity() instanceof IdentityLink);
    assertEquals(processDefinition.getId(), event.getProcessDefinitionId());
    assertNull(event.getProcessInstanceId());
    assertNull(event.getExecutionId());
   
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(3);
    assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
    listener.clearEventsReceived();

    // Delete identity links
    repositoryService.deleteCandidateStarterUser(processDefinition.getId(), "kermit");
    repositoryService.deleteCandidateStarterGroup(processDefinition.getId(), "sales");
    assertEquals(2, listener.getEventsReceived().size());
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
    assertTrue(event.getEntity() instanceof IdentityLink);
    assertEquals(processDefinition.getId(), event.getProcessDefinitionId());
    assertNull(event.getProcessInstanceId());
    assertNull(event.getExecutionId());
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
    assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
    assertTrue(event.getEntity() instanceof IdentityLink);
    assertEquals(processDefinition.getId(), event.getProcessDefinitionId());
    assertNull(event.getProcessInstanceId());
    assertNull(event.getExecutionId());
  }
View Full Code Here


    // Check create-event one main process the second one Scope execution, and the third one subprocess
    assertEquals(6, listener.getEventsReceived().size());
    assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);

    ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
    assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getId());
    assertEquals(processInstance.getId(), event.getProcessInstanceId());
    assertEquals(processInstance.getId(), event.getExecutionId());
    assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
   
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
    assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
    assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getId());

    event = (ActivitiEntityEvent) listener.getEventsReceived().get(2);
    assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
    assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getParentId());
   
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(3);
    assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
    assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getParentId());

    event = (ActivitiEntityEvent) listener.getEventsReceived().get(4);
    assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
    assertEquals("simpleSubProcess", ((ExecutionEntity) event.getEntity()).getProcessDefinition().getKey());

    event = (ActivitiEntityEvent) listener.getEventsReceived().get(5);
    assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
    assertEquals("simpleSubProcess", ((ExecutionEntity) event.getEntity()).getProcessDefinition().getKey());

    listener.clearEventsReceived();
  }
View Full Code Here

      // Check create-event
      assertEquals(2, listener.getEventsReceived().size());
      assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);
     
      ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
      assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getId());
      assertEquals(processInstance.getId(), event.getProcessInstanceId());
      assertEquals(processInstance.getId(), event.getExecutionId());
      assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
            assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
            assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getId());
            assertEquals(processInstance.getId(), event.getProcessInstanceId());
            assertEquals(processInstance.getId(), event.getExecutionId());
            assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
      listener.clearEventsReceived();

      // Check update event when suspended/activated
      runtimeService.suspendProcessInstanceById(processInstance.getId());
      runtimeService.activateProcessInstanceById(processInstance.getId());
     
      assertEquals(2, listener.getEventsReceived().size());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getId());
      assertEquals(ActivitiEventType.ENTITY_SUSPENDED, event.getType());
      assertEquals(processInstance.getId(), event.getProcessInstanceId());
      assertEquals(processInstance.getId(), event.getExecutionId());
      assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
      assertEquals(ActivitiEventType.ENTITY_ACTIVATED, event.getType());
      assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getId());
      assertEquals(processInstance.getId(), event.getProcessInstanceId());
      assertEquals(processInstance.getId(), event.getExecutionId());
      assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
      listener.clearEventsReceived();
     
      // Check update event when process-definition is supended (should cascade suspend/activate all process instances)
      repositoryService.suspendProcessDefinitionById(processInstance.getProcessDefinitionId(), true, null);
      repositoryService.activateProcessDefinitionById(processInstance.getProcessDefinitionId(), true, null);
     
      assertEquals(2, listener.getEventsReceived().size());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getId());
      assertEquals(ActivitiEventType.ENTITY_SUSPENDED, event.getType());
      assertEquals(processInstance.getId(), event.getProcessInstanceId());
      assertEquals(processInstance.getId(), event.getExecutionId());
      assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
      assertEquals(ActivitiEventType.ENTITY_ACTIVATED, event.getType());
      assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getId());
      assertEquals(processInstance.getId(), event.getProcessInstanceId());
      assertEquals(processInstance.getId(), event.getExecutionId());
      assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
      listener.clearEventsReceived();
     
      // Check update-event when business-key is updated
      runtimeService.updateBusinessKey(processInstance.getId(), "thekey");
      assertEquals(1, listener.getEventsReceived().size());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getId());
      assertEquals(ActivitiEventType.ENTITY_UPDATED, event.getType());
      assertEquals(processInstance.getId(), event.getProcessInstanceId());
      assertEquals(processInstance.getId(), event.getExecutionId());
      assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
      listener.clearEventsReceived();
     
      runtimeService.deleteProcessInstance(processInstance.getId(), "Testing events");
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
      assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getId());
      assertEquals(processInstance.getId(), event.getProcessInstanceId());
      assertEquals(processInstance.getId(), event.getExecutionId());
      assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
      listener.clearEventsReceived();
  }
View Full Code Here

    @Override
    public void onEvent(ActivitiEvent event) {
        if (event.getType().equals(ActivitiEventType.TASK_CREATED)
                || event.getType().equals(ActivitiEventType.TASK_ASSIGNED)) {
            ActivitiEntityEvent entityEvent = (ActivitiEntityEvent) event;

            Object entity = entityEvent.getEntity();
            if (entity instanceof TaskEntity) {
                TaskEntity taskEntity = (TaskEntity) entityEvent.getEntity();

                Map<String, String> skipTasks = new HashMap<>();
                skipTasks.put("usertask2", "user1"); // 预先设定
                skipTasks.put("usertask4", "user1"); // 动态设定以
                skipTasks.put("usertask5", "user1"); // 候选人
                skipTasks.put("usertask6", "user1"); // 候选组

                EngineServices engineServices = entityEvent.getEngineServices();
                IdentityService identityService = engineServices.getIdentityService();
                TaskService taskService = engineServices.getTaskService();

                String taskDefinitionKey = taskEntity.getTaskDefinitionKey();
                String userId = skipTasks.get(taskDefinitionKey);
View Full Code Here

TOP

Related Classes of org.activiti.engine.delegate.event.ActivitiEntityEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.