Coverage Report - org.jtheque.films.controllers.impl.ExportController
 
Classes in this File Line Coverage Branch Coverage Complexity
ExportController
0 %
0/14
N/A
1
 
 1  
 package org.jtheque.films.controllers.impl;
 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.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  
  * A controller for the export view.
 35  
  *
 36  
  * @author Baptiste Wicht
 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  
 }