org.hibernate.search.engine.spi

## Class DocumentBuilderIndexedEntity

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

-     public class DocumentBuilderIndexedEntity
      extends AbstractDocumentBuilder

  Set up and provide a manager for classes which are directly annotated with `@Indexed`.
  Author:
    Gavin King, Emmanuel Bernard, Sylvain Vieujot, Richard Hallier, Hardy Ferentschik

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `TENANT_ID_FIELDNAME` The tenant identifier.

    - ### Fields inherited from class org.hibernate.search.engine.spi.AbstractDocumentBuilder

      `entityState`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DocumentBuilderIndexedEntity(org.hibernate.annotations.common.reflection.XClass clazz, TypeMetadata typeMetadata, ConfigContext context, org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager, Set<org.hibernate.annotations.common.reflection.XClass> optimizationBlackList, InstanceInitializer instanceInitializer)` Creates a document builder for entities annotated with `@Indexed`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addWorkToQueue(String tenantId, IndexedTypeIdentifier typeIdentifier, Object entity, Serializable id, boolean delete, boolean add, List<LuceneWork> queue, ConversionContext contextualBridge)`
    `boolean` | `allowFieldSelectionInProjection()`
    `AddLuceneWork` | `createAddWork(String tenantId, IndexedTypeIdentifier entityType, Object entity, Serializable id, String idInString, InstanceInitializer sessionInitializer, ConversionContext conversionContext)`
    `UpdateLuceneWork` | `createUpdateWork(String tenantId, IndexedTypeIdentifier entityType, Object entity, Serializable id, String idInString, InstanceInitializer sessionInitializer, ConversionContext contextualBridge)`
    `FieldBridge` | `getBridge(String fieldName)`
    `Document` | `getDocument(String tenantId, Object instance, Serializable id, Map<String,String> fieldToAnalyzerMap, InstanceInitializer objectInitializer, ConversionContext conversionContext, String[] includedFieldNames)` Builds the Lucene `Document` for a given entity instance and its id.
    `Set<FieldCacheType>` | `getFieldCacheOption()` Deprecated.
    `Serializable` | `getId(Object entity)` Return the id used for indexing if possible An IllegalStateException otherwise
    `TwoWayFieldBridge` | `getIdBridge()`
    `String` | `getIdFieldName()`
    `org.hibernate.annotations.common.reflection.XMember` | `getIdGetter()`
    `String` | `getIdPropertyName()`
    `IndexedTypeIdentifier` | `getTypeIdentifier()`
    `boolean` | `isIdMatchingJpaId()` FIXME remove the need for such a method, we should always be able to rely on Work.id, but to respect @DocumentId which is being processed in the DocumentBuilder currently finding out which id we need is tricky, and requires helpers method like this one.
    `String` | `objectToString(String fieldName, FieldBridge bridge, Object value, ConversionContext conversionContext)`
    `String` | `objectToString(String fieldName, Object value, ConversionContext conversionContext)`
    `boolean` | `requiresProvidedId()` To be removed, see org.hibernate.search.engine.DocumentBuilderIndexedEntity.isIdMatchingJpaId()

    - ### Methods inherited from class org.hibernate.search.engine.spi.AbstractDocumentBuilder

      `appendContainedInWorkForInstance, appendContainedInWorkForInstance, collectionChangeRequiresIndexUpdate, forceStateInspectionOptimizationsDisabled, getAnalyzerReference, getEntityState, getInstanceInitializer, getMappedSubclasses, getTypeMetadata, isDirty, isRoot, postInitialize, toString`

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

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

