Package io.jmix.dynmodel
Class DynamicModelManager
java.lang.Object
io.jmix.dynmodel.DynamicModelManager
Calculates and applies dynamic model metadata and schema migrations.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(DynamicModelDefinition modelDefinition) Calculates and applies migrations for the provided dynamic model definition.voidapply(List<DynamicModelMigration> migrations) Applies the provided migration list.voidapply(List<DynamicModelMigration> migrations, DynamicModelDefinition modelDefinition) Applies the provided migration list and runs apply interceptors with the full model definition.protected voidapplyInternal(List<DynamicModelMigration> migrations, @Nullable DynamicModelDefinition modelDefinition) Applies the provided migrations against a cloned working session and publishes the resulting generation atomically when metadata changes were produced.voidclear()Removes all runtime dynamic model metadata, generated classes, dynamic messages, and managed schema objects.protected voidClears all currently managed dynamic metadata and publishes a fresh session without dynamic additions.protected @Nullable StringfindInstanceNameAttribute(DynamicEntityDefinition entityDef) protected Class<?> getAttributeJavaType(DynamicAttributeDefinition attributeDef) protected MetaProperty.TypegetAttributeType(DynamicAttributeDefinition attributeDef) getMigrations(DynamicModelDefinition modelDefinition) Calculates migrations required to make the current runtime model match the provided definition.protected List<DynamicModelMigration> getMigrationsInternal(DynamicModelDefinition modelDefinition) Compares the requested model definition with the currently published dynamic model state and produces an ordered migration plan.getStoredAttributeKind(MetaProperty property) getStoredAttributeKind(DynamicAttributeDefinition attributeDef) protected IllegalArgumentExceptionincompatibleConstraint(String ownerEntityName, DynamicAttributeDefinition attributeDef, String annotation, String expectedType) protected Map<String, DynamicUniqueConstraintDefinition> indexUniqueConstraintsByName(List<DynamicUniqueConstraintDefinition> uniqueConstraints) protected booleanisPropertyInstanceName(MetaProperty property) protected DynamicAttributeDefinitionnormalizeAttributeDefinition(DynamicAttributeDefinition attributeDef, String basePackage, boolean instanceName) protected List<DynamicUniqueConstraintDefinition> protected voidrefreshEnumerationMetaProperties(String enumerationFqn, SessionImplementation session) protected voidregisterPhysicalColumn(Map<String, String> logicalNamesByColumn, String columnName, String logicalName, String tableName) protected StringresolveEntityStore(DynamicEntityDefinition entityDefinition) resolveModelEntityStores(List<DynamicEntityDefinition> entityDefinitions) protected voidsetInstanceNameAnnotation(MetaProperty property, boolean instanceName) protected StringtoLogicalPropertyName(MetaClass metaClass, String propertyPath) protected voidvalidateAttributeConstraintDefinition(String ownerEntityName, DynamicAttributeDefinition attributeDef, DynamicAttributeConstraintDefinition constraint) protected voidvalidateAttributeDefinition(String ownerEntityName, DynamicAttributeDefinition attributeDef, Set<String> modelEntityNames, Map<String, String> modelEntityStores) protected voidvalidateAttributeIdentityUnchanged(String entityName, DynamicAttributeDefinition attributeDef, MetaProperty existingProperty) protected voidvalidateAttributeValidationDefinition(String ownerEntityName, DynamicAttributeDefinition attributeDef) protected voidvalidateCalculatedAttributeAcyclic(String entityName, String attributeName, Map<String, DynamicAttributeDefinition> attributesByName, LinkedHashSet<String> stack, Set<String> visited) protected voidvalidateCalculatedAttributeDefinition(String ownerEntityName, DynamicAttributeDefinition attributeDef) protected voidprotected voidvalidateCollectionPropertyTarget(MetaClass ownerMetaClass, DynamicAttributeDefinition attributeDef, MetaClass childMetaClass) protected voidvalidateCollectionTarget(String ownerEntityName, DynamicAttributeDefinition attributeDef, Set<String> modelEntityNames) protected voidprotected voidvalidateLobAttribute(DynamicAttributeDefinition attributeDef) protected voidvalidateNewPhysicalColumn(Map<String, String> logicalNamesByColumn, String columnName, String logicalName, String tableName) protected voidvalidateOwnerType(String ownerEntityName, DynamicAttributeDefinition attributeDef) protected voidvalidateReferenceStore(String ownerEntityName, DynamicAttributeDefinition attributeDef, String targetEntityName, Map<String, String> modelEntityStores) protected voidvalidateReferenceTarget(String ownerEntityName, DynamicAttributeDefinition attributeDef, Set<String> modelEntityNames, Map<String, String> modelEntityStores) protected voidvalidateStoredColumnConflicts(MetaClass metaClass, Collection<MetaProperty> newProperties) protected voidvalidateUniqueConstraint(String entityName, Map<String, DynamicAttributeDefinition> attributesByName, DynamicUniqueConstraintDefinition uniqueConstraint) protected voidvalidateUniqueConstraints(DynamicEntityDefinition entityDef, List<DynamicUniqueConstraintDefinition> uniqueConstraints)
-
Constructor Details
-
DynamicModelManager
public DynamicModelManager()
-
-
Method Details
-
apply
Calculates and applies migrations for the provided dynamic model definition.- Parameters:
modelDefinition- dynamic model definition
-
getMigrations
Calculates migrations required to make the current runtime model match the provided definition.- Parameters:
modelDefinition- target dynamic model definition- Returns:
- ordered migration list
-
getMigrationsInternal
Compares the requested model definition with the currently published dynamic model state and produces an ordered migration plan.This method validates declarative metadata as it walks the definition and emits only the minimal set of migration objects needed to converge the runtime model, including metadata, schema, and message updates.
- Parameters:
modelDefinition- target dynamic model definition- Returns:
- ordered migrations required to reach the target definition
-
apply
Applies the provided migration list.- Parameters:
migrations- migrations to apply
-
apply
Applies the provided migration list and runs apply interceptors with the full model definition.- Parameters:
migrations- migrations to applymodelDefinition- source dynamic model definition
-
applyInternal
protected void applyInternal(List<DynamicModelMigration> migrations, @Nullable DynamicModelDefinition modelDefinition) Applies the provided migrations against a cloned working session and publishes the resulting generation atomically when metadata changes were produced.Interceptors run against the working session before publication so dependent modules can validate and prepare generation-aligned runtime artifacts such as dynamic views and policies.
- Parameters:
migrations- ordered migrations to applymodelDefinition- full source definition when interceptor callbacks should run, ornullfor direct migration-only apply
-
validateLobAttribute
-
clear
public void clear()Removes all runtime dynamic model metadata, generated classes, dynamic messages, and managed schema objects. -
clearInternal
protected void clearInternal()Clears all currently managed dynamic metadata and publishes a fresh session without dynamic additions. Runtime cleanup is deferred through retire actions so in-flight work can finish against the old generation. -
resolveModelEntityStores
protected Map<String,String> resolveModelEntityStores(List<DynamicEntityDefinition> entityDefinitions) -
resolveEntityStore
-
findInstanceNameAttribute
-
normalizeAttributeDefinition
protected DynamicAttributeDefinition normalizeAttributeDefinition(DynamicAttributeDefinition attributeDef, String basePackage, boolean instanceName) -
normalizeUniqueConstraints
protected List<DynamicUniqueConstraintDefinition> normalizeUniqueConstraints(DynamicEntityDefinition entityDef) -
validateAttributeDefinition
-
validateUniqueConstraints
protected void validateUniqueConstraints(DynamicEntityDefinition entityDef, List<DynamicUniqueConstraintDefinition> uniqueConstraints) -
validateUniqueConstraint
protected void validateUniqueConstraint(String entityName, Map<String, DynamicAttributeDefinition> attributesByName, DynamicUniqueConstraintDefinition uniqueConstraint) -
validateAttributeValidationDefinition
protected void validateAttributeValidationDefinition(String ownerEntityName, DynamicAttributeDefinition attributeDef) -
validateAttributeConstraintDefinition
protected void validateAttributeConstraintDefinition(String ownerEntityName, DynamicAttributeDefinition attributeDef, DynamicAttributeConstraintDefinition constraint) -
incompatibleConstraint
protected IllegalArgumentException incompatibleConstraint(String ownerEntityName, DynamicAttributeDefinition attributeDef, String annotation, String expectedType) -
validateEntityValidationDefinition
-
validateCalculatedAttributeDefinition
protected void validateCalculatedAttributeDefinition(String ownerEntityName, DynamicAttributeDefinition attributeDef) -
validateCalculatedAttributeGraph
-
validateCalculatedAttributeAcyclic
protected void validateCalculatedAttributeAcyclic(String entityName, String attributeName, Map<String, DynamicAttributeDefinition> attributesByName, LinkedHashSet<String> stack, Set<String> visited) -
validateAttributeIdentityUnchanged
protected void validateAttributeIdentityUnchanged(String entityName, DynamicAttributeDefinition attributeDef, MetaProperty existingProperty) -
getStoredAttributeKind
protected DynamicModelManager.AttributeIdentityKind getStoredAttributeKind(DynamicAttributeDefinition attributeDef) -
getStoredAttributeKind
-
getAttributeType
-
getAttributeJavaType
-
validateReferenceTarget
-
validateReferenceStore
-
validateCollectionTarget
protected void validateCollectionTarget(String ownerEntityName, DynamicAttributeDefinition attributeDef, Set<String> modelEntityNames) -
validateOwnerType
-
validateCollectionPropertyTarget
protected void validateCollectionPropertyTarget(MetaClass ownerMetaClass, DynamicAttributeDefinition attributeDef, MetaClass childMetaClass) -
refreshEnumerationMetaProperties
protected void refreshEnumerationMetaProperties(String enumerationFqn, SessionImplementation session) -
isPropertyInstanceName
-
setInstanceNameAnnotation
-
validateStoredColumnConflicts
protected void validateStoredColumnConflicts(MetaClass metaClass, Collection<MetaProperty> newProperties) -
registerPhysicalColumn
-
validateNewPhysicalColumn
-
toLogicalPropertyName
-
indexUniqueConstraintsByName
protected Map<String,DynamicUniqueConstraintDefinition> indexUniqueConstraintsByName(List<DynamicUniqueConstraintDefinition> uniqueConstraints)
-