org.hibernate.search.engine
Class AbstractDocumentBuilder<T>

java.lang.Object
  extended by org.hibernate.search.engine.AbstractDocumentBuilder<T>
All Implemented Interfaces:
DocumentBuilder
Direct Known Subclasses:
DocumentBuilderContainedEntity, DocumentBuilderIndexedEntity

public abstract class AbstractDocumentBuilder<T>
extends Object
implements DocumentBuilder

Abstract base class for the document builders.

Author:
Hardy Ferentschik

Nested Class Summary
protected static class AbstractDocumentBuilder.PropertiesMetadata
          Wrapper class containing all the meta data extracted out of a single entity.
 
Field Summary
protected  Class<?> beanClass
           
protected  String beanXClassName
           
protected  Set<String> containedInCollectionRoles
           
protected  EntityState entityState
           
protected  Set<String> fieldCollectionRoles
           
protected  Set<String> indexedEmbeddedCollectionRoles
           
protected  AbstractDocumentBuilder.PropertiesMetadata metadata
           
protected  org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager
           
 
Fields inherited from interface org.hibernate.search.engine.DocumentBuilder
CLASS_FIELDNAME
 
Constructor Summary
AbstractDocumentBuilder(org.hibernate.annotations.common.reflection.XClass xClass, ConfigContext context, Similarity similarity, org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager, Set<org.hibernate.annotations.common.reflection.XClass> optimizationBlackList)
          Constructor used on contained entities not annotated with @Indexed themselves.
 
Method Summary
protected  void addToScopedAnalyzer(String fieldName, Analyzer analyzer, Index index)
           
abstract  void addWorkToQueue(Class<T> entityClass, T entity, Serializable id, boolean delete, boolean add, boolean batch, List<LuceneWork> queue)
           
 void appendContainedInWorkForInstance(Object instance, WorkPlan workplan)
          If we have a work instance we have to check whether the instance to be indexed is contained in any other indexed entities.
protected abstract  void documentBuilderSpecificChecks(org.hibernate.annotations.common.reflection.XProperty member, AbstractDocumentBuilder.PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix, ConfigContext context)
           
 void forceStateInspectionOptimizationsDisabled()
          Makes sure isCollectionRoleExcluded will always return false, so that collection update events are always processed.
 Analyzer getAnalyzer()
           
protected  Analyzer getAnalyzer(org.hibernate.annotations.common.reflection.XAnnotatedElement annotatedElement, ConfigContext context)
           
 Class<?> getBeanClass()
           
 org.hibernate.annotations.common.reflection.XClass getBeanXClass()
           
protected  Float getBoost(org.hibernate.annotations.common.reflection.XProperty member, Field fieldAnn)
           
protected  BoostStrategy getDynamicBoost(org.hibernate.annotations.common.reflection.XProperty member)
           
 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  Field.Index getIndex(Index index)
           
 Set<Class<?>> getMappedSubclasses()
           
 AbstractDocumentBuilder.PropertiesMetadata getMetadata()
           
protected  Integer getPrecisionStep(NumericField numericFieldAnn)
           
 Similarity getSimilarity()
           
protected  Field.TermVector getTermVector(TermVector vector)
           
 boolean isCollectionRoleExcluded(String collectionRole)
          Returns true if the collection event is not going to affect the index state, so that the indexing event can be skipped.
 boolean isDirty(String[] dirtyPropertyNames)
          Hibernate entities might be considered dirty, but still have only changes that don't affect indexing.
 boolean isRoot()
           
 void postInitialize(Set<Class<?>> indexedClasses)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beanXClassName

protected final String beanXClassName

beanClass

protected final Class<?> beanClass

fieldCollectionRoles

protected final Set<String> fieldCollectionRoles

indexedEmbeddedCollectionRoles

protected final Set<String> indexedEmbeddedCollectionRoles

containedInCollectionRoles

