Class JpaDomainModelIntrospector

java.lang.Object
io.jmix.aitools.dataload.introspection.JpaDomainModelIntrospector

public class JpaDomainModelIntrospector extends Object
Builds and provides in-memory descriptors of JPA entities and their properties.
  • Field Details

  • 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:

      1. listed in excludeEntities — excluded (takes precedence over everything else);
      2. listed in includeEntities or matching includePackages — included, overriding the system-level, DTO and excludePackages rules below;
      3. system-level entity while excludeSystemLevelEntities is enabled — excluded;
      4. not a JPA entity or embeddable (a DTO) — excluded;
      5. matching excludePackages — excluded;
      6. otherwise — included.

      includeEntities/includePackages are additive: they force-include the listed entities (overriding the exclusions above) without narrowing the otherwise-included set.

      See Also:
    • getEntityDescriptor

      public @Nullable EntityDescriptor getEntityDescriptor(MetaClass metaClass)
      Returns a descriptor for the given metaclass.
      Parameters:
      metaClass - entity metaclass
      Returns:
      entity descriptor, or null if the entity is not indexed
    • getEntityDescriptor

      public @Nullable EntityDescriptor getEntityDescriptor(String entityName)
      Returns descriptor by entity name.
      Parameters:
      entityName - Jmix entity name
      Returns:
      entity descriptor, or null if the entity is not indexed
    • getEntityDescriptors

      public Collection<EntityDescriptor> getEntityDescriptors()
      Returns all indexed entity descriptors.
      Returns:
      collection of all indexed entity descriptors
    • containsEntity

      public boolean containsEntity(String entityName)
      Checks whether the entity is indexed.
      Parameters:
      entityName - entity name
      Returns:
      true if entity is indexed, false otherwise
    • containsProperty

      public boolean containsProperty(String entityName, String propertyName)
      Checks whether the entity contains the given property.
      Parameters:
      entityName - Jmix entity name
      propertyName - property name
      Returns:
      true if entity contains given property, false otherwise
    • getPropertyDescriptor

      public @Nullable EntityPropertyDescriptor getPropertyDescriptor(String entityName, String propertyName)
      Returns property descriptor for an entity property.
      Parameters:
      entityName - Jmix entity name
      propertyName - property name
      Returns:
      property descriptor, or null if entity or property is not indexed
    • getPropertyDescriptors

      public Collection<EntityPropertyDescriptor> getPropertyDescriptors(String entityName)
      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 name
      propertyName - property name
      Returns:
      relation descriptor, or null if property is missing or not a relation
    • containsPropertyPath

      public boolean containsPropertyPath(String entityName, String propertyPath)
      Checks whether a dot-separated property path can be resolved for the entity.
      Parameters:
      entityName - entity name
      propertyPath - dot-separated property path
      Returns:
      true if the path can be resolved, false otherwise
    • resolvePropertyPath

      public @Nullable List<EntityPropertyDescriptor> resolvePropertyPath(String entityName, String propertyPath)
      Resolves a dot-separated property path to property descriptors.
      Parameters:
      entityName - root entity name
      propertyPath - dot-separated property path
      Returns:
      resolved descriptors in traversal order, or null if a path is invalid
    • introspect

      public EntityDescriptor introspect(MetaClass metaClass)
      Creates a descriptor for a single entity.
      Parameters:
      metaClass - entity meta-class
      Returns:
      entity descriptor with localized names and properties
    • introspectProperties

      protected List<EntityPropertyDescriptor> introspectProperties(MetaClass metaClass)
    • introspectProperty

      protected @Nullable EntityPropertyDescriptor introspectProperty(MetaProperty property)
    • getEntityLocalizedNames

      protected List<String> getEntityLocalizedNames(MetaClass metaClass)
    • isEntityCaptionFallback

      protected boolean isEntityCaptionFallback(MetaClass metaClass, String localizedName)
    • shouldInclude

      protected boolean shouldInclude(MetaClass metaClass)
    • isExplicitlyIncluded

      protected boolean isExplicitlyIncluded(MetaClass metaClass)
    • isExplicitlyExcluded

      protected boolean isExplicitlyExcluded(MetaClass metaClass)
    • matchesEntityName

      protected boolean matchesEntityName(MetaClass metaClass, List<String> entityNames)
    • matchesAnyPackagePrefix

      protected boolean matchesAnyPackagePrefix(String packageName, List<String> packagePrefixes)
    • isDtoEntity

      protected boolean isDtoEntity(MetaClass metaClass)
    • indexProperties

      protected Map<String,EntityPropertyDescriptor> indexProperties(EntityDescriptor entityDescriptor)