Package org.activiti.engine

Examples of org.activiti.engine.TaskService


      .setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000")
      .setJobExecutorActivate(false)
      .buildProcessEngine();
    RepositoryService repositoryService2 = processEngine2.getRepositoryService();
    RuntimeService runtimeService2 = processEngine2.getRuntimeService();
    TaskService taskService2 = processEngine2.getTaskService();
   
    // Deploy first version of process: start->originalTask->end on first process engine
    String deploymentId = repositoryService1.createDeployment()
      .addClasspathResource("org/activiti/engine/test/cache/originalProcess.bpmn20.xml")
      .deploy()
      .getId();
   
    // Start process instance on second engine
    String processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId();
    runtimeService2.startProcessInstanceById(processDefinitionId);
    Task task = taskService2.createTaskQuery().singleResult();
    assertEquals("original task", task.getName());
   
    // Delete the deployment on second process engine
    repositoryService2.deleteDeployment(deploymentId, true);
    assertEquals(0, repositoryService2.createDeploymentQuery().count());
    assertEquals(0, runtimeService2.createProcessInstanceQuery().count());
   
    // deploy a revised version of the process: start->revisedTask->end on first process engine
    //
    // Before the bugfix, this would set the cache on the first process engine,
    // but the second process engine still has the original process definition in his cache.
    // Since there is a deployment delete in between, the new generated process definition id is the same
    // as in the original deployment, making the second process engine using the old cached process definition.
    deploymentId = repositoryService1.createDeployment()
      .addClasspathResource("org/activiti/engine/test/cache/revisedProcess.bpmn20.xml")
      .deploy()
      .getId();
   
    // Start process instance on second process engine -> must use revised process definition
    repositoryService2.createProcessDefinitionQuery().singleResult().getId();
    runtimeService2.startProcessInstanceByKey("oneTaskProcess");
    task = taskService2.createTaskQuery().singleResult();
    assertEquals("revised task", task.getName());
   
    // cleanup
    repositoryService1.deleteDeployment(deploymentId, true);
    processEngine1.close();
View Full Code Here


    Label description = new Label(attachment.getDescription());
    description.setSizeUndefined();
    verticalLayout.addComponent(description);
   
    // Image
    TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
   
    String mimeType = extractMineType(attachment.getType());
   
    InputStream imageStream = ImageUtil.resizeImage(taskService.getAttachmentContent(attachment.getId()), mimeType, 900, 550);
    Resource resource = new StreamResource(new InputStreamStreamSource(imageStream),
            attachment.getName() + extractExtention(attachment.getType()),ExplorerApp.get());
    Embedded image = new Embedded(null, resource);
    verticalLayout.addComponent(image);
   
    // Linke
    HorizontalLayout LinkLayout = new HorizontalLayout();
    LinkLayout.setSpacing(true);
    verticalLayout.addComponent(LinkLayout);
    verticalLayout.setComponentAlignment(LinkLayout, Alignment.MIDDLE_CENTER);
   
    Label fullSizeLabel = new Label(ExplorerApp.get().getI18nManager().getMessage(Messages.RELATED_CONTENT_SHOW_FULL_SIZE));
    LinkLayout.addComponent(fullSizeLabel);
   
    Link link = null;
    if(attachment.getUrl() != null) {
      link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    } else {
      taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
      Resource res = new StreamResource(new InputStreamStreamSource(taskService.getAttachmentContent(attachment.getId())),
              attachment.getName() + extractExtention(attachment.getType()),ExplorerApp.get());
     
      link = new Link(attachment.getName(), res);
    }
   
View Full Code Here

    public ActivitiContextFactoryImpl.CustomStandaloneProcessEngineConfiguration getCustomStandaloneProcessEngineConfiguration() {
        return customStandaloneProcessEngineConfiguration;
    }
   
    public Map<String, Object> getBpmVariables(ProcessInstance pi) {
        TaskService es = getProcessEngine().getTaskService();
        return es.getVariables(pi.getInternalId());
    }
View Full Code Here

        TaskService es = getProcessEngine().getTaskService();
        return es.getVariables(pi.getInternalId());
    }

  public Object getBpmVariable(ProcessInstance pi, String variableName) {
    TaskService es = getProcessEngine().getTaskService();
    return es.getVariable(pi.getInternalId(), variableName);
  }
