/** * 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 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 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 ); } }
final Band footer = AutoGeneratorUtility.findGeneratedContent( groupDataBody.getDetailsFooter() );