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


Java ProcessInstance.getProcessDefinitionId方法代碼示例

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


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

示例1: resourceRead

import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
/**
 * 讀取資源,通過部署ID
 * @param processDefinitionId  流程定義ID
 * @param processInstanceId 流程實例ID
 * @param resourceType 資源類型(xml|image)
 */
public InputStream resourceRead(String procDefId, String proInsId, String resType) throws Exception {
	
	if (StringUtils.isBlank(procDefId)){
		ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(proInsId).singleResult();
		procDefId = processInstance.getProcessDefinitionId();
	}
	ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).singleResult();
	
	String resourceName = "";
	if (resType.equals("image")) {
		resourceName = processDefinition.getDiagramResourceName();
	} else if (resType.equals("xml")) {
		resourceName = processDefinition.getResourceName();
	}
	
	InputStream resourceAsStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), resourceName);
	return resourceAsStream;
}
 
開發者ID:EleTeam,項目名稱:Shop-for-JavaWeb,代碼行數:25,代碼來源:ActProcessService.java

示例2: main

import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的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");
 }
 
開發者ID:balsarori,項目名稱:activiti-examples,代碼行數:35,代碼來源:ChangeServiceClass.java

示例3: 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);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:53,代碼來源:ActivitiTypeConverter.java

示例4: getVariables

import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
@Override
public CollectionWithPagingInfo<Variable> getVariables(String processId, Paging paging)
{
    CollectionWithPagingInfo<Variable> result = null;
    
    // Check if user is allowed to get variables
    List<HistoricVariableInstance> variableInstances = validateIfUserAllowedToWorkWithProcess(processId);
    Map<String, Object> variables = new HashMap<String, Object>();
    for (HistoricVariableInstance variable : variableInstances)
    {
        variables.put(variable.getVariableName(), variable.getValue());
    }
    
    ProcessInstance processInstance = activitiProcessEngine.getRuntimeService()
            .createProcessInstanceQuery()
            .processInstanceId(processId)
            .singleResult();
    
    String processDefinitionId = null;
    
    if (processInstance != null)
    {
        processDefinitionId = processInstance.getProcessDefinitionId();
    }
    else
    {
        // Completed process instance
        HistoricProcessInstance historicInstance = activitiProcessEngine.getHistoryService().createHistoricProcessInstanceQuery()
            .processInstanceId(processId).singleResult();
        
        if (historicInstance == null)
        {
            throw new EntityNotFoundException(processId);
        }
        
        processDefinitionId = historicInstance.getProcessDefinitionId();
    }

    // Get start-task definition for explicit typing of variables submitted at the start
    String formKey = null;
    StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(processDefinitionId);
    if (startFormData != null)
    {
        formKey = startFormData.getFormKey();
    }
    
    TypeDefinition startTaskTypeDefinition = getWorkflowFactory().getTaskFullTypeDefinition(formKey, true);
    
    // Convert raw variables to Variable objects
    List<Variable> resultingVariables = restVariableHelper.getVariables(variables, startTaskTypeDefinition);
    result = CollectionWithPagingInfo.asPaged(paging, resultingVariables);
    return result;
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:54,代碼來源:ProcessesImpl.java

示例5: generateImage

import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
/**
 * 生成流程實例的流程圖片,並重點高亮當前節點,高亮已經執行的鏈路
 *
 * @param instanceId 流程實例
 * @param request
 * @return 第二個參數為生成的圖片路徑
 */
@RequestMapping(value = "/processinstance/generate/{instanceId}", method = RequestMethod.POST)
@ResponseBody
public Result generateImage(@PathVariable("instanceId") String instanceId, HttpServletRequest request) {
    try {
        String dirPath = request.getRealPath("/");
        ProcessInstance processInstance=runtimeService.createProcessInstanceQuery().processInstanceId(instanceId)
                .singleResult();
        BpmnModel bpmnModel;
        List<String> activeActivityIds=new ArrayList<>();
        String processDefinitionId;
        //存在活動節點,流程正在進行中
        if(processInstance!=null) {
            processDefinitionId=processInstance.getProcessDefinitionId();
            //task = taskService.createTaskQuery().processInstanceId(instanceId).singleResult();
            //流程定義
            //正在活動的節點
            activeActivityIds = runtimeService.getActiveActivityIds(instanceId);//(task.getExecutionId());
        }else {
            //流程已經結束
            HistoricProcessInstance instance=historyService.createHistoricProcessInstanceQuery()
                    .processInstanceId(instanceId).singleResult();
            processDefinitionId=instance.getProcessDefinitionId();
        }

        bpmnModel = repositoryService.getBpmnModel(processDefinitionId);

        ProcessDiagramGenerator pdg = processEngine.getProcessEngineConfiguration().getProcessDiagramGenerator();

        //-------------------------------executedActivityIdList已經執行的節點------------------------------------
        List<HistoricActivityInstance> historicActivityInstanceList = historyService
                .createHistoricActivityInstanceQuery()
                .processInstanceId(instanceId).orderByHistoricActivityInstanceStartTime().asc().list();

        // 已執行的節點ID集合
        List<String> executedActivityIdList = new ArrayList<>();
        for (HistoricActivityInstance activityInstance : historicActivityInstanceList) {
            executedActivityIdList.add(activityInstance.getActivityId());
        }

        ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processDefinitionId);
        String resourceName = instanceId + "_" + processDefinition.getDiagramResourceName();

        List<String> highLightedFlows = getHighLightedFlows((ProcessDefinitionEntity) processDefinition,
                historicActivityInstanceList);

        //生成流圖片 所有走過的節點高亮 第三個參數 activeActivityIds=當前活動節點點高亮;executedActivityIdList=已經執行過的節點高亮
        InputStream inputStream = pdg.generateDiagram(bpmnModel, "PNG", activeActivityIds, highLightedFlows,
                processEngine.getProcessEngineConfiguration().getActivityFontName(),
                processEngine.getProcessEngineConfiguration().getLabelFontName(),
                processEngine.getProcessEngineConfiguration().getActivityFontName(),
                processEngine.getProcessEngineConfiguration().getProcessEngineConfiguration().getClassLoader(), 1);

        resourceName=DateUtil.format(new Date(),"yyyyMMddHHmmss")+"_"+resourceName;
        //生成本地圖片
        String realPath = dirPath + File.separator + DIR_PATH + File.separator + resourceName;
        realPath=realPath.replaceAll("\\\\", "/");
        File file = new File(realPath);
        if (file.exists()) {
            file.delete();
        }
        FileUtil.copyInputStreamToFile(inputStream, file);
        String realName = (DIR_PATH + File.separator + resourceName).replaceAll("\\\\", "/");
        inputStream.close();
        return new Result(true, realName, "成功生成png");
    } catch (Exception e) {
        LOGGER.error("生成圖像文件異常,instanceId={}", instanceId, e);
        return new Result(false);
    }
}
 
開發者ID:bill1012,項目名稱:AdminEAP,代碼行數:77,代碼來源:ProcessInstanceController.java


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