View Full Code Here

    variableMap.put("users", Arrays.asList(new Object[] {"user1", "user2", "user3"}));
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("MultiInstanceBug", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    List<Task> list = taskService.createTaskQuery().list();
   
    taskService.complete(list.get(0).getId());
    taskService.complete(list.get(1).getId());
    taskService.complete(list.get(2).getId());
  }
View Full Code Here

    variableMap.put("userGroup", new ArrayList<String>());
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("leave-qjsq", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    assertEquals(1, taskService.createTaskQuery().count());
   
    List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskService.createTaskQuery().singleResult().getId());
    assertEquals(2, identityLinksForTask.size());
  }
View Full Code Here

                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);

                if (userId == null) {
                    return;
                }
                System.out.println("key: " + taskDefinitionKey + ", userId=" + userId);

                // 查询当前人的组
                List<String> groupIds = new ArrayList<>();
                List<Group> list = identityService.createGroupQuery().groupMember(userId).list();
                for (Group group : list) {
                    groupIds.add(group.getId());
                }

                // 如果当前节点是需要跳过的,直接调用任务完成命令
                if (event.getType().equals(ActivitiEventType.TASK_ASSIGNED)) {
                    if (userId != null) {
                        if (taskEntity.getAssignee().equals(userId)) {
                            skipTask(taskEntity, event);
                        }
                    }
                }

                // 创建事件用来处理候选的情况
                if (event.getType().equals(ActivitiEventType.TASK_CREATED) && taskEntity.getAssignee() == null) {
                    Set<IdentityLink> candidates = taskEntity.getCandidates();
                    for (IdentityLink identityLink : candidates) {
                        // 处理候选人
                        if (identityLink.getUserId() != null && identityLink.getUserId().equals(userId)) {
                            // 必须删除link,否则报错
                            taskEntity.deleteUserIdentityLink(identityLink.getUserId(), "candidate");

                            // 签收触发TASK_ASSIGNED
                            taskService.claim(taskEntity.getId(), userId);
                        } else if (groupIds.contains(identityLink.getGroupId())) {
                            // 必须删除link,否则报错
                            taskEntity.deleteGroupIdentityLink(identityLink.getGroupId(), "candidate");

                            // 签收触发TASK_ASSIGNED
                            taskService.claim(taskEntity.getId(), userId);
                        }
                    }
                }
            }
        } else {
View Full Code Here

        }
    }

    private void skipTask(TaskEntity taskEntity, ActivitiEvent event) {
        ManagementService managementService = event.getEngineServices().getManagementService();
        TaskService taskService = event.getEngineServices().getTaskService();
        String taskDefinitionKey = taskEntity.getTaskDefinitionKey();
        if (skipedTasks.contains(taskDefinitionKey)) {
            return;
        }
        // 设置变量
        Map<String, Object> variables = new HashMap<String, Object>();
        variables.put("skip", true);
        CompleteTaskCmd command = new CompleteTaskCmd(taskEntity.getId(), variables, true);

        taskService.addComment(taskEntity.getId(), taskEntity.getProcessInstanceId(), "自动跳过");

        // 执行命令,直接完成当前任务
//        System.out.println("准备跳过任务:" + taskEntity.getName() + "-->" + taskDefinitionKey);
        managementService.executeCommand(command);
        System.out.println("已跳过任务:" + taskEntity.getName() + "-->" + taskDefinitionKey);
View Full Code Here

 
  public void run() {
   
    // UpgradeTaskOneTest
    RuntimeService runtimeService = processEngine.getRuntimeService();
    TaskService taskService = processEngine.getTaskService();

    processEngine.getRepositoryService()
      .createDeployment()
      .name("simpleTaskProcess")
      .addClasspathResource("org/activiti/upgrade/test/UserTaskBeforeTest.testSimplestTask.bpmn20.xml")
      .deploy();

    runtimeService.startProcessInstanceByKey("simpleTaskProcess");
    String taskId = taskService.createTaskQuery().singleResult().getId();
    taskService.complete(taskId);
   
    // UpgradeTaskTwoTest
    processEngine.getRepositoryService().createDeployment().name("simpleTaskProcess")
            .addClasspathResource("org/activiti/upgrade/test/UserTaskBeforeTest.testTaskWithExecutionVariables.bpmn20.xml")
            .deploy();
View Full Code Here

    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("EventSubprocess", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());

    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    variableMap = new HashMap<String, Object>();
    variableMap.put("pass", false);
    taskService.complete(task.getId(), variableMap);

    Task task2 = taskService.createTaskQuery().singleResult();
    assertNotNull(task2);
    taskService.complete(task2.getId());
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.TaskService

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.