protected boolean isActivityIdInProcessDefinitionModel(String activityId, BpmnModel bpmnModel) { return bpmnModel.getFlowElement(activityId) != null; }
public void createBPMNEdge(String key, List<GraphicInfo> graphicList) { FlowElement flowElement = bpmnModel.getFlowElement(key); if (flowElement != null && sequenceFlows.containsKey(key)) { TransitionImpl sequenceFlow = sequenceFlows.get(key); List<Integer> waypoints = new ArrayList<>(); for (GraphicInfo waypointInfo : graphicList) { waypoints.add((int) waypointInfo.getX()); waypoints.add((int) waypointInfo.getY()); } sequenceFlow.setWaypoints(waypoints); } else if (bpmnModel.getArtifact(key) != null) { // it's an association, so nothing to do } else { LOGGER.warn("Invalid reference in 'bpmnElement' attribute, sequenceFlow {} not found", key); } }
protected static void createBpmnShape(BpmnModel model, String elementId, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_SHAPE, BPMNDI_NAMESPACE); xtw.writeAttribute(ATTRIBUTE_DI_BPMNELEMENT, elementId); xtw.writeAttribute(ATTRIBUTE_ID, "BPMNShape_" + elementId); GraphicInfo graphicInfo = model.getGraphicInfo(elementId); FlowElement flowElement = model.getFlowElement(elementId); if (flowElement instanceof SubProcess && graphicInfo.getExpanded() != null) { xtw.writeAttribute(ATTRIBUTE_DI_IS_EXPANDED, String.valueOf(graphicInfo.getExpanded())); } xtw.writeStartElement(OMGDC_PREFIX, ELEMENT_DI_BOUNDS, OMGDC_NAMESPACE); xtw.writeAttribute(ATTRIBUTE_DI_HEIGHT, String.valueOf(graphicInfo.getHeight())); xtw.writeAttribute(ATTRIBUTE_DI_WIDTH, String.valueOf(graphicInfo.getWidth())); xtw.writeAttribute(ATTRIBUTE_DI_X, String.valueOf(graphicInfo.getX())); xtw.writeAttribute(ATTRIBUTE_DI_Y, String.valueOf(graphicInfo.getY())); xtw.writeEndElement(); xtw.writeEndElement(); }
public void createBPMNEdge(String key, List<GraphicInfo> graphicList) { FlowElement flowElement = bpmnModel.getFlowElement(key); if (flowElement instanceof SequenceFlow) { SequenceFlow sequenceFlow = (SequenceFlow) flowElement; List<Integer> waypoints = new ArrayList<>(); for (GraphicInfo waypointInfo : graphicList) { waypoints.add((int) waypointInfo.getX()); waypoints.add((int) waypointInfo.getY()); } sequenceFlow.setWaypoints(waypoints); } else if (bpmnModel.getArtifact(key) != null) { // it's an association, so nothing to do } else { LOGGER.warn("Invalid reference in 'bpmnElement' attribute, sequenceFlow {} not found", key); } }
if (bpmnModel.getFlowElement(bpmnReference) == null) { addWarning(errors, Problems.DI_INVALID_REFERENCE, null, bpmnModel.getFlowElement(bpmnReference), "Invalid reference in diagram interchange definition: could not find " + bpmnReference); } else if (!(bpmnModel.getFlowElement(bpmnReference) instanceof FlowNode)) { addWarning(errors, Problems.DI_DOES_NOT_REFERENCE_FLOWNODE, null, bpmnModel.getFlowElement(bpmnReference), "Invalid reference in diagram interchange definition: " + bpmnReference + " does not reference a flow node"); if (bpmnModel.getFlowElement(bpmnReference) == null) { addWarning(errors, Problems.DI_INVALID_REFERENCE, null, bpmnModel.getFlowElement(bpmnReference), "Invalid reference in diagram interchange definition: could not find " + bpmnReference); } else if (!(bpmnModel.getFlowElement(bpmnReference) instanceof SequenceFlow)) { addWarning(errors, Problems.DI_DOES_NOT_REFERENCE_SEQ_FLOW, null, bpmnModel.getFlowElement(bpmnReference), "Invalid reference in diagram interchange definition: " + bpmnReference + " does not reference a sequence flow");
protected FlowElement resolveFlowElementFromBpmnModel(BpmnModel bpmnModel, String activityId) { FlowElement flowElement = bpmnModel.getFlowElement(activityId); if (flowElement == null) { throw new FlowableException("Cannot find activity '" + activityId + "' in process definition with id '" + bpmnModel.getMainProcess().getId() + "'"); } return flowElement; } //-- Move container preparation section end
FlowElement flowElement = model.getFlowElement(elementId); MessageFlow messageFlow = null; if (flowElement == null) {
/** * Returns the current {@link FlowElement} where the {@link DelegateExecution} is currently at. */ public static FlowElement getFlowElement(DelegateExecution execution) { BpmnModel bpmnModel = getBpmnModel(execution); FlowElement flowElement = bpmnModel.getFlowElement(execution.getCurrentActivityId()); if (flowElement == null) { throw new FlowableException("Could not find a FlowElement for activityId " + execution.getCurrentActivityId()); } return flowElement; }
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; }
if (bpmnModel.getFlowElement(bpmnReference) == null) { } else if (!(bpmnModel.getFlowElement(bpmnReference) instanceof FlowNode)) { LOGGER.warn("Invalid reference in diagram interchange definition: {} does not reference a flow node", bpmnReference); if (bpmnModel.getFlowElement(bpmnReference) == null) { } else if (!(bpmnModel.getFlowElement(bpmnReference) instanceof SequenceFlow)) { LOGGER.warn("Invalid reference in diagram interchange definition: {} does not reference a sequence flow", bpmnReference); if (bpmnModel.getFlowElement(edgeId) != null) { createBPMNEdge(edgeId, bpmnModel.getFlowLocationGraphicInfo(edgeId));
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; }
FlowElement flowElement = bpmnModel.getFlowElement(elementId); if (flowElement == null) { throw new IllegalStateException("No flow element with id " + elementId + " found in bpmnmodel " + bpmnModel.getMainProcess().getId());
if (bpmnModel.getFlowElement(bpmnReference) == null) { } else if (!(bpmnModel.getFlowElement(bpmnReference) instanceof FlowNode)) { LOGGER.warn("Invalid reference in diagram interchange definition: {} does not reference a flow node", bpmnReference); if (bpmnModel.getFlowElement(bpmnReference) == null) { } else if (!(bpmnModel.getFlowElement(bpmnReference) instanceof SequenceFlow)) { LOGGER.warn("Invalid reference in diagram interchange definition: {} does not reference a sequence flow", bpmnReference); if (bpmnModel.getFlowElement(edgeId) != null) { createBPMNEdge(edgeId, bpmnModel.getFlowLocationGraphicInfo(edgeId));
@Override protected void updateExecutions(CommandContext commandContext, ProcessDefinitionEntity processDefinitionEntity, ExecutionEntity processInstance, List<ExecutionEntity> childExecutions) { TaskEntity taskEntity = CommandContextUtil.getTaskService().getTask(taskId); ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext); ExecutionEntity executionAtTask = executionEntityManager.findById(taskEntity.getExecutionId()); BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionEntity.getId()); FlowElement taskElement = bpmnModel.getFlowElement(executionAtTask.getCurrentActivityId()); FlowElement subProcessElement = bpmnModel.getFlowElement(((SubProcess) taskElement.getParentContainer()).getId()); ExecutionEntity subProcessExecution = executionEntityManager.createChildExecution(executionAtTask.getParent()); subProcessExecution.setScope(true); subProcessExecution.setCurrentFlowElement(subProcessElement); CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityStart(subProcessExecution); executionAtTask.setParent(subProcessExecution); ExecutionEntity taskExecution = executionEntityManager.createChildExecution(subProcessExecution); FlowElement userTaskElement = bpmnModel.getFlowElement(dynamicUserTaskBuilder.getDynamicTaskId()); taskExecution.setCurrentFlowElement(userTaskElement); Context.getAgenda().planContinueProcessOperation(taskExecution); } }
FlowElement defaultFlowElement = model.getFlowElement(activity.getDefaultFlow()); if (defaultFlowElement instanceof SequenceFlow) { writeDefaultAttribute(ATTRIBUTE_DEFAULT, activity.getDefaultFlow(), xtw); final Gateway gateway = (Gateway) baseElement; if (StringUtils.isNotEmpty(gateway.getDefaultFlow())) { FlowElement defaultFlowElement = model.getFlowElement(gateway.getDefaultFlow()); if (defaultFlowElement instanceof SequenceFlow) { writeDefaultAttribute(ATTRIBUTE_DEFAULT, gateway.getDefaultFlow(), xtw);
@Override protected void updateExecutions(CommandContext commandContext, ProcessDefinitionEntity processDefinitionEntity, ExecutionEntity processInstance, List<ExecutionEntity> childExecutions) { ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext); TaskEntity taskEntity = CommandContextUtil.getTaskService().getTask(taskId); ExecutionEntity executionAtTask = executionEntityManager.findById(taskEntity.getExecutionId()); BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionEntity.getId()); FlowElement taskElement = bpmnModel.getFlowElement(executionAtTask.getCurrentActivityId()); FlowElement subProcessElement = bpmnModel.getFlowElement(((SubProcess) taskElement.getParentContainer()).getId()); ExecutionEntity subProcessExecution = executionEntityManager.createChildExecution(executionAtTask.getParent()); subProcessExecution.setScope(true); subProcessExecution.setCurrentFlowElement(subProcessElement); CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityStart(subProcessExecution); executionAtTask.setParent(subProcessExecution); ExecutionEntity execution = executionEntityManager.createChildExecution(subProcessExecution); FlowElement newSubProcess = bpmnModel.getMainProcess().getFlowElement(dynamicEmbeddedSubProcessBuilder.getDynamicSubProcessId(), true); execution.setCurrentFlowElement(newSubProcess); CommandContextUtil.getAgenda().planContinueProcessOperation(execution); }
SubProcess subProcess = (SubProcess) bpmnModel.getFlowElement(dynamicEmbeddedSubProcessBuilder.getDynamicSubProcessId()); ExecutionEntity subProcessExecution = executionEntityManager.createChildExecution(processInstance); subProcessExecution.setScope(true);
Activity miActivityElement = (Activity) bpmnModel.getFlowElement(miExecution.getActivityId()); MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = miActivityElement.getLoopCharacteristics();
public static TimerJobEntity rescheduleTimerJob(String timerJobId, TimerEventDefinition timerEventDefinition) { TimerJobService timerJobService = CommandContextUtil.getTimerJobService(); TimerJobEntity timerJob = timerJobService.findTimerJobById(timerJobId); if (timerJob != null) { BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(timerJob.getProcessDefinitionId()); Event eventElement = (Event) bpmnModel.getFlowElement(TimerEventHandler.getActivityIdFromConfiguration(timerJob.getJobHandlerConfiguration())); boolean isInterruptingTimer = false; if (eventElement instanceof BoundaryEvent) { isInterruptingTimer = ((BoundaryEvent) eventElement).isCancelActivity(); } ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager().findById(timerJob.getExecutionId()); TimerJobEntity rescheduledTimerJob = TimerUtil.createTimerEntityForTimerEventDefinition(timerEventDefinition, isInterruptingTimer, execution, timerJob.getJobHandlerType(), timerJob.getJobHandlerConfiguration()); timerJobService.deleteTimerJob(timerJob); timerJobService.insertTimerJob(rescheduledTimerJob); FlowableEventDispatcher eventDispatcher = CommandContextUtil.getProcessEngineConfiguration().getEventDispatcher(); if (eventDispatcher.isEnabled()) { eventDispatcher.dispatchEvent( FlowableEventBuilder.createJobRescheduledEvent(FlowableEngineEventType.JOB_RESCHEDULED, rescheduledTimerJob, timerJob.getId())); // job rescheduled event should occur before new timer scheduled event eventDispatcher.dispatchEvent( FlowableJobEventBuilder.createEntityEvent(FlowableEngineEventType.TIMER_SCHEDULED, rescheduledTimerJob)); } return rescheduledTimerJob; } return null; }
Activity miActivityElement = (Activity) bpmnModel.getFlowElement(execution.getActivityId()); MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = miActivityElement.getLoopCharacteristics();