@Test public void createReport() throws Exception { LoggingObjectInterface log = mock( LoggingObjectInterface.class ); AutoDocOptionsInterface options = mock( AutoDocOptionsInterface.class ); when( options.isIncludingImage() ).thenReturn( Boolean.TRUE ); KettleReportBuilder builder = new KettleReportBuilder( log, Collections.<ReportSubjectLocation>emptyList(), "", options ); builder.createReport(); assertNotNull( builder.getReport() ); assertNotNull( builder.getReport().getDataFactory() ); assertNotNull( builder.getReport().getReportHeader() ); assertNotNull( builder.getReport().getReportFooter() ); assertNotNull( builder.getReport().getRootGroup() ); assertNotNull( builder.getReport().getPageDefinition() ); assertTrue( builder.getReport().getExpressions().size() > 0 ); }
public void createReport() throws Exception { report = new MasterReport(); KettleFileTableModel transMetaTableModel = new KettleFileTableModel( parentObject, filenames ); TableDataFactory dataFactory = new TableDataFactory( "default", transMetaTableModel ); report.setDataFactory( dataFactory ); ReportHeader reportHeader = new ReportHeader(); report.setReportHeader( reportHeader ); ReportFooter reportFooter = new ReportFooter(); report.setReportFooter( reportFooter ); RelationalGroup group = new RelationalGroup(); group.addField( "filename" ); GroupDataBody groupData = new GroupDataBody(); ItemBand itemBand = new ItemBand(); itemBand.setVisible( true ); itemBand.setLayout( BandStyleKeys.LAYOUT_AUTO ); groupData.setItemBand( itemBand ); group.setBody( groupData ); report.setRootGroup( group ); int pagePosition = 0; reportHeader.getStyle().setStyleProperty( TextStyleKeys.BOLD, true ); pagePosition = createTextField( itemBand, "Filename: ", "filename", pagePosition ); if ( options.isIncludingName() ) { pagePosition = createTextField( itemBand, "Name: ", "name", pagePosition ); } if ( options.isIncludingDescription() ) { pagePosition = createTextField( itemBand, "Description: ", "description", pagePosition ); } if ( options.isIncludingExtendedDescription() ) { pagePosition = createTextField( itemBand, "Long description: ", "extended_description", pagePosition ); } if ( options.isIncludingLoggingConfiguration() ) { pagePosition = createTextField( itemBand, "Logging: ", "logging", pagePosition ); } if ( options.isIncludingCreated() ) { pagePosition = createTextField( itemBand, "Creation: ", "creation", pagePosition ); } if ( options.isIncludingModified() ) { pagePosition = createTextField( itemBand, "Modification: ", "modification", pagePosition ); } if ( options.isIncludingLastExecutionResult() ) { pagePosition = createTextField( itemBand, "Last execution result: : ", "last_exec_result", pagePosition ); } if ( options.isIncludingImage() ) { String bshCode = "Object getValue() { " + Const.CR + " return new " + TransJobDrawable.class.getName() + "(dataRow, " + ( options.getOutputType() == OutputType.PDF ? "true" : "false" ) + ");" + Const.CR + "}"; BSHExpression bshExpression = new BSHExpression(); bshExpression.setExpression( bshCode ); bshExpression.setName( "getImage" ); report.addExpression( bshExpression ); ContentElementFactory contentElementFactory = new ContentElementFactory(); contentElementFactory.setName( "image" ); contentElementFactory.setAbsolutePosition( new Point( 0, pagePosition ) ); contentElementFactory.setMinimumWidth( 750f ); contentElementFactory.setMaximumWidth( 750f ); contentElementFactory.setMinimumHeight( 400f ); contentElementFactory.setMaximumHeight( 750f ); contentElementFactory.setScale( true ); contentElementFactory.setDynamicHeight( true ); Element imageElement = contentElementFactory.createElement(); imageElement .setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, bshExpression ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_QUALITY, "9" ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_TYPE, "PNG" ); ItemBand imageBand = new ItemBand(); imageBand.setLayout( BandStyleKeys.LAYOUT_ROW ); imageBand.addElement( imageElement ); itemBand.addElement( imageBand ); } Paper a4Paper = new Paper(); double paperWidth = 8.26; double paperHeight = 11.69; a4Paper.setSize( paperWidth * 72.0, paperHeight * 72.0 ); double leftMargin = 0.78; double rightMargin = 0.78; double topMargin = 0.08; double bottomMargin = 0.78; a4Paper.setImageableArea( leftMargin * 72.0, topMargin * 72.0, ( paperWidth - leftMargin - rightMargin ) * 72.0, ( paperHeight - topMargin - bottomMargin ) * 72.0 ); PageFormat pageFormat = new PageFormat(); pageFormat.setOrientation( PageFormat.LANDSCAPE ); pageFormat.setPaper( a4Paper ); SimplePageDefinition pageDefinition = new SimplePageDefinition( pageFormat ); report.setPageDefinition( pageDefinition ); }
KettleReportBuilder { public void createReport() throws Exception { report = new MasterReport(); KettleFileTableModel transMetaTableModel = new KettleFileTableModel( parentObject, filenames ); TableDataFactory dataFactory = new TableDataFactory( "default", transMetaTableModel ); report.setDataFactory( dataFactory ); ReportHeader reportHeader = new ReportHeader(); report.setReportHeader( reportHeader ); ReportFooter reportFooter = new ReportFooter(); report.setReportFooter( reportFooter ); RelationalGroup group = new RelationalGroup(); group.addField( "filename" ); GroupDataBody groupData = new GroupDataBody(); ItemBand itemBand = new ItemBand(); itemBand.setVisible( true ); itemBand.setLayout( BandStyleKeys.LAYOUT_AUTO ); groupData.setItemBand( itemBand ); group.setBody( groupData ); report.setRootGroup( group ); int pagePosition = 0; reportHeader.getStyle().setStyleProperty( TextStyleKeys.BOLD, true ); pagePosition = createTextField( itemBand, "Filename: ", "filename", pagePosition ); if ( options.isIncludingName() ) { pagePosition = createTextField( itemBand, "Name: ", "name", pagePosition ); } if ( options.isIncludingDescription() ) { pagePosition = createTextField( itemBand, "Description: ", "description", pagePosition ); } if ( options.isIncludingExtendedDescription() ) { pagePosition = createTextField( itemBand, "Long description: ", "extended_description", pagePosition ); } if ( options.isIncludingLoggingConfiguration() ) { pagePosition = createTextField( itemBand, "Logging: ", "logging", pagePosition ); } if ( options.isIncludingCreated() ) { pagePosition = createTextField( itemBand, "Creation: ", "creation", pagePosition ); } if ( options.isIncludingModified() ) { pagePosition = createTextField( itemBand, "Modification: ", "modification", pagePosition ); } if ( options.isIncludingLastExecutionResult() ) { pagePosition = createTextField( itemBand, "Last execution result: : ", "last_exec_result", pagePosition ); } if ( options.isIncludingImage() ) { String bshCode = "Object getValue() { " + Const.CR + " return new " + TransJobDrawable.class.getName() + "(dataRow, " + ( options.getOutputType() == OutputType.PDF ? "true" : "false" ) + ");" + Const.CR + "}"; BSHExpression bshExpression = new BSHExpression(); bshExpression.setExpression( bshCode ); bshExpression.setName( "getImage" ); report.addExpression( bshExpression ); ContentElementFactory contentElementFactory = new ContentElementFactory(); contentElementFactory.setName( "image" ); contentElementFactory.setAbsolutePosition( new Point( 0, pagePosition ) ); contentElementFactory.setMinimumWidth( 750f ); contentElementFactory.setMaximumWidth( 750f ); contentElementFactory.setMinimumHeight( 400f ); contentElementFactory.setMaximumHeight( 750f ); contentElementFactory.setScale( true ); contentElementFactory.setDynamicHeight( true ); Element imageElement = contentElementFactory.createElement(); imageElement .setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, bshExpression ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_QUALITY, "9" ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_TYPE, "PNG" ); ItemBand imageBand = new ItemBand(); imageBand.setLayout( BandStyleKeys.LAYOUT_ROW ); imageBand.addElement( imageElement ); itemBand.addElement( imageBand ); } Paper a4Paper = new Paper(); double paperWidth = 8.26; double paperHeight = 11.69; a4Paper.setSize( paperWidth * 72.0, paperHeight * 72.0 ); double leftMargin = 0.78; double rightMargin = 0.78; double topMargin = 0.08; double bottomMargin = 0.78; a4Paper.setImageableArea( leftMargin * 72.0, topMargin * 72.0, ( paperWidth - leftMargin - rightMargin ) * 72.0, ( paperHeight - topMargin - bottomMargin ) * 72.0 ); PageFormat pageFormat = new PageFormat(); pageFormat.setOrientation( PageFormat.LANDSCAPE ); pageFormat.setPaper( a4Paper ); SimplePageDefinition pageDefinition = new SimplePageDefinition( pageFormat ); report.setPageDefinition( pageDefinition ); } }
KettleReportBuilder { public void createReport() throws Exception { report = new MasterReport(); KettleFileTableModel transMetaTableModel = new KettleFileTableModel( parentObject, filenames ); TableDataFactory dataFactory = new TableDataFactory( "default", transMetaTableModel ); report.setDataFactory( dataFactory ); ReportHeader reportHeader = new ReportHeader(); report.setReportHeader( reportHeader ); ReportFooter reportFooter = new ReportFooter(); report.setReportFooter( reportFooter ); RelationalGroup group = new RelationalGroup(); group.addField( "filename" ); GroupDataBody groupData = new GroupDataBody(); ItemBand itemBand = new ItemBand(); itemBand.setVisible( true ); itemBand.setLayout( BandStyleKeys.LAYOUT_AUTO ); groupData.setItemBand( itemBand ); group.setBody( groupData ); report.setRootGroup( group ); int pagePosition = 0; reportHeader.getStyle().setStyleProperty( TextStyleKeys.BOLD, true ); pagePosition = createTextField( itemBand, "Filename: ", "filename", pagePosition ); if ( options.isIncludingName() ) { pagePosition = createTextField( itemBand, "Name: ", "name", pagePosition ); } if ( options.isIncludingDescription() ) { pagePosition = createTextField( itemBand, "Description: ", "description", pagePosition ); } if ( options.isIncludingExtendedDescription() ) { pagePosition = createTextField( itemBand, "Long description: ", "extended_description", pagePosition ); } if ( options.isIncludingLoggingConfiguration() ) { pagePosition = createTextField( itemBand, "Logging: ", "logging", pagePosition ); } if ( options.isIncludingCreated() ) { pagePosition = createTextField( itemBand, "Creation: ", "creation", pagePosition ); } if ( options.isIncludingModified() ) { pagePosition = createTextField( itemBand, "Modification: ", "modification", pagePosition ); } if ( options.isIncludingLastExecutionResult() ) { pagePosition = createTextField( itemBand, "Last execution result: : ", "last_exec_result", pagePosition ); } if ( options.isIncludingImage() ) { String bshCode = "Object getValue() { " + Const.CR + " return new " + TransJobDrawable.class.getName() + "(dataRow, " + ( options.getOutputType() == OutputType.PDF ? "true" : "false" ) + ");" + Const.CR + "}"; BSHExpression bshExpression = new BSHExpression(); bshExpression.setExpression( bshCode ); bshExpression.setName( "getImage" ); report.addExpression( bshExpression ); ContentElementFactory contentElementFactory = new ContentElementFactory(); contentElementFactory.setName( "image" ); contentElementFactory.setAbsolutePosition( new Point( 0, pagePosition ) ); contentElementFactory.setMinimumWidth( 750f ); contentElementFactory.setMaximumWidth( 750f ); contentElementFactory.setMinimumHeight( 400f ); contentElementFactory.setMaximumHeight( 750f ); contentElementFactory.setScale( true ); contentElementFactory.setDynamicHeight( true ); Element imageElement = contentElementFactory.createElement(); imageElement .setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, bshExpression ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_QUALITY, "9" ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_TYPE, "PNG" ); ItemBand imageBand = new ItemBand(); imageBand.setLayout( BandStyleKeys.LAYOUT_ROW ); imageBand.addElement( imageElement ); itemBand.addElement( imageBand ); } Paper a4Paper = new Paper(); double paperWidth = 8.26; double paperHeight = 11.69; a4Paper.setSize( paperWidth * 72.0, paperHeight * 72.0 ); double leftMargin = 0.78; double rightMargin = 0.78; double topMargin = 0.08; double bottomMargin = 0.78; a4Paper.setImageableArea( leftMargin * 72.0, topMargin * 72.0, ( paperWidth - leftMargin - rightMargin ) * 72.0, ( paperHeight - topMargin - bottomMargin ) * 72.0 ); PageFormat pageFormat = new PageFormat(); pageFormat.setOrientation( PageFormat.LANDSCAPE ); pageFormat.setPaper( a4Paper ); SimplePageDefinition pageDefinition = new SimplePageDefinition( pageFormat ); report.setPageDefinition( pageDefinition ); } KettleReportBuilder( LoggingObjectInterface parentObject, List<ReportSubjectLocation> locations,
    String targetFilename, AutoDocOptionsInterface options ); }
