org.hibernate.search.engine.spi
Class DocumentBuilderIndexedEntity<T>
java.lang.Object
org.hibernate.search.engine.spi.AbstractDocumentBuilder<T>
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
|
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)
|
boolean |
allowFieldSelectionInProjection()
|
protected void |
checkDocumentId(org.hibernate.annotations.common.reflection.XProperty member,
AbstractDocumentBuilder.PropertiesMetadata propertiesMetadata,
boolean isRoot,
String prefix,
ConfigContext context)
|
AddLuceneWork |
createAddWork(Class<T> entityClass,
T entity,
Serializable id,
String idInString,
InstanceInitializer sessionInitializer)
|
UpdateLuceneWork |
createUpdateWork(Class<T> entityClass,
T entity,
Serializable id,
String idInString,
InstanceInitializer sessionInitializer)
|
protected void |
documentBuilderSpecificChecks(org.hibernate.annotations.common.reflection.XProperty member,
AbstractDocumentBuilder.PropertiesMetadata propertiesMetadata,
boolean isRoot,
String prefix,
ConfigContext context)
|
FieldBridge |
getBridge(String fieldName)
|
org.apache.lucene.document.Document |
getDocument(T instance,
Serializable id,
Map<String,String> fieldToAnalyzerMap,
InstanceInitializer objectInitializer)
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)
|
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)
|
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 |
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 DocumentBuilderContainedEntitycontext - Handle to default configuration settingssimilarity - the Similarity implementation set at the related index levelreflectionManager - Reflection manager to use for processing the annotationsoptimizationBlackList - mutable register, keeps track of types on which we need to disable collection events optimizationsinstanceInitializer - helper class for class object graph navigation
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)
- 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)
addWorkToQueue
public void addWorkToQueue(Class<T> entityClass,
T entity,
Serializable id,
boolean delete,
boolean add,
List<LuceneWork> queue)
- Specified by:
addWorkToQueue in class AbstractDocumentBuilder<T>
createAddWork
public AddLuceneWork createAddWork(Class<T> entityClass,
T entity,
Serializable id,
String idInString,
InstanceInitializer sessionInitializer)
createUpdateWork
public UpdateLuceneWork createUpdateWork(Class<T> entityClass,
T entity,
Serializable id,
String idInString,
InstanceInitializer sessionInitializer)
getDocument
public org.apache.lucene.document.Document getDocument(T instance,
Serializable id,
Map<String,String> fieldToAnalyzerMap,
InstanceInitializer objectInitializer)
- Builds the Lucene
Document for a given entity instance and its id.
- Parameters:
instance - The entity for which to build the matching Lucene Documentid - 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
- Returns:
- The Lucene
Document for the specified entity.
getIdentifierName
public String getIdentifierName()
allowFieldSelectionInProjection
public boolean allowFieldSelectionInProjection()
getFieldCacheOption
public Set<FieldCacheType> getFieldCacheOption()
getTerm
public org.apache.lucene.index.Term getTerm(Serializable id)
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)
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 Hibernate. All Rights Reserved.