Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#setQueryLimit()

The following examples show how to use org.pentaho.reporting.engine.classic.core.MasterReport#setQueryLimit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Prd4295IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testBold() throws Exception {
  final MasterReport masterReport = DebugReportRunner.parseGoldenSampleReport( "Prd-3857-002.prpt" );
  masterReport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );
  masterReport.setQueryLimit( 1 );
  final CrosstabCellBody crosstabCellBody = masterReport.getCrosstabCellBody();
  final CrosstabCell element = crosstabCellBody.findElement( null, null );
  element.setName( "Cell-Sample" );
  element.getStyle().setStyleProperty( TextStyleKeys.BOLD, true );
  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( masterReport, 0 );
  final RenderNode[] elementsByName = MatchFactory.findElementsByName( logicalPageBox, "Cell-Sample" );
  assertTrue( elementsByName.length > 0 );
  final RenderNode renderNode = elementsByName[0];
  assertEquals( Boolean.TRUE, renderNode.getNodeLayoutProperties().getStyleSheet().getStyleProperty(
      TextStyleKeys.BOLD ) );

  // ModelPrinter.INSTANCE.print(renderNode);
  final RenderNode[] texts = MatchFactory.findElementsByNodeType( renderNode, LayoutNodeTypes.TYPE_NODE_TEXT );
  assertEquals( Boolean.TRUE, texts[0].getStyleSheet().getStyleProperty( TextStyleKeys.BOLD ) );
  assertEquals( 1945000, texts[0].getMinimumChunkWidth() );

  DebugReportRunner.showDialog( masterReport );
}
 
Example 2
Source File: Prd4295IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testBoldComplex() throws Exception {
  final MasterReport masterReport = DebugReportRunner.parseGoldenSampleReport( "Prd-3857-002.prpt" );
  masterReport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "true" );
  masterReport.getStyle().setStyleProperty( TextStyleKeys.WORDBREAK, true );
  masterReport.setQueryLimit( 1 );
  final CrosstabCellBody crosstabCellBody = masterReport.getCrosstabCellBody();
  final CrosstabCell element = crosstabCellBody.findElement( null, null );
  element.setName( "Cell-Sample" );
  element.getStyle().setStyleProperty( TextStyleKeys.BOLD, true );
  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( masterReport, 0 );
  final RenderNode[] elementsByName = MatchFactory.findElementsByName( logicalPageBox, "Cell-Sample" );
  assertTrue( elementsByName.length > 0 );
  final RenderNode renderNode = elementsByName[0];
  assertEquals( Boolean.TRUE, renderNode.getNodeLayoutProperties().getStyleSheet().getStyleProperty(
      TextStyleKeys.BOLD ) );

  // ModelPrinter.INSTANCE.print(renderNode);
  final RenderNode[] texts = MatchFactory.findElementsByNodeType( renderNode, LayoutNodeTypes.TYPE_NODE_COMPLEX_TEXT );
  assertEquals( Boolean.TRUE, texts[0].getStyleSheet().getStyleProperty( TextStyleKeys.BOLD ) );
  assertTrue( texts[0].getWidth() > 0 );
  // complex-text nodes no longer have a min-chunk width after line-breaking
  assertEquals( texts[0].getWidth(), extractOriginalPool( texts[0] ).getMinimumChunkWidth() );

  DebugReportRunner.showDialog( masterReport );
}
 
Example 3
Source File: Prd4071IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testRealWorldReportEmptyPage2() throws Exception {
  if ( DebugReportRunner.isSkipLongRunTest() ) {
    return;
  }
  final MasterReport report = DebugReportRunner.parseGoldenSampleReport( "Prd-2087-small.prpt" );
  report.getItemBand().getStyle().setStyleProperty( ElementStyleKeys.AVOID_PAGEBREAK_INSIDE, false );
  report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );
  report.setQueryLimit( 100 );

  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 1 );
  // ModelPrinter.INSTANCE.print(logicalPageBox);
  assertEquals( 71700000, logicalPageBox.getPageEnd() );
  final RenderNode[] elementsByElementType =
      MatchFactory.findElementsByElementType( logicalPageBox, ItemBandType.INSTANCE );
  assertEquals( 22, elementsByElementType.length );
  // The second page is not empty even though a break-marker box exists at the beginning.
  // This break-marker is ignored as its validity range is wrong for the page it is on.
  // If it were NOT ingnored, there would be no itembands on that page.
}
 
Example 4
Source File: Prd4071IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testRealWorldReport() throws Exception {
  if ( DebugReportRunner.isSkipLongRunTest() ) {
    return;
  }
  final MasterReport report = DebugReportRunner.parseGoldenSampleReport( "Prd-2087-small.prpt" );
  report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );
  report.setQueryLimit( 100 );

  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 );
  // ModelPrinter.INSTANCE.print(logicalPageBox);
  assertEquals( 71700000, logicalPageBox.getPageEnd() );
  final RenderNode[] elementsByElementType =
      MatchFactory.findElementsByElementType( logicalPageBox, ItemBandType.INSTANCE );
  assertEquals( 21, elementsByElementType.length ); // 21
  final RenderNode lastChild = elementsByElementType[20];
  // important part is that the y2 is less than the page-end
  assertEquals( 69420900, lastChild.getY() + lastChild.getHeight() );

}
 
