本文整理匯總了Java中org.activiti.engine.runtime.ProcessInstance.getId方法的典型用法代碼示例。如果您正苦於以下問題:Java ProcessInstance.getId方法的具體用法?Java ProcessInstance.getId怎麽用?Java ProcessInstance.getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.activiti.engine.runtime.ProcessInstance
的用法示例。
在下文中一共展示了ProcessInstance.getId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startProcess
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
public String startProcess(String userId, String businessKey,
String processDefinitionId, Map<String, Object> processParameters) {
// 先設置登錄用戶
IdentityService identityService = processEngine.getIdentityService();
identityService.setAuthenticatedUserId(userId);
ProcessInstance processInstance = processEngine.getRuntimeService()
.startProcessInstanceById(processDefinitionId, businessKey,
processParameters);
/*
* // {流程標題:title}-{發起人:startUser}-{發起時間:startTime} String processDefinitionName =
* processEngine.getRepositoryService() .createProcessDefinitionQuery()
* .processDefinitionId(processDefinitionId).singleResult() .getName(); String processInstanceName =
* processDefinitionName + "-" + userConnector.findById(userId).getDisplayName() + "-" + new
* SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
* processEngine.getRuntimeService().setProcessInstanceName( processInstance.getId(), processInstanceName);
*/
return processInstance.getId();
}
示例2: endStartTaskAutomatically
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
/**
* @param path WorkflowPath
* @param instance ProcessInstance
*/
private void endStartTaskAutomatically(WorkflowPath path, ProcessInstance instance)
{
// Check if StartTask Needs to be ended automatically
WorkflowDefinition definition = path.getInstance().getDefinition();
TypeDefinition metadata = definition.getStartTaskDefinition().getMetadata();
Set<QName> aspects = metadata.getDefaultAspectNames();
if(aspects.contains(WorkflowModel.ASPECT_END_AUTOMATICALLY))
{
String taskId = ActivitiConstants.START_TASK_PREFIX + instance.getId();
endStartTask(taskId);
}
}
示例3: testDeploy
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的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());
}
}
示例4: testSmoke
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
public void testSmoke() throws Exception
{
assertNotNull(runtime);
ProcessInstance instance = runtime.startProcessInstanceByKey(PROC_DEF_KEY);
assertNotNull(instance);
String instanceId = instance.getId();
ProcessInstance instanceInDb = findProcessInstance(instanceId);
assertNotNull(instanceInDb);
runtime.deleteProcessInstance(instance.getId(), "");
assertNotNull(instance);
}
示例5: testNestedWithoutPropogation
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
/**
* Checks nesting of two transactions with <code>requiresNew == true</code>
*/
public void testNestedWithoutPropogation()
{
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
ProcessInstance instance = runtime.startProcessInstanceByKey(PROC_DEF_KEY);
final String id = instance.getId();
ProcessInstance instanceInDb = findProcessInstance(id);
assertNotNull("Can't read process instance in same transaction!", instanceInDb);
RetryingTransactionCallback<Void> callbackInner = new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
ProcessInstance instanceInDb2 = findProcessInstance(id);
assertNull("Should not be able to read process instance in inner transaction!", instanceInDb2);
return null;
}
};
try
{
txnHelper.doInTransaction(callbackInner, false, true);
return null;
}
finally
{
runtime.deleteProcessInstance(id, "FOr test");
}
}
};
txnHelper.doInTransaction(callback);
}
示例6: testSignal
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
@Test
public void testSignal() throws Exception
{
WorkflowDefinition def = deployTestSignallingDefinition();
ProcessInstance processInstance = runtime.startProcessInstanceById(BPMEngineRegistry.getLocalId(def.getId()));
String procId = processInstance.getId();
List<String> nodeIds = runtime.getActiveActivityIds(procId);
assertEquals(1, nodeIds.size());
assertEquals("task1", nodeIds.get(0));
String pathId = BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, procId);
WorkflowPath path = workflowEngine.signal(pathId, null);
assertEquals(pathId, path.getId());
assertEquals("task2", path.getNode().getName());
assertEquals(pathId, path.getInstance().getId());
assertTrue(path.isActive());
nodeIds = runtime.getActiveActivityIds(procId);
assertEquals(1, nodeIds.size());
assertEquals("task2", nodeIds.get(0));
// Should end the WorkflowInstance
path = workflowEngine.signal(pathId, null);
assertEquals(pathId, path.getId());
assertNull(path.getNode());
assertEquals(pathId, path.getInstance().getId());
assertFalse(path.isActive());
}
示例7: testGetActiveWorkflows
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
@Test
public void testGetActiveWorkflows() throws Exception
{
WorkflowDefinition def = deployTestAdhocDefinition();
String activitiProcessDefinitionId = BPMEngineRegistry.getLocalId(def.getId());
ProcessInstance activeInstance = runtime.startProcessInstanceById(activitiProcessDefinitionId);
ProcessInstance completedInstance = runtime.startProcessInstanceById(activitiProcessDefinitionId);
ProcessInstance cancelledInstance = runtime.startProcessInstanceById(activitiProcessDefinitionId);
ProcessInstance deletedInstance = runtime.startProcessInstanceById(activitiProcessDefinitionId);
// Complete completedProcessInstance.
String completedId = completedInstance.getId();
boolean isActive = true;
while (isActive)
{
Execution execution = runtime.createExecutionQuery()
.processInstanceId(completedId)
.singleResult();
runtime.signal(execution.getId());
ProcessInstance instance = runtime.createProcessInstanceQuery()
.processInstanceId(completedId)
.singleResult();
isActive = instance != null;
}
// Deleted and canceled instances shouldn't be returned
workflowEngine.cancelWorkflow(workflowEngine.createGlobalId(cancelledInstance.getId()));
workflowEngine.deleteWorkflow(workflowEngine.createGlobalId(deletedInstance.getId()));
// Validate if a workflow exists
List<WorkflowInstance> instances = workflowEngine.getActiveWorkflows(def.getId());
assertNotNull(instances);
assertEquals(1, instances.size());
String instanceId = instances.get(0).getId();
assertEquals(activeInstance.getId(), BPMEngineRegistry.getLocalId(instanceId));
}
示例8: testGetCompletedWorkflows
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
@Test
public void testGetCompletedWorkflows() throws Exception
{
WorkflowDefinition def = deployTestAdhocDefinition();
String activitiProcessDefinitionId = BPMEngineRegistry.getLocalId(def.getId());
runtime.startProcessInstanceById(activitiProcessDefinitionId);
ProcessInstance completedInstance = runtime.startProcessInstanceById(activitiProcessDefinitionId);
ProcessInstance cancelledInstance = runtime.startProcessInstanceById(activitiProcessDefinitionId);
ProcessInstance deletedInstance = runtime.startProcessInstanceById(activitiProcessDefinitionId);
// Complete completedProcessInstance.
String completedId = completedInstance.getId();
boolean isActive = true;
while (isActive)
{
Execution execution = runtime.createExecutionQuery()
.processInstanceId(completedId)
.singleResult();
runtime.signal(execution.getId());
ProcessInstance instance = runtime.createProcessInstanceQuery()
.processInstanceId(completedId)
.singleResult();
isActive = instance != null;
}
// Deleted and canceled instances shouldn't be returned
workflowEngine.cancelWorkflow(workflowEngine.createGlobalId(cancelledInstance.getId()));
workflowEngine.deleteWorkflow(workflowEngine.createGlobalId(deletedInstance.getId()));
// Validate if a workflow exists
List<WorkflowInstance> instances = workflowEngine.getCompletedWorkflows(def.getId());
assertNotNull(instances);
assertEquals(1, instances.size());
String instanceId = instances.get(0).getId();
assertEquals(completedId, BPMEngineRegistry.getLocalId(instanceId));
}
示例9: testGetWorkflows
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
@Test
public void testGetWorkflows() throws Exception
{
WorkflowDefinition def = deployTestAdhocDefinition();
String activitiProcessDefinitionId = BPMEngineRegistry.getLocalId(def.getId());
ProcessInstance activeInstance = runtime.startProcessInstanceById(activitiProcessDefinitionId);
ProcessInstance completedInstance = runtime.startProcessInstanceById(activitiProcessDefinitionId);
ProcessInstance cancelledInstance = runtime.startProcessInstanceById(activitiProcessDefinitionId);
ProcessInstance deletedInstance = runtime.startProcessInstanceById(activitiProcessDefinitionId);
// Complete completedProcessInstance.
String completedId = completedInstance.getId();
boolean isActive = true;
while (isActive)
{
Execution execution = runtime.createExecutionQuery()
.processInstanceId(completedId)
.singleResult();
runtime.signal(execution.getId());
ProcessInstance instance = runtime.createProcessInstanceQuery()
.processInstanceId(completedId)
.singleResult();
isActive = instance != null;
}
// Deleted and canceled instances shouldn't be returned
workflowEngine.cancelWorkflow(workflowEngine.createGlobalId(cancelledInstance.getId()));
workflowEngine.deleteWorkflow(workflowEngine.createGlobalId(deletedInstance.getId()));
// Validate if a workflow exists
List<WorkflowInstance> instances = workflowEngine.getWorkflows(def.getId());
assertNotNull(instances);
assertEquals(2, instances.size());
String instanceId = instances.get(0).getId();
assertEquals(activeInstance.getId(), BPMEngineRegistry.getLocalId(instanceId));
instanceId = instances.get(1).getId();
assertEquals(completedId, BPMEngineRegistry.getLocalId(instanceId));
}
示例10: startOpsProcess
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
/**
* Start ops process.
*
* @param processKey the process key
* @param params the params
* @return the string
*/
public String startOpsProcess(String processKey, Map<String,Object> params){
logger.info("starting process for " + processKey + " with params: " + params.toString());
ProcessInstance pi = runtimeService.startProcessInstanceByKey(processKey, params);
logger.info("started process with id - " + pi.getId());
return pi.getId();
}
示例11: startOrder
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
@RequestMapping("/ocs/order")
public String startOrder(HttpServletRequest req){
String cartUser = (String)req.getSession().getAttribute("cartUser");
System.out.println("Cart user" + cartUser);
ProcessInstance processInstance = getRuntimeService().startProcessInstanceByKey("shopping");
processId = processInstance.getId();
execAndCompleteTask(processId, cartUser, "start");
return "order";
}
示例12: startProcessInstanceByKey
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
@Override
public String startProcessInstanceByKey(String processDefinitionKey,
String businessKey, Map<String, Object> variables) {
ProcessInstance pi = runtimeService.startProcessInstanceByKey(AvtivitiDic.dev_task, businessKey, variables);
logger.info("startProcessInstanceByKey successed, pdKey:{}, buKey:{}, var:{}, pdId:{}",
new Object[]{processDefinitionKey, businessKey, variables, pi.getId()});
return pi.getId();
}
示例13: getVirtualStartTask
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
private WorkflowTask getVirtualStartTask(ProcessInstance processInstance, boolean inProgress)
{
String processInstanceId = processInstance.getId();
if (!activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && !isCorrectTenantRuntime(processInstanceId))
{
return null;
}
String id = ActivitiConstants.START_TASK_PREFIX + processInstanceId;
WorkflowTaskState state = null;
if(inProgress)
{
state = WorkflowTaskState.IN_PROGRESS;
}
else
{
state = WorkflowTaskState.COMPLETED;
}
WorkflowPath path = convert((Execution)processInstance);
// Convert start-event to start-task Node
String definitionId = processInstance.getProcessDefinitionId();
ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(definitionId);
WorkflowNode startNode = convert(procDef.getInitial(), true);
String key = ((ProcessDefinition)procDef).getKey();
StartFormData startFormData = getStartFormData(definitionId, key);
String taskDefId = null;
if(startFormData != null)
{
taskDefId = startFormData.getFormKey();
}
WorkflowTaskDefinition taskDef = factory.createTaskDefinition(taskDefId, startNode, taskDefId, true);
// Add properties based on HistoricProcessInstance
HistoricProcessInstance historicProcessInstance = historyService
.createHistoricProcessInstanceQuery()
.processInstanceId(processInstanceId)
.singleResult();
Map<QName, Serializable> properties = propertyConverter.getStartTaskProperties(historicProcessInstance, taskDefId, !inProgress);
// TODO: Figure out what name/description should be used for the start-task, start event's name?
String defaultTitle = null;
String defaultDescription = null;
return factory.createTask(id,
taskDef, taskDef.getId(), defaultTitle, defaultDescription, state, path, properties);
}
示例14: getProcessInstanceChangeStateCmd
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
@Override
protected AbstractSetProcessInstanceStateCmd getProcessInstanceChangeStateCmd(ProcessInstance processInstance) {
return new SuspendProcessInstanceCmd(processInstance.getId());
}
示例15: getProcessInstanceChangeStateCmd
import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
@Override
protected AbstractSetProcessInstanceStateCmd getProcessInstanceChangeStateCmd(ProcessInstance processInstance) {
return new ActivateProcessInstanceCmd(processInstance.getId());
}