-
Notifications
You must be signed in to change notification settings - Fork 7
feat: form flow ui editor #883
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
mbritense
wants to merge
6
commits into
next-minor
Choose a base branch
from
story/form-flow-editor
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b424c73
form flow registry, fix be types gen and implement in fe
mbritense 9082f2c
tab infrastructure
mbritense 5aab04f
Merge branch 'next-minor' into story/form-flow-editor
mbritense 715277f
complete formflow editor functionality
mbritense 6980d10
Add form flow editor documentation and 13.41.0 release notes
mbritense 7e48502
Merge remote-tracking branch 'origin/next-minor' into story/form-flow…
mbritense 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
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
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
203 changes: 203 additions & 0 deletions
203
backend/form-flow/src/main/kotlin/com/ritense/formflow/service/FormFlowRegistryService.kt
|
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. Just adding it as a comment here so you can respond. I don't think these are all things that need to happen, they're just things I'm noticing. I'll test more tomorrow.
|
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,203 @@ | ||
| /* | ||
| * 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.formflow.service | ||
|
|
||
| import com.fasterxml.jackson.databind.jsontype.NamedType | ||
| import com.ritense.formflow.AbstractFormFlowLinkTaskProvider | ||
| import com.ritense.formflow.domain.definition.configuration.step.StepTypeProperties | ||
| import com.ritense.formflow.expression.FormFlowBean | ||
| import com.ritense.formflow.handler.FormFlowStepTypeHandler | ||
| import com.ritense.formflow.web.rest.dto.FormFlowAdditionalPropertyDto | ||
| import com.ritense.formflow.web.rest.dto.FormFlowExpressionBeanDto | ||
| import com.ritense.formflow.web.rest.dto.FormFlowExpressionMethodDto | ||
| import com.ritense.formflow.web.rest.dto.FormFlowExpressionParameterDto | ||
| import com.ritense.formflow.web.rest.dto.FormFlowRegistryDto | ||
| import com.ritense.formflow.web.rest.dto.FormFlowStepTypeDto | ||
| import com.ritense.formflow.web.rest.dto.FormFlowStepTypePropertyDto | ||
| import org.springframework.boot.context.event.ApplicationReadyEvent | ||
| import org.springframework.context.ApplicationContext | ||
| import org.springframework.context.event.EventListener | ||
| import org.springframework.core.DefaultParameterNameDiscoverer | ||
| import org.springframework.util.ClassUtils | ||
| import java.lang.reflect.Method | ||
| import java.lang.reflect.Modifier | ||
|
|
||
| class FormFlowRegistryService( | ||
| private val stepTypeHandlers: List<FormFlowStepTypeHandler>, | ||
| private val stepPropertiesTypes: Collection<NamedType>, | ||
| private val applicationContext: ApplicationContext, | ||
| ) { | ||
| private val parameterNameDiscoverer = DefaultParameterNameDiscoverer() | ||
| private val cacheLock = Any() | ||
|
|
||
| @Volatile | ||
| private var cachedRegistry: FormFlowRegistryDto? = null | ||
|
|
||
| /** | ||
| * Builds the registry once during startup, so requests never pay the discovery cost. All | ||
| * expression beans exist by the time [ApplicationReadyEvent] fires, matching when the SpEL | ||
| * expression beans are collected for form flow execution. | ||
| */ | ||
| @EventListener(ApplicationReadyEvent::class) | ||
| fun warmUp() { | ||
| getRegistry() | ||
| } | ||
|
|
||
| /** | ||
| * Returns the registry that describes what can be used in a form flow definition. | ||
| * | ||
| * Step types and expression beans are determined by the application classpath and Spring | ||
| * configuration, so they do not change while the application is running. The result is | ||
| * therefore built once and reused for subsequent calls. | ||
| */ | ||
| fun getRegistry(): FormFlowRegistryDto { | ||
| cachedRegistry?.let { return it } | ||
|
|
||
| return synchronized(cacheLock) { | ||
| cachedRegistry ?: createRegistry().also { | ||
| cachedRegistry = it | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun createRegistry(): FormFlowRegistryDto { | ||
| return FormFlowRegistryDto( | ||
| stepTypes = createStepTypes(), | ||
| expressionBeans = createExpressionBeans(), | ||
| additionalProperties = ADDITIONAL_PROPERTIES, | ||
| ) | ||
| } | ||
|
|
||
| private fun createStepTypes(): List<FormFlowStepTypeDto> { | ||
| val propertiesByTypeName = stepPropertiesTypes | ||
| .filter { StepTypeProperties::class.java.isAssignableFrom(it.type) } | ||
| .associate { it.name to it.type } | ||
|
|
||
| return stepTypeHandlers | ||
| .map { it.getType() } | ||
| .distinct() | ||
| .sorted() | ||
| .map { typeName -> | ||
| FormFlowStepTypeDto( | ||
| name = typeName, | ||
| properties = propertiesByTypeName[typeName] | ||
| ?.let(::extractStepTypeProperties) | ||
| ?: emptyList(), | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| private fun extractStepTypeProperties(clazz: Class<*>): List<FormFlowStepTypePropertyDto> { | ||
| return clazz.declaredFields | ||
| .filterNot { it.isSynthetic || Modifier.isStatic(it.modifiers) } | ||
| .map { | ||
| FormFlowStepTypePropertyDto( | ||
| name = it.name, | ||
| type = it.type.simpleName, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| private fun createExpressionBeans(): List<FormFlowExpressionBeanDto> { | ||
| return applicationContext.getBeansWithAnnotation(FormFlowBean::class.java) | ||
| .map { (beanName, bean) -> | ||
| FormFlowExpressionBeanDto( | ||
| name = beanName, | ||
| methods = extractMethods(ClassUtils.getUserClass(bean)), | ||
| ) | ||
| } | ||
| .sortedBy(FormFlowExpressionBeanDto::name) | ||
| } | ||
|
|
||
| private fun extractMethods(clazz: Class<*>): List<FormFlowExpressionMethodDto> { | ||
| return clazz.methods | ||
| .filterNot { it.isSynthetic || it.isBridge } | ||
| .filterNot { it.declaringClass == Any::class.java } | ||
| .filterNot { Modifier.isStatic(it.modifiers) } | ||
| .map { method -> | ||
| FormFlowExpressionMethodDto( | ||
| name = method.name, | ||
| parameters = extractParameters(method), | ||
| returnType = method.returnType.simpleName, | ||
| ) | ||
| } | ||
| .sortedWith( | ||
| compareBy( | ||
| { it.name }, | ||
| { it.parameters.size }, | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| private fun extractParameters(method: Method): List<FormFlowExpressionParameterDto> { | ||
| val parameterNames = parameterNameDiscoverer.getParameterNames(method) | ||
|
|
||
| return method.parameters.mapIndexed { index, parameter -> | ||
| FormFlowExpressionParameterDto( | ||
| name = parameterNames?.getOrNull(index) ?: parameter.name, | ||
| type = parameter.type.simpleName, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| private const val CONTEXT_USER_TASK = "userTask" | ||
| private const val CONTEXT_START_EVENT = "startEvent" | ||
|
|
||
| /** | ||
| * The `additionalProperties` entries that form flow instances receive, as populated by | ||
| * [AbstractFormFlowLinkTaskProvider] and its process link activity handler. | ||
| */ | ||
| private val ADDITIONAL_PROPERTIES = listOf( | ||
| FormFlowAdditionalPropertyDto( | ||
| name = AbstractFormFlowLinkTaskProvider.PROCESS_INSTANCE_ID, | ||
| context = CONTEXT_USER_TASK, | ||
| alwaysPresent = true, | ||
| ), | ||
| FormFlowAdditionalPropertyDto( | ||
| name = AbstractFormFlowLinkTaskProvider.PROCESS_INSTANCE_BUSINESS_KEY, | ||
| context = CONTEXT_USER_TASK, | ||
| alwaysPresent = true, | ||
| ), | ||
| FormFlowAdditionalPropertyDto( | ||
| name = AbstractFormFlowLinkTaskProvider.TASK_INSTANCE_ID, | ||
| context = CONTEXT_USER_TASK, | ||
| alwaysPresent = true, | ||
| ), | ||
| FormFlowAdditionalPropertyDto( | ||
| name = AbstractFormFlowLinkTaskProvider.DOCUMENT_ID, | ||
| context = CONTEXT_USER_TASK, | ||
| alwaysPresent = false, | ||
| ), | ||
| FormFlowAdditionalPropertyDto( | ||
| name = AbstractFormFlowLinkTaskProvider.PROCESS_DEFINITION_KEY, | ||
| context = CONTEXT_START_EVENT, | ||
| alwaysPresent = true, | ||
| ), | ||
| FormFlowAdditionalPropertyDto( | ||
| name = AbstractFormFlowLinkTaskProvider.DOCUMENT_ID, | ||
| context = CONTEXT_START_EVENT, | ||
| alwaysPresent = false, | ||
| ), | ||
| FormFlowAdditionalPropertyDto( | ||
| name = AbstractFormFlowLinkTaskProvider.DOCUMENT_DEFINITION_NAME, | ||
| context = CONTEXT_START_EVENT, | ||
| alwaysPresent = false, | ||
| ), | ||
| ) | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
backend/form-flow/src/main/kotlin/com/ritense/formflow/web/rest/FormFlowRegistryResource.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,38 @@ | ||
| /* | ||
| * 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.formflow.web.rest | ||
|
|
||
| import com.ritense.formflow.service.FormFlowRegistryService | ||
| import com.ritense.formflow.web.rest.dto.FormFlowRegistryDto | ||
| import com.ritense.valtimo.contract.annotation.SkipComponentScan | ||
| import com.ritense.valtimo.contract.domain.ValtimoMediaType.APPLICATION_JSON_UTF8_VALUE | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.springframework.web.bind.annotation.RestController | ||
|
|
||
| @RestController | ||
| @SkipComponentScan | ||
| @RequestMapping("/api/management", produces = [APPLICATION_JSON_UTF8_VALUE]) | ||
| class FormFlowRegistryResource( | ||
| private val formFlowRegistryService: FormFlowRegistryService, | ||
| ) { | ||
| @GetMapping("/v1/form-flow/registry") | ||
| fun getRegistry(): ResponseEntity<FormFlowRegistryDto> { | ||
| return ResponseEntity.ok(formFlowRegistryService.getRegistry()) | ||
| } | ||
| } |
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.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: valtimo-platform/valtimo
Length of output: 2288
🏁 Script executed:
Repository: valtimo-platform/valtimo
Length of output: 9804
Use the qualified constants from the superclass.
AbstractFormFlowLinkTaskProviderdefinesFORM_FLOW_TASK_TYPE_KEY,PROCESS_DEFINITION_KEY,DOCUMENT_ID, andDOCUMENT_DEFINITION_NAME, but Kotlin does not import superclass companion members; call them throughAbstractFormFlowLinkTaskProvider.*or add local imports/aliases.