本文整理汇总了Java中org.activiti.engine.runtime.Execution类的典型用法代码示例。如果您正苦于以下问题:Java Execution类的具体用法?Java Execution怎么用?Java Execution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Execution类属于org.activiti.engine.runtime包,在下文中一共展示了Execution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTaskForTimer
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
private WorkflowTask getTaskForTimer(Job job, ProcessInstance processInstance, Execution jobExecution)
{
if (job instanceof TimerEntity)
{
ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
List<String> activeActivityIds = runtimeService.getActiveActivityIds(jobExecution.getId());
if(activeActivityIds.size() == 1)
{
PvmActivity targetActivity = def.findActivity(activeActivityIds.get(0));
if(targetActivity != null)
{
// Only get tasks of active activity is a user-task
String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE);
if(ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType))
{
Task task = taskService.createTaskQuery().executionId(job.getExecutionId()).singleResult();
return typeConverter.convert(task);
}
}
}
}
return null;
}
示例2: getWorkflowPaths
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public List<WorkflowPath> getWorkflowPaths(String workflowId)
{
try
{
String processInstanceId = createLocalId(workflowId);
List<Execution> executions = runtimeService
.createExecutionQuery()
.processInstanceId(processInstanceId)
.list();
return typeConverter.convertExecution(executions);
}
catch (ActivitiException ae)
{
String msg = messageService.getMessage(ERR_GET_WORKFLOW_PATHS);
if(logger.isDebugEnabled())
{
logger.debug(msg, ae);
}
throw new WorkflowException(msg, ae);
}
}
示例3: convert
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
public WorkflowPath convert(Execution execution, ProcessInstance instance)
{
if(execution == null)
return null;
boolean isActive = !execution.isEnded();
// Convert workflow and collect variables
Map<String, Object> workflowInstanceVariables = new HashMap<String, Object>();
WorkflowInstance wfInstance = convertAndSetVariables(instance, workflowInstanceVariables);
WorkflowNode node = null;
// Get active node on execution
List<String> nodeIds = runtimeService.getActiveActivityIds(execution.getId());
if (nodeIds != null && nodeIds.size() >= 1)
{
ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(instance.getProcessDefinitionId());
PvmActivity activity = procDef.findActivity(nodeIds.get(0));
node = convert(activity);
}
return factory.createPath(execution.getId(), wfInstance, node, isActive);
}
示例4: getWorkflowPath
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
public WorkflowPath getWorkflowPath(String executionId, boolean ignoreDomainMismatch)
{
Execution execution = activitiUtil.getExecution(executionId);
WorkflowPath path = null;
try
{
path = convert(execution);
}
catch(RuntimeException re)
{
if(!ignoreDomainMismatch)
{
throw re;
}
}
return path;
}
示例5: approved
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
public void approved(Execution execution) {
try {
approverThread.set(true);
Map<String, Object> variables = runtimeService.getVariables(execution.getId());
String resourceType = (String) variables.get("resourceType");
RegistryEntry registryEntry = moduleRegistry.getResourceRegistry().getEntry(resourceType);
ResourceInformation resourceInformation = registryEntry.getResourceInformation();
// fetch resource and changes
ApprovalProcessInstance processResource = newApprovalProcessInstance(resourceInformation.getResourceClass());
resourceMapper.mapFromVariables(processResource, variables);
Object resource = get(registryEntry, processResource.getResourceId());
// apply and save changes
approvalMapper.unmapValues(processResource.getNewValues(), resource);
save(registryEntry, resource);
LOGGER.debug("approval accepted: " + execution.getProcessInstanceId());
}
finally {
approverThread.remove();
}
}
示例6: checkApprovedForwardsToRepository
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
@Test
public void checkApprovedForwardsToRepository() {
Map processVariable = new HashMap();
processVariable.put("resourceId", mockId.toString());
processVariable.put("resourceType", "schedule");
processVariable.put("newValues.name", "John");
processVariable.put("previousValues.name", "Jane");
Mockito.when(runtimeService.getVariables(Mockito.anyString())).thenReturn(processVariable);
Execution execution = Mockito.mock(Execution.class);
manager.approved(execution);
ArgumentCaptor<Object> savedEntityCaptor = ArgumentCaptor.forClass(Object.class);
Mockito.verify(repositoryAdapter, Mockito.times(1)).update(savedEntityCaptor.capture(), Mockito.any(QueryAdapter.class));
// check value updated on original resource
Schedule savedEntity = (Schedule) savedEntityCaptor.getValue();
Assert.assertSame(originalResource, savedEntity);
Assert.assertEquals("John", savedEntity.getName());
}
示例7: getExecutionId
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
private String getExecutionId(String processId, String activityId, long timeoutInMillis) {
long deadline = System.currentTimeMillis() + timeoutInMillis;
while (true) {
Execution execution = engine.getRuntimeService()
.createExecutionQuery()
.processInstanceId(processId)
.activityId(activityId)
.singleResult();
if (execution != null && execution.getParentId() != null) {
return execution.getId();
}
if (isPastDeadline(deadline)) {
IllegalStateException timeoutException = new IllegalStateException(
format(Messages.PROCESS_STEP_NOT_REACHED_BEFORE_TIMEOUT, activityId, processId));
LOGGER.error(timeoutException.toString(), timeoutException);
throw timeoutException;
}
try {
Thread.sleep(GET_EXECUTION_RETRY_INTERVAL_MS);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
}
}
示例8: execute
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
@Override
public T execute(CommandContext commandContext) {
if (executionId == null) {
throw new ActivitiIllegalArgumentException("executionId is null");
}
ExecutionEntity execution = commandContext
.getExecutionEntityManager()
.findExecutionById(executionId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
}
if (execution.isSuspended()) {
throw new ActivitiException(getSuspendedExceptionMessage());
}
return execute(commandContext, execution);
}
示例9: execute
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
@Override
public VariableInstance execute(CommandContext commandContext) {
if (executionId == null) {
throw new FlowableIllegalArgumentException("executionId is null");
}
if (variableName == null) {
throw new FlowableIllegalArgumentException("variableName is null");
}
ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(executionId);
if (execution == null) {
throw new FlowableObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
}
VariableInstance variableEntity = null;
if (isLocal) {
variableEntity = execution.getVariableInstanceLocal(variableName, false);
} else {
variableEntity = execution.getVariableInstance(variableName, false);
}
return variableEntity;
}
示例10: execute
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
@Override
public List<String> execute(CommandContext commandContext) {
if (executionId == null) {
throw new ActivitiIllegalArgumentException("executionId is null");
}
ExecutionEntity execution = commandContext
.getExecutionEntityManager()
.findExecutionById(executionId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
}
return execution.findActiveActivityIds();
}
示例11: localize
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
protected void localize(Execution execution, String activityId) {
ExecutionEntity executionEntity = (ExecutionEntity) execution;
executionEntity.setLocalizedName(null);
executionEntity.setLocalizedDescription(null);
String processDefinitionId = executionEntity.getProcessDefinitionId();
if (locale != null && processDefinitionId != null) {
ObjectNode languageNode = Context.getLocalizationElementProperties(locale, activityId, processDefinitionId, withLocalizationFallback);
if (languageNode != null) {
JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME);
if (languageNameNode != null && !languageNameNode.isNull()) {
executionEntity.setLocalizedName(languageNameNode.asText());
}
JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION);
if (languageDescriptionNode != null && !languageDescriptionNode.isNull()) {
executionEntity.setLocalizedDescription(languageDescriptionNode.asText());
}
}
}
}
示例12: testReceiveMessageManual
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
/**
* 在审核文件节点抛出消息事件触发消息边界事件--cancelActivity='true'
*/
@Deployment(resources = "chapter11/boundaryEvent/signalBoundaryEvent.bpmn")
public void testReceiveMessageManual() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalBoundaryEvent");
assertNotNull(processInstance);
// 审核文件任务
Task task = taskService.createTaskQuery().taskName("审核文件").singleResult();
assertNotNull(task);
ExecutionQuery executionQuery = runtimeService.createExecutionQuery().signalEventSubscriptionName("S_协助处理");
Execution execution = executionQuery.singleResult();
runtimeService.signalEventReceived("S_协助处理", execution.getId());
// 任务到达“协助处理节点”
task = taskService.createTaskQuery().taskName("协助处理").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
// 任务流转至审核文件节点
task = taskService.createTaskQuery().taskName("审核文件").singleResult();
assertNotNull(task);
// 验证流程实例运行结束
taskService.complete(task.getId());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().finished().count());
}
示例13: testCompleteDirectly
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
/**
* 不触发消息边界事件,直接完成任务--cancelActivity='true'
*/
@Deployment(resources = "chapter11/boundaryEvent/signalBoundaryEvent.bpmn")
public void testCompleteDirectly() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalBoundaryEvent");
assertNotNull(processInstance);
// 审核文件任务
Task task = taskService.createTaskQuery().taskName("审核文件").singleResult();
assertNotNull(task);
ExecutionQuery executionQuery = runtimeService.createExecutionQuery();
Execution execution = executionQuery.signalEventSubscriptionName("S_协助处理").singleResult();
assertNotNull(execution);
taskService.complete(task.getId());
}
示例14: testCompleteDirectly
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
/**
* 不触发消息边界事件,直接完成任务--cancelActivity='true'
*/
@Deployment(resources = "chapter11/boundaryEvent/messageBoundaryEvent.bpmn")
public void testCompleteDirectly() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageBoundaryEvent");
assertNotNull(processInstance);
// 审核文件任务
Task task = taskService.createTaskQuery().taskName("审核文件").singleResult();
assertNotNull(task);
ExecutionQuery executionQuery = runtimeService.createExecutionQuery();
Execution execution = executionQuery.messageEventSubscriptionName("MSG_协助处理").singleResult();
assertNotNull(execution);
taskService.complete(task.getId());
execution = executionQuery.messageEventSubscriptionName("MSG_协助处理").singleResult();
assertNull(execution);
}
示例15: testResolveProcessInstanceBean
import org.activiti.engine.runtime.Execution; //导入依赖的package包/类
@Deployment(resources = "org/activiti/cdi/BusinessProcessBeanTest.test.bpmn20.xml")
public void testResolveProcessInstanceBean() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
assertNull(getBeanInstance(ProcessInstance.class));
assertNull(getBeanInstance("processInstanceId"));
assertNull(getBeanInstance(Execution.class));
assertNull(getBeanInstance("executionId"));
String pid = businessProcess.startProcessByKey("businessProcessBeanTest").getId();
// assert that now we can resolve the ProcessInstance-bean
assertEquals(pid, getBeanInstance(ProcessInstance.class).getId());
assertEquals(pid, getBeanInstance("processInstanceId"));
assertEquals(pid, getBeanInstance(Execution.class).getId());
assertEquals(pid, getBeanInstance("executionId"));
taskService.complete(taskService.createTaskQuery().singleResult().getId());
}