Coverage Report - org.jtheque.films.services.impl.utils.file.exports.JTFExporter
 
Classes in this File Line Coverage Branch Coverage Complexity
JTFExporter
0 %
0/13
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.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  
  * An exporter to JTF.
 31  
  *
 32  
  * @author Baptiste Wicht
 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  
 }