Package io.jmix.datatools.datamodel
Class DataModelRegistry
java.lang.Object
io.jmix.datatools.datamodel.DataModelRegistry
Provides information about entity data models organized by data stores.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected List<DataModelContributor> protected DbmsTypeprotected DiagramEngineprotected Metadataprotected MetadataGenerationManagerprotected MetadataToolsprotected final GenerationStateStore<DataModelRegistry.State> protected StoreAwareLocator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddContributedAttribute(MetaClass entity, MetaProperty field, EntityDescriptor entityDescriptor, List<AttributeModel> attributeModelsList, Map<RelationType, List<Relation>> relationsMap) protected voidaddDatatypeAttribute(MetaClass entity, boolean isEmbeddable, MetaProperty field, String fieldName, List<AttributeModel> attributeModelsList) protected voidaddElementCollectionAttribute(MetaClass entity, MetaProperty field, String fieldName, List<AttributeModel> attributeModelsList) protected voidaddEmbeddedAttribute(DataModelRegistry.State state, MetaClass entity, MetaProperty field, String fieldName, List<AttributeModel> attributeModelsList) protected voidaddManyToManyAttribute(MetaClass entity, MetaProperty field, String fieldName, String dataStoreName, Map<RelationType, List<Relation>> relationsMap, List<AttributeModel> attributeModelsList) protected voidaddManyToOneAttribute(MetaClass entity, boolean isEmbeddable, MetaProperty field, String fieldName, List<AttributeModel> attributeModelsList, String dataStoreName, Map<RelationType, List<Relation>> relationsMap) protected voidaddOneToManyAttribute(MetaClass entity, MetaProperty field, String fieldName, String dataStoreName, Map<RelationType, List<Relation>> relationsMap, List<AttributeModel> attributeModelsList) protected voidaddOneToOneAttribute(MetaClass entity, boolean isEmbeddable, MetaProperty field, String fieldName, String dataStoreName, Map<RelationType, List<Relation>> relationsMap, List<AttributeModel> attributeModelsList) protected StringapplyRegister(String name, String storeName) protected <R> @Nullable RcallContributor(DataModelContributor contributor, String operation, Function<DataModelContributor, R> call) Invokes a contributor, isolating the rest of the data model from its failure.protected voidprotected AttributeModelconstructAttribute(String fieldName, String fieldType) protected AttributeModelconstructAttribute(String fieldName, String fieldType, boolean isMandatory) protected AttributeModelconstructAttribute(String columnName, String fieldName, String fieldType, MetaClass entity, boolean isMandatory) protected AttributeModelconstructAttribute(String columnName, String fieldName, String fieldType, String dbType, boolean isMandatory) protected AttributeModelconstructAttribute(List<String> columnNames, String fieldName, String fieldType, MetaClass entity, boolean isMandatory) protected AttributeModelconstructContributedAttribute(AttributeDescriptor descriptor, EntityDescriptor entityDescriptor) protected voidprotected EntityModelconstructEntityModel(MetaClass entity, boolean isSystem, EntityDescriptor descriptor) protected AttributeModelcreateAttributeModel(String fieldName, String fieldType, boolean dynamic) protected DataModelcreateEntityDescription(DataModelRegistry.State state, MetaClass entity, boolean isEmbeddable) protected @Nullable DataModelfindDataModel(DataModelRegistry.State state, MetaClass metaClass) protected MetaClassfindEntityForField(MetaClass entity, MetaProperty field) Finds the most appropriateMetaClassrepresentation of the entity to which a given field belongs.protected <T extends Annotation>
TgetAnnotation(MetaProperty field, Class<T> annotationClass) protected @Nullable StringgetCatalogName(jakarta.persistence.Table annotation) protected StringgetContributedColumnType(String storeName, String tableName, String columnName) protected StringgetDatabaseColumnType(MetaClass entity, String columnName) protected StringgetDatabaseColumnType(String storeName, @Nullable String schemaName, @Nullable String catalogName, String tableName, String columnName) Retrieves an unmodifiable view of the internal data model storage.getDataModels(String dataStore) Retrieves the data models associated with a specific data store.protected StringgetElementTypeFromCollection(MetaProperty metaProperty) getJoinColumnNames(MetaProperty field) Returns names of the join columns declared on the given field.protected @Nullable StringgetSchemaName(jakarta.persistence.Table annotation) protected DataModelRegistry.StategetState()booleanReturns whether any module contributes entities or attributes the JPA metadata cannot describe.protected booleanhasJoinColumns(MetaProperty field) Checks whether the given field declares join columns, regardless of whether their names are set explicitly.protected voidinit(DataModelRegistry.State state) protected booleanisAnnotationPresent(MetaProperty field, Class<? extends Annotation> annotationClass) voidRemoves registry state cached for a retired metadata generation.protected voidputDataModel(DataModelRegistry.State state, DataModel dataModel) protected voidputRelation(Map<RelationType, List<Relation>> relations, RelationType relationType, Relation relation) voidreset()Make the registry to reload data models on the next request.protected EntityDescriptorresolveEntityDescriptor(MetaClass entity)
-
Field Details
-
COLUMN_NAME_SEPARATOR
- See Also:
-
dbmsType
-
metadata
-
diagramEngine
-
metadataTools
-
storeAwareLocator
-
metadataGenerationManager
-
contributors
-
stateStore
-
-
Constructor Details
-
DataModelRegistry
public DataModelRegistry()
-
-
Method Details
-
getState
-
hasContributors
public boolean hasContributors()Returns whether any module contributes entities or attributes the JPA metadata cannot describe. When nothing does, the data model holds only JPA entities and thedynamicflag of every entity and attribute isfalse.- Returns:
trueif at least oneDataModelContributoris registered
-
reset
public void reset()Make the registry to reload data models on the next request. -
onMetadataGenerationRetired
Removes registry state cached for a retired metadata generation.- Parameters:
event- retired-generation event
-
checkInitialized
-
init
-
constructDataModel
-
callContributor
protected <R> @Nullable R callContributor(DataModelContributor contributor, String operation, Function<DataModelContributor, R> call) Invokes a contributor, isolating the rest of the data model from its failure.- Returns:
- the contributor's result, or
nullif it returnednullor threw
-
findDataModel
-
resolveEntityDescriptor
-
createEntityDescription
protected DataModel createEntityDescription(DataModelRegistry.State state, MetaClass entity, boolean isEmbeddable) -
addContributedAttribute
protected void addContributedAttribute(MetaClass entity, MetaProperty field, EntityDescriptor entityDescriptor, List<AttributeModel> attributeModelsList, Map<RelationType, List<Relation>> relationsMap) -
constructContributedAttribute
protected AttributeModel constructContributedAttribute(AttributeDescriptor descriptor, EntityDescriptor entityDescriptor) -
getContributedColumnType
-
addDatatypeAttribute
protected void addDatatypeAttribute(MetaClass entity, boolean isEmbeddable, MetaProperty field, String fieldName, List<AttributeModel> attributeModelsList) -
findEntityForField
Finds the most appropriateMetaClassrepresentation of the entity to which a given field belongs. It checks the declaring class of the field and navigates through the entity's inheritance hierarchy to locate the last JPA entity associated with the given field.NOTE: needed for inheritance strategy 'JOINED'.
- Parameters:
entity- the initialMetaClassrepresenting the starting point for the search in the hierarchyfield- theMetaPropertyrepresenting the field whose associated entity is to be determined- Returns:
- the
MetaClassrepresenting the most specific JPA entity associated with the field or the initial entity if no more specific JPA entity could be found
-
addEmbeddedAttribute
protected void addEmbeddedAttribute(DataModelRegistry.State state, MetaClass entity, MetaProperty field, String fieldName, List<AttributeModel> attributeModelsList) -
addManyToOneAttribute
protected void addManyToOneAttribute(MetaClass entity, boolean isEmbeddable, MetaProperty field, String fieldName, List<AttributeModel> attributeModelsList, String dataStoreName, Map<RelationType, List<Relation>> relationsMap) -
addOneToManyAttribute
protected void addOneToManyAttribute(MetaClass entity, MetaProperty field, String fieldName, String dataStoreName, Map<RelationType, List<Relation>> relationsMap, List<AttributeModel> attributeModelsList) -
addOneToOneAttribute
protected void addOneToOneAttribute(MetaClass entity, boolean isEmbeddable, MetaProperty field, String fieldName, String dataStoreName, Map<RelationType, List<Relation>> relationsMap, List<AttributeModel> attributeModelsList) -
addManyToManyAttribute
protected void addManyToManyAttribute(MetaClass entity, MetaProperty field, String fieldName, String dataStoreName, Map<RelationType, List<Relation>> relationsMap, List<AttributeModel> attributeModelsList) -
addElementCollectionAttribute
protected void addElementCollectionAttribute(MetaClass entity, MetaProperty field, String fieldName, List<AttributeModel> attributeModelsList) -
constructEntityModel
protected EntityModel constructEntityModel(MetaClass entity, boolean isSystem, EntityDescriptor descriptor) -
putRelation
protected void putRelation(Map<RelationType, List<Relation>> relations, RelationType relationType, Relation relation) -
constructAttribute
-
createAttributeModel
-
constructAttribute
protected AttributeModel constructAttribute(String fieldName, String fieldType, boolean isMandatory) -
constructAttribute
protected AttributeModel constructAttribute(String columnName, String fieldName, String fieldType, MetaClass entity, boolean isMandatory) -
constructAttribute
-
constructAttribute
protected AttributeModel constructAttribute(String columnName, String fieldName, String fieldType, String dbType, boolean isMandatory) -
getDatabaseColumnType
-
getDatabaseColumnType
-
applyRegister
-
getCatalogName
-
getSchemaName
-
putDataModel
-
getDataStoreNames
-
getDataModels
Retrieves an unmodifiable view of the internal data model storage. The returned map represents an organizational structure where the first-level keys are data store identifiers and the values are nested maps. The nested maps use entity names as keys and their correspondingDataModelobjects as values.- Returns:
- a map containing data store identifiers as keys, where each value is another map that
maps entity names to their respective
DataModelinstances. The returned map is unmodifiable.
-
getDataModels
Retrieves the data models associated with a specific data store.- Parameters:
dataStore- the name of the data store whose data models are to be retrieved; must not be null- Returns:
- a map where the keys are entity names and the values are the corresponding
DataModelinstances
-
isAnnotationPresent
protected boolean isAnnotationPresent(MetaProperty field, Class<? extends Annotation> annotationClass) -
hasJoinColumns
Checks whether the given field declares join columns, regardless of whether their names are set explicitly. An owning side of an association always declares them, an inverse side never does.- Parameters:
field- the field to inspect- Returns:
trueif the field declares at least one join column
-
getJoinColumnNames
Returns names of the join columns declared on the given field. Supports both a singleJoinColumnand a composite foreign key declared viaJoinColumns:JoinColumnis repeatable, so it is not directly present on the field when wrapped into the container annotation.- Parameters:
field- the field to inspect- Returns:
- names of the declared join columns, empty if the field has no explicitly named join column
-
getAnnotation
-
getElementTypeFromCollection
-