Class IndexConfigurationManager

java.lang.Object
io.jmix.search.index.mapping.IndexConfigurationManager

@Component("search_IndexConfigurationManager") public class IndexConfigurationManager extends Object
The IndexConfigurationManager class provides functionality for managing index configurations within an application. It allows for retrieving, creating, and refreshing index definitions, as well as for determining the involvement of entities in the indexing process.

This class is responsible for ensuring index configuration consistency and providing metadata about entities and their relationships in the indexing context.

Main Responsibilities

  • Managing index definitions and their lifecycle
  • Retrieving index configurations by entity or index name
  • Determining the extent to which entities are indexed
  • Providing metadata on dependencies between entities in the indexing process
  • Field Details

  • Constructor Details

  • Method Details

    • refreshIndexDefinitions

      public void refreshIndexDefinitions()
      Refreshes and recreates the index definitions by creating and registering them.

      This method ensures that the current index configurations are updated to reflect any changes in the index definitions within the application.

      This refreshing also takes into account any changes in the dynamic attributes metadata if the Dynamic attributes add-on is used in the project.

    • getAllIndexConfigurations

      public Collection<IndexConfiguration> getAllIndexConfigurations()
      Gets all IndexConfiguration registered in application
      Returns:
      all IndexConfiguration
    • getIndexConfigurationByEntityName

      public IndexConfiguration getIndexConfigurationByEntityName(String entityName)
      Gets IndexConfiguration registered for provided entity name. Throws IllegalArgumentException if there is no configuration for provided entity name.
      Parameters:
      entityName - entity name.
      Returns:
      IndexConfiguration
    • getIndexConfigurationByEntityNameOpt

      public Optional<IndexConfiguration> getIndexConfigurationByEntityNameOpt(String entityName)
      Gets optional IndexConfiguration registered for provided entity name.
      Parameters:
      entityName - entity name
      Returns:
      optional IndexConfiguration
    • getIndexConfigurationByIndexName

      public IndexConfiguration getIndexConfigurationByIndexName(String indexName)
      Gets IndexConfiguration registered for provided index name. Throws IllegalArgumentException if there is no configuration for provided index name.
      Parameters:
      indexName - index name
      Returns:
      IndexConfiguration
    • getIndexConfigurationByIndexNameOpt

      public Optional<IndexConfiguration> getIndexConfigurationByIndexNameOpt(String indexName)
      Gets optional IndexConfiguration registered for provided index name.
      Parameters:
      indexName - index name
      Returns:
      optional IndexConfiguration
    • getAllIndexedEntities

      public Collection<String> getAllIndexedEntities()
    • isDirectlyIndexed

      public boolean isDirectlyIndexed(String entityName)
      Checks if the provided entity is declared to be indexed directly (not as a part of another entity).
      Parameters:
      entityName - entity name
      Returns:
      true if the entity is indexed, false otherwise
    • isAffectedEntityClass

      public boolean isAffectedEntityClass(Class<?> entityClass)
      Checks if the provided entity is involved in the index process directly or as a part of another entity.
      Parameters:
      entityClass - entity java class
      Returns:
      true if the entity is involved in the index process, false otherwise
    • getLocalPropertyNamesAffectedByUpdate

      public Set<String> getLocalPropertyNamesAffectedByUpdate(Class<?> entityClass)
      Gets local property names of the provided entity involved into the index update process
      Parameters:
      entityClass - entity class
      Returns:
      set of property names
    • getDependenciesMetaDataForUpdate

      public Map<MetaClass,Set<MetaPropertyPath>> getDependenciesMetaDataForUpdate(Class<?> entityClass, Set<String> changedProperties)
      Gets metadata of entities dependent on the updated main entity and its changed properties.
      Parameters:
      entityClass - java class of the main entity
      changedProperties - changed property of the main entity
      Returns:
      dependent entities grouped by their MetaClass. For every meta class group there are set of properties representing dependency-to-main references
    • getDependenciesMetaDataForDelete

      public Map<MetaClass,Set<MetaPropertyPath>> getDependenciesMetaDataForDelete(Class<?> deletedEntityClass)
      Gets metadata of entities dependent on the deleted main entity.
      Parameters:
      deletedEntityClass - java class of the main entity
      Returns:
      dependent entities grouped by their MetaClass. For every meta class group there are set of properties representing dependency-to-main references
    • initializeIndexDefinitions

      protected void initializeIndexDefinitions()
      Initializes the index definitions by creating and registering them.

      The method ensures that the current index configurations are updated to match the definitions specified by the provided class names.

    • replaceConfigurations

      protected void replaceConfigurations(List<IndexConfiguration> configurations)
      Replaces the current index configurations with the provided list of new configurations.
      Parameters:
      configurations - the list of IndexConfiguration objects to be set in the registry
    • optimisticReadOpt

      protected <T> Optional<T> optimisticReadOpt(Supplier<T> supplier)
      Executes the given supplier function using an optimistic read lock and wraps the result in an Optional.
      Type Parameters:
      T - the type of the result provided by the supplier
      Parameters:
      supplier - the supplier function to execute within the optimistic read lock
      Returns:
      an Optional containing the result of the supplier's execution, or an empty Optional if the result is null
    • optimisticRead

      @Nullable protected <T> T optimisticRead(Supplier<T> supplier)
      Executes the given supplier function in a read-safe manner using an optimistic read lock, ensuring the consistency of the read operation. If the optimistic lock fails validation, a fallback using a read lock is performed.
      Type Parameters:
      T - the type of the result provided by the supplier
      Parameters:
      supplier - the supplier function to execute within the optimistic read lock
      Returns:
      the result of the supplier's execution