|
28 | 28 | import mediathek.tool.LuceneDefaultAnalyzer;
|
29 | 29 | import mediathek.tool.SwingErrorDialog;
|
30 | 30 | import mediathek.tool.datum.DateUtil;
|
| 31 | +import mediathek.tool.datum.DatumFilm; |
31 | 32 | import org.apache.logging.log4j.LogManager;
|
32 | 33 | import org.apache.logging.log4j.Logger;
|
33 | 34 | import org.apache.lucene.document.*;
|
|
39 | 40 | import javax.swing.*;
|
40 | 41 | import java.io.IOException;
|
41 | 42 | import java.nio.file.Files;
|
| 43 | +import java.text.DateFormat; |
| 44 | +import java.text.SimpleDateFormat; |
| 45 | +import java.util.Locale; |
42 | 46 |
|
43 | 47 | public class LuceneIndexWorker extends SwingWorker<Void, Void> {
|
44 | 48 | private static final Logger logger = LogManager.getLogger();
|
45 | 49 | private final JProgressBar progressBar;
|
46 | 50 | private final JLabel progLabel;
|
| 51 | + private final DateFormat weekdayFormatter = new SimpleDateFormat("EEEE", Locale.GERMAN); |
47 | 52 | private int oldProgress;
|
48 | 53 |
|
49 | 54 | public LuceneIndexWorker(@NotNull JLabel progLabel, @NotNull JProgressBar progressBar) {
|
@@ -82,10 +87,19 @@ private void indexFilm(@NotNull IndexWriter writer, @NotNull DatenFilm film) thr
|
82 | 87 | doc.add(new StringField(LuceneIndexKeys.DUPLICATE, Boolean.toString(film.isDuplicate()), Field.Store.NO));
|
83 | 88 |
|
84 | 89 | addSendeDatum(doc, film);
|
| 90 | + addWochentag(doc, film); |
85 | 91 |
|
86 | 92 | writer.addDocument(doc);
|
87 | 93 | }
|
88 | 94 |
|
| 95 | + private void addWochentag(@NotNull Document doc, @NotNull DatenFilm film) { |
| 96 | + var date = film.getDatumFilm(); |
| 97 | + if (date != DatumFilm.UNDEFINED_FILM_DATE) { |
| 98 | + String strDate = weekdayFormatter.format(date); |
| 99 | + doc.add(new TextField(LuceneIndexKeys.SENDE_WOCHENTAG, strDate, Field.Store.NO)); |
| 100 | + } |
| 101 | + } |
| 102 | + |
89 | 103 | private void addSendeDatum(@NotNull Document doc, @NotNull DatenFilm film) {
|
90 | 104 | String sendeDatumStr = DateTools.timeToString(DateUtil.convertFilmDateToLuceneDate(film),
|
91 | 105 | DateTools.Resolution.DAY);
|
@@ -135,14 +149,16 @@ protected Void doInBackground() {
|
135 | 149 | }
|
136 | 150 | reader = DirectoryReader.open(filmListe.getLuceneDirectory());
|
137 | 151 | filmListe.setReader(reader);
|
138 |
| - } catch (Exception ex) { |
| 152 | + } |
| 153 | + catch (Exception ex) { |
139 | 154 | logger.error("Lucene film index most probably damaged, deleting it.");
|
140 | 155 | try {
|
141 | 156 | var indexPath = StandardLocations.getFilmIndexPath();
|
142 | 157 | if (Files.exists(indexPath)) {
|
143 | 158 | FileUtils.deletePathRecursively(indexPath);
|
144 | 159 | }
|
145 |
| - } catch (IOException e) { |
| 160 | + } |
| 161 | + catch (IOException e) { |
146 | 162 | logger.error("Unable to delete lucene index path", e);
|
147 | 163 | }
|
148 | 164 | SwingUtilities.invokeLater(() -> {
|
|
0 commit comments