public void setStrictLegacyMode( final boolean strict ) { getReportConfiguration().setConfigProperty( "org.pentaho.reporting.engine.classic.core.legacy.StrictCompatibility", String.valueOf( strict ) ); }
/** * Creates a new <code>CSVProcessor</code>. The processor will use a comma (",") to separate the column values, unless * defined otherwise in the report configuration. The processor creates a private copy of the clone, so that no change * to the original report will influence the report processing. DataRow names are not written. * * @param report * the report to be processed. * @throws ReportProcessingException * if the report initialisation failed. */ public CSVProcessor( final MasterReport report ) throws ReportProcessingException { this( report, report.getReportConfiguration().getConfigProperty( CSVProcessor.CSV_SEPARATOR, "," ) ); }
public boolean isStrictLegacyMode() { return "true".equals( getReportConfiguration().getConfigProperty( "org.pentaho.reporting.engine.classic.core.legacy.StrictCompatibility" ) ); }
/** * Creates a new CSVProcessor. The processor will use the specified separator, the report configuration is not queried * for a separator. The processor creates a private copy of the clone, so that no change to the original report will * influence the report processing. DataRowNames are not written. * * @param report * the report to be processed. * @param separator * the separator string to mark column boundaries. * @throws ReportProcessingException * if the report initialisation failed. */ public CSVProcessor( final MasterReport report, final String separator ) throws ReportProcessingException { this( report, separator, CSVProcessor.queryBoolConfig( report.getReportConfiguration(), CSVProcessor.CSV_DATAROWNAME ) ); }
/** * Saves a report to Excel format. * * @param report the report. * @param filename target file name. * @param strict defines whether the strict layout mode should be activated. * @throws ReportProcessingException if the report processing failed. * @throws IOException if there was an IOerror while processing the report. */ public static void createXLS( final MasterReport report, final String filename, final boolean strict ) throws IOException, ReportProcessingException { if ( report == null ) { throw new NullPointerException(); } if ( filename == null ) { throw new NullPointerException(); } report.getReportConfiguration().setConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.base.StrictLayout", String.valueOf( strict ) ); OutputStream fout = new BufferedOutputStream( new FileOutputStream( filename ) ); processFlowXls( report, fout ); }
/** * Saves a report to Excel format. * * @param report the report. * @param filename target file name. * @param strict defines whether the strict layout mode should be activated. * @throws ReportProcessingException if the report processing failed. * @throws IOException if there was an IOerror while processing the report. */ public static void createXLSX( final MasterReport report, final String filename, final boolean strict ) throws IOException, ReportProcessingException { if ( report == null ) { throw new NullPointerException(); } if ( filename == null ) { throw new NullPointerException(); } report.getReportConfiguration().setConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.base.StrictLayout", String.valueOf( strict ) ); OutputStream fout = new BufferedOutputStream( new FileOutputStream( filename ) ); processFlowXlsx( report, fout ); }
/** * Epson targets need special care, sadly the old printers used their own code page schema, which is totally * incompatible with the modern ones. All epson printers that were manufactured before 1991/1992 suffer form this * weakness. * * @param driver * the driver, which should be configured. */ private void applyFallbackEncoding( final AbstractEpsonPrinterDriver driver ) { final String encoding = report.getReportConfiguration().getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.plaintext.FallbackEncoding" ); //$NON-NLS-1$ driver.setFallBackCharset( (byte) ParserUtil.parseInt( encoding, 0 ) ); }
private boolean parseSettings( final String settingsFile ) throws ParseException { try { final Map parameters = deriveParseParameters(); parameters.put( new FactoryParameterKey( ReportParserUtil.HELPER_OBJ_REPORT_NAME ), null ); final BundleSettings settings = (BundleSettings) performExternalParsing( settingsFile, BundleSettings.class, parameters ); // todo: Apply settings final Configuration configuration = settings.getConfiguration(); final Enumeration configProperties = configuration.getConfigProperties(); while ( configProperties.hasMoreElements() ) { final String key = (String) configProperties.nextElement(); final String value = configuration.getConfigProperty( key ); if ( value != null ) { report.getReportConfiguration().setConfigProperty( key, value ); } } return true; } catch ( ResourceLoadingException e ) { ContentRootElementHandler.logger.warn( "Unable to parse the settingsFile for this bundle from file: " + settingsFile ); return false; } }
/** * Builds a default configuration from a given report definition object. * <p/> * This will only create a valid definition, if the report has a valid content base object set. * * @param report * the report for which to create the writer configuration. * @return the generated configuration. */ public static Configuration createDefaultConfiguration( final MasterReport report ) { final ModifiableConfiguration repConf = new HierarchicalConfiguration( report.getReportConfiguration() ); final ResourceKey contentBase = report.getContentBase(); if ( contentBase != null ) { final ResourceManager resourceManager = report.getResourceManager(); final URL value = resourceManager.toURL( contentBase ); if ( value != null ) { repConf.setConfigProperty( AbstractXmlResourceFactory.CONTENTBASE_KEY, value.toExternalForm() ); } } return repConf; }
protected MasterReport tuneForTesting( final MasterReport report ) throws Exception { final ModifiableConfiguration configuration = report.getReportConfiguration(); configuration.setConfigProperty( DefaultReportEnvironment.ENVIRONMENT_KEY + "::internal::report.date", "2011-04-07T15:00:00.000+0000" ); configuration.setConfigProperty( DefaultReportEnvironment.ENVIRONMENT_TYPE + "::internal::report.date", "java.util.Date" ); return report; }
protected void writeConfiguration( final BundleWriterState state, final XmlWriter writer ) throws IOException { if ( state == null ) { throw new NullPointerException(); } if ( writer == null ) { throw new NullPointerException(); } final MasterReport report = state.getMasterReport(); final ModifiableConfiguration rawConfig = report.getReportConfiguration(); if ( rawConfig instanceof HierarchicalConfiguration ) { writer.writeTag( BundleNamespaces.SETTINGS, "configuration", XmlWriterSupport.OPEN ); final HierarchicalConfiguration configuration = (HierarchicalConfiguration) rawConfig; final Enumeration keys = configuration.getConfigProperties(); while ( keys.hasMoreElements() ) { final String key = (String) keys.nextElement(); final String value = configuration.getConfigProperty( key ); if ( value != null && configuration.isLocallyDefined( key ) ) { writer.writeTag( BundleNamespaces.SETTINGS, "property", "name", key, XmlWriterSupport.OPEN ); writer.writeTextNormalized( value, true ); writer.writeCloseTag(); } } writer.writeCloseTag(); } } }
return new SimplePageDefinitionReadHandler(); } else if ( "configuration".equals( tagName ) ) { return new ConfigurationReadHandler( masterReport.getReportConfiguration() );
@Test public void testHandleRotatedTextHTML() throws Exception { URL url = getClass().getResource( "BACKLOG-10064.prpt" ); MasterReport report = (MasterReport) new ResourceManager().createDirectly( url, MasterReport.class ).getResource(); report.getReportConfiguration().setConfigProperty( HtmlTableModule.INLINE_STYLE, "true" ); report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.STRICT_ERROR_HANDLING_KEY, "false" ); List<String> elementsIdList = Arrays.asList("topLeft90","topCenter90","topRight90","topJustify90", "topLeft-90","topCenter-90","topRight-90","topJustify-90", "middleLeft90","middleCenter90","middleRight90","middleJustify90", "middleLeft-90","middleCenter-90","middleRight-90","middleJustify-90", "bottomLeft90","bottomCenter90","bottomRight90","bottomJustify90", "bottomLeft-90","bottomCenter-90","bottomRight-90","bottomJustify-90"); XPathFactory xpathFactory = XPathFactory.newInstance(); try ( ByteArrayOutputStream stream = new ByteArrayOutputStream() ) { HtmlReportUtil.createStreamHTML( report, stream ); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware( true ); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse( new ByteArrayInputStream( stream.toByteArray() ) ); for ( String elementId : elementsIdList ) { org.w3c.dom.Element element = document.getElementById( elementId ); Node rotatedTextStyle = element.getFirstChild().getAttributes().getNamedItem( "style" ); Node trSryle = element.getParentNode().getParentNode().getAttributes().getNamedItem( "style" ); assertTrue( isStyleValid( rotatedTextStyle.getNodeValue(), trSryle.getNodeValue(), elementId.contains( "middle" ) ) ); } } catch ( final IOException | ReportProcessingException e ) { fail(); } }
this.outputProcessor = outputProcessor; final Configuration configuration = report.getReportConfiguration(); this.paranoidChecks = "true".equals( configuration
/** * Exports a report. * * @param report * the report. * @return true, if the export was successful, false otherwise. */ public boolean performExport( final MasterReport report ) { // need to connect to the report pane to receive state updates ... final ReportProgressDialog progressDialog; if ( "true".equals( report.getReportConfiguration().getConfigProperty( PrintingPlugin.PROGRESS_DIALOG_ENABLE_KEY, "false" ) ) ) { //$NON-NLS-1$ //$NON-NLS-2$ progressDialog = createProgressDialog(); if ( report.getTitle() == null ) { progressDialog.setTitle( getResources().getString( "ProgressDialog.EMPTY_TITLE" ) ); } else { progressDialog.setTitle( getResources().formatMessage( "ProgressDialog.TITLE", report.getTitle() ) ); } } else { progressDialog = null; } final PrintExportTask task = new PrintExportTask( report, progressDialog, getContext() ); final Thread worker = new Thread( task ); worker.start(); return true; }
public static void printDirectly( final MasterReport report, final ReportProgressListener progressListener ) throws PrinterException, ReportProcessingException { final ModifiableConfiguration reportConfiguration = report.getReportConfiguration(); final String jobName = reportConfiguration.getConfigProperty( PRINTER_JOB_NAME_KEY, report.getTitle() ); final PrinterJob printerJob = PrinterJob.getPrinterJob(); if ( jobName != null ) { printerJob.setJobName( jobName ); } final PrintReportProcessor reportPane = new PrintReportProcessor( report ); if ( progressListener != null ) { reportPane.addReportProgressListener( progressListener ); } printerJob.setPageable( reportPane ); try { printerJob.setCopies( getNumberOfCopies( reportConfiguration ) ); printerJob.print(); } finally { reportPane.close(); if ( progressListener != null ) { reportPane.removeReportProgressListener( progressListener ); } } }
throw new NullPointerException( "ContentBase is null" ); final ModifiableConfiguration config = new HierarchicalConfiguration( report.getReportConfiguration() ); config.setConfigProperty( AbstractXmlResourceFactory.CONTENTBASE_KEY, contentBase.toExternalForm() );
protected OutputFunction createLayoutManager() { final CSVWriter lm = new CSVWriter(); lm.setSeparator( separator ); lm.setWriteDataRowNames( writeDataRowNames ); lm.setWriter( getWriter() ); final Configuration config = getReport().getReportConfiguration(); lm.setWriteStateColumns( CSVProcessor.queryBoolConfig( config, CSVProcessor.CSV_WRITE_STATECOLUMNS ) ); lm.setEnableReportHeader( CSVProcessor.queryBoolConfig( config, CSVProcessor.CSV_ENABLE_REPORTHEADER ) ); lm.setEnableReportFooter( CSVProcessor.queryBoolConfig( config, CSVProcessor.CSV_ENABLE_REPORTFOOTER ) ); lm.setEnableGroupHeader( CSVProcessor.queryBoolConfig( config, CSVProcessor.CSV_ENABLE_GROUPHEADERS ) ); lm.setEnableGroupFooter( CSVProcessor.queryBoolConfig( config, CSVProcessor.CSV_ENABLE_GROUPFOOTERS ) ); lm.setEnableItemband( CSVProcessor.queryBoolConfig( config, CSVProcessor.CSV_ENABLE_ITEMBANDS ) ); return lm; }
public static boolean print( final MasterReport report, final ReportProgressListener progressListener ) throws PrinterException, ReportProcessingException { final ModifiableConfiguration reportConfiguration = report.getReportConfiguration(); final String jobName = reportConfiguration.getConfigProperty( PRINTER_JOB_NAME_KEY, report.getTitle() ); final PrinterJob printerJob = PrinterJob.getPrinterJob(); if ( jobName != null ) { printerJob.setJobName( jobName ); } final PrintReportProcessor reportPane = new PrintReportProcessor( report ); if ( progressListener != null ) { reportPane.addReportProgressListener( progressListener ); } try { reportPane.fireProcessingStarted(); printerJob.setPageable( reportPane ); printerJob.setCopies( getNumberOfCopies( reportConfiguration ) ); if ( printerJob.printDialog() ) { printerJob.print(); return true; } return false; } finally { reportPane.fireProcessingFinished(); reportPane.close(); if ( progressListener != null ) { reportPane.removeReportProgressListener( progressListener ); } } }
public void testCreate() throws Exception { final MasterReport report = new MasterReport(); // Report name is null report.setName( "MyTestReport" ); assertNotNull( report.getPageDefinition() ); assertNotNull( report.getExpressions() ); assertNotNull( report.getRootGroup() ); assertEquals( report.getGroupCount(), 1 ); assertNotNull( report.getItemBand() ); assertNotNull( report.getName() ); assertNotNull( report.getPageFooter() ); assertNotNull( report.getPageHeader() ); assertNotNull( report.getReportConfiguration() ); assertNotNull( report.getReportFooter() ); assertNotNull( report.getReportHeader() ); assertNotNull( report.getGroup( 0 ) ); // the default group must be defined ... assertNotNull( report.clone() ); }