-
Notifications
You must be signed in to change notification settings - Fork 7
Include process links when exporting and importing a system process #869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maarten-ritense
wants to merge
6
commits into
next-minor
Choose a base branch
from
story/481-system-process-export-include-process-links
base: next-minor
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d27e08d
Include process links when exporting and importing a system process (…
maarten-ritense 92bacb6
Update system process documentation and screenshots
maarten-ritense 726c750
Process review feedback on the system process export and import
maarten-ritense 38ea059
Add an export manifest to the system process export
maarten-ritense 794cba0
Move the plugin configuration mapping types to the models folder
maarten-ritense 49863f0
Merge branch 'next-minor' into story/481-system-process-export-includ…
maarten-ritense File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
backend/core/src/main/kotlin/com/ritense/valtimo/exporter/GlobalProcessDefinitionExporter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /* | ||
| * Copyright 2015-2026 Ritense BV, the Netherlands. | ||
| * | ||
| * Licensed under EUPL, Version 1.2 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" basis, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.ritense.valtimo.exporter | ||
|
|
||
| import com.ritense.exporter.ExportFile | ||
| import com.ritense.exporter.ExportResult | ||
| import com.ritense.exporter.Exporter | ||
| import com.ritense.exporter.manifest.ArtifactManifestEntry | ||
| import com.ritense.exporter.manifest.ArtifactType | ||
| import com.ritense.exporter.manifest.ResolvableValue | ||
| import com.ritense.exporter.request.GlobalProcessDefinitionExportRequest | ||
| import com.ritense.valtimo.operaton.domain.OperatonProcessDefinition | ||
| import com.ritense.valtimo.operaton.service.OperatonRepositoryService | ||
| import org.operaton.bpm.engine.RepositoryService | ||
| import org.operaton.bpm.model.bpmn.Bpmn | ||
| import java.io.ByteArrayOutputStream | ||
|
|
||
| /** | ||
| * Exports the BPMN of a process definition that is not part of a case definition. | ||
| * | ||
| * Unlike [ProcessDefinitionExporter] this exporter does not create related export requests for | ||
| * called sub-processes or referenced decision definitions. Those can be shared with other | ||
| * processes and are exported and imported separately. | ||
| */ | ||
| class GlobalProcessDefinitionExporter( | ||
| private val operatonRepositoryService: OperatonRepositoryService, | ||
| private val repositoryService: RepositoryService, | ||
| ) : Exporter<GlobalProcessDefinitionExportRequest> { | ||
|
|
||
| override fun supports(): Class<GlobalProcessDefinitionExportRequest> = | ||
| GlobalProcessDefinitionExportRequest::class.java | ||
|
|
||
| override fun export(request: GlobalProcessDefinitionExportRequest): ExportResult { | ||
| val processDefinition = requireNotNull( | ||
| operatonRepositoryService.findProcessDefinitionById(request.processDefinitionId) | ||
| ) { | ||
| "Process definition with id '${request.processDefinitionId}' could not be found!" | ||
| } | ||
|
|
||
| val bpmnModelInstance = repositoryService.getProcessModel(processDefinition.id).use { inputStream -> | ||
| Bpmn.readModelFromStream(inputStream) | ||
| } | ||
|
|
||
| val exportFile = ByteArrayOutputStream().use { | ||
| Bpmn.writeModelToStream(it, bpmnModelInstance) | ||
| ExportFile( | ||
| PATH.format(processDefinition.key), | ||
| it.toByteArray() | ||
| ) | ||
| } | ||
|
|
||
| return ExportResult( | ||
| exportFiles = setOf(exportFile), | ||
| relatedRequests = emptySet(), | ||
| manifestArtifact = ArtifactManifestEntry( | ||
| artifactVersionTag = ResolvableValue.of(getArtifactVersionTag(processDefinition)), | ||
| title = ResolvableValue.of(processDefinition.name ?: processDefinition.key), | ||
| type = ArtifactType.PROCESS_DEFINITION, | ||
| // Filled in by the export service | ||
| valtimoVersion = "", | ||
| dependencies = emptyList(), | ||
| ), | ||
| manifestDependencies = emptySet(), | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * A BPMN file has no field the manifest can reference, so the version is written as a literal | ||
| * value. The version tag of the model is preferred over the version of the deployment: the latter | ||
| * differs per environment. A version tag that encodes a case or building block definition is not | ||
| * a version of the process itself and is therefore ignored. | ||
| */ | ||
| private fun getArtifactVersionTag(processDefinition: OperatonProcessDefinition): String = | ||
| processDefinition.takeIf { it.getBlueprintId() == null }?.versionTag | ||
| ?: processDefinition.version.toString() | ||
|
|
||
| companion object { | ||
| private const val PATH = "config/global/bpmn/%s.bpmn" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...rter/src/main/kotlin/com/ritense/exporter/request/GlobalProcessDefinitionExportRequest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * Copyright 2015-2026 Ritense BV, the Netherlands. | ||
| * | ||
| * Licensed under EUPL, Version 1.2 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" basis, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.ritense.exporter.request | ||
|
|
||
| /** | ||
| * Export request for a process definition that is not linked to a case definition or building block. | ||
| * Exports into the `config/global` folder structure, so it can be imported on another environment | ||
| * without a case definition being involved. | ||
| */ | ||
| data class GlobalProcessDefinitionExportRequest( | ||
| val processDefinitionId: String, | ||
| override val required: Boolean = true, | ||
| ) : ExportRequest(required) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,8 @@ import com.ritense.logging.withLoggingContext | |
| import com.ritense.processlink.autodeployment.ProcessLinkDeployDto | ||
| import com.ritense.processlink.domain.ProcessLink | ||
| import com.ritense.processlink.mapper.ProcessLinkMapper | ||
| import com.ritense.processlink.web.rest.dto.MissingReferenceDto | ||
| import com.ritense.processlink.web.rest.dto.MissingReferenceType | ||
| import com.ritense.processlink.web.rest.dto.ProcessLinkCreateRequestDto | ||
| import com.ritense.processlink.web.rest.dto.ProcessLinkExportResponseDto | ||
| import com.ritense.processlink.web.rest.dto.ProcessLinkResponseDto | ||
|
|
@@ -193,6 +195,26 @@ class FormFlowProcessLinkMapper( | |
|
|
||
| override fun getImporterType() = "formflow" | ||
|
|
||
| override fun getMissingReference(deployDto: ProcessLinkDeployDto, blueprintId: BlueprintId?): MissingReferenceDto? { | ||
| deployDto as FormFlowProcessLinkDeployDto | ||
| val definition = when (blueprintId) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're calling the same method twice, why are you using a when for this? |
||
| is CaseDefinitionId -> formFlowService.findDefinitionOrNull(deployDto.formFlowDefinitionKey, blueprintId) | ||
| is BuildingBlockDefinitionId -> formFlowService.findDefinitionOrNull(deployDto.formFlowDefinitionKey, blueprintId) | ||
| // A form flow definition only exists for a case or building block, so a form flow process | ||
| // link can never be created without one. See assertFormFlowDefinitionExists. | ||
| else -> null | ||
| } | ||
| return if (definition != null) { | ||
| null | ||
| } else { | ||
| MissingReferenceDto( | ||
| type = MissingReferenceType.FORM_FLOW, | ||
| reference = deployDto.formFlowDefinitionKey, | ||
| activityId = deployDto.activityId, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| const val PROCESS_LINK_TYPE_FORM_FLOW = "form-flow" | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we not want to export called subprocesses/decision definitions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed it a bit more internally, we would like to see this included before we accept it into the product. People will get wrong expectations if they export a process definition that references other process or decision definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is/was to mimic the existing export of a 'system' process with its process links included. As the existing system process export only exports the bpmn definition and not also its called elements I made the decision for this new export to exclude these as well.
Including these will extend the scope significantly and introduces more complexity if you ask me. It will do a lot more than the existing 'simple' system process export. What should the scope be then, include all called bpmn elements including and referenced form definitions too? What if called elements are used by other bpmn's as well, same question for forms.
Maybe we should discuss this a little more or it could be an iteration of this in the (near) future if there is demand for this.