本文整理汇总了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);
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例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();
}
示例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());
}
示例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();
}
示例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());
}
}
示例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());
}
示例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());
}
示例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;
}