FileDocCategorySizeDatePackage
IndexDocumentBuilderTask.javaAPI DocApache Lucene 2.1.04084Wed Feb 14 10:46:06 GMT 2007org.apache.lucene.gdata.search.index

IndexDocumentBuilderTask

public class IndexDocumentBuilderTask extends Object implements IndexDocumentBuilder
This callable does all of the entiti processing concurrently while added to the {@link org.apache.lucene.gdata.search.index.GDataIndexer} task queue;
see
org.apache.lucene.gdata.search.analysis.Indexable
see
org.apache.lucene.gdata.search.analysis.ContentStrategy
author
Simon Willnauer

Fields Summary
private static final Log
LOG
private final org.apache.lucene.gdata.data.ServerBaseEntry
entry
private final org.apache.lucene.gdata.search.config.IndexSchema
schema
private final IndexAction
action
private final boolean
commitAfter
private final boolean
optimizeAfter
Constructors Summary
protected IndexDocumentBuilderTask(org.apache.lucene.gdata.data.ServerBaseEntry entry, org.apache.lucene.gdata.search.config.IndexSchema schema, IndexAction action, boolean commitAfter, boolean optimizeAfter)

       
                     
        /*
         * omit check for null parameter this happens in the controller.
         */
        this.schema = schema;
        this.entry = entry;
        this.action = action;
        this.commitAfter = commitAfter;
        this.optimizeAfter = optimizeAfter;
    
Methods Summary
public Tcall()

see
java.util.concurrent.Callable#call()

        
        Collection<IndexSchemaField> fields = this.schema.getFields();
        GDataIndexDocument document = new GDataIndexDocument(this.action,
                this.entry.getId(),this.entry.getFeedId(), this.commitAfter,this.optimizeAfter);
        if(this.action != IndexAction.DELETE){
        int addedFields = 0;
        for (IndexSchemaField field : fields) {
            /*
             * get the strategy to process the field
             */
            ContentStrategy strategy = ContentStrategy.getFieldStrategy(field);
            if (LOG.isInfoEnabled())
                LOG.info("Process indexable for " + field);
            try {
                /*
                 * get the indexable via the factory method to enable new /
                 * different implementation of the interface (this could be a
                 * faster dom impl e.g. dom4j)
                 */
                strategy.processIndexable(Indexable.getIndexable(this.entry));
                addedFields++;
            } catch (NotIndexableException e) {
                LOG.warn("Can not create field for " + field+" field will be skipped -- reason: ", e);
                continue;
            }
         
            document.addField(strategy);

        }
        if(addedFields == 0)
            throw new GdataIndexerException("No field added to document for Schema: "+this.schema); 
        }
        return (T)document;