本文整理汇总了Java中org.activiti.engine.history.HistoricProcessInstance.getProcessDefinitionId方法的典型用法代码示例。如果您正苦于以下问题:Java HistoricProcessInstance.getProcessDefinitionId方法的具体用法?Java HistoricProcessInstance.getProcessDefinitionId怎么用?Java HistoricProcessInstance.getProcessDefinitionId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.history.HistoricProcessInstance
的用法示例。
在下文中一共展示了HistoricProcessInstance.getProcessDefinitionId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: traceProcessInstance
import org.activiti.engine.history.HistoricProcessInstance; //导入方法依赖的package包/类
public List<NodeDTO> traceProcessInstance(String processInstanceId) {
HistoricProcessInstance historicProcessInstance = processEngine
.getHistoryService().createHistoricProcessInstanceQuery()
.processInstanceId(processInstanceId).singleResult();
GetBpmnModelCmd getBpmnModelCmd = new GetBpmnModelCmd(
historicProcessInstance.getProcessDefinitionId());
BpmnModel bpmnModel = processEngine.getManagementService()
.executeCommand(getBpmnModelCmd);
Map<String, GraphicInfo> graphicInfoMap = bpmnModel.getLocationMap();
List<NodeDTO> nodeDtos = new ArrayList<NodeDTO>();
for (Map.Entry<String, GraphicInfo> entry : graphicInfoMap.entrySet()) {
String key = entry.getKey();
GraphicInfo graphicInfo = entry.getValue();
nodeDtos.add(this.convertNodeDto(graphicInfo,
bpmnModel.getFlowElement(key), key, bpmnModel));
}
return nodeDtos;
}
示例2: localize
import org.activiti.engine.history.HistoricProcessInstance; //导入方法依赖的package包/类
protected void localize(HistoricProcessInstance processInstance, CommandContext commandContext) {
processInstance.setLocalizedName(null);
processInstance.setLocalizedDescription(null);
if (locale != null && processInstance.getProcessDefinitionId() != null) {
ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processInstance.getProcessDefinitionId());
ObjectNode languageNode = Context.getLocalizationElementProperties(locale, processDefinition.getKey(),
processInstance.getProcessDefinitionId(), withLocalizationFallback);
if (languageNode != null) {
JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME);
if (languageNameNode != null && !languageNameNode.isNull()) {
processInstance.setLocalizedName(languageNameNode.asText());
}
JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION);
if (languageDescriptionNode != null && !languageDescriptionNode.isNull()) {
processInstance.setLocalizedDescription(languageDescriptionNode.asText());
}
}
}
}
示例3: drawHistoryFlow
import org.activiti.engine.history.HistoricProcessInstance; //导入方法依赖的package包/类
public void drawHistoryFlow(BufferedImage image, String processInstanceId) {
HistoricProcessInstance historicProcessInstance = Context
.getCommandContext().getHistoricProcessInstanceEntityManager()
.findHistoricProcessInstance(processInstanceId);
String processDefinitionId = historicProcessInstance
.getProcessDefinitionId();
Graph graph = new ActivitiHistoryGraphBuilder(processInstanceId)
.build();
for (Edge edge : graph.getEdges()) {
drawSequenceFlow(image, processDefinitionId, edge.getName());
}
}
示例4: ProcessInfo
import org.activiti.engine.history.HistoricProcessInstance; //导入方法依赖的package包/类
public ProcessInfo(HistoricProcessInstance processInstance)
{
this.id = processInstance.getId();
this.processDefinitionId = processInstance.getProcessDefinitionId();
this.startedAt = processInstance.getStartTime();
this.endedAt = processInstance.getEndTime();
this.durationInMs = processInstance.getDurationInMillis();
this.deleteReason = processInstance.getDeleteReason();
this.startUserId = processInstance.getStartUserId();
this.startActivityId = processInstance.getStartActivityId();
this.endActivityId = processInstance.getEndActivityId();
this.businessKey = processInstance.getBusinessKey();
this.superProcessInstanceId = processInstance.getSuperProcessInstanceId();
this.completed = (processInstance.getEndTime() != null);
}
示例5: findProcessDefinitionByPid
import org.activiti.engine.history.HistoricProcessInstance; //导入方法依赖的package包/类
/**
* 根据流程实例ID查询流程定义对象{@link ProcessDefinition}
*
* @param processInstanceId 流程实例ID
* @return 流程定义对象{@link ProcessDefinition}
*/
public ProcessDefinition findProcessDefinitionByPid(String processInstanceId) {
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
String processDefinitionId = historicProcessInstance.getProcessDefinitionId();
ProcessDefinition processDefinition = findProcessDefinition(processDefinitionId);
return processDefinition;
}
示例6: copyProcessInstance
import org.activiti.engine.history.HistoricProcessInstance; //导入方法依赖的package包/类
@RequestMapping("workspace-copyProcessInstance")
public String copyProcessInstance(
@RequestParam("processInstanceId") String processInstanceId)
throws Exception {
// 复制流程
// 1. 从历史获取businessKey
HistoricProcessInstance historicProcessInstance = processEngine
.getHistoryService().createHistoricProcessInstanceQuery()
.processInstanceId(processInstanceId).singleResult();
String businessKey = historicProcessInstance.getBusinessKey();
String processDefinitionId = historicProcessInstance
.getProcessDefinitionId();
// 2. 从businessKey获取keyvalue
Record original = keyValueConnector.findByCode(businessKey);
// 3. 找到流程的第一个form
FormDTO formDto = this.processConnector
.findStartForm(processDefinitionId);
List<String> fieldNames = new ArrayList<String>();
if (formDto.isExists()) {
String content = formDto.getContent();
logger.debug("content : {}", content);
Map<String, Object> formJson = jsonMapper.fromJson(
formDto.getContent(), Map.class);
List<Map<String, Object>> sections = (List<Map<String, Object>>) formJson
.get("sections");
for (Map<String, Object> section : sections) {
if (!"grid".equals(section.get("type"))) {
continue;
}
List<Map<String, Object>> fields = (List<Map<String, Object>>) section
.get("fields");
for (Map<String, Object> field : fields) {
logger.debug("field : {}", field);
String type = (String) field.get("type");
String name = (String) field.get("name");
String label = name;
if ("label".equals(type)) {
continue;
}
// if (formField != null) {
// continue;
// }
fieldNames.add(name);
}
}
}
logger.debug("fieldNames : {}", fieldNames);
// 4. 使用第一个form复制数据,后续的审批意见数据之类的不要复制
Record record = keyValueConnector.copyRecord(original, fieldNames);
// 5. 跳转到草稿箱
return "redirect:/operation/process-operation-listDrafts.do";
}
示例7: publishProcessDocument
import org.activiti.engine.history.HistoricProcessInstance; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void publishProcessDocument(Map<String, Object> processMap, HistoricProcessInstance processInstanceDetails) throws Exception {
String documentId = processInstanceDetails.getProcessDefinitionId() + "-" + processInstanceDetails.getId();
String indexName = indexPrefix;
String processState = (String) processMap.get("ProcessState");
if (processState.equals("Unknown")) {
// If Status unknown, we need to search for an existing doc in all
// indexes. Creating the payload for the search
String idIndexSearchQuery = "{\"query\":{\"term\":{\"_id\":\"" + documentId + "\"}}}";
// If doc found during search, just update the status. Creating the
// update request payload below
String updatePayload = "{\"doc\":{\"ProcessState\":\"Unknown\"}}";
String searchResponse = elasticHTTPClient.execute(esUrl + "bpmanalyticseventlog*/bpmanalyticsevent/_search",
idIndexSearchQuery, "POST");
Map<String, Object> searchResponseMap = null;
try {
searchResponseMap = new ObjectMapper().readValue(searchResponse, Map.class);
} catch (Exception e) {
logger.error("Error while trying parse the searchResponseMap for documentId: " + documentId);
}
if (searchResponseMap != null
&& (Integer) ((Map<String, Object>) searchResponseMap.get("hits")).get("total") > 0) {
indexName = (String) ((List<Map<String, Object>>) ((Map<String, Object>) searchResponseMap.get("hits"))
.get("hits")).get(0).get("_index");
elasticHTTPClient.execute(esUrl + indexName + "/bpmanalyticsevent/" + documentId + "/_update",
updatePayload, "POST");
} else {
elasticHTTPClient.execute(esUrl + indexName + "/bpmanalyticsevent/" + documentId,
objectMapper.writeValueAsString(processMap), "PUT");
}
} else {
if (processInstanceDetails.getStartTime() != null) {
indexName = indexName + '-'
+ new SimpleDateFormat("yyyy.MM").format(processInstanceDetails.getStartTime());
}
elasticHTTPClient.execute(esUrl + indexName + "/bpmanalyticsevent/" + documentId,
objectMapper.writeValueAsString(processMap), "PUT");
}
}
开发者ID:cijujoseph,项目名称:activiti-analytics-spring-boot,代码行数:44,代码来源:CustomElasticAnalyticsEndpoint.java
示例8: getVariables
import org.activiti.engine.history.HistoricProcessInstance; //导入方法依赖的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;
}
示例9: generateImage
import org.activiti.engine.history.HistoricProcessInstance; //导入方法依赖的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);
}
}