當前位置: 首頁>>代碼示例>>Java>>正文


Java TaskService類代碼示例

本文整理匯總了Java中org.activiti.engine.TaskService的典型用法代碼示例。如果您正苦於以下問題:Java TaskService類的具體用法?Java TaskService怎麽用?Java TaskService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TaskService類屬於org.activiti.engine包,在下文中一共展示了TaskService類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setTaskProperties

import org.activiti.engine.TaskService; //導入依賴的package包/類
/**
 * Sets the properties on the task, using Activiti API.
 */
public void setTaskProperties(Task task, Map<QName, Serializable> properties)
{
    if(properties==null || properties.isEmpty())
        return;
    
    TypeDefinition type = typeManager.getFullTaskDefinition(task);
    Map<String, Object> variablesToSet = handlerRegistry.handleVariablesToSet(properties, type, task, Task.class);

    TaskService taskService = activitiUtil.getTaskService();
    
    // Will be set when an assignee is present in passed properties. 
    taskService.saveTask(task);            

    // Set the collected variables on the task
    taskService.setVariablesLocal(task.getId(), variablesToSet);

    setTaskOwner(task, properties);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:22,代碼來源:ActivitiPropertyConverter.java

示例2: getEngineServices

import org.activiti.engine.TaskService; //導入依賴的package包/類
@Override
public EngineServices getEngineServices() {
    if (this.engineServicesMock != null) {
        return this.engineServicesMock;
    }

    this.engineServicesMock = mock(EngineServices.class);
    when(engineServicesMock.getFormService()).thenReturn(mock(FormService.class));
    when(engineServicesMock.getHistoryService()).thenReturn(mock(HistoryService.class));
    when(engineServicesMock.getIdentityService()).thenReturn(mock(IdentityService.class));
    when(engineServicesMock.getManagementService()).thenReturn(mock(ManagementService.class));
    when(engineServicesMock.getRepositoryService()).thenReturn(mock(RepositoryService.class));
    when(engineServicesMock.getRuntimeService()).thenReturn(mock(RuntimeService.class));
    when(engineServicesMock.getTaskService()).thenReturn(mock(TaskService.class));

    return engineServicesMock;
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:18,代碼來源:MockDelegateExecution.java

示例3: setVariable

import org.activiti.engine.TaskService; //導入依賴的package包/類
@Test
public void setVariable() {
    ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml").buildProcessEngine();
    logger.info("### ============= 創建Activiti流程引擎實例, {}", processEngine);

    TaskService taskService = processEngine.getTaskService();

    Task task = taskService.createTaskQuery()
            .processInstanceId("2501")
            .singleResult();

    taskService.setVariable(task.getId(), "流程變量名01", "流程變量值01");
    taskService.setVariable(task.getId(), "流程變量名02", "流程變量值02");
    taskService.setVariable(task.getId(), "流程變量名03", "流程變量值03");

    processEngine.close();
}
 
開發者ID:Lzw2016,項目名稱:study,代碼行數:18,代碼來源:Test01.java

示例4: getVariable

import org.activiti.engine.TaskService; //導入依賴的package包/類
@Test
public void getVariable() {
    ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml").buildProcessEngine();
    logger.info("### ============= 創建Activiti流程引擎實例, {}", processEngine);

    TaskService taskService = processEngine.getTaskService();

    Task task = taskService.createTaskQuery()
            .processInstanceId("2501")
            .singleResult();

    String tmp = taskService.getVariable(task.getId(), "流程變量名01", String.class);
    logger.info("### ==================== {}", tmp);
    tmp = taskService.getVariable(task.getId(), "流程變量名02", String.class);
    logger.info("### ==================== {}", tmp);
    tmp = taskService.getVariable(task.getId(), "流程變量名03", String.class);
    logger.info("### ==================== {}", tmp);

    processEngine.close();
}
 
開發者ID:Lzw2016,項目名稱:study,代碼行數:21,代碼來源:Test01.java

示例5: queryTask

import org.activiti.engine.TaskService; //導入依賴的package包/類
@Test
public void queryTask() throws Exception {
	
	String assignee = "張三";
	
	TaskService taskService = (TaskService) AppContext.getBean("taskService");
	List<Task> tasks = taskService.createTaskQuery().taskAssignee( assignee ).list();
	if (tasks == null || tasks.size()<1 ) {
		System.out.println("no task.");
		return;
	}
	for (Task task : tasks) {
		this.printTask(task);
	}
	
}
 
開發者ID:billchen198318,項目名稱:bamboobsc,代碼行數:17,代碼來源:TestBPMN001.java

示例6: completeTask

import org.activiti.engine.TaskService; //導入依賴的package包/類
@Test
public void completeTask() throws Exception {
	
	String assignee = "張三";
	//String assignee = "王經理";
			
	TaskService taskService = (TaskService) AppContext.getBean("taskService");
	List<Task> tasks = taskService.createTaskQuery().list();
	if (tasks == null || tasks.size()<1 ) {
		System.out.println("no task.");
		return;
	}
	for (Task task : tasks) {
		taskService.setAssignee(task.getId(), assignee);
		taskService.complete(task.getId());
		this.printTask(task);
	}
	
}
 
開發者ID:billchen198318,項目名稱:bamboobsc,代碼行數:20,代碼來源:TestBPMN001.java

示例7: main

import org.activiti.engine.TaskService; //導入依賴的package包/類
public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx =
            new AnnotationConfigApplicationContext();
    ctx.register(SpringAnnotationConfiguration.class);
    ctx.refresh();

    assertNotNull(ctx.getBean(ProcessEngine.class));
    assertNotNull(ctx.getBean(RuntimeService.class));
    TaskService bean = ctx.getBean(TaskService.class);
    assertNotNull(bean);
    assertNotNull(ctx.getBean(HistoryService.class));
    assertNotNull(ctx.getBean(RepositoryService.class));
    assertNotNull(ctx.getBean(ManagementService.class));
    assertNotNull(ctx.getBean(FormService.class));
    Task task = bean.newTask();
    task.setName("哈哈");
    bean.saveTask(task);
}
 
開發者ID:shawn-gogh,項目名稱:myjavacode,代碼行數:19,代碼來源:InitProcessEngineBySpringAnnotation.java

示例8: onEvent

import org.activiti.engine.TaskService; //導入依賴的package包/類
@Override
public void onEvent(ActivitiEvent event) {
    ActivitiEntityEvent entityEvent = (ActivitiEntityEvent) event;
    Object entity = entityEvent.getEntity();
    if (entity instanceof TaskEntity) {
        TaskEntity task = (TaskEntity) entity;
        String originUserId = task.getAssignee();
        String newUserId = userMap.get(originUserId);
        if (StringUtils.isNotBlank(newUserId)) {
            task.setAssignee(newUserId);
            TaskService taskService = event.getEngineServices().getTaskService();
            String message = getClass().getName() + "-> 任務[" + task.getName() + "]的辦理人[" +
                    originUserId + "]自動轉辦給了用戶[" + newUserId + "]";
            taskService.addComment(task.getId(), task.getProcessInstanceId(), "redirect", message);
        }
    }
}
 
開發者ID:shawn-gogh,項目名稱:myjavacode,代碼行數:18,代碼來源:TaskAutoRedirectGlobalEventListener.java

示例9: testSpringMaster

import org.activiti.engine.TaskService; //導入依賴的package包/類
@Test
public void testSpringMaster() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("mule/spring-master/spring-master.xml");

    MuleContext mc = (MuleContext) ctx.getBean("_muleContext");
    mc.start();

    RepositoryService repositoryService = (RepositoryService) ctx.getBean("repositoryService");
    repositoryService.createDeployment().addClasspathResource("mule/leaveWithMule.bpmn").deploy();

    RuntimeService runtimeService = (RuntimeService) ctx.getBean("runtimeService");

    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("days", 5);
    runtimeService.startProcessInstanceByKey("leaveWithMule", variableMap);

    TaskService taskService = (TaskService) ctx.getBean("taskService");
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    assertEquals("部門經理審批", task.getName());

    mc.stop();
}
 
