| 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.JTZippedFileWriter; |
| 22 | |
import org.jtheque.films.persistence.od.able.Film; |
| 23 | |
import org.jtheque.films.services.impl.utils.file.jt.sources.JTFEDataSource; |
| 24 | |
import org.jtheque.films.services.impl.utils.file.jt.writer.JTFEFileWriter; |
| 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 JTFEExporter extends AbstractExporter<Film> { |
| 35 | |
@Override |
| 36 | |
public boolean canExportTo(FileType fileType) { |
| 37 | 0 | return fileType == FileType.JTFE; |
| 38 | |
} |
| 39 | |
|
| 40 | |
@Override |
| 41 | |
@SuppressWarnings("unchecked") |
| 42 | |
public void export(String path) { |
| 43 | 0 | JTFEDataSource source = new JTFEDataSource(); |
| 44 | 0 | source.setFileVersion(Constants.Files.Versions.JTF.FIRST); |
| 45 | 0 | source.setVersion(Managers.getCore().getApplication().getVersion()); |
| 46 | 0 | source.setFilms(getDatas()); |
| 47 | |
|
| 48 | 0 | JTZippedFileWriter writer = new JTFEFileWriter(); |
| 49 | |
|
| 50 | |
try { |
| 51 | 0 | writer.writeFile(path, source); |
| 52 | 0 | } catch (FileException e) { |
| 53 | 0 | Managers.getManager(ILoggingManager.class).getLogger(getClass()).error(e); |
| 54 | 0 | } |
| 55 | 0 | } |
| 56 | |
} |