Java Code Examples for org.flowable.bpmn.model.FlowElement#getId()
The following examples show how to use
org.flowable.bpmn.model.FlowElement#getId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BpmnLoggingSessionUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
public static void addLoggingData(String type, String message, DelegateExecution execution) { FlowElement flowElement = execution.getCurrentFlowElement(); String activityId = null; String activityName = null; String activityType = null; String activitySubType = null; if (flowElement != null) { activityId = flowElement.getId(); activityName = flowElement.getName(); activityType = flowElement.getClass().getSimpleName(); activitySubType = getActivitySubType(flowElement); } ObjectNode loggingNode = LoggingSessionUtil.fillLoggingData(message, execution.getProcessInstanceId(), execution.getId(), ScopeTypes.BPMN, execution.getProcessDefinitionId(), activityId, activityName, activityType, activitySubType); fillScopeDefinitionInfo(execution.getProcessDefinitionId(), loggingNode); LoggingSessionUtil.addLoggingData(type, loggingNode); }
Example 2
Source File: BpmnLoggingSessionUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
public static void addErrorLoggingData(String type, String message, Throwable t, DelegateExecution execution) { FlowElement flowElement = execution.getCurrentFlowElement(); String activityId = null; String activityName = null; String activityType = null; String activitySubType = null; if (flowElement != null) { activityId = flowElement.getId(); activityName = flowElement.getName(); activityType = flowElement.getClass().getSimpleName(); activitySubType = getActivitySubType(flowElement); } ObjectNode loggingNode = LoggingSessionUtil.fillLoggingData(message, execution.getProcessInstanceId(), execution.getId(), ScopeTypes.BPMN, execution.getProcessDefinitionId(), activityId, activityName, activityType, activitySubType); fillScopeDefinitionInfo(execution.getProcessDefinitionId(), loggingNode); LoggingSessionUtil.addErrorLoggingData(type, loggingNode, t); }
Example 3
Source File: ExecutionTreeNode.java From flowable-engine with Apache License 2.0 | 5 votes |
protected String getCurrentFlowElementId() { FlowElement flowElement = getExecutionEntity().getCurrentFlowElement(); if (flowElement instanceof SequenceFlow) { SequenceFlow sequenceFlow = (SequenceFlow) flowElement; return sequenceFlow.getSourceRef() + " -> " + sequenceFlow.getTargetRef(); } else if (flowElement != null) { return flowElement.getId() + " (" + flowElement.getClass().getSimpleName(); } else { return ""; } }
Example 4
Source File: ExecutionEntityImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void setCurrentFlowElement(FlowElement currentFlowElement) { this.currentFlowElement = currentFlowElement; if (currentFlowElement != null) { this.activityId = currentFlowElement.getId(); this.activityName = currentFlowElement.getName(); } else { this.activityId = null; this.activityName = null; } }
Example 5
Source File: AbstractBpmnParseHandler.java From flowable-engine with Apache License 2.0 | 5 votes |
protected String getPrecedingEventBasedGateway(BpmnParse bpmnParse, IntermediateCatchEvent event) { String eventBasedGatewayId = null; for (SequenceFlow sequenceFlow : event.getIncomingFlows()) { FlowElement sourceElement = bpmnParse.getBpmnModel().getFlowElement(sequenceFlow.getSourceRef()); if (sourceElement instanceof EventGateway) { eventBasedGatewayId = sourceElement.getId(); break; } } return eventBasedGatewayId; }
Example 6
Source File: ExecutionEntity.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void setCurrentFlowElement(FlowElement currentFlowElement) { this.currentFlowElement = currentFlowElement; if (currentFlowElement != null) { this.activityId = currentFlowElement.getId(); } else { this.activityId = null; } }
Example 7
Source File: AbstractBpmnParseHandler.java From flowable-engine with Apache License 2.0 | 5 votes |
protected String getPrecedingEventBasedGateway(BpmnParse bpmnParse, IntermediateCatchEvent event) { String eventBasedGatewayId = null; for (SequenceFlow sequenceFlow : event.getIncomingFlows()) { FlowElement sourceElement = bpmnParse.getBpmnModel().getFlowElement(sequenceFlow.getSourceRef()); if (sourceElement instanceof EventGateway) { eventBasedGatewayId = sourceElement.getId(); break; } } return eventBasedGatewayId; }
Example 8
Source File: ExternalWorkerTaskActivityBehavior.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override public void execute(DelegateExecution execution) { CommandContext commandContext = CommandContextUtil.getCommandContext(); String skipExpressionText = null; if (skipExpression != null) { skipExpressionText = skipExpression.getExpressionText(); } FlowElement currentFlowElement = execution.getCurrentFlowElement(); String elementId = currentFlowElement.getId(); boolean isSkipExpressionEnabled = SkipExpressionUtil.isSkipExpressionEnabled(skipExpressionText, elementId, execution, commandContext); if (!isSkipExpressionEnabled || !SkipExpressionUtil.shouldSkipFlowElement(skipExpressionText, elementId, execution, commandContext)) { CreateExternalWorkerJobInterceptor interceptor = CommandContextUtil.getProcessEngineConfiguration(commandContext) .getCreateExternalWorkerJobInterceptor(); CreateExternalWorkerJobBeforeContext beforeContext = new CreateExternalWorkerJobBeforeContext( externalWorkerServiceTask, execution, getJobCategory(currentFlowElement) ); if (interceptor != null) { interceptor.beforeCreateExternalWorkerJob(beforeContext); } JobServiceConfiguration jobServiceConfiguration = CommandContextUtil.getJobServiceConfiguration(commandContext); JobService jobService = jobServiceConfiguration.getJobService(); ExternalWorkerJobEntity job = jobService.createExternalWorkerJob(); job.setExecutionId(execution.getId()); job.setProcessInstanceId(execution.getProcessInstanceId()); job.setProcessDefinitionId(execution.getProcessDefinitionId()); job.setElementId(elementId); job.setElementName(currentFlowElement.getName()); job.setJobHandlerType(ExternalWorkerTaskCompleteJobHandler.TYPE); job.setExclusive(exclusive); if (StringUtils.isNotEmpty(beforeContext.getJobCategory())) { Expression categoryExpression = CommandContextUtil.getProcessEngineConfiguration(commandContext) .getExpressionManager() .createExpression(beforeContext.getJobCategory()); Object categoryValue = categoryExpression.getValue(execution); if (categoryValue != null) { job.setCategory(categoryValue.toString()); } } job.setJobType(JobEntity.JOB_TYPE_EXTERNAL_WORKER); job.setRetries(jobServiceConfiguration.getAsyncExecutorNumberOfRetries()); // Inherit tenant id (if applicable) if (execution.getTenantId() != null) { job.setTenantId(execution.getTenantId()); } Expression jobTopicExpression; if (StringUtils.isEmpty(beforeContext.getJobTopicExpression())) { jobTopicExpression = this.jobTopicExpression; } else { jobTopicExpression = CommandContextUtil.getProcessEngineConfiguration(commandContext) .getExpressionManager() .createExpression(beforeContext.getJobTopicExpression()); } Object topicValue = jobTopicExpression.getValue(execution); if (topicValue != null && !topicValue.toString().isEmpty()) { job.setJobHandlerConfiguration(topicValue.toString()); } else { throw new FlowableException("Expression " + jobTopicExpression + " did not evaluate to a valid value (non empty String). Was: " + topicValue); } jobService.insertExternalWorkerJob(job); if (interceptor != null) { interceptor.afterCreateExternalWorkerJob(new CreateExternalWorkerJobAfterContext( (ExternalWorkerServiceTask) currentFlowElement, job, execution )); } } else { leave(execution); } }
Example 9
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 4 votes |
protected boolean localizeFlowElements(Collection<FlowElement> flowElements, ObjectNode infoNode) { boolean localizationValuesChanged = false; if (flowElements == null) return localizationValuesChanged; CommandContext commandContext = Context.getCommandContext(); DynamicBpmnService dynamicBpmnService = CommandContextUtil.getProcessEngineConfiguration(commandContext).getDynamicBpmnService(); for (FlowElement flowElement : flowElements) { if (flowElement instanceof UserTask || flowElement instanceof SubProcess) { List<ExtensionElement> localizationElements = flowElement.getExtensionElements().get("localization"); if (localizationElements != null) { for (ExtensionElement localizationElement : localizationElements) { if (BpmnXMLConstants.FLOWABLE_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix()) || BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) { String locale = localizationElement.getAttributeValue(null, "locale"); String name = localizationElement.getAttributeValue(null, "name"); String documentation = null; List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation"); if (documentationElements != null) { for (ExtensionElement documentationElement : documentationElements) { documentation = StringUtils.trimToNull(documentationElement.getElementText()); break; } } String flowElementId = flowElement.getId(); if (!isEqualToCurrentLocalizationValue(locale, flowElementId, "name", name, infoNode)) { dynamicBpmnService.changeLocalizationName(locale, flowElementId, name, infoNode); localizationValuesChanged = true; } if (documentation != null && !isEqualToCurrentLocalizationValue(locale, flowElementId, "description", documentation, infoNode)) { dynamicBpmnService.changeLocalizationDescription(locale, flowElementId, documentation, infoNode); localizationValuesChanged = true; } } } } if (flowElement instanceof SubProcess) { SubProcess subprocess = (SubProcess) flowElement; boolean isFlowElementLocalizationChanged = localizeFlowElements(subprocess.getFlowElements(), infoNode); boolean isDataObjectLocalizationChanged = localizeDataObjectElements(subprocess.getDataObjects(), infoNode); if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) { localizationValuesChanged = true; } } } } return localizationValuesChanged; }
Example 10
Source File: BaseDynamicSubProcessInjectUtil.java From flowable-engine with Apache License 2.0 | 4 votes |
protected static void generateIdForDuplicateFlowElement(String prefix, org.flowable.bpmn.model.Process process, BpmnModel bpmnModel, BpmnModel subProcessBpmnModel, FlowElement duplicateFlowElement, Map<String, FlowElement> generatedIds, boolean includeDiInfo) { String originalFlowElementId = duplicateFlowElement.getId(); if (process.getFlowElement(originalFlowElementId, true) != null) { String newFlowElementId = prefix + "-" + originalFlowElementId; int counter = 0; boolean maxLengthReached = false; while (!maxLengthReached && process.getFlowElement(newFlowElementId, true) != null) { newFlowElementId = prefix + counter++ + "-" + originalFlowElementId; if (newFlowElementId.length() > 255) { maxLengthReached = true; } } if (maxLengthReached) { newFlowElementId = prefix + "-" + UUID.randomUUID().toString(); } duplicateFlowElement.setId(newFlowElementId); generatedIds.put(originalFlowElementId, duplicateFlowElement); if (includeDiInfo) { if (duplicateFlowElement instanceof SequenceFlow) { bpmnModel.addFlowGraphicInfoList(newFlowElementId, subProcessBpmnModel.getFlowLocationGraphicInfo(originalFlowElementId)); } else { bpmnModel.addGraphicInfo(newFlowElementId, subProcessBpmnModel.getGraphicInfo(originalFlowElementId)); } } for (FlowElement flowElement : duplicateFlowElement.getParentContainer().getFlowElements()) { if (flowElement instanceof SequenceFlow) { SequenceFlow sequenceFlow = (SequenceFlow) flowElement; if (sequenceFlow.getSourceRef().equals(originalFlowElementId)) { sequenceFlow.setSourceRef(newFlowElementId); } if (sequenceFlow.getTargetRef().equals(originalFlowElementId)) { sequenceFlow.setTargetRef(newFlowElementId); } } else if (flowElement instanceof BoundaryEvent) { BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement; if (boundaryEvent.getAttachedToRefId().equals(originalFlowElementId)) { boundaryEvent.setAttachedToRefId(newFlowElementId); } if (boundaryEvent.getEventDefinitions() != null && boundaryEvent.getEventDefinitions().size() > 0 && (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition)) { CompensateEventDefinition compensateEventDefinition = (CompensateEventDefinition) boundaryEvent.getEventDefinitions().get(0); if (compensateEventDefinition.getActivityRef().equals(originalFlowElementId)) { compensateEventDefinition.setActivityRef(newFlowElementId); } } } } } if (duplicateFlowElement instanceof FlowElementsContainer) { FlowElementsContainer flowElementsContainer = (FlowElementsContainer) duplicateFlowElement; for (FlowElement childFlowElement : flowElementsContainer.getFlowElements()) { generateIdForDuplicateFlowElement(prefix, process, bpmnModel, subProcessBpmnModel, childFlowElement, generatedIds, includeDiInfo); } } }
Example 11
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 4 votes |
protected boolean localizeFlowElements(Collection<FlowElement> flowElements, ObjectNode infoNode) { boolean localizationValuesChanged = false; if (flowElements == null) return localizationValuesChanged; CommandContext commandContext = Context.getCommandContext(); DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService(); for (FlowElement flowElement : flowElements) { if (flowElement instanceof UserTask || flowElement instanceof SubProcess) { List<ExtensionElement> localizationElements = flowElement.getExtensionElements().get("localization"); if (localizationElements != null) { for (ExtensionElement localizationElement : localizationElements) { if (BpmnXMLConstants.FLOWABLE_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix()) || BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) { String locale = localizationElement.getAttributeValue(null, "locale"); String name = localizationElement.getAttributeValue(null, "name"); String documentation = null; List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation"); if (documentationElements != null) { for (ExtensionElement documentationElement : documentationElements) { documentation = StringUtils.trimToNull(documentationElement.getElementText()); break; } } String flowElementId = flowElement.getId(); if (!isEqualToCurrentLocalizationValue(locale, flowElementId, "name", name, infoNode)) { dynamicBpmnService.changeLocalizationName(locale, flowElementId, name, infoNode); localizationValuesChanged = true; } if (documentation != null && !isEqualToCurrentLocalizationValue(locale, flowElementId, "description", documentation, infoNode)) { dynamicBpmnService.changeLocalizationDescription(locale, flowElementId, documentation, infoNode); localizationValuesChanged = true; } } } } if (flowElement instanceof SubProcess) { SubProcess subprocess = (SubProcess) flowElement; boolean isFlowElementLocalizationChanged = localizeFlowElements(subprocess.getFlowElements(), infoNode); boolean isDataObjectLocalizationChanged = localizeDataObjectElements(subprocess.getDataObjects(), infoNode); if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) { localizationValuesChanged = true; } } } } return localizationValuesChanged; }
Example 12
Source File: CdiEventSupportBpmnParseHandler.java From flowable-engine with Apache License 2.0 | 4 votes |
protected void addStartEventListener(FlowElement flowElement) { CdiExecutionListener listener = new CdiExecutionListener(flowElement.getId(), BusinessProcessEventType.START_ACTIVITY); addListenerToElement(flowElement, ExecutionListener.EVENTNAME_START, listener); }
Example 13
Source File: CdiEventSupportBpmnParseHandler.java From flowable-engine with Apache License 2.0 | 4 votes |
protected void addEndEventListener(FlowElement flowElement) { CdiExecutionListener listener = new CdiExecutionListener(flowElement.getId(), BusinessProcessEventType.END_ACTIVITY); addListenerToElement(flowElement, ExecutionListener.EVENTNAME_END, listener); }