開發者ID:shawn-gogh,項目名稱:myjavacode,代碼行數:24,代碼來源:ActivitiWithMuleTest.java

示例10: main

import org.activiti.engine.TaskService; //導入依賴的package包/類
public static void main(String[] args) {
	// 創建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	// 得到流程存儲服務組件
	RepositoryService repositoryService = engine.getRepositoryService();
	// 得到運行時服務組件
	RuntimeService runtimeService = engine.getRuntimeService();
	// 得到任務服務組件
	TaskService taskService = engine.getTaskService();
	// 得到管理服務組件
	ManagementService managementService = engine.getManagementService();
	// 部署流程文件
	repositoryService.createDeployment()
			.addClasspathResource("bpmn/SignalThrowingEvent.bpmn").deploy();
	// 啟動流程
	runtimeService.startProcessInstanceByKey("stProcess");
	// 完成選擇商品任務
	Task firstTask = taskService.createTaskQuery().singleResult();
	taskService.complete(firstTask.getId());
	// 完成用戶支付任務
	Task payTask = taskService.createTaskQuery().singleResult();
	taskService.complete(payTask.getId());
	// 由於使用了異步的中間Throwing事件,因此會產生2條工作數據
	List<Job> jobs = managementService.createJobQuery().list();
	System.out.println(jobs.size());
}
 