KettleReportBuilder { public void createReport() throws Exception { report = new MasterReport(); KettleFileTableModel transMetaTableModel = new KettleFileTableModel( parentObject, filenames ); TableDataFactory dataFactory = new TableDataFactory( "default", transMetaTableModel ); report.setDataFactory( dataFactory ); ReportHeader reportHeader = new ReportHeader(); report.setReportHeader( reportHeader ); ReportFooter reportFooter = new ReportFooter(); report.setReportFooter( reportFooter ); RelationalGroup group = new RelationalGroup(); group.addField( "filename" ); GroupDataBody groupData = new GroupDataBody(); ItemBand itemBand = new ItemBand(); itemBand.setVisible( true ); itemBand.setLayout( BandStyleKeys.LAYOUT_AUTO ); groupData.setItemBand( itemBand ); group.setBody( groupData ); report.setRootGroup( group ); int pagePosition = 0; reportHeader.getStyle().setStyleProperty( TextStyleKeys.BOLD, true ); pagePosition = createTextField( itemBand, "Filename: ", "filename", pagePosition ); if ( options.isIncludingName() ) { pagePosition = createTextField( itemBand, "Name: ", "name", pagePosition ); } if ( options.isIncludingDescription() ) { pagePosition = createTextField( itemBand, "Description: ", "description", pagePosition ); } if ( options.isIncludingExtendedDescription() ) { pagePosition = createTextField( itemBand, "Long description: ", "extended_description", pagePosition ); } if ( options.isIncludingLoggingConfiguration() ) { pagePosition = createTextField( itemBand, "Logging: ", "logging", pagePosition ); } if ( options.isIncludingCreated() ) { pagePosition = createTextField( itemBand, "Creation: ", "creation", pagePosition ); } if ( options.isIncludingModified() ) { pagePosition = createTextField( itemBand, "Modification: ", "modification", pagePosition ); } if ( options.isIncludingLastExecutionResult() ) { pagePosition = createTextField( itemBand, "Last execution result: : ", "last_exec_result", pagePosition ); } if ( options.isIncludingImage() ) { String bshCode = "Object getValue() { " + Const.CR + " return new " + TransJobDrawable.class.getName() + "(dataRow, " + ( options.getOutputType() == OutputType.PDF ? "true" : "false" ) + ");" + Const.CR + "}"; BSHExpression bshExpression = new BSHExpression(); bshExpression.setExpression( bshCode ); bshExpression.setName( "getImage" ); report.addExpression( bshExpression ); ContentElementFactory contentElementFactory = new ContentElementFactory(); contentElementFactory.setName( "image" ); contentElementFactory.setAbsolutePosition( new Point( 0, pagePosition ) ); contentElementFactory.setMinimumWidth( 750f ); contentElementFactory.setMaximumWidth( 750f ); contentElementFactory.setMinimumHeight( 400f ); contentElementFactory.setMaximumHeight( 750f ); contentElementFactory.setScale( true ); contentElementFactory.setDynamicHeight( true ); Element imageElement = contentElementFactory.createElement(); imageElement .setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, bshExpression ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_QUALITY, "9" ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_TYPE, "PNG" ); ItemBand imageBand = new ItemBand(); imageBand.setLayout( BandStyleKeys.LAYOUT_ROW ); imageBand.addElement( imageElement ); itemBand.addElement( imageBand ); } Paper a4Paper = new Paper(); double paperWidth = 8.26; double paperHeight = 11.69; a4Paper.setSize( paperWidth * 72.0, paperHeight * 72.0 ); double leftMargin = 0.78; double rightMargin = 0.78; double topMargin = 0.08; double bottomMargin = 0.78; a4Paper.setImageableArea( leftMargin * 72.0, topMargin * 72.0, ( paperWidth - leftMargin - rightMargin ) * 72.0, ( paperHeight - topMargin - bottomMargin ) * 72.0 ); PageFormat pageFormat = new PageFormat(); pageFormat.setOrientation( PageFormat.LANDSCAPE ); pageFormat.setPaper( a4Paper ); SimplePageDefinition pageDefinition = new SimplePageDefinition( pageFormat ); report.setPageDefinition( pageDefinition ); } KettleReportBuilder( LoggingObjectInterface parentObject, List<ReportSubjectLocation> locations,
    String targetFilename, AutoDocOptionsInterface options ); void createReport(); void render(); }
