/** * Returns the "no-data" band, which is displayed if there is no data available. * * @return The no-data band. */ public NoDataBand getNoDataBand() { final Group group = getInnerMostGroup(); final GroupBody body = group.getBody(); if ( body instanceof GroupDataBody ) { final GroupDataBody dataBody = (GroupDataBody) body; return dataBody.getNoDataBand(); } return null; }
/** * Returns the report's no-data band. * * @return the no-data band (never <code>null</code>). */ public NoDataBand getNoDataBand() { Group innerMostRelationalGroup = getInnerMostRelationalGroup(); if ( innerMostRelationalGroup instanceof CrosstabGroup ) { CrosstabGroup cg = (CrosstabGroup) innerMostRelationalGroup; return cg.getNoDataBand(); } GroupBody body = innerMostRelationalGroup.getBody(); if ( body instanceof GroupDataBody ) { GroupDataBody gd = (GroupDataBody) body; return gd.getNoDataBand(); } return null; }
@Test public void testSetNoDataBand() { NoDataBand noDataBand = mock( NoDataBand.class ); body.setNoDataBand( noDataBand ); assertThat( body.getNoDataBand(), is( equalTo( noDataBand ) ) ); assertThat( (GroupDataBody) body.getNoDataBand().getParentSection(), is( equalTo( body ) ) ); NoDataBand band = new NoDataBand(); band.setParent( body ); body.setNoDataBand( band ); assertThat( body.getNoDataBand(), is( equalTo( noDataBand ) ) ); }
@Test public void testCreation() { assertThat( body.getElementType(), is( instanceOf( GroupDataBodyType.class ) ) ); assertThat( body.getNoDataBand(), is( notNullValue() ) ); assertThat( (GroupDataBody) body.getNoDataBand().getParentSection(), is( equalTo( body ) ) ); assertThat( body.getItemBand(), is( notNullValue() ) ); assertThat( (GroupDataBody) body.getItemBand().getParentSection(), is( equalTo( body ) ) ); assertThat( body.getDetailsHeader(), is( notNullValue() ) ); assertThat( (GroupDataBody) body.getDetailsHeader().getParentSection(), is( equalTo( body ) ) ); assertThat( body.getDetailsFooter(), is( notNullValue() ) ); assertThat( (GroupDataBody) body.getDetailsFooter().getParentSection(), is( equalTo( body ) ) ); }
@Test public void testSetElementAt() { ItemBand itemBand = mock( ItemBand.class ); NoDataBand band = mock( NoDataBand.class ); DetailsHeader header = mock( DetailsHeader.class ); DetailsFooter footer = mock( DetailsFooter.class ); body.setElementAt( 0, header ); body.setElementAt( 1, itemBand ); body.setElementAt( 2, band ); body.setElementAt( 3, footer ); assertThat( body.getDetailsHeader(), is( equalTo( header ) ) ); assertThat( body.getItemBand(), is( equalTo( itemBand ) ) ); assertThat( body.getNoDataBand(), is( equalTo( band ) ) ); assertThat( body.getDetailsFooter(), is( equalTo( footer ) ) ); }
@Test public void testRemoveElement() { ItemBand itemBand = mock( ItemBand.class ); NoDataBand band = mock( NoDataBand.class ); DetailsHeader header = mock( DetailsHeader.class ); DetailsFooter footer = mock( DetailsFooter.class ); body.setItemBand( itemBand ); body.setNoDataBand( band ); body.setDetailsHeader( header ); body.setDetailsFooter( footer ); body.removeElement( itemBand ); assertThat( itemBand.getParentSection(), is( nullValue() ) ); assertThat( body.getItemBand(), is( not( equalTo( itemBand ) ) ) ); assertThat( (GroupDataBody) body.getItemBand().getParentSection(), is( equalTo( body ) ) ); body.removeElement( band ); assertThat( band.getParentSection(), is( nullValue() ) ); assertThat( body.getNoDataBand(), is( not( equalTo( band ) ) ) ); assertThat( (GroupDataBody) body.getNoDataBand().getParentSection(), is( equalTo( body ) ) ); body.removeElement( header ); assertThat( header.getParentSection(), is( nullValue() ) ); assertThat( body.getDetailsHeader(), is( not( equalTo( header ) ) ) ); assertThat( (GroupDataBody) body.getDetailsHeader().getParentSection(), is( equalTo( body ) ) ); body.removeElement( footer ); assertThat( footer.getParentSection(), is( nullValue() ) ); assertThat( body.getDetailsFooter(), is( not( equalTo( footer ) ) ) ); assertThat( (GroupDataBody) body.getDetailsFooter().getParentSection(), is( equalTo( body ) ) ); }
public void installIntoReport( final AbstractReportDefinition report ) throws ParseException { final GroupDataBody originalGroupDataBody = (GroupDataBody) report.getChildElementByType( GroupDataBodyType.INSTANCE ); if ( originalGroupDataBody == null ) { throw new ParseException( "The report is not a relational report, cannot install relational detail sections here" ); } final ItemBand ib = originalGroupDataBody.getItemBand(); final NoDataBand nd = originalGroupDataBody.getNoDataBand(); final DetailsHeader detailsHeader = originalGroupDataBody.getDetailsHeader(); final DetailsFooter detailsFooter = originalGroupDataBody.getDetailsFooter(); final Group newRootGroup = constructRootGroup(); if ( report.getRootGroup() == newRootGroup ) { return; } report.setRootGroup( newRootGroup ); final GroupDataBody groupDataBody = (GroupDataBody) newRootGroup.getChildElementByType( GroupDataBodyType.INSTANCE ); if ( groupDataBody == null ) { return; } groupDataBody.setDetailsFooter( detailsFooter ); groupDataBody.setDetailsHeader( detailsHeader ); groupDataBody.setItemBand( ib ); groupDataBody.setNoDataBand( nd ); } }
/** * Writes a report description element to a character stream writer. * * @throws IOException * if there is an I/O problem. * @throws ReportWriterException * if there is a problem writing the report. */ public void write() throws IOException, ReportWriterException { final XmlWriter writer = getXmlWriter(); writer.writeTag( ExtParserModule.NAMESPACE, ReportDescriptionWriter.REPORT_DESCRIPTION_TAG, XmlWriterSupport.OPEN ); writeRootBand( ReportDescriptionWriter.REPORT_HEADER_TAG, getReport().getReportHeader() ); writeRootBand( ReportDescriptionWriter.REPORT_FOOTER_TAG, getReport().getReportFooter() ); writeRootBand( ReportDescriptionWriter.PAGE_HEADER_TAG, getReport().getPageHeader() ); writeRootBand( ReportDescriptionWriter.PAGE_FOOTER_TAG, getReport().getPageFooter() ); writeRootBand( ReportDescriptionWriter.WATERMARK_TAG, getReport().getWatermark() ); writeGroups(); final GroupDataBody dataBody = (GroupDataBody) getReport().getChildElementByType( GroupDataBodyType.INSTANCE ); if ( dataBody != null ) { writeRootBand( ReportDescriptionWriter.ITEMBAND_TAG, dataBody.getItemBand() ); writeRootBand( ReportDescriptionWriter.NO_DATA_BAND_TAG, dataBody.getNoDataBand() ); } writer.writeCloseTag(); }