開發者ID:yudar1024,項目名稱:spring4-springmvc4-mybatis3-activiti,代碼行數:27,代碼來源:SignalThrowingEvent.java

示例11: main

import org.activiti.engine.TaskService; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
	// 創建流程引擎
	ProcessEngineImpl engine = (ProcessEngineImpl)ProcessEngines
			.getDefaultProcessEngine();
	// 啟動JobExecutor
	engine.getProcessEngineConfiguration().getJobExecutor().start();
	// 得到流程存儲服務組件
	RepositoryService repositoryService = engine.getRepositoryService();
	// 得到運行時服務組件
	RuntimeService runtimeService = engine.getRuntimeService();
	TaskService taskService = engine.getTaskService();
	// 部署流程文件
	repositoryService.createDeployment()
			.addClasspathResource("bpmn/TimerCatchingEvent.bpmn").deploy();
	// 啟動流程
	runtimeService.startProcessInstanceByKey("tcProcess");
	// 查詢當前任務
	Task currentTask = taskService.createTaskQuery().singleResult();
	taskService.complete(currentTask.getId());
	Thread.sleep(1000 * 61);
	// 重新查詢當前任務
	currentTask = taskService.createTaskQuery().singleResult();
	System.out.println("定時器中間事件的觸發後任務:" + currentTask.getName());
	//關閉JobExecutor
	engine.getProcessEngineConfiguration().getJobExecutor().shutdown();
}
 
開發者ID:yudar1024,項目名稱:spring4-springmvc4-mybatis3-activiti,代碼行數:27,代碼來源:TimerCatchingEvent.java

示例12: main

import org.activiti.engine.TaskService; //導入依賴的package包/類
public static void main(String[] args) {
	// 創建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	// 得到流程存儲服務組件
	RepositoryService repositoryService = engine.getRepositoryService();
	// 得到運行時服務組件
	RuntimeService runtimeService = engine.getRuntimeService();
	TaskService taskService = engine.getTaskService();
	// 部署流程文件
	repositoryService.createDeployment()
			.addClasspathResource("bpmn/MessageCatchingEvent.bpmn").deploy();
	// 啟動流程
	ProcessInstance pi = runtimeService.startProcessInstanceByKey("mcProcess");
	Execution exe = runtimeService.createExecutionQuery().activityId("messageintermediatecatchevent1").singleResult();
	runtimeService.messageEventReceived("myMsg", exe.getId());
	// 輸出當前的任務
	List<Task> tasks = taskService.createTaskQuery().list();
	for (Task task : tasks) {
		System.out.println(task.getName());
	}
}
 
