Package io.jmix.dynmodelflowui.impl
Class DynamicModelDefinitionModelConverter
java.lang.Object
io.jmix.dynmodelflowui.impl.DynamicModelDefinitionModelConverter
@Component("dynmod_DynamicModelDefinitionModelConverter")
public class DynamicModelDefinitionModelConverter
extends Object
Converts dynamic model definitions between YAML content, immutable metadata definition records and mutable model
entities used by the Admin UI graphical editor.
The converter delegates YAML root parsing and writing to DynamicModelDefinitionSerializer so generated
content stays compatible with the existing dynamic model YAML serializer. Nested arbitrary object maps, such as
validation parameters and view template parameters, are represented in DTOs as YAML fragments to preserve their
original value types.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ClassManagerCanonical order of lookup picker actions as written to YAML and offered in the settings UI.protected Metadataprotected DynamicModelDefinitionSerializerprotected final com.fasterxml.jackson.databind.ObjectMapper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable StringblankToNull(@Nullable String value) protected <T> Tdeserialize(String content) Deserializes YAML content into a mutable model graph.protected StringemptyIfNull(@Nullable String value) protected @Nullable DynamicAttributeResourceRolesModelfromAttributeAccessDefinition(@Nullable DynamicAttributeAccessDefinition definition) protected DynamicAttributeConstraintModelprotected DynamicAttributeModelfromAttributeDefinition(DynamicAttributeDefinition definition) protected List<DynamicAttributeConstraintModel> fromAttributeValidation(@Nullable DynamicValidationDefinition<DynamicAttributeConstraintDefinition> validation) protected @Nullable DynamicCalculatedAttributeModelfromCalculatedAttributeDefinition(@Nullable DynamicCalculatedAttributeDefinition definition) fromDefinition(DynamicModelDefinition definition) Converts an immutable dynamic model definition into a mutable model graph.protected @Nullable DynamicEntityResourceRolesModelfromEntityAccessDefinition(@Nullable DynamicEntityAccessDefinition definition) protected DynamicEntityConstraintModelprotected DynamicEntityModelfromEntityDefinition(DynamicEntityDefinition definition) protected List<DynamicEntityConstraintModel> fromEntityValidation(@Nullable DynamicValidationDefinition<DynamicEntityConstraintDefinition> validation) protected DynamicEnumerationModelprotected DynamicEnumerationValueModelprotected List<DynamicViewHandlerModel> fromHandlerList(@Nullable List<DynamicViewHandlerDefinition> handlers) protected @Nullable DynamicLocalizedValueModelfromLocalizedValue(@Nullable LocalizedValue value) protected List<DynamicStringValueModel> fromMenuAccessDefinition(@Nullable DynamicMenuAccessDefinition definition) protected @Nullable DynamicMenuItemModelfromMenuItemDefinition(@Nullable MenuItemDefinition definition) protected List<DynamicLocalizedMessageModel> fromMessageMap(@Nullable Map<String, String> messages) protected List<DynamicKeyValueModel> fromObjectMap(@Nullable Map<String, Object> values) protected List<DynamicStringValueModel> fromStringList(List<String> values) protected DynamicUniqueConstraintModelprotected List<DynamicStringValueModel> fromViewAccessDefinition(@Nullable DynamicViewAccessDefinition definition) protected DynamicViewModelfromViewDefinition(DynamicViewDefinition definition) protected @Nullable DynamicViewDescriptorModelfromViewDescriptorDefinition(@Nullable DynamicViewDescriptorDefinition definition) protected booleanprotected booleanprotected voidkeepFirstInstanceNameFlag(List<DynamicAttributeModel> attributes) Clears the instance-name flag on every attribute after the first flagged one.protected @Nullable Class<?> loadClassOrNull(@Nullable String attributeName, @Nullable String className) Loads a class named in the graphical model.protected @Nullable ObjectreadYamlFragment(@Nullable String valueYaml) Serializes a mutable model graph into YAML content.serialize(DynamicModelDefinitionModel model, @Nullable String existingContent) Serializes a mutable model graph into YAML content and replaces themodelsection in existing content.Orders lookup action ids into the canonicalLOOKUP_ACTION_IDSorder.protected Stringprotected @Nullable DynamicAttributeAccessDefinitiontoAttributeAccessDefinition(@Nullable DynamicAttributeResourceRolesModel model) protected DynamicAttributeConstraintDefinitionprotected DynamicAttributeDefinitiontoAttributeDefinition(String ownerEntityName, DynamicAttributeModel model) protected @Nullable DynamicValidationDefinition<DynamicAttributeConstraintDefinition> toAttributeValidation(List<DynamicAttributeConstraintModel> constraints) protected @Nullable DynamicCalculatedAttributeDefinitiontoCalculatedAttributeDefinition(@Nullable DynamicCalculatedAttributeModel model) Converts a mutable model graph into an immutable dynamic model definition.protected @Nullable DynamicEntityAccessDefinitiontoEntityAccessDefinition(@Nullable DynamicEntityResourceRolesModel model) protected DynamicEntityConstraintDefinitionprotected DynamicEntityDefinitionprotected @Nullable DynamicValidationDefinition<DynamicEntityConstraintDefinition> toEntityValidation(List<DynamicEntityConstraintModel> constraints) protected DynamicEnumerationDefinitionprotected DynamicEnumerationValueDefinitionprotected @Nullable List<DynamicViewHandlerDefinition> toHandlerList(List<DynamicViewHandlerModel> models) protected @Nullable LocalizedValuetoLocalizedValue(@Nullable DynamicLocalizedValueModel model) protected @Nullable DynamicLookupFieldDefinitionprotected @Nullable DynamicMenuAccessDefinitiontoMenuAccessDefinition(List<DynamicStringValueModel> roleCodes) protected @Nullable MenuItemDefinitiontoMenuItemDefinition(@Nullable DynamicMenuItemModel model) toMessageMap(List<DynamicLocalizedMessageModel> messages) toNullableObjectMap(List<DynamicKeyValueModel> values) toObjectMap(List<DynamicKeyValueModel> values) Converts key-value model rows to a plain object map.toStringList(List<DynamicStringValueModel> values) protected DynamicUniqueConstraintDefinitionprotected @Nullable DynamicViewAccessDefinitiontoViewAccessDefinition(List<DynamicStringValueModel> roleCodes) protected DynamicViewDefinitiontoViewDefinition(DynamicViewModel model) protected @Nullable DynamicViewDescriptorDefinitiontoViewDescriptorDefinition(@Nullable DynamicViewDescriptorModel model) protected StringwriteYamlFragment(@Nullable Object value)
-
Field Details
-
yamlMapper
protected final com.fasterxml.jackson.databind.ObjectMapper yamlMapper -
metadata
-
classManager
-
serializer
-
LOOKUP_ACTION_IDS
Canonical order of lookup picker actions as written to YAML and offered in the settings UI.
-
-
Constructor Details
-
DynamicModelDefinitionModelConverter
public DynamicModelDefinitionModelConverter()
-
-
Method Details
-
deserialize
Deserializes YAML content into a mutable model graph.- Parameters:
content- YAML content compatible withDynamicModelDefinitionSerializer- Returns:
- root Model entity for UI editing
-
serialize
Serializes a mutable model graph into YAML content.- Parameters:
model- root Model entity- Returns:
- YAML content compatible with
DynamicModelDefinitionSerializer
-
serialize
Serializes a mutable model graph into YAML content and replaces themodelsection in existing content.- Parameters:
model- root Model entityexistingContent- existing YAML content, ornull- Returns:
- YAML content compatible with
DynamicModelDefinitionSerializer
-
fromDefinition
Converts an immutable dynamic model definition into a mutable model graph.- Parameters:
definition- dynamic model definition- Returns:
- root Model entity for UI editing
-
toDefinition
Converts a mutable model graph into an immutable dynamic model definition.- Parameters:
model- root Model entity- Returns:
- dynamic model definition
-
fromEnumerationDefinition
protected DynamicEnumerationModel fromEnumerationDefinition(DynamicEnumerationDefinition definition) -
toEnumerationDefinition
-
fromEnumerationValueDefinition
protected DynamicEnumerationValueModel fromEnumerationValueDefinition(DynamicEnumerationValueDefinition definition) -
toEnumerationValueDefinition
protected DynamicEnumerationValueDefinition toEnumerationValueDefinition(DynamicEnumerationValueModel model) -
fromEntityDefinition
-
keepFirstInstanceNameFlag
Clears the instance-name flag on every attribute after the first flagged one. An entity has one instance-name attribute, and applying a definition with several flags uses the first one, so the editor shows the flag only where it has an effect. -
toEntityDefinition
-
fromAttributeDefinition
-
toAttributeDefinition
protected DynamicAttributeDefinition toAttributeDefinition(String ownerEntityName, DynamicAttributeModel model) -
toLookupDefinition
-
sortLookupActionIds
Orders lookup action ids into the canonicalLOOKUP_ACTION_IDSorder. Unknown ids (not in the canonical list) are kept and appended after the known ones in their original order. -
fromCalculatedAttributeDefinition
protected @Nullable DynamicCalculatedAttributeModel fromCalculatedAttributeDefinition(@Nullable DynamicCalculatedAttributeDefinition definition) -
toCalculatedAttributeDefinition
protected @Nullable DynamicCalculatedAttributeDefinition toCalculatedAttributeDefinition(@Nullable DynamicCalculatedAttributeModel model) -
fromUniqueConstraintDefinition
protected DynamicUniqueConstraintModel fromUniqueConstraintDefinition(DynamicUniqueConstraintDefinition definition) -
toUniqueConstraintDefinition
protected DynamicUniqueConstraintDefinition toUniqueConstraintDefinition(DynamicUniqueConstraintModel model) -
fromViewDefinition
-
toViewDefinition
-
fromHandlerList
protected List<DynamicViewHandlerModel> fromHandlerList(@Nullable List<DynamicViewHandlerDefinition> handlers) -
toHandlerList
protected @Nullable List<DynamicViewHandlerDefinition> toHandlerList(List<DynamicViewHandlerModel> models) -
fromMenuItemDefinition
protected @Nullable DynamicMenuItemModel fromMenuItemDefinition(@Nullable MenuItemDefinition definition) -
toMenuItemDefinition
-
fromViewDescriptorDefinition
protected @Nullable DynamicViewDescriptorModel fromViewDescriptorDefinition(@Nullable DynamicViewDescriptorDefinition definition) -
toViewDescriptorDefinition
protected @Nullable DynamicViewDescriptorDefinition toViewDescriptorDefinition(@Nullable DynamicViewDescriptorModel model) -
stripTrailingWhitespacePerLine
-
fromEntityAccessDefinition
protected @Nullable DynamicEntityResourceRolesModel fromEntityAccessDefinition(@Nullable DynamicEntityAccessDefinition definition) -
toEntityAccessDefinition
protected @Nullable DynamicEntityAccessDefinition toEntityAccessDefinition(@Nullable DynamicEntityResourceRolesModel model) -
fromAttributeAccessDefinition
protected @Nullable DynamicAttributeResourceRolesModel fromAttributeAccessDefinition(@Nullable DynamicAttributeAccessDefinition definition) -
toAttributeAccessDefinition
protected @Nullable DynamicAttributeAccessDefinition toAttributeAccessDefinition(@Nullable DynamicAttributeResourceRolesModel model) -
fromViewAccessDefinition
protected List<DynamicStringValueModel> fromViewAccessDefinition(@Nullable DynamicViewAccessDefinition definition) -
toViewAccessDefinition
protected @Nullable DynamicViewAccessDefinition toViewAccessDefinition(List<DynamicStringValueModel> roleCodes) -
fromMenuAccessDefinition
protected List<DynamicStringValueModel> fromMenuAccessDefinition(@Nullable DynamicMenuAccessDefinition definition) -
toMenuAccessDefinition
protected @Nullable DynamicMenuAccessDefinition toMenuAccessDefinition(List<DynamicStringValueModel> roleCodes) -
fromAttributeValidation
protected List<DynamicAttributeConstraintModel> fromAttributeValidation(@Nullable DynamicValidationDefinition<DynamicAttributeConstraintDefinition> validation) -
toAttributeValidation
protected @Nullable DynamicValidationDefinition<DynamicAttributeConstraintDefinition> toAttributeValidation(List<DynamicAttributeConstraintModel> constraints) -
fromAttributeConstraintDefinition
protected DynamicAttributeConstraintModel fromAttributeConstraintDefinition(DynamicAttributeConstraintDefinition definition) -
toAttributeConstraintDefinition
protected DynamicAttributeConstraintDefinition toAttributeConstraintDefinition(DynamicAttributeConstraintModel model) -
fromEntityValidation
protected List<DynamicEntityConstraintModel> fromEntityValidation(@Nullable DynamicValidationDefinition<DynamicEntityConstraintDefinition> validation) -
toEntityValidation
protected @Nullable DynamicValidationDefinition<DynamicEntityConstraintDefinition> toEntityValidation(List<DynamicEntityConstraintModel> constraints) -
fromEntityConstraintDefinition
protected DynamicEntityConstraintModel fromEntityConstraintDefinition(DynamicEntityConstraintDefinition definition) -
toEntityConstraintDefinition
protected DynamicEntityConstraintDefinition toEntityConstraintDefinition(DynamicEntityConstraintModel model) -
fromLocalizedValue
-
toLocalizedValue
-
fromMessageMap
-
toMessageMap
-
fromObjectMap
-
toObjectMap
Converts key-value model rows to a plain object map. Public so callers that need the map form oftemplateParamsoutside conversion — for example when rendering a template preview — can reuse the same YAML value semantics. -
toNullableObjectMap
-
fromStringList
-
toStringList
-
loadClassOrNull
protected @Nullable Class<?> loadClassOrNull(@Nullable String attributeName, @Nullable String className) Loads a class named in the graphical model. A name that does not resolve is a mistake the user has to fix in the editor, so it is reported the same way the YAML side reports it, naming the attribute and the value, instead of the class loader's own message. -
writeYamlFragment
-
readYamlFragment
-
create
-
emptyIfNull
-
blankToNull
-
isBlank
-
isTrue
-