本文整理汇总了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;
}
示例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");
}
示例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);
}
示例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;
}
示例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);
}
}