開發者ID:yudar1024,項目名稱:spring4-springmvc4-mybatis3-activiti,代碼行數:22,代碼來源:MessageCatchingEvent.java

示例13: main

import org.activiti.engine.TaskService; //導入依賴的package包/類
public static void main(String[] args) {
	// 創建流程引擎
	ProcessEngine engine = ProcessEngines
			.getDefaultProcessEngine();
	// 得到流程存儲服務組件
	RepositoryService repositoryService = engine.getRepositoryService();
	// 得到運行時服務組件
	RuntimeService runtimeService = engine.getRuntimeService();
	// 獲取流程任務組件
	TaskService taskService = engine.getTaskService();
	// 部署流程文件
	repositoryService.createDeployment()
			.addClasspathResource("bpmn/ErrorBoundaryEvent.bpmn").deploy();
	// 啟動流程
	runtimeService.startProcessInstanceByKey("ebProcess");
	// 進行任務查詢
	Task task = taskService.createTaskQuery().singleResult();
	System.out.println(task.getName());
}
 
開發者ID:yudar1024,項目名稱:spring4-springmvc4-mybatis3-activiti,代碼行數:20,代碼來源:ErrorBoundaryEvent.java

示例14: main

import org.activiti.engine.TaskService; //導入依賴的package包/類
public static void main(String[] args) {
	// 創建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	// 得到流程存儲服務組件
	RepositoryService repositoryService = engine.getRepositoryService();
	// 得到運行時服務組件
	RuntimeService runtimeService = engine.getRuntimeService();
	TaskService taskService = engine.getTaskService();
	// 部署流程文件
	repositoryService.createDeployment()
			.addClasspathResource("bpmn/SignalCatchingEvent.bpmn").deploy();
	// 啟動流程
	runtimeService.startProcessInstanceByKey("scProcess");
	Task firstTask = taskService.createTaskQuery().singleResult();
	taskService.complete(firstTask.getId());
	// 此時會出現並行的兩個流程分支,查找用戶任務並完成
	Task payTask = taskService.createTaskQuery().singleResult();
	// 完成任務
	taskService.complete(payTask.getId());
	// 發送信號完成支付
	runtimeService.signalEventReceived("finishPay");
	Task finishTask = taskService.createTaskQuery().singleResult();
	System.out.println("當前流程任務:" + finishTask.getName());
}
 
開發者ID:yudar1024,項目名稱:spring4-springmvc4-mybatis3-activiti,代碼行數:25,代碼來源:SignalCatchingEvent.java

示例15: getTasksOfUser

import org.activiti.engine.TaskService; //導入依賴的package包/類
public BPMNTask[] getTasksOfUser(String username) throws BPSFault {

        Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        ProcessEngine engine = BPMNServerHolder.getInstance().getEngine();
        TaskService taskService = engine.getTaskService();
        List<Task> tasks = taskService.createTaskQuery().taskTenantId(tenantId.toString()).taskAssignee(username).list();

        BPMNTask[] bpmnTasks = new BPMNTask[tasks.size() + 1];
        int i = 0;
        for (Task t : tasks) {
            BPMNTask bpmnTask = new BPMNTask();
            bpmnTask.setId(t.getId());
            bpmnTask.setName(t.getName());
            bpmnTask.setProcessInstanceId(t.getProcessInstanceId());
            bpmnTasks[i] = bpmnTask;
            i++;
        }
        return bpmnTasks;

    }
 
開發者ID:wso2,項目名稱:carbon-business-process,代碼行數:21,代碼來源:BPMNHumanTasksService.java


注:本文中的org.activiti.engine.TaskService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。