Example 5
Source File: ProcessStateTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testInitializeForSubreport() throws Exception {
  MasterReport masterReport = new MasterReport();
  ProcessingContext processingContext = new DefaultProcessingContext();
  OutputFunction outputFunction = new DefaultOutputFunction();
  SubReport subReportSpy = spy( new SubReport() );
  InstanceID instanceID = new InstanceID();
  InlineSubreportMarker[] inlineSubreportMarkers = new InlineSubreportMarker[1];
  inlineSubreportMarkers[0] = new InlineSubreportMarker( subReportSpy, instanceID, SubReportProcessType.INLINE );
  ProcessState parentProcessStateSpy = spy( new ProcessState() );
  ProcessState processState = new ProcessState();

  masterReport.getRelationalGroup( 0 ).getHeader().addSubReport( subReportSpy );
  masterReport.setQueryLimit( 3 );
  subReportSpy.reconnectParent( masterReport );

  when( subReportSpy.isQueryLimitInherited() ).thenReturn( false ).thenReturn( true );
  when( parentProcessStateSpy.getReport() ).thenReturn( masterReport );

  parentProcessStateSpy.initializeForMasterReport( masterReport, processingContext, outputFunction );

  processState.initializeForSubreport( inlineSubreportMarkers, 0, parentProcessStateSpy );
  assertEquals( Integer.valueOf( -1 ), processState.getQueryLimit() );

  processState.initializeForSubreport( inlineSubreportMarkers, 0, parentProcessStateSpy );
  assertEquals( Integer.valueOf( 3 ), processState.getQueryLimit() );
}
 
Example 6
Source File: AbstractReportProcessorTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testIsQueryLimitNotReachedForUnlimitedQueryLimit() throws Exception {
  final MasterReport report = new MasterReport();
  final DefaultTableModel model = new DefaultTableModel( 500, 10 );
  report.setDataFactory( new TableDataFactory( "default", model ) );
  report.setQueryLimit( -1 );
  final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report );
  reportProcessor.prepareReportProcessing();
  assertEquals( reportProcessor.isQueryLimitReached(), false );
}
 
Example 7
Source File: AbstractReportProcessorTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testIsQueryLimitNotReachedForZeroQueryLimit() throws Exception {
  final MasterReport report = new MasterReport();
  final DefaultTableModel model = new DefaultTableModel( 500, 10 );
  report.setDataFactory( new TableDataFactory( "default", model ) );
  report.setQueryLimit( 0 );
  final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report );
  reportProcessor.prepareReportProcessing();
  assertEquals( reportProcessor.isQueryLimitReached(), false );
}
 
Example 8
Source File: AbstractReportProcessorTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testIsQueryLimitReachedForNumberOfRowsGreaterQueryLimit() throws Exception {
  final MasterReport report = new MasterReport();
  final DefaultTableModel model = new DefaultTableModel( 501, 10 );
  report.setDataFactory( new TableDataFactory( "default", model ) );
  report.setQueryLimit( 500 );
  final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report );
  reportProcessor.prepareReportProcessing();
  assertEquals( reportProcessor.isQueryLimitReached(), true );
}
 
Example 9
Source File: AbstractReportProcessorTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testIsQueryLimitNotReachedForNumberOfRowsEqualQueryLimit() throws Exception {
  final MasterReport report = new MasterReport();
  final DefaultTableModel model = new DefaultTableModel( 500, 10 );
  report.setDataFactory( new TableDataFactory( "default", model ) );
  report.setQueryLimit( 500 );
  final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report );
  reportProcessor.prepareReportProcessing();
  assertEquals( reportProcessor.isQueryLimitReached(), false );
}
 
Example 10
Source File: AbstractReportProcessorTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testIsQueryLimitNotReachedForNumberOfRowsLessQueryLimit() throws Exception {
  final MasterReport report = new MasterReport();
  final DefaultTableModel model = new DefaultTableModel( 499, 10 );
  report.setDataFactory( new TableDataFactory( "default", model ) );
  report.setQueryLimit( 500 );
  final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report );
  reportProcessor.prepareReportProcessing();
  assertEquals( reportProcessor.isQueryLimitReached(), false );
}
 
Example 11
Source File: AbstractReportProcessorTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testIsLimitReachedForNumberOfRowsGreaterQueryLimit() throws Exception {
  //When data source enforce limit itself
  // report with 148 rows
  final URL url = getClass().getResource( "report1.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setQueryLimit( 147 );
  final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report );
  reportProcessor.prepareReportProcessing();
  assertEquals( reportProcessor.isQueryLimitReached(), true );
}
 
Example 12
Source File: AbstractReportProcessorTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testIsLimitNotReachedForNumberOfRowsEqualQueryLimit() throws Exception {
  //When data source enforce limit itself
  // report with 148 rows
  final URL url = getClass().getResource( "report1.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setQueryLimit( 148 );
  final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report );
  reportProcessor.prepareReportProcessing();
  assertEquals( reportProcessor.isQueryLimitReached(), false );
}
 
Example 13
Source File: AbstractReportProcessorTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testIsLimitNotReachedForNumberOfRowsLessQueryLimit() throws Exception {
  //When data source enforce limit itself
  // report with 148 rows
  final URL url = getClass().getResource( "report1.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setQueryLimit( 149 );
  final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report );
  reportProcessor.prepareReportProcessing();
  assertEquals( reportProcessor.isQueryLimitReached(), false );
}