Class JpaDomainModelIntrospector
java.lang.Object
io.jmix.aitools.dataload.introspection.JpaDomainModelIntrospector
Builds and provides in-memory descriptors of JPA entities and their properties.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AiToolsDataLoadPropertiesprotected Map<String, EntityDescriptor> protected booleanprotected MessageToolsprotected Metadataprotected MetadataToolsprotected Map<String, Map<String, EntityPropertyDescriptor>> protected List<MetaPropertyIntrospector> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsEntity(String entityName) Checks whether the entity is indexed.booleancontainsProperty(String entityName, String propertyName) Checks whether the entity contains the given property.booleancontainsPropertyPath(String entityName, String propertyPath) Checks whether a dot-separated property path can be resolved for the entity.@Nullable EntityDescriptorgetEntityDescriptor(MetaClass metaClass) Returns a descriptor for the given metaclass.@Nullable EntityDescriptorgetEntityDescriptor(String entityName) Returns descriptor by entity name.Returns all indexed entity descriptors.getEntityLocalizedNames(MetaClass metaClass) @Nullable EntityPropertyDescriptorgetPropertyDescriptor(String entityName, String propertyName) Returns property descriptor for an entity property.getPropertyDescriptors(String entityName) Returns all property descriptors for the entity.@Nullable RelationPropertyDescriptorgetRelationPropertyDescriptor(String entityName, String propertyName) Returns relation descriptor for the given property if it is a relation.protected Map<String, EntityPropertyDescriptor> indexProperties(EntityDescriptor entityDescriptor) voidRebuilds entity and property descriptor indexes from current metadata, applying the inclusion and exclusion rules from the application properties.introspect(MetaClass metaClass) Creates a descriptor for a single entity.protected List<EntityPropertyDescriptor> introspectProperties(MetaClass metaClass) protected @Nullable EntityPropertyDescriptorintrospectProperty(MetaProperty property) protected booleanisDtoEntity(MetaClass metaClass) protected booleanisEntityCaptionFallback(MetaClass metaClass, String localizedName) protected booleanisExplicitlyExcluded(MetaClass metaClass) protected booleanisExplicitlyIncluded(MetaClass metaClass) protected booleanmatchesAnyPackagePrefix(String packageName, List<String> packagePrefixes) protected booleanmatchesEntityName(MetaClass metaClass, List<String> entityNames) protected voidonApplicationStarted(org.springframework.context.event.ContextRefreshedEvent event) @Nullable List<EntityPropertyDescriptor> resolvePropertyPath(String entityName, String propertyPath) Resolves a dot-separated property path to property descriptors.protected booleanshouldInclude(MetaClass metaClass)
-
Field Details
-
metadata
-
messageTools
-
metadataTools
-
dataLoadProperties
-
propertyIntrospectors
-
entitiesByName
-
propertiesByEntityName
-
initialized
protected volatile boolean initialized
-
-
Constructor Details
-
JpaDomainModelIntrospector
public JpaDomainModelIntrospector()
-
-
Method Details
-
onApplicationStarted
@EventListener protected void onApplicationStarted(org.springframework.context.event.ContextRefreshedEvent event) -
introspect
public void introspect()Rebuilds entity and property descriptor indexes from current metadata, applying the inclusion and exclusion rules from the application properties.Each entity is checked against the rules below, in order; the first matching rule wins:
- listed in
excludeEntities— excluded (takes precedence over everything else); - listed in
includeEntitiesor matchingincludePackages— included, overriding the system-level, DTO andexcludePackagesrules below; - system-level entity while
excludeSystemLevelEntitiesis enabled — excluded; - not a JPA entity or embeddable (a DTO) — excluded;
- matching
excludePackages— excluded; - otherwise — included.
includeEntities/includePackagesare additive: they force-include the listed entities (overriding the exclusions above) without narrowing the otherwise-included set.- See Also:
- listed in
-
getEntityDescriptor
Returns a descriptor for the given metaclass.- Parameters:
metaClass- entity metaclass- Returns:
- entity descriptor, or
nullif the entity is not indexed
-
getEntityDescriptor
Returns descriptor by entity name.- Parameters:
entityName- Jmix entity name- Returns:
- entity descriptor, or
nullif the entity is not indexed
-
getEntityDescriptors
Returns all indexed entity descriptors.- Returns:
- collection of all indexed entity descriptors
-
containsEntity
Checks whether the entity is indexed.- Parameters:
entityName- entity name- Returns:
trueif entity is indexed,falseotherwise
-
containsProperty
Checks whether the entity contains the given property.- Parameters:
entityName- Jmix entity namepropertyName- property name- Returns:
trueif entity contains given property,falseotherwise
-
getPropertyDescriptor
public @Nullable EntityPropertyDescriptor getPropertyDescriptor(String entityName, String propertyName) Returns property descriptor for an entity property.- Parameters:
entityName- Jmix entity namepropertyName- property name- Returns:
- property descriptor, or
nullif entity or property is not indexed
-
getPropertyDescriptors
Returns all property descriptors for the entity.- Parameters:
entityName- entity name- Returns:
- property descriptors, or empty collection if entity is not indexed
-
getRelationPropertyDescriptor
public @Nullable RelationPropertyDescriptor getRelationPropertyDescriptor(String entityName, String propertyName) Returns relation descriptor for the given property if it is a relation.- Parameters:
entityName- entity namepropertyName- property name- Returns:
- relation descriptor, or
nullif property is missing or not a relation
-
containsPropertyPath
Checks whether a dot-separated property path can be resolved for the entity.- Parameters:
entityName- entity namepropertyPath- dot-separated property path- Returns:
trueif the path can be resolved,falseotherwise
-
resolvePropertyPath
public @Nullable List<EntityPropertyDescriptor> resolvePropertyPath(String entityName, String propertyPath) Resolves a dot-separated property path to property descriptors.- Parameters:
entityName- root entity namepropertyPath- dot-separated property path- Returns:
- resolved descriptors in traversal order, or
nullif a path is invalid
-
introspect
Creates a descriptor for a single entity.- Parameters:
metaClass- entity meta-class- Returns:
- entity descriptor with localized names and properties
-
introspectProperties
-
introspectProperty
-
getEntityLocalizedNames
-
isEntityCaptionFallback
-
shouldInclude
-
isExplicitlyIncluded
-
isExplicitlyExcluded
-
matchesEntityName
-
matchesAnyPackagePrefix
-
isDtoEntity
-
indexProperties
-