org.hibernate.search.engine.spi

## Class AbstractDocumentBuilder

- java.lang.Object
- - org.hibernate.search.engine.spi.AbstractDocumentBuilder

- Direct Known Subclasses:
    DocumentBuilderContainedEntity, DocumentBuilderIndexedEntity

      public abstract class AbstractDocumentBuilder
      extends Object

  Abstract base class for the document builders.
  Author:
    Hardy Ferentschik, Davide D'Alto, Sanne Grinovero

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected EntityState` | `entityState`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractDocumentBuilder(org.hibernate.annotations.common.reflection.XClass xClass, TypeMetadata typeMetadata, org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager, Set<org.hibernate.annotations.common.reflection.XClass> optimizationBlackList, InstanceInitializer instanceInitializer)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `addWorkToQueue(String tenantIdentifier, IndexedTypeIdentifier typeIdentifier, Object entity, Serializable id, boolean delete, boolean add, List<LuceneWork> queue, ConversionContext contextualBridge)`
    `void` | `appendContainedInWorkForInstance(Object instance, WorkPlan workPlan, ContainedInRecursionContext currentRecursionContext)` If we have a work instance we have to check whether the instance to be indexed is contained in any other indexed entities.
    `void` | `appendContainedInWorkForInstance(Object instance, WorkPlan workPlan, ContainedInRecursionContext currentRecursionContext, String tenantIdentifier)` If we have a work instance we have to check whether the instance to be indexed is contained in any other indexed entities for a tenant.
    `boolean` | `collectionChangeRequiresIndexUpdate(String collectionRoleName)` Returns `true` if the collection event is going to affect the index state.
    `void` | `forceStateInspectionOptimizationsDisabled()` Makes sure isCollectionRoleExcluded will always return false, so that collection update events are always processed.
    `ScopedAnalyzerReference` | `getAnalyzerReference()`
    `EntityState` | `getEntityState()`
    `abstract Serializable` | `getId(Object entity)` In case of an indexed entity, return the value of it's identifier: what is marked as @Id or @DocumentId; in case the entity uses @ProvidedId, it's illegal to call this method.
    `protected InstanceInitializer` | `getInstanceInitializer()`
    `Set<Class<?>>` | `getMappedSubclasses()`
    `TypeMetadata` | `getTypeMetadata()`
    `boolean` | `isDirty(String[] dirtyPropertyNames)` Hibernate entities might be dirty (their state has changed), but none of these changes would affect the index state.
    `boolean` | `isIdMatchingJpaId()` To be removed, see org.hibernate.search.engine.DocumentBuilderIndexedEntity.isIdMatchingJpaId()
    `boolean` | `isRoot()`
    `void` | `postInitialize(IndexedTypeSet indexedClassesSet)`
    `boolean` | `requiresProvidedId()` To be removed, see org.hibernate.search.engine.DocumentBuilderIndexedEntity.isIdMatchingJpaId()
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### entityState

          protected EntityState entityState

  - ### Constructor Detail

    - #### AbstractDocumentBuilder

          public AbstractDocumentBuilder(org.hibernate.annotations.common.reflection.XClass xClass,
                                         TypeMetadata typeMetadata,
                                         org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager,
                                         Set<org.hibernate.annotations.common.reflection.XClass> optimizationBlackList,
                                         InstanceInitializer instanceInitializer)

      Constructor.
      Parameters:
        `xClass` - The class for which to build a document builder
        `typeMetadata` - metadata for the specified class
        `reflectionManager` - Reflection manager to use for processing the annotations
        `optimizationBlackList` - keeps track of types on which we need to disable collection events optimizations
        `instanceInitializer` - a `InstanceInitializer` object.

  - ### Method Detail

    - #### addWorkToQueue

          public abstract void addWorkToQueue(String tenantIdentifier,
                                              IndexedTypeIdentifier typeIdentifier,
                                              Object entity,
                                              Serializable id,
                                              boolean delete,
                                              boolean add,
                                              List<LuceneWork> queue,
                                              ConversionContext contextualBridge)

    - #### getId

          public abstract Serializable getId(Object entity)

      In case of an indexed entity, return the value of it's identifier: what is marked as @Id or @DocumentId; in case the entity uses @ProvidedId, it's illegal to call this method.
      Parameters:
        `entity` - the instance for which to retrieve the id
      Returns:
        the value, or null if it's not an indexed entity
      Throws:
        `IllegalStateException` - when used with a @ProvidedId annotated entity

    - #### getTypeMetadata

          public TypeMetadata getTypeMetadata()

    - #### isRoot

          public boolean isRoot()

    - #### getAnalyzerReference

          public ScopedAnalyzerReference getAnalyzerReference()

    - #### getEntityState

          public EntityState getEntityState()

    - #### getMappedSubclasses

          public Set<Class<?>> getMappedSubclasses()

    - #### postInitialize

          public void postInitialize(IndexedTypeSet indexedClassesSet)

    - #### appendContainedInWorkForInstance

          public void appendContainedInWorkForInstance(Object instance,
                                                       WorkPlan workPlan,
                                                       ContainedInRecursionContext currentRecursionContext)

      If we have a work instance we have to check whether the instance to be indexed is contained in any other indexed entities.
      Parameters:
        `instance` - the instance to be indexed
        `workPlan` - the current work plan
        `currentRecursionContext` - the current `ContainedInRecursionContext` object used to check the graph traversal
      See Also:
        `appendContainedInWorkForInstance(Object, WorkPlan, ContainedInRecursionContext, String)`

    - #### appendContainedInWorkForInstance

          public void appendContainedInWorkForInstance(Object instance,
                                                       WorkPlan workPlan,
                                                       ContainedInRecursionContext currentRecursionContext,
                                                       String tenantIdentifier)

      If we have a work instance we have to check whether the instance to be indexed is contained in any other indexed entities for a tenant.
      Parameters:
        `instance` - the instance to be indexed
        `workPlan` - the current work plan
        `currentRecursionContext` - the current `ContainedInRecursionContext` object used to check the graph traversal
        `tenantIdentifier` - the identifier of the tenant or null, if there isn't one
      See Also:
        `appendContainedInWorkForInstance(Object, WorkPlan, ContainedInRecursionContext)`

    - #### getInstanceInitializer

          protected InstanceInitializer getInstanceInitializer()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### isDirty

          public boolean isDirty(String[] dirtyPropertyNames)

      Hibernate entities might be dirty (their state has changed), but none of these changes would affect the index state. This method will return `true` if any of changed entity properties identified by their names (`dirtyPropertyNames`) will effect the index state.
      Parameters:
        `dirtyPropertyNames` - array of property names for the changed entity properties, `null` in case the changed properties cannot be specified.
      Returns:
        `true` if the entity changes will effect the index state, `false` otherwise
      Since:
        3.4

    - #### requiresProvidedId

          public boolean requiresProvidedId()

      To be removed, see org.hibernate.search.engine.DocumentBuilderIndexedEntity.isIdMatchingJpaId()
      Returns:
        true if a providedId needs to be provided for indexing

    - #### isIdMatchingJpaId

          public boolean isIdMatchingJpaId()

      To be removed, see org.hibernate.search.engine.DocumentBuilderIndexedEntity.isIdMatchingJpaId()
      Returns:
        true if @DocumentId and @Id are found on the same property

    - #### collectionChangeRequiresIndexUpdate

          public boolean collectionChangeRequiresIndexUpdate(String collectionRoleName)

      Returns `true` if the collection event is going to affect the index state. In this case the indexing event can be ignored. `false` otherwise.
      Parameters:
        `collectionRoleName` - a `String` object.
      Returns:
        `true` if an update to the collection identified by the given role name effects the index state, `false` otherwise.

    - #### forceStateInspectionOptimizationsDisabled

          public void forceStateInspectionOptimizationsDisabled()

      Makes sure isCollectionRoleExcluded will always return false, so that collection update events are always processed.
      See Also:
        `collectionChangeRequiresIndexUpdate(String)`

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved