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 DbmsTypeprotected DiagramEngineprotected Metadataprotected MetadataGenerationManagerprotected MetadataToolsprotected final GenerationStateStore<DataModelRegistry.State> protected StoreAwareLocator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 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 voidprotected EntityModelconstructEntityModel(MetaClass entity, boolean isSystem) protected DataModelcreateEntityDescription(DataModelRegistry.State state, MetaClass entity, boolean isEmbeddable) 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 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) protected @Nullable StringgetSchemaName(jakarta.persistence.Table annotation) protected DataModelRegistry.StategetState()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.
-
Field Details
-
dbmsType
-
metadata
-
diagramEngine
-
metadataTools
-
storeAwareLocator
-
metadataGenerationManager
-
stateStore
-
-
Constructor Details
-
DataModelRegistry
public DataModelRegistry()
-
-
Method Details
-
getState
-
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
-
createEntityDescription
protected DataModel createEntityDescription(DataModelRegistry.State state, MetaClass entity, boolean isEmbeddable) -
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
-
putRelation
protected void putRelation(Map<RelationType, List<Relation>> relations, RelationType relationType, Relation relation) -
constructAttribute
-
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
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) -
getAnnotation
-
getElementTypeFromCollection
-