Coverage Report - org.jtheque.films.services.impl.utils.file.exports.RTFExporter
 
Classes in this File Line Coverage Branch Coverage Complexity
RTFExporter
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 net.sf.jasperreports.engine.JRException;
 20  
 import net.sf.jasperreports.engine.JRExporterParameter;
 21  
 import net.sf.jasperreports.engine.JasperCompileManager;
 22  
 import net.sf.jasperreports.engine.JasperPrint;
 23  
 import net.sf.jasperreports.engine.JasperReport;
 24  
 import net.sf.jasperreports.engine.design.JasperDesign;
 25  
 import net.sf.jasperreports.engine.export.JRRtfExporter;
 26  
 import net.sf.jasperreports.engine.xml.JRXmlLoader;
 27  
 import org.jtheque.core.managers.Managers;
 28  
 import org.jtheque.core.managers.log.ILoggingManager;
 29  
 import org.jtheque.films.persistence.od.able.Film;
 30  
 import org.jtheque.films.utils.Constants.Files.FileType;
 31  
 import org.jtheque.films.utils.Constants.Report;
 32  
 import org.jtheque.films.utils.ReportUtils;
 33  
 
 34  
 /**
 35  
  * An exporter to PDF.
 36  
  *
 37  
  * @author Baptiste Wicht
 38  
  */
 39  0
 public final class RTFExporter extends AbstractExporter<Film> {
 40  
     @Override
 41  
     public boolean canExportTo(FileType fileType) {
 42  0
         return fileType == FileType.RTF;
 43  
     }
 44  
 
 45  
     @Override
 46  
     @SuppressWarnings("unchecked")
 47  
     public void export(String path) {
 48  
         try {
 49  0
             JasperDesign jasperDesign = JRXmlLoader.load(getClass().getClassLoader().getResourceAsStream(Report.FORM001_PAGE));
 50  0
             JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
 51  
 
 52  0
             JasperPrint jasperPrint = ReportUtils.configureForm001(jasperReport, getDatas());
 53  
 
 54  0
             JRRtfExporter rtfExporter = new JRRtfExporter();
 55  0
             rtfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
 56  0
             rtfExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, path);
 57  
 
 58  0
             rtfExporter.exportReport();
 59  0
         } catch (JRException e) {
 60  0
             Managers.getManager(ILoggingManager.class).getLogger(getClass()).error(e);
 61  0
         }
 62  0
     }
 63  
 }