1 | |
package org.jtheque.films.controllers.impl; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.view.able.controller.AbstractController; |
20 | |
import org.jtheque.films.controllers.able.IExportController; |
21 | |
import org.jtheque.films.persistence.od.able.Film; |
22 | |
import org.jtheque.films.services.able.IFilmsService; |
23 | |
import org.jtheque.films.services.impl.utils.file.exports.Exporter; |
24 | |
import org.jtheque.films.services.impl.utils.file.exports.ExporterFactory; |
25 | |
import org.jtheque.films.services.impl.utils.file.jt.FileFilterFactory; |
26 | |
import org.jtheque.films.services.impl.utils.search.Searcher; |
27 | |
import org.jtheque.films.utils.Constants.Files.FileType; |
28 | |
import org.jtheque.films.view.able.IExportView; |
29 | |
|
30 | |
import javax.annotation.Resource; |
31 | |
import java.util.Arrays; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | public final class ExportController extends AbstractController implements IExportController { |
39 | |
private FileType fileType; |
40 | |
|
41 | |
@Resource |
42 | |
private IExportView exportView; |
43 | |
|
44 | |
@Resource |
45 | |
private IFilmsService filmsService; |
46 | |
|
47 | |
@Override |
48 | |
public void openExportView(FileType fileType) { |
49 | 0 | this.fileType = fileType; |
50 | |
|
51 | 0 | exportView.sendMessage("filter", FileFilterFactory.getFileFilter(fileType)); |
52 | 0 | displayView(); |
53 | 0 | } |
54 | |
|
55 | |
@Override |
56 | |
public void export(Searcher<Film> search, String filePath) { |
57 | 0 | Exporter<Film> exporter = ExporterFactory.getExporter(fileType); |
58 | |
|
59 | 0 | exporter.setDatas(search.search(filmsService.getDatas())); |
60 | |
|
61 | 0 | exporter.export(filePath); |
62 | 0 | } |
63 | |
|
64 | |
@Override |
65 | |
public void exportFilm(String filePath, Film film) { |
66 | 0 | Exporter<Film> exporter = ExporterFactory.getExporter(FileType.JTF); |
67 | |
|
68 | 0 | exporter.setDatas(Arrays.asList(film)); |
69 | |
|
70 | 0 | exporter.export(filePath); |
71 | 0 | } |
72 | |
|
73 | |
@Override |
74 | |
public IExportView getView() { |
75 | 0 | return exportView; |
76 | |
} |
77 | |
} |