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 );
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 ); } }
public void setElementAt( final int position, final Element element ) { switch ( position ) { case 0: setDetailsHeader( (DetailsHeader) element ); break; case 1: setItemBand( (ItemBand) element ); break; case 2: setNoDataBand( (NoDataBand) element ); break; case 3: setDetailsFooter( (DetailsFooter) element ); break; default: throw new IndexOutOfBoundsException(); } }
@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 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 ) ) ); }
final Band details = AutoGeneratorUtility.findGeneratedContent( groupDataBody.getItemBand() ); final Band header = AutoGeneratorUtility.findGeneratedContent( groupDataBody.getDetailsHeader() ); final Band footer = AutoGeneratorUtility.findGeneratedContent( groupDataBody.getDetailsFooter() );
public ReportElement create() { return new GroupDataBody(); } }
@Test public void testSetItemBand() { ItemBand itemBand = mock( ItemBand.class ); body.setItemBand( itemBand ); assertThat( body.getItemBand(), is( equalTo( itemBand ) ) ); assertThat( (GroupDataBody) body.getItemBand().getParentSection(), is( equalTo( body ) ) ); ItemBand band = new ItemBand(); band.setParent( body ); body.setItemBand( band ); assertThat( body.getItemBand(), is( equalTo( itemBand ) ) ); }
@Test public void testSetDetailsHeader() { DetailsHeader detailsHeader = mock( DetailsHeader.class ); body.setDetailsHeader( detailsHeader ); assertThat( body.getDetailsHeader(), is( equalTo( detailsHeader ) ) ); assertThat( (GroupDataBody) body.getDetailsHeader().getParentSection(), is( equalTo( body ) ) ); DetailsHeader header = new DetailsHeader(); header.setParent( body ); body.setDetailsHeader( header ); assertThat( body.getDetailsHeader(), is( equalTo( detailsHeader ) ) ); }
@Test public void testSetDetailsFooter() { DetailsFooter detailsFooter = mock( DetailsFooter.class ); body.setDetailsFooter( detailsFooter ); assertThat( body.getDetailsFooter(), is( equalTo( detailsFooter ) ) ); assertThat( (GroupDataBody) body.getDetailsFooter().getParentSection(), is( equalTo( body ) ) ); DetailsFooter footer = new DetailsFooter(); footer.setParent( body ); body.setDetailsFooter( footer ); assertThat( body.getDetailsFooter(), is( equalTo( detailsFooter ) ) ); }
@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 ) ) ); }
RelationalGroup group = Mockito.spy( new RelationalGroup() ); group.setName( "a" ); GroupDataBody groupBody = new GroupDataBody(); ItemBand ib = new ItemBand(); Mockito.doReturn( schema ).when( fc ).getDataSchema(); element.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_TYPE, o1 ); ib.addElement( element ); groupBody.setElementAt(1, ib ); group.setElementAt(1, groupBody ); section.setElementAt( 2, group );
/** * 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(); }
/** * Returns the report's item band. * * @return the item band (never <code>null</code>). */ public ItemBand getItemBand() { final Group group = getInnerMostGroup(); final GroupBody body = group.getBody(); if ( body instanceof GroupDataBody ) { final GroupDataBody dataBody = (GroupDataBody) body; return dataBody.getItemBand(); } return null; }
@Test( expected = NullPointerException.class ) public void testSetItemBandException() { body.setItemBand( null ); }
/** * 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 details header band. * * @return The details header band. */ public DetailsHeader getDetailsHeader() { final Group group = getInnerMostGroup(); final GroupBody body = group.getBody(); if ( body instanceof GroupDataBody ) { final GroupDataBody dataBody = (GroupDataBody) body; return dataBody.getDetailsHeader(); } return null; }
/** * Returns the details header band. * * @return The details header band. */ public DetailsFooter getDetailsFooter() { final Group group = getInnerMostGroup(); final GroupBody body = group.getBody(); if ( body instanceof GroupDataBody ) { final GroupDataBody dataBody = (GroupDataBody) body; return dataBody.getDetailsFooter(); } return null; }
@Test( expected = NullPointerException.class ) public void testSetNoDataBandException() { body.setNoDataBand( null ); }
@Test( expected = NullPointerException.class ) public void testSetDetailsHeaderException() { body.setDetailsHeader( null ); }