// Path: lucene/src/main/java/de/fhopf/lucenesolrtalk/Talk.java
// public class Talk {
// 
//     public final String path;
//     public final String title;
//     public final List<String> speakers;
//     public final Date date;
//     public final String content;
//     public final List<String> categories;
//     public final String organizer;
// 
//     public Talk(String path, String title, List<String> speakers, Date date, String content, List<String> categories, String organizer) {
//         this.path = path;
//         this.title = title;
//         this.speakers = speakers;
//         this.date = date;
//         this.content = content;
//         this.categories = categories;
//         this.organizer = organizer;
//     }
// }
// 
// Path: lucene/src/main/java/de/fhopf/lucenesolrtalk/TalkFromFile.java
// public class TalkFromFile implements Function<File, Talk> {
// 
//     private DateFormat format = new SimpleDateFormat("dd.MM.yyyy");
// 
//     @Override
//     public Talk apply(File input) {
//         Properties props = read(input);
//         String speakerValue = props.getProperty("speaker");
//         String title = props.getProperty("title");
//         String dateValue = props.getProperty("date");
//         String contents = props.getProperty("content");
//         String categoriesValue = props.getProperty("categories");
//         String organizer = props.getProperty("organizer", "");
// 
//         List<String> speakers = Arrays.asList(speakerValue.split(","));
//         List<String> categories = Collections.emptyList();
//         if (categoriesValue != null) {
//             categories = Arrays.asList(categoriesValue.split(","));    
//         }        
//         
// 
//         return new Talk(input.getAbsolutePath(), title, speakers, parseDate(dateValue), contents, categories, organizer);
//     }
// 
//     private Date parseDate(String dateValue) {
//         try {
//             return format.parse(dateValue);
//         } catch (ParseException e) {
//             throw new IllegalStateException(e);
//         }
//     }
// 
//     private Properties read(File input) {
//         Properties props = new Properties();
//         FileInputStream in = null;
//         try {
//             in = new FileInputStream(input);
//             props.load(in);
//         } catch (IOException e) {
//             throw new IllegalStateException(e);
//         } finally {
//             if (in != null) {
//                 try {
//                     in.close();
//                 } catch (IOException e) {
//                     e.printStackTrace();
//                 }
//             }
//         }
//         return props;
//     }
// }


import com.google.common.collect.Collections2;
import de.fhopf.lucenesolrtalk.Talk;
import de.fhopf.lucenesolrtalk.TalkFromFile;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import org.apache.lucene.analysis.de.GermanAnalyzer;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
package de.fhopf.lucenesolrtalk.lucene;



/**
 * Indexes talks in Lucene.
 */
public class Indexer {

    private Logger logger = LoggerFactory.getLogger(Indexer.class);

    private final Directory directory;

    public Indexer(Directory directory) {
        this.directory = directory;
    }

// Path: lucene/src/main/java/de/fhopf/lucenesolrtalk/Talk.java
// public class Talk {
// 
//     public final String path;
//     public final String title;
//     public final List<String> speakers;
//     public final Date date;
//     public final String content;
//     public final List<String> categories;
//     public final String organizer;
// 
//     public Talk(String path, String title, List<String> speakers, Date date, String content, List<String> categories, String organizer) {
//         this.path = path;
//         this.title = title;
//         this.speakers = speakers;
//         this.date = date;
//         this.content = content;
//         this.categories = categories;
//         this.organizer = organizer;
//     }
// }
// 
// Path: lucene/src/main/java/de/fhopf/lucenesolrtalk/TalkFromFile.java
// public class TalkFromFile implements Function<File, Talk> {
// 
//     private DateFormat format = new SimpleDateFormat("dd.MM.yyyy");
// 
//     @Override
//     public Talk apply(File input) {
//         Properties props = read(input);
//         String speakerValue = props.getProperty("speaker");
//         String title = props.getProperty("title");
//         String dateValue = props.getProperty("date");
//         String contents = props.getProperty("content");
//         String categoriesValue = props.getProperty("categories");
//         String organizer = props.getProperty("organizer", "");
// 
//         List<String> speakers = Arrays.asList(speakerValue.split(","));
//         List<String> categories = Collections.emptyList();
//         if (categoriesValue != null) {
//             categories = Arrays.asList(categoriesValue.split(","));    
//         }        
//         
// 
//         return new Talk(input.getAbsolutePath(), title, speakers, parseDate(dateValue), contents, categories, organizer);
//     }
// 
//     private Date parseDate(String dateValue) {
//         try {
//             return format.parse(dateValue);
//         } catch (ParseException e) {
//             throw new IllegalStateException(e);
//         }
//     }
// 
//     private Properties read(File input) {
//         Properties props = new Properties();
//         FileInputStream in = null;
//         try {
//             in = new FileInputStream(input);
//             props.load(in);
//         } catch (IOException e) {
//             throw new IllegalStateException(e);
//         } finally {
//             if (in != null) {
//                 try {
//                     in.close();
//                 } catch (IOException e) {
//                     e.printStackTrace();
//                 }
//             }
//         }
//         return props;
//     }
// }


// Path: lucene/src/main/java/de/fhopf/lucenesolrtalk/lucene/Indexer.java
import com.google.common.collect.Collections2;
import de.fhopf.lucenesolrtalk.Talk;
import de.fhopf.lucenesolrtalk.TalkFromFile;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import org.apache.lucene.analysis.de.GermanAnalyzer;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;

package de.fhopf.lucenesolrtalk.lucene;



/**
 * Indexes talks in Lucene.
 */
public class Indexer {

    private Logger logger = LoggerFactory.getLogger(Indexer.class);

    private final Directory directory;

    public Indexer(Directory directory) {
        this.directory = directory;
    }

    public void index(Talk...talks) {