Java Code Examples for org.flowable.bpmn.model.BpmnModel#getFlowElement()
The following examples show how to use
org.flowable.bpmn.model.BpmnModel#getFlowElement() .
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: BPMNDIExport.java From flowable-engine with Apache License 2.0 | 6 votes |
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(); }
Example 2
Source File: DataStoreConverterTest.java From flowable-engine with Apache License 2.0 | 6 votes |
private void validateModel(BpmnModel model) { assertThat(model.getDataStores()) .containsOnlyKeys("DataStore_1"); DataStore dataStore = model.getDataStore("DataStore_1"); assertThat(dataStore).isNotNull(); assertThat(dataStore.getId()).isEqualTo("DataStore_1"); assertThat(dataStore.getDataState()).isEqualTo("test"); assertThat(dataStore.getName()).isEqualTo("Test Database"); assertThat(dataStore.getItemSubjectRef()).isEqualTo("test"); FlowElement refElement = model.getFlowElement("DataStoreReference_1"); assertThat(refElement).isInstanceOf(DataStoreReference.class); assertThat(model.getPools()) .extracting(Pool::getId) .containsExactly("pool1"); }
Example 3
Source File: BoundaryEventGraphicInfoTest.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void validate(BpmnModel model) { BoundaryEvent event = (BoundaryEvent) model.getFlowElement(TIMER_BOUNDERY_ID); assertThat(event.getAttachedToRefId()).isEqualTo(USER_TASK_ID); //check graphicinfo boundary GraphicInfo giBoundary = model.getGraphicInfo(TIMER_BOUNDERY_ID); assertThat(giBoundary.getX()).isEqualTo(334.2201675394047); assertThat(giBoundary.getY()).isEqualTo(199.79587432571776); assertThat(giBoundary.getHeight()).isEqualTo(31.0); assertThat(giBoundary.getWidth()).isEqualTo(31.0); //check graphicinfo task GraphicInfo giTaskOne = model.getGraphicInfo(USER_TASK_ID); assertThat(giTaskOne.getX()).isEqualTo(300.0); assertThat(giTaskOne.getY()).isEqualTo(135.0); assertThat(giTaskOne.getWidth()).isEqualTo(100.0); assertThat(giTaskOne.getHeight()).isEqualTo(80.0); }
Example 4
Source File: InjectParallelUserTaskCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
@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); }
Example 5
Source File: InjectParallelEmbeddedSubProcessCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
@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); }
Example 6
Source File: FlowableAbstractTaskService.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void verifyProcessInstanceStartUser(TaskRepresentation taskRepresentation, TaskInfo task) { if (task.getProcessInstanceId() != null) { HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult(); if (historicProcessInstance != null && StringUtils.isNotEmpty(historicProcessInstance.getStartUserId())) { taskRepresentation.setProcessInstanceStartUserId(historicProcessInstance.getStartUserId()); BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; List<ExtensionElement> extensionElements = userTask.getExtensionElements().get("initiator-can-complete"); if (CollectionUtils.isNotEmpty(extensionElements)) { String value = extensionElements.get(0).getElementText(); if (StringUtils.isNotEmpty(value)) { taskRepresentation.setInitiatorCanCompleteTask(Boolean.valueOf(value)); } } } } } }
Example 7
Source File: InjectEmbeddedSubProcessInProcessInstanceCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override protected void updateExecutions(CommandContext commandContext, ProcessDefinitionEntity processDefinitionEntity, ExecutionEntity processInstance, List<ExecutionEntity> childExecutions) { ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext); BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionEntity.getId()); SubProcess subProcess = (SubProcess) bpmnModel.getFlowElement(dynamicEmbeddedSubProcessBuilder.getDynamicSubProcessId()); ExecutionEntity subProcessExecution = executionEntityManager.createChildExecution(processInstance); subProcessExecution.setScope(true); subProcessExecution.setCurrentFlowElement(subProcess); CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityStart(subProcessExecution); ExecutionEntity childExecution = executionEntityManager.createChildExecution(subProcessExecution); StartEvent initialEvent = null; for (FlowElement subElement : subProcess.getFlowElements()) { if (subElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) subElement; if (startEvent.getEventDefinitions().size() == 0) { initialEvent = startEvent; break; } } } if (initialEvent == null) { throw new FlowableException("Could not find a none start event in dynamic sub process"); } childExecution.setCurrentFlowElement(initialEvent); Context.getAgenda().planContinueProcessOperation(childExecution); }
Example 8
Source File: CollapsedSubWithSubSequenceFlowTest.java From flowable-engine with Apache License 2.0 | 5 votes |
private void validateModel(BpmnModel model) { //It appears that the sequenceflows of the expanded subprocess are also stored as a child of the collapsed subprocess... //this lead to duplications when writing back to json... SubProcess collapsedSubprocess = (SubProcess) model.getFlowElement(COLLAPSED_SUBPROCESS); Collection<FlowElement> flowElements = collapsedSubprocess.getFlowElements(); assertThat(flowElements).hasSize(5); //start - sf - sub - sf - end SubProcess subProcess = (SubProcess) model.getFlowElement(EXPANED_SUBPROCESS_IN_CP); assertThat(subProcess.getFlowElements()).hasSize(5); //start-sf-task-sf-end }
Example 9
Source File: EventSubprocessSequenceFlowTest.java From flowable-engine with Apache License 2.0 | 5 votes |
private void validate(BpmnModel model) { EventSubProcess eventSubProcess = (EventSubProcess) model.getFlowElement(EVENT_SUBPROCESS_ID); //assert that there where 5 sequenceflows registered. assertThat(model.getFlowLocationMap()).hasSize(5); List<GraphicInfo> graphicInfo = model.getFlowLocationGraphicInfo(FROM_SE_TO_TASK); GraphicInfo start = graphicInfo.get(0); assertThat(start.getX()).isCloseTo(180.5, offset(PRECISION)); //75.0+105.5 (parent + interception point) assertThat(start.getY()).isCloseTo(314.0, offset(PRECISION)); //230.0 + 99.0 - 15.0 (parent + lower right y - bounds y) GraphicInfo end = graphicInfo.get(1); assertThat(end.getX()).isCloseTo(225.5, offset(PRECISION)); //75.0 +150.5 assertThat(end.getY()).isCloseTo(314.0, offset(PRECISION)); //230.0 + 44.0 + 40 }
Example 10
Source File: MultiInstanceConverterTest.java From flowable-engine with Apache License 2.0 | 5 votes |
private void validateModel(BpmnModel model) { Activity activity = (Activity) model.getFlowElement("multi-instance"); assertThat(activity.getLoopCharacteristics().isSequential()).isTrue(); assertThat(activity.getLoopCharacteristics().getLoopCardinality()).isEqualTo("3"); assertThat(activity.getLoopCharacteristics().getElementVariable()).isEqualTo("instanceVar"); assertThat(activity.getLoopCharacteristics().getInputDataItem()).isEqualTo("collection"); assertThat(activity.getLoopCharacteristics().getElementIndexVariable()).isEqualTo("index"); assertThat(activity.getLoopCharacteristics().getCompletionCondition()).isEqualTo("completionCondition"); }
Example 11
Source File: AbstractDynamicStateManager.java From flowable-engine with Apache License 2.0 | 5 votes |
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; }
Example 12
Source File: ConditionalConverterTest.java From flowable-engine with Apache License 2.0 | 5 votes |
private void validateModel(BpmnModel model) { FlowElement flowElement = model.getFlowElement("conditionalCatch"); assertThat(flowElement).isInstanceOf(IntermediateCatchEvent.class); IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement; assertThat(catchEvent.getEventDefinitions()).hasSize(1); ConditionalEventDefinition event = (ConditionalEventDefinition) catchEvent.getEventDefinitions().get(0); assertThat(event.getConditionExpression()).isEqualTo("${testVar == 'test'}"); }
Example 13
Source File: TimerUtil.java From flowable-engine with Apache License 2.0 | 5 votes |
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, eventElement, isInterruptingTimer, execution, timerJob.getJobHandlerType(), timerJob.getJobHandlerConfiguration()); timerJobService.deleteTimerJob(timerJob); timerJobService.insertTimerJob(rescheduledTimerJob); FlowableEventDispatcher eventDispatcher = CommandContextUtil.getProcessEngineConfiguration().getEventDispatcher(); if (eventDispatcher != null && 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; }
Example 14
Source File: TextAnnotationConverterTest.java From flowable-engine with Apache License 2.0 | 5 votes |
private void validateModel(BpmnModel model) { FlowElement flowElement = model.getFlowElement("_5"); assertThat(flowElement) .isInstanceOfSatisfying(ScriptTask.class, scriptTask -> { assertThat(scriptTask.getId()).isEqualTo("_5"); assertThat(scriptTask.getName()).isEqualTo("Send Hello Message"); }); }
Example 15
Source File: DelegateHelper.java From flowable-engine with Apache License 2.0 | 5 votes |
/** * 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; }
Example 16
Source File: PermissionService.java From flowable-engine with Apache License 2.0 | 5 votes |
public boolean validateIfUserIsInitiatorAndCanCompleteTask(User user, Task task) { boolean canCompleteTask = false; if (task.getProcessInstanceId() != null) { HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult(); if (historicProcessInstance != null && StringUtils.isNotEmpty(historicProcessInstance.getStartUserId())) { String processInstanceStartUserId = historicProcessInstance.getStartUserId(); if (String.valueOf(user.getId()).equals(processInstanceStartUserId)) { BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; List<ExtensionElement> extensionElements = userTask.getExtensionElements().get("initiator-can-complete"); if (CollectionUtils.isNotEmpty(extensionElements)) { String value = extensionElements.get(0).getElementText(); if (StringUtils.isNotEmpty(value) && Boolean.valueOf(value)) { canCompleteTask = true; } } } } } } else if (task.getScopeId() != null) { HistoricCaseInstance historicCaseInstance = cmmnHistoryService.createHistoricCaseInstanceQuery().caseInstanceId(task.getScopeId()).singleResult(); if (historicCaseInstance != null && StringUtils.isNotEmpty(historicCaseInstance.getStartUserId())) { String caseInstanceStartUserId = historicCaseInstance.getStartUserId(); if (String.valueOf(user.getId()).equals(caseInstanceStartUserId)) { canCompleteTask = true; } } } return canCompleteTask; }
Example 17
Source File: CollapsedSubProcessConverterTest.java From flowable-engine with Apache License 2.0 | 4 votes |
private void validateModel(BpmnModel bpmnModel) { //temp vars GraphicInfo gi; List<GraphicInfo> flowLocationGraphicInfo; //validate parent gi = bpmnModel.getGraphicInfo(START_EVENT); assertThat(gi.getX()).isEqualTo(73.0); assertThat(gi.getY()).isEqualTo(96.0); assertThat(gi.getWidth()).isEqualTo(30.0); assertThat(gi.getHeight()).isEqualTo(30.0); assertThat(gi.getExpanded()).isNull(); flowLocationGraphicInfo = bpmnModel.getFlowLocationGraphicInfo(SEQUENCEFLOW_TO_COLLAPSEDSUBPROCESS); gi = bpmnModel.getGraphicInfo(COLLAPSEDSUBPROCESS); assertThat(gi.getExpanded()).isFalse(); //intersection points traversed from xml are full points it seems... assertThat(flowLocationGraphicInfo) .extracting(GraphicInfo::getX, GraphicInfo::getY) .containsExactly( tuple(102.0, 111.0), tuple(165.0, 112.0) ); //validate graphic infos FlowElement flowElement = bpmnModel.getFlowElement(IN_CSB_START_EVENT); assertThat(flowElement).isInstanceOf(StartEvent.class); gi = bpmnModel.getGraphicInfo(IN_CSB_START_EVENT); assertThat(gi.getX()).isEqualTo(90.0); assertThat(gi.getY()).isEqualTo(135.0); assertThat(gi.getWidth()).isEqualTo(30.0); assertThat(gi.getHeight()).isEqualTo(30.0); flowElement = bpmnModel.getFlowElement(IN_CSB_SEQUENCEFLOW_TO_USERTASK); assertThat(flowElement).isInstanceOf(SequenceFlow.class); assertThat(flowElement.getName()).isEqualTo("to ut"); flowLocationGraphicInfo = bpmnModel.getFlowLocationGraphicInfo(IN_CSB_SEQUENCEFLOW_TO_USERTASK); assertThat(flowLocationGraphicInfo) .extracting(GraphicInfo::getX, GraphicInfo::getY) .containsExactly( tuple(120.0, 150.0), tuple(232.0, 150.0) ); flowElement = bpmnModel.getFlowElement(IN_CSB_USERTASK); assertThat(flowElement).isInstanceOf(UserTask.class); assertThat(flowElement.getName()).isEqualTo("User task 1"); gi = bpmnModel.getGraphicInfo(IN_CSB_USERTASK); assertThat(gi.getX()).isEqualTo(232.0); assertThat(gi.getY()).isEqualTo(110.0); assertThat(gi.getWidth()).isEqualTo(100.0); assertThat(gi.getHeight()).isEqualTo(80.0); flowElement = bpmnModel.getFlowElement(IN_CSB_SEQUENCEFLOW_TO_END); assertThat(flowElement).isInstanceOf(SequenceFlow.class); assertThat(flowElement.getName()).isEqualTo("to end"); flowLocationGraphicInfo = bpmnModel.getFlowLocationGraphicInfo(IN_CSB_SEQUENCEFLOW_TO_END); assertThat(flowLocationGraphicInfo) .extracting(GraphicInfo::getX, GraphicInfo::getY) .containsExactly( tuple(332.0, 150.0), tuple(435.0, 150.0) ); }
Example 18
Source File: BPMNDIExport.java From flowable-engine with Apache License 2.0 | 4 votes |
protected static void createBpmnEdge(BpmnModel model, String elementId, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_EDGE, BPMNDI_NAMESPACE); xtw.writeAttribute(ATTRIBUTE_DI_BPMNELEMENT, elementId); xtw.writeAttribute(ATTRIBUTE_ID, "BPMNEdge_" + elementId); List<GraphicInfo> graphicInfoList = model.getFlowLocationGraphicInfo(elementId); for (GraphicInfo graphicInfo : graphicInfoList) { xtw.writeStartElement(OMGDI_PREFIX, ELEMENT_DI_WAYPOINT, OMGDI_NAMESPACE); xtw.writeAttribute(ATTRIBUTE_DI_X, String.valueOf(graphicInfo.getX())); xtw.writeAttribute(ATTRIBUTE_DI_Y, String.valueOf(graphicInfo.getY())); xtw.writeEndElement(); } GraphicInfo labelGraphicInfo = model.getLabelGraphicInfo(elementId); FlowElement flowElement = model.getFlowElement(elementId); MessageFlow messageFlow = null; if (flowElement == null) { messageFlow = model.getMessageFlow(elementId); } boolean hasName = false; if (flowElement != null && StringUtils.isNotEmpty(flowElement.getName())) { hasName = true; } else if (messageFlow != null && StringUtils.isNotEmpty(messageFlow.getName())) { hasName = true; } if (labelGraphicInfo != null && hasName) { xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_LABEL, BPMNDI_NAMESPACE); xtw.writeStartElement(OMGDC_PREFIX, ELEMENT_DI_BOUNDS, OMGDC_NAMESPACE); xtw.writeAttribute(ATTRIBUTE_DI_HEIGHT, String.valueOf(labelGraphicInfo.getHeight())); xtw.writeAttribute(ATTRIBUTE_DI_WIDTH, String.valueOf(labelGraphicInfo.getWidth())); xtw.writeAttribute(ATTRIBUTE_DI_X, String.valueOf(labelGraphicInfo.getX())); xtw.writeAttribute(ATTRIBUTE_DI_Y, String.valueOf(labelGraphicInfo.getY())); xtw.writeEndElement(); xtw.writeEndElement(); } xtw.writeEndElement(); }
Example 19
Source File: CollapsebleSubprocessTest.java From flowable-engine with Apache License 2.0 | 4 votes |
private void validateModel(BpmnModel bpmnModel) { //temp vars GraphicInfo gi = null; GraphicInfo start = null; GraphicInfo end = null; List<GraphicInfo> flowLocationGraphicInfo = null; //validate parent gi = bpmnModel.getGraphicInfo(START_EVENT); assertThat(gi.getX()).isEqualTo(73.0); assertThat(gi.getY()).isEqualTo(96.0); assertThat(gi.getWidth()).isEqualTo(30.0); assertThat(gi.getHeight()).isEqualTo(30.0); flowLocationGraphicInfo = bpmnModel.getFlowLocationGraphicInfo(SEQUENCEFLOW_TO_COLLAPSEDSUBPROCESS); assertThat(flowLocationGraphicInfo).hasSize(2); gi = bpmnModel.getGraphicInfo(COLLAPSEDSUBPROCESS); assertThat(gi.getExpanded()).isFalse(); //the intersection points are not full values so its a strange double here... start = flowLocationGraphicInfo.get(0); assertThat(start.getX()).isCloseTo(102.99814034216989, offset(PRECISION)); assertThat(start.getY()).isCloseTo(111.23619118649086, offset(PRECISION)); end = flowLocationGraphicInfo.get(1); assertThat(end.getX()).isCloseTo(165.0, offset(PRECISION)); assertThat(end.getY()).isCloseTo(112.21259842519686, offset(PRECISION)); //validate graphic infos FlowElement flowElement = bpmnModel.getFlowElement(IN_CSB_START_EVENT); assertThat(flowElement).isInstanceOf(StartEvent.class); gi = bpmnModel.getGraphicInfo(IN_CSB_START_EVENT); assertThat(gi.getX()).isEqualTo(90.0); assertThat(gi.getY()).isEqualTo(135.0); assertThat(gi.getWidth()).isEqualTo(30.0); assertThat(gi.getHeight()).isEqualTo(30.0); flowElement = bpmnModel.getFlowElement(IN_CSB_SEQUENCEFLOW_TO_USERTASK); assertThat(flowElement).isInstanceOf(SequenceFlow.class); assertThat(flowElement.getName()).isEqualTo("to ut"); flowLocationGraphicInfo = bpmnModel.getFlowLocationGraphicInfo(IN_CSB_SEQUENCEFLOW_TO_USERTASK); assertThat(flowLocationGraphicInfo).hasSize(2); start = flowLocationGraphicInfo.get(0); assertThat(start.getX()).isCloseTo(120.0, offset(PRECISION)); assertThat(start.getY()).isCloseTo(150.0, offset(PRECISION)); end = flowLocationGraphicInfo.get(1); assertThat(end.getX()).isCloseTo(232.0, offset(PRECISION)); assertThat(end.getY()).isEqualTo(150.0); flowElement = bpmnModel.getFlowElement(IN_CSB_USERTASK); assertThat(flowElement).isInstanceOf(UserTask.class); assertThat(flowElement.getName()).isEqualTo("User task 1"); gi = bpmnModel.getGraphicInfo(IN_CSB_USERTASK); assertThat(gi.getX()).isEqualTo(232.0); assertThat(gi.getY()).isEqualTo(110.0); assertThat(gi.getWidth()).isEqualTo(100.0); assertThat(gi.getHeight()).isEqualTo(80.0); flowElement = bpmnModel.getFlowElement(IN_CSB_SEQUENCEFLOW_TO_END); assertThat(flowElement).isInstanceOf(SequenceFlow.class); assertThat(flowElement.getName()).isEqualTo("to end"); flowLocationGraphicInfo = bpmnModel.getFlowLocationGraphicInfo(IN_CSB_SEQUENCEFLOW_TO_END); assertThat(flowLocationGraphicInfo).hasSize(2); start = flowLocationGraphicInfo.get(0); assertThat(start.getX()).isCloseTo(332.0, offset(PRECISION)); assertThat(start.getY()).isCloseTo(150.0, offset(PRECISION)); end = flowLocationGraphicInfo.get(1); assertThat(end.getX()).isEqualTo(435.0); assertThat(end.getY()).isEqualTo(150.0); }
Example 20
Source File: DynamicBpmnInjectionTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@Test @org.flowable.engine.test.Deployment public void testOneTaskDi() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); Task task = taskService.createTaskQuery().singleResult(); DynamicUserTaskBuilder taskBuilder = new DynamicUserTaskBuilder(); taskBuilder.id("custom_task") .name("My injected task") .assignee("kermit"); dynamicBpmnService.injectParallelUserTask(task.getId(), taskBuilder); List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskProcess").list(); assertEquals(2, processDefinitions.size()); ProcessDefinition rootDefinition = null; ProcessDefinition derivedFromDefinition = null; for (ProcessDefinition definitionItem : processDefinitions) { if (definitionItem.getDerivedFrom() != null && definitionItem.getDerivedFromRoot() != null) { derivedFromDefinition = definitionItem; } else { rootDefinition = definitionItem; } } assertNotNull(derivedFromDefinition); deploymentIdsForAutoCleanup.add(derivedFromDefinition.getDeploymentId()); // For auto-cleanup BpmnModel bpmnModel = repositoryService.getBpmnModel(derivedFromDefinition.getId()); FlowElement taskElement = bpmnModel.getFlowElement("theTask"); SubProcess subProcessElement = (SubProcess) taskElement.getParentContainer(); assertNotNull(subProcessElement); GraphicInfo subProcessGraphicInfo = bpmnModel.getGraphicInfo(subProcessElement.getId()); assertNotNull(subProcessGraphicInfo); assertFalse(subProcessGraphicInfo.getExpanded()); BpmnModel rootBpmnModel = repositoryService.getBpmnModel(rootDefinition.getId()); GraphicInfo taskGraphicInfo = rootBpmnModel.getGraphicInfo("theTask"); assertEquals(taskGraphicInfo.getX(), subProcessGraphicInfo.getX()); assertEquals(taskGraphicInfo.getY(), subProcessGraphicInfo.getY()); assertEquals(taskGraphicInfo.getWidth(), subProcessGraphicInfo.getWidth()); assertEquals(taskGraphicInfo.getHeight(), subProcessGraphicInfo.getHeight()); if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult(); assertEquals(derivedFromDefinition.getId(), historicProcessInstance.getProcessDefinitionId()); assertEquals(Integer.valueOf(derivedFromDefinition.getVersion()), historicProcessInstance.getProcessDefinitionVersion()); List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstance.getId()).list(); assertEquals(2, historicTasks.size()); for (HistoricTaskInstance historicTaskInstance : historicTasks) { assertEquals(derivedFromDefinition.getId(), historicTaskInstance.getProcessDefinitionId()); } List<HistoricActivityInstance> historicActivities = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).list(); assertEquals(5, historicActivities.size()); for (HistoricActivityInstance historicActivityInstance : historicActivities) { assertActivityInstancesAreSame(historicActivityInstance, runtimeService.createActivityInstanceQuery().activityInstanceId(historicActivityInstance.getId()).singleResult()); assertEquals(derivedFromDefinition.getId(), historicActivityInstance.getProcessDefinitionId()); } } List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); assertEquals(2, tasks.size()); for (Task t : tasks) { taskService.complete(t.getId()); } assertProcessEnded(processInstance.getId()); }