- - ### Field Detail

    - #### TENANT_ID_FIELDNAME

          public static final String TENANT_ID_FIELDNAME

      The tenant identifier. This is not a projection constant as we're not storing it.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DocumentBuilderIndexedEntity

          public DocumentBuilderIndexedEntity(org.hibernate.annotations.common.reflection.XClass clazz,
                                              TypeMetadata typeMetadata,
                                              ConfigContext context,
                                              org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager,
                                              Set<org.hibernate.annotations.common.reflection.XClass> optimizationBlackList,
                                              InstanceInitializer instanceInitializer)

      Creates a document builder for entities annotated with `@Indexed`.
      Parameters:
        `clazz` - The class for which to build a `DocumentBuilderContainedEntity`
        `typeMetadata` - all the metadata for the entity type
        `context` - Handle to default configuration settings
        `reflectionManager` - Reflection manager to use for processing the annotations
        `optimizationBlackList` - mutable register, keeps track of types on which we need to disable collection events optimizations
        `instanceInitializer` - helper class for class object graph navigation

  - ### Method Detail

    - #### getIdGetter

          public org.hibernate.annotations.common.reflection.XMember getIdGetter()

    - #### getTypeIdentifier

          public IndexedTypeIdentifier getTypeIdentifier()

      Returns:
        which indexed type is being mapped by this DocumentBuilder

    - #### addWorkToQueue

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

      Specified by:
        `addWorkToQueue` in class `AbstractDocumentBuilder`

    - #### createAddWork

          public AddLuceneWork createAddWork(String tenantId,
                                             IndexedTypeIdentifier entityType,
                                             Object entity,
                                             Serializable id,
                                             String idInString,
                                             InstanceInitializer sessionInitializer,
                                             ConversionContext conversionContext)

    - #### createUpdateWork

          public UpdateLuceneWork createUpdateWork(String tenantId,
                                                   IndexedTypeIdentifier entityType,
                                                   Object entity,
                                                   Serializable id,
                                                   String idInString,
                                                   InstanceInitializer sessionInitializer,
                                                   ConversionContext contextualBridge)

    - #### getDocument

          public Document getDocument(String tenantId,
                                      Object instance,
                                      Serializable id,
                                      Map<String,String> fieldToAnalyzerMap,
                                      InstanceInitializer objectInitializer,
                                      ConversionContext conversionContext,
                                      String[] includedFieldNames)

      Builds the Lucene `Document` for a given entity instance and its id.
      Parameters:
        `tenantId` - the identifier of the tenant or null if there isn't one
        `instance` - The entity for which to build the matching Lucene `Document`
        `id` - the entity id.
        `fieldToAnalyzerMap` - this maps gets populated while generating the `Document`. It allows to specify for any document field a named analyzer to use. This parameter cannot be `null`.
        `objectInitializer` - used to ensure that all objects are initialized
        `conversionContext` - a `ConversionContext` object.
        `includedFieldNames` - list of field names to consider. Others can be excluded. Null if all fields are considered.
      Returns:
        The Lucene `Document` for the specified entity.

    - #### getIdPropertyName

          public String getIdPropertyName()

    - #### allowFieldSelectionInProjection

          public boolean allowFieldSelectionInProjection()

    - #### getFieldCacheOption

          @Deprecated
          public Set<FieldCacheType> getFieldCacheOption()

      Deprecated.
      This method will be removed as Field caching is no longer implemented (as it is no longer useful)
      Returns:
        Always returns an empty Set.

    - #### getIdBridge

          public TwoWayFieldBridge getIdBridge()

    - #### getIdFieldName

          public String getIdFieldName()

    - #### getId

          public Serializable getId(Object entity)

      Return the id used for indexing if possible An IllegalStateException otherwise

      If the id is provided, we can't extract it from the entity

      Specified by:
        `getId` in class `AbstractDocumentBuilder`
      Parameters:
        `entity` - the instance for which to retrieve the id
      Returns:
        the value, or null if it's not an indexed entity

    - #### objectToString

          public String objectToString(String fieldName,
                                       Object value,
                                       ConversionContext conversionContext)

    - #### objectToString

          public String objectToString(String fieldName,
                                       FieldBridge bridge,
                                       Object value,
                                       ConversionContext conversionContext)

    - #### getBridge

          public FieldBridge getBridge(String fieldName)

    - #### requiresProvidedId

          public boolean requiresProvidedId()

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

    - #### isIdMatchingJpaId

          public boolean isIdMatchingJpaId()

      FIXME remove the need for such a method, we should always be able to rely on Work.id, but to respect @DocumentId which is being processed in the DocumentBuilder currently finding out which id we need is tricky, and requires helpers method like this one.
      Overrides:
        `isIdMatchingJpaId` in class `AbstractDocumentBuilder`
      Returns:
        true if @DocumentId and @Id are found on the same property

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