1 /* 2 * Copyright (c) 2012, FDV Solutions S.A. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * * Neither the name of the FDV Solutions S.A. nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL FDV Solutions S.A. BE LIABLE FOR ANY 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 package ar.com.fdvs.dj.test; 29 30 31 import ar.com.fdvs.dj.core.DJConstants; 32 import ar.com.fdvs.dj.domain.DynamicReport; 33 import ar.com.fdvs.dj.domain.builders.FastReportBuilder; 34 import net.sf.jasperreports.view.JasperDesignViewer; 35 import net.sf.jasperreports.view.JasperViewer; 36 37 import java.util.Date; 38 39 public class ReportLanguageTest extends BaseDjReportTest { 40 41 public DynamicReport buildReport() throws Exception { 42 43 44 /** 45 * Creates the DynamicReportBuilder and sets the basic options for 46 * the report 47 */ 48 FastReportBuilder drb = new FastReportBuilder(); 49 drb.addColumn("State", "state", String.class.getName(),30) 50 .addColumn("Branch", "branch", String.class.getName(),30) 51 .addColumn("Product Line", "productLine", String.class.getName(),50) 52 .addColumn("Item", "item", String.class.getName(),50) 53 .addColumn("Item Code", "id", Long.class.getName(),30,true) 54 .addColumn("Quantity", "quantity", Long.class.getName(),60,true) 55 .addColumn("Amount", "amount", Float.class.getName(),70,true) 56 .addGroups(2) 57 .setTitle("November " + getYear() + " sales report") 58 .setSubtitle("This report was generated at " + new Date()) 59 .setPrintBackgroundOnOddRows(true) 60 .setUseFullPageWidth(true); 61 62 drb.setLanguage(DJConstants.REPORT_LANGUAGE_JAVA); 63 64 DynamicReport dr = drb.build(); 65 66 return dr; 67 } 68 69 public static void main(String[] args) throws Exception { 70 ReportLanguageTest test = new ReportLanguageTest(); 71 test.testReport(); 72 test.exportToJRXML(); 73 JasperViewer.viewReport(test.jp); //finally display the report report 74 JasperDesignViewer.viewReportDesign(test.jr); 75 } 76 77 }