Java Code Examples for org.flowable.bpmn.model.Process#getInitialFlowElement()
The following examples show how to use
org.flowable.bpmn.model.Process#getInitialFlowElement() .
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: FlowableProcessDefinitionService.java From flowable-engine with Apache License 2.0 | 6 votes |
protected FormInfo getStartForm(ProcessDefinition processDefinition) { FormInfo formInfo = null; BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); Process process = bpmnModel.getProcessById(processDefinition.getKey()); FlowElement startElement = process.getInitialFlowElement(); if (startElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) startElement; if (StringUtils.isNotEmpty(startEvent.getFormKey())) { Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(processDefinition.getDeploymentId()).singleResult(); formInfo = formRepositoryService.getFormModelByKeyAndParentDeploymentId(startEvent.getFormKey(), deployment.getParentDeploymentId(), processDefinition.getTenantId(), processEngineConfiguration.isFallbackToDefaultTenant()); } } if (formInfo == null) { // Definition found, but no form attached throw new NotFoundException("Process definition does not have a form defined: " + processDefinition.getId()); } return formInfo; }
Example 2
Source File: ProcessDefinitionResource.java From flowable-engine with Apache License 2.0 | 6 votes |
protected FormInfo getStartForm(ProcessDefinition processDefinition) { FormInfo formInfo = null; BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); Process process = bpmnModel.getProcessById(processDefinition.getKey()); FlowElement startElement = process.getInitialFlowElement(); if (startElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) startElement; if (StringUtils.isNotEmpty(startEvent.getFormKey())) { if (startEvent.isSameDeployment()) { Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(processDefinition.getDeploymentId()).singleResult(); formInfo = formRepositoryService.getFormModelByKeyAndParentDeploymentId(startEvent.getFormKey(), deployment.getParentDeploymentId(), processDefinition.getTenantId(), processEngineConfiguration.isFallbackToDefaultTenant()); } else { formInfo = formRepositoryService.getFormModelByKey(startEvent.getFormKey(), processDefinition.getTenantId(), processEngineConfiguration.isFallbackToDefaultTenant()); } } } if (formInfo == null) { // Definition found, but no form attached throw new FlowableObjectNotFoundException("Process definition does not have a form defined: " + processDefinition.getId()); } return formInfo; }
Example 3
Source File: ProcessInstanceHelper.java From flowable-engine with Apache License 2.0 | 5 votes |
public ProcessInstance createProcessInstance(ProcessDefinition processDefinition, String businessKey, String processInstanceName, String overrideDefinitionTenantId, String predefinedProcessInstanceId, Map<String, Object> variables, Map<String, Object> transientVariables, String callbackId, String callbackType, String referenceId, String referenceType, String stageInstanceId, boolean startProcessInstance) { CommandContext commandContext = Context.getCommandContext(); if (Flowable5Util.isFlowable5ProcessDefinition(processDefinition, commandContext)) { Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler(); return compatibilityHandler.startProcessInstance(processDefinition.getKey(), processDefinition.getId(), variables, transientVariables, businessKey, processDefinition.getTenantId(), processInstanceName); } // Do not start process a process instance if the process definition is suspended if (ProcessDefinitionUtil.isProcessDefinitionSuspended(processDefinition.getId())) { throw new FlowableException("Cannot start process instance. Process definition " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended"); } // Get model from cache Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId()); if (process == null) { throw new FlowableException("Cannot start process instance. Process model " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") could not be found"); } FlowElement initialFlowElement = process.getInitialFlowElement(); if (initialFlowElement == null) { throw new FlowableException("No start element found for process definition " + processDefinition.getId()); } return createAndStartProcessInstanceWithInitialFlowElement(processDefinition, businessKey, processInstanceName, overrideDefinitionTenantId, predefinedProcessInstanceId, initialFlowElement, process, variables, transientVariables, callbackId, callbackType, referenceId, referenceType, stageInstanceId, startProcessInstance); }
Example 4
Source File: GetStartFormModelCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public FormInfo execute(CommandContext commandContext) { ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); FormService formService = CommandContextUtil.getFormService(commandContext); if (formService == null) { throw new FlowableIllegalArgumentException("Form engine is not initialized"); } FormInfo formInfo = null; ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(processDefinitionId); BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId); Process process = bpmnModel.getProcessById(processDefinition.getKey()); FlowElement startElement = process.getInitialFlowElement(); if (startElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) startElement; if (StringUtils.isNotEmpty(startEvent.getFormKey())) { Deployment deployment = CommandContextUtil.getDeploymentEntityManager(commandContext).findById(processDefinition.getDeploymentId()); formInfo = formService.getFormInstanceModelByKeyAndParentDeploymentId(startEvent.getFormKey(), deployment.getParentDeploymentId(), null, processInstanceId, null, processDefinition.getTenantId(), processEngineConfiguration.isFallbackToDefaultTenant()); } } // If form does not exists, we don't want to leak out this info to just anyone if (formInfo == null) { throw new FlowableObjectNotFoundException("Form model for process definition " + processDefinitionId + " cannot be found"); } FormFieldHandler formFieldHandler = processEngineConfiguration.getFormFieldHandler(); formFieldHandler.enrichFormFields(formInfo); return formInfo; }
Example 5
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 5 votes |
/** * Sets the version on each process definition entity, and the identifier. If the map contains an older version for a process definition, then the version is set to that older entity's version * plus one; otherwise it is set to 1. Also dispatches an ENTITY_CREATED event. */ protected void setProcessDefinitionVersionsAndIds(ParsedDeployment parsedDeployment, Map<ProcessDefinitionEntity, ProcessDefinitionEntity> mapNewToOldProcessDefinitions) { CommandContext commandContext = Context.getCommandContext(); for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) { int version = 1; ProcessDefinitionEntity latest = mapNewToOldProcessDefinitions.get(processDefinition); if (latest != null) { version = latest.getVersion() + 1; } processDefinition.setVersion(version); processDefinition.setId(getIdForNewProcessDefinition(processDefinition)); Process process = parsedDeployment.getProcessModelForProcessDefinition(processDefinition); FlowElement initialElement = process.getInitialFlowElement(); if (initialElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) initialElement; if (startEvent.getFormKey() != null) { processDefinition.setHasStartFormKey(true); } } cachingAndArtifactsManager.updateProcessDefinitionCache(parsedDeployment); FlowableEventDispatcher eventDispatcher = CommandContextUtil.getProcessEngineConfiguration(commandContext).getEventDispatcher(); if (eventDispatcher != null && eventDispatcher.isEnabled()) { eventDispatcher .dispatchEvent(FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_CREATED, processDefinition)); } } }
Example 6
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 4 votes |
protected void setDerivedProcessDefinitionVersionsAndIds(ParsedDeployment parsedDeployment, Map<ProcessDefinitionEntity, ProcessDefinitionEntity> mapNewToOldProcessDefinitions, Map<String, Object> deploymentSettings) { CommandContext commandContext = Context.getCommandContext(); for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) { int derivedVersion = 1; ProcessDefinitionEntity latest = mapNewToOldProcessDefinitions.get(processDefinition); if (latest != null) { derivedVersion = latest.getDerivedVersion() + 1; } processDefinition.setVersion(0); processDefinition.setDerivedVersion(derivedVersion); if (usePrefixId) { processDefinition.setId(processDefinition.getIdPrefix() + idGenerator.getNextId()); } else { processDefinition.setId(idGenerator.getNextId()); } processDefinition.setDerivedFrom((String) deploymentSettings.get(DeploymentSettings.DERIVED_PROCESS_DEFINITION_ID)); processDefinition.setDerivedFromRoot((String) deploymentSettings.get(DeploymentSettings.DERIVED_PROCESS_DEFINITION_ROOT_ID)); Process process = parsedDeployment.getProcessModelForProcessDefinition(processDefinition); FlowElement initialElement = process.getInitialFlowElement(); if (initialElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) initialElement; if (startEvent.getFormKey() != null) { processDefinition.setHasStartFormKey(true); } } cachingAndArtifactsManager.updateProcessDefinitionCache(parsedDeployment); FlowableEventDispatcher eventDispatcher = CommandContextUtil.getProcessEngineConfiguration(commandContext).getEventDispatcher(); if (eventDispatcher != null && eventDispatcher.isEnabled()) { eventDispatcher .dispatchEvent(FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_CREATED, processDefinition)); } } }