KettleReportBuilder { public void createReport() throws Exception { report = new MasterReport(); KettleFileTableModel transMetaTableModel = new KettleFileTableModel( parentObject, filenames ); TableDataFactory dataFactory = new TableDataFactory( "default", transMetaTableModel ); report.setDataFactory( dataFactory ); ReportHeader reportHeader = new ReportHeader(); report.setReportHeader( reportHeader ); ReportFooter reportFooter = new ReportFooter(); report.setReportFooter( reportFooter ); RelationalGroup group = new RelationalGroup(); group.addField( "filename" ); GroupDataBody groupData = new GroupDataBody(); ItemBand itemBand = new ItemBand(); itemBand.setVisible( true ); itemBand.setLayout( BandStyleKeys.LAYOUT_AUTO ); groupData.setItemBand( itemBand ); group.setBody( groupData ); report.setRootGroup( group ); int pagePosition = 0; reportHeader.getStyle().setStyleProperty( TextStyleKeys.BOLD, true ); pagePosition = createTextField( itemBand, "Filename: ", "filename", pagePosition ); if ( options.isIncludingName() ) { pagePosition = createTextField( itemBand, "Name: ", "name", pagePosition ); } if ( options.isIncludingDescription() ) { pagePosition = createTextField( itemBand, "Description: ", "description", pagePosition ); } if ( options.isIncludingExtendedDescription() ) { pagePosition = createTextField( itemBand, "Long description: ", "extended_description", pagePosition ); } if ( options.isIncludingLoggingConfiguration() ) { pagePosition = createTextField( itemBand, "Logging: ", "logging", pagePosition ); } if ( options.isIncludingCreated() ) { pagePosition = createTextField( itemBand, "Creation: ", "creation", pagePosition ); } if ( options.isIncludingModified() ) { pagePosition = createTextField( itemBand, "Modification: ", "modification", pagePosition ); } if ( options.isIncludingLastExecutionResult() ) { pagePosition = createTextField( itemBand, "Last execution result: : ", "last_exec_result", pagePosition ); } if ( options.isIncludingImage() ) { String bshCode = "Object getValue() { " + Const.CR + " return new " + TransJobDrawable.class.getName() + "(dataRow, " + ( options.getOutputType() == OutputType.PDF ? "true" : "false" ) + ");" + Const.CR + "}"; BSHExpression bshExpression = new BSHExpression(); bshExpression.setExpression( bshCode ); bshExpression.setName( "getImage" ); report.addExpression( bshExpression ); ContentElementFactory contentElementFactory = new ContentElementFactory(); contentElementFactory.setName( "image" ); contentElementFactory.setAbsolutePosition( new Point( 0, pagePosition ) ); contentElementFactory.setMinimumWidth( 750f ); contentElementFactory.setMaximumWidth( 750f ); contentElementFactory.setMinimumHeight( 400f ); contentElementFactory.setMaximumHeight( 750f ); contentElementFactory.setScale( true ); contentElementFactory.setDynamicHeight( true ); Element imageElement = contentElementFactory.createElement(); imageElement .setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, bshExpression ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_QUALITY, "9" ); imageElement.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.IMAGE_ENCODING_TYPE, "PNG" ); ItemBand imageBand = new ItemBand(); imageBand.setLayout( BandStyleKeys.LAYOUT_ROW ); imageBand.addElement( imageElement ); itemBand.addElement( imageBand ); } Paper a4Paper = new Paper(); double paperWidth = 8.26; double paperHeight = 11.69; a4Paper.setSize( paperWidth * 72.0, paperHeight * 72.0 ); double leftMargin = 0.78; double rightMargin = 0.78; double topMargin = 0.08; double bottomMargin = 0.78; a4Paper.setImageableArea( leftMargin * 72.0, topMargin * 72.0, ( paperWidth - leftMargin - rightMargin ) * 72.0, ( paperHeight - topMargin - bottomMargin ) * 72.0 ); PageFormat pageFormat = new PageFormat(); pageFormat.setOrientation( PageFormat.LANDSCAPE ); pageFormat.setPaper( a4Paper ); SimplePageDefinition pageDefinition = new SimplePageDefinition( pageFormat ); report.setPageDefinition( pageDefinition ); } KettleReportBuilder( LoggingObjectInterface parentObject, List<ReportSubjectLocation> locations,
    String targetFilename, AutoDocOptionsInterface options ); void createReport(); void render();  }