1 | |
package org.jtheque.films.services.impl.utils.file.exports; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.Managers; |
20 | |
import org.jtheque.core.managers.log.ILoggingManager; |
21 | |
import org.jtheque.core.utils.file.jt.JTFileWriter; |
22 | |
import org.jtheque.films.persistence.od.able.Film; |
23 | |
import org.jtheque.films.services.impl.utils.file.jt.sources.JTFDataSource; |
24 | |
import org.jtheque.films.services.impl.utils.file.jt.writer.JTFFileWriter; |
25 | |
import org.jtheque.films.utils.Constants; |
26 | |
import org.jtheque.films.utils.Constants.Files.FileType; |
27 | |
import org.jtheque.utils.io.FileException; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public final class JTFExporter extends AbstractExporter<Film> { |
35 | |
@Override |
36 | |
public boolean canExportTo(FileType fileType) { |
37 | 0 | return fileType == FileType.JTF; |
38 | |
} |
39 | |
|
40 | |
@Override |
41 | |
public void export(String path) { |
42 | 0 | Film result = getDatas().iterator().next(); |
43 | |
|
44 | 0 | JTFDataSource source = new JTFDataSource(); |
45 | |
|
46 | 0 | source.setFileVersion(Constants.Files.Versions.JTF.SECOND); |
47 | 0 | source.setVersion(Managers.getCore().getApplication().getVersion()); |
48 | 0 | source.setFilm(result); |
49 | |
|
50 | 0 | JTFileWriter writer = new JTFFileWriter(); |
51 | |
|
52 | |
try { |
53 | 0 | writer.writeFile(path, source); |
54 | 0 | } catch (FileException e) { |
55 | 0 | Managers.getManager(ILoggingManager.class).getLogger(getClass()).error(e); |
56 | 0 | } |
57 | 0 | } |
58 | |
} |