org.xwiki.search.solr.internal.metadata
Class AbstractSolrMetadataExtractor

java.lang.Object
  extended by org.xwiki.search.solr.internal.metadata.AbstractSolrMetadataExtractor
All Implemented Interfaces:
SolrMetadataExtractor
Direct Known Subclasses:
AttachmentSolrMetadataExtractor, DocumentSolrMetadataExtractor, ObjectPropertySolrMetadataExtractor, ObjectSolrMetadataExtractor

public abstract class AbstractSolrMetadataExtractor
extends Object
implements SolrMetadataExtractor

Abstract implementation for a metadata extractor.

Since:
4.3M2

Field Summary
protected  DocumentAccessBridge documentAccessBridge
          DocumentAccessBridge component.
protected  Execution execution
          Execution component.
protected  EntityReferenceSerializer<String> localSerializer
          Reference to String serializer.
protected  org.slf4j.Logger logger
          Logging framework.
protected  EntityReferenceSerializer<String> serializer
          Reference to String serializer.
 
Constructor Summary
AbstractSolrMetadataExtractor()
           
 
Method Summary
protected  void addDocumentFields(DocumentReference documentReference, SolrInputDocument solrDocument)
          Adds to a Solr document the fields that are specific to the XWiki document that contains the entity to be indexed.
protected  void addObjectContent(SolrInputDocument solrDocument, BaseObject object, String language)
          Adds the properties of a given object to a Solr document inside the multiValued field Fields.OBJECT_CONTENT.
protected  XWikiDocument getDocument(DocumentReference documentReference)
          Utility method.
 String getId(EntityReference reference)
           
protected  String getLanguage(DocumentReference documentReference)
           
protected  XWikiDocument getTranslatedDocument(DocumentReference documentReference)
          Fetch translated document.
protected  XWikiContext getXWikiContext()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xwiki.search.solr.internal.metadata.SolrMetadataExtractor
getSolrDocument
 

Field Detail

logger

@Inject
protected org.slf4j.Logger logger
Logging framework.


execution

@Inject
protected Execution execution
Execution component.


serializer

@Inject
protected EntityReferenceSerializer<String> serializer
Reference to String serializer.


localSerializer

@Inject
@Named(value="local")
protected EntityReferenceSerializer<String> localSerializer
Reference to String serializer. Used for fields such as class and fullname that are relative to their wiki and are stored without the wiki name.


documentAccessBridge

@Inject
protected DocumentAccessBridge documentAccessBridge
DocumentAccessBridge component.

Constructor Detail

AbstractSolrMetadataExtractor

public AbstractSolrMetadataExtractor()
Method Detail

getId

public String getId(EntityReference reference)
             throws SolrIndexException
Specified by:
getId in interface SolrMetadataExtractor
Parameters:
reference - reference to an entity.
Returns:
the ID of the entity, as it is used in the index.
Throws:
SolrIndexException - if problems occur.

getXWikiContext

protected XWikiContext getXWikiContext()
Returns:
the XWikiContext

getDocument

protected XWikiDocument getDocument(DocumentReference documentReference)
                             throws XWikiException
Utility method.

Parameters:
documentReference - reference to a document.
Returns:
the XWikiDocument instance referenced.
Throws:
XWikiException - if problems occur.

getTranslatedDocument

protected XWikiDocument getTranslatedDocument(DocumentReference documentReference)
                                       throws SolrIndexException
Fetch translated document.

Parameters:
documentReference - reference to the document to be translated.
Returns:
translated document.
Throws:
SolrIndexException - if problems occur.

addDocumentFields

protected void addDocumentFields(DocumentReference documentReference,
                                 SolrInputDocument solrDocument)
                          throws Exception
Adds to a Solr document the fields that are specific to the XWiki document that contains the entity to be indexed. These fields required to identify the owning document and to also reflect some properties of the owning document towards the indexed entity (like language and hidden flag).

Parameters:
documentReference - reference to document.
solrDocument - the Solr document to which to add the fields.
Throws:
Exception - if problems occur.

getLanguage

protected String getLanguage(DocumentReference documentReference)
                      throws SolrIndexException
Parameters:
documentReference - reference to the document.
Returns:
the language code of the referenced document.
Throws:
SolrIndexException - if problems occur.

addObjectContent

protected void addObjectContent(SolrInputDocument solrDocument,
                                BaseObject object,
                                String language)
Adds the properties of a given object to a Solr document inside the multiValued field Fields.OBJECT_CONTENT.

Parameters:
solrDocument - the document where to add the properties.
object - the object whose properties to add.
language - the language of the indexed document. In case of translations, this will obviously be different than the original document's language.