本文整理汇总了Java中org.activiti.engine.RuntimeService.startProcessInstanceByKey方法的典型用法代码示例。如果您正苦于以下问题:Java RuntimeService.startProcessInstanceByKey方法的具体用法?Java RuntimeService.startProcessInstanceByKey怎么用?Java RuntimeService.startProcessInstanceByKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.RuntimeService
的用法示例。
在下文中一共展示了RuntimeService.startProcessInstanceByKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startProcess
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
@Test
public void startProcess() throws Exception {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("confirmPublish", "N");
String processId = "Employee360DegreeFeedbackProjectPublishProcess";
RuntimeService runtimeService = (RuntimeService) AppContext.getBean("runtimeService");
ProcessInstance process = runtimeService.startProcessInstanceByKey(processId, paramMap);
System.out.println("DeploymentId: " + process.getDeploymentId() );
System.out.println("ActivityId: " + process.getActivityId() );
System.out.println("Name: " + process.getName() );
System.out.println("ProcessDefinitionId: " + process.getProcessDefinitionId());
System.out.println("ProcessDefinitionKey: " + process.getProcessDefinitionKey());
System.out.println("ProcessDefinitionName: " + process.getProcessDefinitionName());
System.out.println("BusinessKey: " + process.getBusinessKey());
}
示例2: main
import org.activiti.engine.RuntimeService; //导入方法依赖的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());
}
示例3: testSend
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
@Deployment
public void testSend() {
ProcessEngine processEngine = muleContext.getRegistry().get("processEngine");
TestHelper.annotationDeploymentSetUp(processEngine, getClass(), getName());
RuntimeService runtimeService = muleContext.getRegistry().get("runtimeService");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
assertFalse(processInstance.isEnded());
Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
assertEquals(10, result);
}
示例4: testStartProcess
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
@Test
public void testStartProcess() throws Exception {
// 创建流程引擎,使用内存数据库
ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneInMemProcessEngineConfiguration()
.buildProcessEngine();
// 部署流程定义文件
RepositoryService repositoryService = processEngine.getRepositoryService();
String processFileName = "me/kafeitu/activiti/helloworld/sayhelloleave.bpmn";
repositoryService.createDeployment().addClasspathResource(processFileName)
.deploy();
// 验证已部署流程定义
ProcessDefinition processDefinition = repositoryService
.createProcessDefinitionQuery().singleResult();
assertEquals("leavesayhello", processDefinition.getKey());
// 启动流程并返回流程实例
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService
.startProcessInstanceByKey("leavesayhello");
assertNotNull(processInstance);
System.out.println("pid=" + processInstance.getId() + ", pdid="
+ processInstance.getProcessDefinitionId());
}
示例5: testSpringMaster
import org.activiti.engine.RuntimeService; //导入方法依赖的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();
}
示例6: main
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
public static void main(String[] args) {
// 创建流程引擎
ProcessEngine engine = ProcessEngines
.getDefaultProcessEngine();
// 得到流程存储服务组件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到运行时服务组件
RuntimeService runtimeService = engine.getRuntimeService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("com/roger/activiti/workflow/CompensationBoundaryEvent.bpmn").deploy();
// 初始化参数
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("result", false);
runtimeService.startProcessInstanceByKey("cbProcess", vars);
}
开发者ID:yudar1024,项目名称:spring4-springmvc4-mybatis3-activiti,代码行数:17,代码来源:CompensationBoundaryEvent.java
示例7: main
import org.activiti.engine.RuntimeService; //导入方法依赖的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());
}
示例8: main
import org.activiti.engine.RuntimeService; //导入方法依赖的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();
}
示例9: startProcess
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
@Test
public void startProcess() throws Exception
{
RepositoryService repositoryService = activitiRule.getRepositoryService();
// TODO:Assembel the process deployment with configuration.
// @see:
repositoryService.createDeployment().addClasspathResource("diagrams/BusinessRuleLoanProcess.bpmn")
.addClasspathResource("diagrams/BusinessRuleLoanProcess.png")
.addClasspathResource("diagrams/LoanRequestRules.drl").enableDuplicateFiltering()
.name("businessRuleLoanProcessSimple").deploy();
// repositoryService.createDeployment().addInputStream("BusinessRuleLoanProcess.bpmn",
// new FileInputStream(filename)).deploy();
RuntimeService runtimeService = activitiRule.getRuntimeService();
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("name", "Nadim");
variableMap.put("amount", 2400L);
variableMap.put("salary", 10000L);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess", variableMap);
assertNotNull(processInstance.getId());
System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
}
示例10: main
import org.activiti.engine.RuntimeService; //导入方法依赖的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());
}
示例11: main
import org.activiti.engine.RuntimeService; //导入方法依赖的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());
}
}
示例12: startPoolManagementProcess
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
@Override
public String startPoolManagementProcess(String businessKey, Pool pool) {
Map<String, Object> arguments = Maps.newHashMap();
arguments.put(CoreProcessVariables.POOL, pool);
arguments.put(CoreProcessVariables.PROVIDER, getId());
arguments.put(CoreProcessVariables.POOL_BUSINESS_KEY, businessKey);
arguments.put(CoreProcessVariables.BOOTSTRAP_TIMEOUT,
convertTimeoutToISO8601TimeDuration(pool.getBootstrapTimeInSeconds()));
/* Authenticate as kermit to make the process visible in the Explorer UI */
processEngine.getIdentityService().setAuthenticatedUserId(CoreConstants.ACTIVITI_EXPLORER_DEFAULT_USER);
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_KEY, businessKey, arguments);
return instance.getProcessInstanceId();
}
示例13: main
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
// Build process enigne
ProcessEngine processEngine = new StandaloneInMemProcessEngineConfiguration()
// enable process definition info cache
.setEnableProcessDefinitionInfoCache(true)
.buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
RuntimeService runtimeService = processEngine.getRuntimeService();
// deploy process definition
repositoryService.createDeployment()
.addClasspathResource("dynamic-service-task.bpmn20.xml")
.deploy();
// this will invoke OldServiceTask
ProcessInstance processInstance =
runtimeService.startProcessInstanceByKey("dynamic-service-task");
String processDefinitionId = processInstance.getProcessDefinitionId();
// change service task class name
System.out.println("==== changing service task class name ====");
DynamicBpmnService dynamicBpmnService = processEngine.getDynamicBpmnService();
ObjectNode infoNode = dynamicBpmnService
.changeServiceTaskClassName("dynamicServiceTask",
"org.activiti.examples.NewServiceTask");
dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
// this will invoke NewServiceTask
processInstance = runtimeService.startProcessInstanceByKey("dynamic-service-task");
}
示例14: main
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
// Build process enigne
ProcessEngine processEngine = new StandaloneInMemProcessEngineConfiguration()
// enable process definition info cache
.setEnableProcessDefinitionInfoCache(true)
.buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
RuntimeService runtimeService = processEngine.getRuntimeService();
// deploy process definition
repositoryService.createDeployment()
.addClasspathResource("dynamic-script-task.bpmn20.xml")
.deploy();
String processDefinitionId = repositoryService.createProcessDefinitionQuery()
.singleResult().getId();
DynamicBpmnService dynamicBpmnService = processEngine.getDynamicBpmnService();
ObjectNode infoNode = dynamicBpmnService
.changeScriptTaskScript("scriptTask",
"java.lang.System.out.println(\"New output\");");
dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
// start a process instance
runtimeService.startProcessInstanceByKey("dynamic-script-task");
}
示例15: testDeploy
import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
public void testDeploy() throws Exception
{
ProcessEngine engine = buildProcessEngine();
RepositoryService repoService = engine.getRepositoryService();
Deployment deployment = deployDefinition(repoService);
assertNotNull(deployment);
RuntimeService runtimeService = engine.getRuntimeService();
try
{
ProcessInstance instance = runtimeService.startProcessInstanceByKey("testTask");
assertNotNull(instance);
String instanceId = instance.getId();
ProcessInstance instanceInDb = findProcessInstance(runtimeService, instanceId);
assertNotNull(instanceInDb);
runtimeService.deleteProcessInstance(instanceId, "");
}
finally
{
// List<Deployment> deployments = repoService.createDeploymentQuery().list();
// for (Deployment deployment2 : deployments)
// {
// repoService.deleteDeployment(deployment2.getId());
// }
repoService.deleteDeployment(deployment.getId());
}
}