當前位置: 首頁>>代碼示例>>Java>>正文


Java ProcessInstance類代碼示例

本文整理匯總了Java中org.activiti.engine.runtime.ProcessInstance的典型用法代碼示例。如果您正苦於以下問題:Java ProcessInstance類的具體用法?Java ProcessInstance怎麽用?Java ProcessInstance使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ProcessInstance類屬於org.activiti.engine.runtime包,在下文中一共展示了ProcessInstance類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startProcess

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
public ProcessInstance startProcess(String userId, String processDefinitionKey, Map<String, Object> variables) {
    try {
        engine.getIdentityService().setAuthenticatedUserId(userId);
        // Get the last deployed version of the process and start a process instance
        ProcessDefinitionQuery query = engine.getRepositoryService()
            .createProcessDefinitionQuery()
            .processDefinitionKey(processDefinitionKey)
            .latestVersion();
        String processDefinitionId = query.singleResult().getId();
        ProcessInstance processInstance = engine.getRuntimeService().startProcessInstanceById(processDefinitionId, variables);
        return processInstance;
    } finally {
        // After the setAuthenticatedUserId() method is invoked, all Activiti service methods
        // executed within the current thread will have access to this userId. Just before
        // leaving the method, the userId is set to null, preventing other services from using
        // it unintentionally.
        engine.getIdentityService().setAuthenticatedUserId(null);
    }
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:20,代碼來源:ActivitiFacade.java

示例2: getTaskForTimer

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的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;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:25,代碼來源:ActivitiWorkflowEngine.java

示例3: convert

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的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);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:25,代碼來源:ActivitiTypeConverter.java

示例4: buildCompletedPath

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
public WorkflowPath buildCompletedPath(String executionId, String processInstanceId)
{
    WorkflowInstance wfInstance = null;
    ProcessInstance processInstance = activitiUtil.getProcessInstance(processInstanceId);
    if(processInstance != null)
    {
        wfInstance = convert(processInstance);
    } 
    else
    {
        HistoricProcessInstance historicProcessInstance = activitiUtil.getHistoricProcessInstance(processInstanceId);
        if(historicProcessInstance!= null)
            wfInstance = convert(historicProcessInstance);
    }
    if(wfInstance == null)
    {
    	// When workflow is cancelled or deleted, WorkflowPath should not be returned
    	return null;
    }
    WorkflowNode node = null;
    return factory.createPath(executionId, wfInstance, node, false);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:23,代碼來源:ActivitiTypeConverter.java

示例5: testGetWorkflowImage

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
@Test
public void testGetWorkflowImage() 
{
    WorkflowDefinition definitionWithoutImage = deployTestAdhocDefinition();
    WorkflowDefinition definitionWithImage = deployTestDiagramDefinition();
    
    // Start process-instance that shouldn't have an image
    ProcessInstance processInstance = runtime.startProcessInstanceById(BPMEngineRegistry.getLocalId(definitionWithoutImage.getId()));
    String worklfowId = BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, processInstance.getId());
    
    assertFalse(workflowEngine.hasWorkflowImage(worklfowId));
    assertNull(workflowEngine.getWorkflowImage(worklfowId));
    
    // Start process-instance that SHOULD have an image
    ProcessInstance processInstanceWithImage = runtime.startProcessInstanceById(BPMEngineRegistry.getLocalId(definitionWithImage.getId()));
    String worklfowWithImageId = BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, processInstanceWithImage.getId());
    
    assertTrue(workflowEngine.hasWorkflowImage(worklfowWithImageId));
    assertNotNull(workflowEngine.getWorkflowImage(worklfowWithImageId));
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:21,代碼來源:ActivitiWorkflowComponentTest.java