protected final Set<String> containedInCollectionRoles

metadata

protected final AbstractDocumentBuilder.PropertiesMetadata metadata

entityState

protected EntityState entityState

reflectionManager

protected org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager
Constructor Detail

AbstractDocumentBuilder

public AbstractDocumentBuilder(org.hibernate.annotations.common.reflection.XClass xClass,
                               ConfigContext context,
                               Similarity similarity,
                               org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager,
                               Set<org.hibernate.annotations.common.reflection.XClass> optimizationBlackList)
Constructor used on contained entities not annotated with @Indexed themselves.

Parameters:
xClass - The class for which to build a DocumentBuilderContainedEntity}
context - Handle to default configuration settings
similarity - The index level similarity
reflectionManager - Reflection manager to use for processing the annotations
Method Detail

addWorkToQueue

public abstract void addWorkToQueue(Class<T> entityClass,
                                    T entity,
                                    Serializable id,
                                    boolean delete,
                                    boolean add,
                                    boolean batch,
                                    List<LuceneWork> queue)

documentBuilderSpecificChecks

protected abstract void documentBuilderSpecificChecks(org.hibernate.annotations.common.reflection.XProperty member,
                                                      AbstractDocumentBuilder.PropertiesMetadata propertiesMetadata,
                                                      boolean isRoot,
                                                      String prefix,
                                                      ConfigContext context)

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

isRoot

public boolean isRoot()

getBeanClass

public Class<?> getBeanClass()

getBeanXClass

public org.hibernate.annotations.common.reflection.XClass getBeanXClass()

getMetadata

public AbstractDocumentBuilder.PropertiesMetadata getMetadata()

getSimilarity

public Similarity getSimilarity()

getAnalyzer

public Analyzer getAnalyzer()

getEntityState

public EntityState getEntityState()

getMappedSubclasses

public Set<Class<?>> getMappedSubclasses()

postInitialize

public void postInitialize(Set<Class<?>> indexedClasses)

getAnalyzer

protected Analyzer getAnalyzer(org.hibernate.annotations.common.reflection.XAnnotatedElement annotatedElement,
                               ConfigContext context)

addToScopedAnalyzer

protected void addToScopedAnalyzer(String fieldName,
                                   Analyzer analyzer,
                                   Index index)

getBoost

protected Float getBoost(org.hibernate.annotations.common.reflection.XProperty member,
                         Field fieldAnn)

getDynamicBoost

protected BoostStrategy getDynamicBoost(org.hibernate.annotations.common.reflection.XProperty member)

getTermVector

protected Field.TermVector getTermVector(TermVector vector)

getIndex

protected Field.Index getIndex(Index index)

appendContainedInWorkForInstance

public void appendContainedInWorkForInstance(Object instance,
                                             WorkPlan workplan)
If we have a work instance we have to check whether the instance to be indexed is contained in any other indexed entities.


getPrecisionStep

protected Integer getPrecisionStep(NumericField numericFieldAnn)

isDirty

public boolean isDirty(String[] dirtyPropertyNames)
Hibernate entities might be considered dirty, but still have only changes that don't affect indexing. So this isDirty() implementation will return true only if the proposed change is possibly affecting the index.

Parameters:
dirtyPropertyNames - Contains the property name of each value which changed, or null for everything.
Returns:
true if it can't make sure the index doesn't need an update
Since:
3.4

isCollectionRoleExcluded

public boolean isCollectionRoleExcluded(String collectionRole)
Returns true if the collection event is not going to affect the index state, so that the indexing event can be skipped.

Parameters:
collectionRole -
Returns:
true if the collection Role does not affect index state
Since:
3.4

forceStateInspectionOptimizationsDisabled

public void forceStateInspectionOptimizationsDisabled()
Makes sure isCollectionRoleExcluded will always return false, so that collection update events are always processed.

See Also:
isCollectionRoleExcluded(String)


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