Class DynamicModelManager
-
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.buildPreviewSession(DynamicModelDefinition modelDefinition) Builds a detached metadata session reflecting the provided model definition without applying it.voidcheckApplyPermitted(List<DynamicModelMigration> migrations) Checks that the current user may apply the provided migrations.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) getDataLosingMigrations(List<DynamicModelMigration> migrations) Returns the migrations from the provided list that can lose stored data when applied: dropping an entity, an attribute or an enumeration, and changing an applied enumeration so that one of its value ids is removed.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 DynamicModelDefinitionExceptionincompatibleConstraint(String ownerEntityName, DynamicAttributeDefinition attributeDef, String annotation, String expectedType) protected Map<String, DynamicUniqueConstraintDefinition> indexUniqueConstraintsByName(List<DynamicUniqueConstraintDefinition> uniqueConstraints) protected DynamicModelDefinitionExceptioninvalidConstraintParameter(String ownerEntityName, DynamicAttributeDefinition attributeDef, DynamicAttributeConstraintDefinition constraint, String parameterName, String problem) protected booleanisDataLosingMigration(DynamicModelMigration migration) protected booleanisPropertyInstanceName(MetaProperty property) protected DynamicAttributeDefinitionnormalizeAttributeDefinition(DynamicAttributeDefinition attributeDef, String basePackage, boolean instanceName) protected List<DynamicUniqueConstraintDefinition> protected voidrefreshEnumerationMetaProperties(String enumerationFqn, SessionImplementation session, GeneratedClassStore classStore) protected voidregisterPhysicalColumn(Map<String, String> logicalNamesByColumn, String columnName, String logicalName, String tableName) protected booleanremovesEnumerationValues(DynamicModelMigration.UpsertEnumeration upsertEnumeration) 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 voidvalidateConstraintParameterTypes(String ownerEntityName, DynamicAttributeDefinition attributeDef, DynamicAttributeConstraintDefinition constraint) protected voidprotected voidvalidateLobAttribute(String ownerEntityName, 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 voidvalidateSearchableAttribute(String ownerEntityName, DynamicAttributeDefinition attributeDef) 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
-
getDataLosingMigrations
Returns the migrations from the provided list that can lose stored data when applied: dropping an entity, an attribute or an enumeration, and changing an applied enumeration so that one of its value ids is removed. Stored values that refer to a removed enumeration value id can no longer be read.A user who has only the
DynmodSafeApplyAccessContextpermission may apply only the migrations that this method does not return.- Parameters:
migrations- migrations calculated against the current runtime model- Returns:
- migrations that can lose data, in the order of the provided list; empty if there are none
-
checkApplyPermitted
Checks that the current user may apply the provided migrations. A user with the full apply permission may apply any migration; a user with only the permission to apply changes that cannot lose data may apply the migrations thatgetDataLosingMigrations(List)does not return.- Parameters:
migrations- migrations calculated against the current runtime model- Throws:
AccessDeniedException- if the user may not apply the migrations
-
isDataLosingMigration
-
removesEnumerationValues
protected boolean removesEnumerationValues(DynamicModelMigration.UpsertEnumeration upsertEnumeration) -
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
-
buildPreviewSession
Builds a detached metadata session reflecting the provided model definition without applying it.The build follows the same path as an apply — migrations against the published state, a cloned working session, metadata mutations — but performs no schema changes, no message updates, and no publication, and loads generated classes into a throwaway class loader instead of the global
ClassManager. The running application observes nothing; the returned session and its classes are garbage-collected when no longer referenced.- Parameters:
modelDefinition- target dynamic model definition- Returns:
- detached session containing the definition's metadata
-
validateLobAttribute
protected void validateLobAttribute(String ownerEntityName, DynamicAttributeDefinition attributeDef) -
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
-
validateSearchableAttribute
protected void validateSearchableAttribute(String ownerEntityName, DynamicAttributeDefinition attributeDef) -
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) -
validateConstraintParameterTypes
protected void validateConstraintParameterTypes(String ownerEntityName, DynamicAttributeDefinition attributeDef, DynamicAttributeConstraintDefinition constraint) -
invalidConstraintParameter
protected DynamicModelDefinitionException invalidConstraintParameter(String ownerEntityName, DynamicAttributeDefinition attributeDef, DynamicAttributeConstraintDefinition constraint, String parameterName, String problem) -
incompatibleConstraint
protected DynamicModelDefinitionException 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, GeneratedClassStore classStore) -
isPropertyInstanceName
-
setInstanceNameAnnotation
-
validateStoredColumnConflicts
protected void validateStoredColumnConflicts(MetaClass metaClass, Collection<MetaProperty> newProperties) -
registerPhysicalColumn
-
validateNewPhysicalColumn
-
toLogicalPropertyName
-
indexUniqueConstraintsByName
protected Map<String,DynamicUniqueConstraintDefinition> indexUniqueConstraintsByName(List<DynamicUniqueConstraintDefinition> uniqueConstraints)
-