示例6: create

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
@Override
public <S extends T> S create(S resource) {
	checkFilter(resource, true);

	String processDefinitionKey = resource.getProcessDefinitionKey();
	String businessKey = resource.getBusinessKey();
	String tenantId = resource.getTenantId();
	Map<String, Object> variables = resourceMapper.mapToVariables(resource);

	ProcessInstance processInstance =
			runtimeService.startProcessInstanceByKeyAndTenantId(processDefinitionKey, businessKey, variables, tenantId);

	applyUpdates(processInstance, resource);

	return (S) findOne(processInstance.getId(), new QuerySpec(getResourceClass()));
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:17,代碼來源:ProcessInstanceResourceRepository.java

示例7: save

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
@Override
public <S extends T> S save(S resource) {
	checkFilter(resource, true);

	ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
			.processInstanceId(resource.getId())
			.includeProcessVariables()
			.singleResult();
	if (processInstance == null) {
		throw new ResourceNotFoundException(resource.getId());
	}
	checkFilter(processInstance, false);
	checkActivate(processInstance, resource);

	Map<String, Object> variables = resourceMapper.mapToVariables(resource);
	runtimeService.setVariables(processInstance.getId(), variables);

	applyUpdates(processInstance, resource);
	return (S) findOne(processInstance.getId(), new QuerySpec(getResourceClass()));
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:21,代碼來源:ProcessInstanceResourceRepository.java

示例8: checkProcessInstance

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
@Test
public void checkProcessInstance() {
	Map<String, Object> variables = mapper.mapToVariables(processResource);
	Assert.assertEquals(3, variables.size());
	Assert.assertEquals("someString", variables.get("stringValue"));
	Assert.assertEquals(13, variables.get("nestedBean.intValue"));
	Assert.assertEquals(Boolean.TRUE, variables.get("booleanValue"));

	TestProcess processCopy = new TestProcess();
	mapper.mapFromVariables(processCopy, variables);
	checkProcessResource(processCopy);

	ProcessInstance processInstance = Mockito.mock(ProcessInstance.class);
	Mockito.when(processInstance.getName()).thenReturn("someProcess");
	Mockito.when(processInstance.getBusinessKey()).thenReturn("someBusinessKey");
	Mockito.when(processInstance.getProcessVariables()).thenReturn(variables);
	TestProcess processResourceCopy = mapper.mapToResource(TestProcess.class, processInstance);
	checkProcessResource(processResourceCopy);
	Assert.assertEquals("someProcess", processResourceCopy.getName());
	Assert.assertEquals("someBusinessKey", processResourceCopy.getBusinessKey());
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:22,代碼來源:ActivitiResourceMapperTest.java

示例9: addProcessInstance

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
private ProcessInstance addProcessInstance() {
	ScheduleApprovalValues newValues = new ScheduleApprovalValues();
	newValues.setName("newName");

	ScheduleApprovalProcessInstance resource = new ScheduleApprovalProcessInstance();
	resource.setResourceType("schedules");
	resource.setResourceId("12");
	resource.setNewValues(newValues);

	Map<String, Object> processVariables = resourceMapper.mapToVariables(resource);
	runtimeService = processEngine.getRuntimeService();
	ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("scheduleChange",
			"testBusinessKey", processVariables);
	runtimeService.setProcessInstanceName(processInstance.getId(), "testName");

	processInstance = runtimeService.createProcessInstanceQuery()
			.processInstanceId(processInstance.getId())
			.includeProcessVariables()
			.singleResult();

	return processInstance;
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:23,代碼來源:ProcessInstanceRepositoryTest.java

示例10: 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();
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:21,代碼來源:ProcessConnectorImpl.java

示例11: executeAsyncStep

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
@Override
protected StepPhase executeAsyncStep(ExecutionWrapper execution) throws Exception {
    try {
        String userId = StepsUtil.determineCurrentUser(execution.getContext(), getStepLogger());

        int nextIterationIndex = getNextIterationIndex(execution);
        execution.getContext().setVariable(getIterationVariableName(),
            getIterationVariable(execution.getContext(), nextIterationIndex));
        Map<String, Object> parentProcessVariables = execution.getContext().getVariables();
        parentProcessVariables.put(Constants.VAR_PARENTPROCESS_ID, execution.getContext().getProcessInstanceId());
        ProcessInstance subProcessInstance = actvitiFacade.startProcess(userId, getProcessDefinitionKey(), parentProcessVariables);
        StepsUtil.setSubProcessId(execution.getContext(), subProcessInstance.getProcessInstanceId());

        return StepPhase.POLL;
    } catch (Exception e) {
        getStepLogger().error(e, "Error starting sub-process");
        throw new SLException(e);
    }
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:20,代碼來源:AbstractSubProcessStarterStep.java

示例12: test

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
/**
 * Test.
 *
 * @return the string
 */
@RequestMapping(method=RequestMethod.GET, value="/resumeall")
@ResponseBody
public String test()
   {
	logger.info("Resuming crashed processes!!!");
	List<ProcessInstance> processes = runtimeService.createProcessInstanceQuery().active().list();
	
	for (ProcessInstance process : processes) {
		ExecutionEntity exec = (ExecutionEntity)process;
		if (exec.isActive() && exec.getActivityId().equals("ackStart")) {
			exec.getId();
			runtimeService.signal(exec.getId());
		}
	}
	return "Resumed all processes";
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:22,代碼來源:CtrlrServlet.java

示例13: setUp

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
@BeforeTest
public void setUp(){
	RuntimeService rts = mock(RuntimeService.class);
	List<ProcessInstance> processList = new ArrayList<ProcessInstance>();
	ExecutionEntity executionEntity = new  ExecutionEntity();
	executionEntity.setActive(false);
	processList.add(executionEntity);
	
	ProcessInstanceQuery pQuery = mock(ProcessInstanceQuery.class);
	when(pQuery.active()).thenReturn(pQuery);
	when(pQuery.list()).thenReturn(processList);
	when(rts.createProcessInstanceQuery()).thenReturn(pQuery);

	this.servlet.setRuntimeService(rts);
	this.servlet.setWoDispatcher(mock(WoDispatcher.class));
	this.servlet.init();
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:18,代碼來源:CtrlrServletTest.java

示例14: deleteProcess

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
@Override
public void deleteProcess(String id)
{
    validateIfUserAllowedToWorkWithProcess(id);
    
    ProcessInstance processInstance = activitiProcessEngine.getRuntimeService()
            .createProcessInstanceQuery()
            .processInstanceId(id)
            .singleResult();
    
    if (processInstance == null)
    {
        throw new EntityNotFoundException(id);
    }
    
    activitiProcessEngine.getRuntimeService().deleteProcessInstance(id, "deleted through REST API call");
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:18,代碼來源:ProcessesImpl.java

示例15: updateVariable

import org.activiti.engine.runtime.ProcessInstance; //導入依賴的package包/類
@Override
public Variable updateVariable(String processId, Variable variable)
{
    validateIfUserAllowedToWorkWithProcess(processId);
    
    ProcessInstance processInstance = activitiProcessEngine.getRuntimeService()
            .createProcessInstanceQuery()
            .processInstanceId(processId)
            .singleResult();
    
    if (processInstance == null)
    {
        throw new EntityNotFoundException(processId);
    }
    
    return updateVariableInProcess(processId, processInstance.getProcessDefinitionId(), variable);
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:18,代碼來源:ProcessesImpl.java


注:本文中的org.activiti.engine.runtime.ProcessInstance類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。