Coverage Report - org.jtheque.films.services.impl.utils.file.exports.JTFEExporter
 
Classes in this File Line Coverage Branch Coverage Complexity
JTFEExporter
0 %
0/12
0 %
0/2
1.5
 
 1  
 package org.jtheque.films.services.impl.utils.file.exports;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 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  
  * An exporter to JTFE.
 31  
  *
 32  
  * @author Baptiste Wicht
 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  
 }