org.hibernate.search.engine.spi
Class DocumentBuilderIndexedEntity<T>

java.lang.Object
  extended by org.hibernate.search.engine.spi.AbstractDocumentBuilder<T>
      extended by org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity<T>

public class DocumentBuilderIndexedEntity<T>
extends AbstractDocumentBuilder<T>

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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.hibernate.search.engine.spi.AbstractDocumentBuilder
AbstractDocumentBuilder.PropertiesMetadata
 
Field Summary
 
Fields inherited from class org.hibernate.search.engine.spi.AbstractDocumentBuilder
beanClass, beanXClassName, containedInCollectionRoles, entityState, fieldCollectionRoles, indexedEmbeddedCollectionRoles, instanceInitalizer, metadata, reflectionManager
 
Constructor Summary
DocumentBuilderIndexedEntity(org.hibernate.annotations.common.reflection.XClass clazz, ConfigContext context, org.apache.lucene.search.Similarity similarity, 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
 void addWorkToQueue(Class<T> entityClass, T entity, Serializable id, boolean delete, boolean add, List<LuceneWork> queue, ConversionContext contextualBridge)
           
 boolean allowFieldSelectionInProjection()
           
protected  void checkDocumentId(org.hibernate.annotations.common.reflection.XProperty member, AbstractDocumentBuilder.PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix, ConfigContext context, org.hibernate.search.engine.spi.AbstractDocumentBuilder.PathsContext pathsContext)
           
 AddLuceneWork createAddWork(Class<T> entityClass, T entity, Serializable id, String idInString, InstanceInitializer sessionInitializer, ConversionContext conversionContext)
           
 UpdateLuceneWork createUpdateWork(Class<T> entityClass, T entity, Serializable id, String idInString, InstanceInitializer sessionInitializer, ConversionContext contextualBridge)
           
protected  void documentBuilderSpecificChecks(org.hibernate.annotations.common.reflection.XProperty member, AbstractDocumentBuilder.PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix, ConfigContext context, org.hibernate.search.engine.spi.AbstractDocumentBuilder.PathsContext pathsContext)
           
 FieldBridge getBridge(String fieldName)
           
 org.apache.lucene.document.Document getDocument(T instance, Serializable id, Map<String,String> fieldToAnalyzerMap, InstanceInitializer objectInitializer, ConversionContext conversionContext)
          Builds the Lucene Document for a given entity instance and its id.
 Set<FieldCacheType> getFieldCacheOption()
           
 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

 TwoWayFieldBridge getIdBridge()
           
 String getIdentifierName()
           
 FieldCacheCollectorFactory getIdFieldCacheCollectionFactory()
           
 org.hibernate.annotations.common.reflection.XMember getIdGetter()
           
 String getIdKeywordName()
           
 org.apache.lucene.index.Term getTerm(Serializable id)
          Deprecated. 
 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, 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
addToScopedAnalyzer, appendContainedInWorkForInstance, close, forceStateInspectionOptimizationsDisabled, getAnalyzer, getBeanClass, getBeanXClass, getEntityState, getMappedSubclasses, getMetadata, getPrecisionStep, getSimilarity, isCollectionRoleExcluded, isDirty, isRoot, postInitialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentBuilderIndexedEntity

public DocumentBuilderIndexedEntity(org.hibernate.annotations.common.reflection.XClass clazz,
                                    ConfigContext context,
                                    org.apache.lucene.search.Similarity similarity,
                                    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
context - Handle to default configuration settings
similarity - the Similarity implementation set at the related index level
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()

getIdFieldCacheCollectionFactory

public FieldCacheCollectorFactory getIdFieldCacheCollectionFactory()

documentBuilderSpecificChecks

protected void documentBuilderSpecificChecks(org.hibernate.annotations.common.reflection.XProperty member,
                                             AbstractDocumentBuilder.PropertiesMetadata propertiesMetadata,
                                             boolean isRoot,
                                             String prefix,
                                             ConfigContext context,
                                             org.hibernate.search.engine.spi.AbstractDocumentBuilder.PathsContext pathsContext)
Specified by:
documentBuilderSpecificChecks in class AbstractDocumentBuilder<T>

checkDocumentId

protected void checkDocumentId(org.hibernate.annotations.common.reflection.XProperty member,
                               AbstractDocumentBuilder.PropertiesMetadata propertiesMetadata,
                               boolean isRoot,
                               String prefix,
                               ConfigContext context,
                               org.hibernate.search.engine.spi.AbstractDocumentBuilder.PathsContext pathsContext)

addWorkToQueue

public void addWorkToQueue(Class<T> entityClass,
                           T entity,
                           Serializable id,
                           boolean delete,
                           boolean add,
                           List<LuceneWork> queue,
                           ConversionContext contextualBridge)
Specified by:
addWorkToQueue in class AbstractDocumentBuilder<T>

createAddWork

public AddLuceneWork createAddWork(Class<T> entityClass,
                                   T entity,
                                   Serializable id,
                                   String idInString,
                                   InstanceInitializer sessionInitializer,
                                   ConversionContext conversionContext)

createUpdateWork

public UpdateLuceneWork createUpdateWork(Class<T> entityClass,
                                         T entity,
                                         Serializable id,
                                         String idInString,
                                         InstanceInitializer sessionInitializer,
                                         ConversionContext contextualBridge)

getDocument

public org.apache.lucene.document.Document getDocument(T instance,
                                                       Serializable id,
                                                       Map<String,String> fieldToAnalyzerMap,
                                                       InstanceInitializer objectInitializer,
                                                       ConversionContext conversionContext)
Builds the Lucene Document for a given entity instance and its id.

Parameters:
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 initalized
conversionContext -
Returns:
The Lucene Document for the specified entity.

getIdentifierName

public String getIdentifierName()

allowFieldSelectionInProjection

public boolean allowFieldSelectionInProjection()

getFieldCacheOption

public Set<FieldCacheType> getFieldCacheOption()

getTerm

@Deprecated
public org.apache.lucene.index.Term getTerm(Serializable id)
Deprecated. 


getIdBridge

public TwoWayFieldBridge getIdBridge()

getIdKeywordName

public String getIdKeywordName()

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<T>
Parameters:
entity - The entity for which to return the id. Cannot be null.
Returns:
entity id

objectToString

public String objectToString(String fieldName,
                             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<T>
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<T>
Returns:
true if @DocumentId and @Id are found on the same property


Copyright © 2006-2012 Red Hat Middleware, LLC. All Rights Reserved