本文整理匯總了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());
}
}