ComputedColumn groupCol = StructureFactory.createComputedColumn( ); groupCol.setName( "data item1" ); groupCol.setExpression( "Total.sum(row[\"CUSTOMERNUMBER\"] , null , null )" ); groupCol.setAggregateOn( "NewGroup" ); groupCol.setDataType( DesignChoiceConstants.PARAM_TYPE_STRING );    tableHandle.addColumnBinding( groupCol, false );  ComputedColumn tableCol = StructureFactory.createComputedColumn( ); tableCol.setName( "data item2" ); tableCol.setExpression( "Total.sum(row[\"CUSTOMERNUMBER\"] , null , null )" ); tableCol.setAggregateOn( "All" ); tableCol.setDataType( DesignChoiceConstants.PARAM_TYPE_STRING );  tableHandle.addColumnBinding( tableCol, false );  List boundList = tableHandle.getListProperty( IReportItemModel.BOUND_DATA_COLUMNS_PROP ); assertEquals( 2, boundList.size( ) ); assertEquals( "data item1" , ((ComputedColumn)boundList.get( 0 )).getName( )); assertEquals( "NewGroup" , ((ComputedColumn)boundList.get( 0 )).getAggregateOn( )); assertEquals( "data item2" , ((ComputedColumn)boundList.get( 1 )).getName( )); assertEquals( "All" , ((ComputedColumn)boundList.get( 1 )).getAggregateOn( ));
	public void testColumnBinding( ) throws SemanticException	{		createDesign( );		TableHandle tableHandle = designHandle.getElementFactory( )				.newTableItem( "new table" ); //$NON-NLS-1$		designHandle.getBody( ).add( tableHandle );		tableHandle = (TableHandle) designHandle.findElement( "new table" ); //$NON-NLS-1$		ComputedColumn col = StructureFactory.createComputedColumn( );		col.setName( null );		col.setExpression( "dataSetRow[\"CUSTOMERNUMBER\"]" ); //$NON-NLS-1$		// add null on table.		assertNull( tableHandle.addColumnBinding( null, true ) );		// add empty name of computed column on table.		try		{			tableHandle.addColumnBinding( col, true );			fail( );		}		catch ( SemanticException e )		{			assertEquals(					PropertyValueException.DESIGN_EXCEPTION_VALUE_REQUIRED, e							.getErrorCode( ) );		}		// add computed column on table.		col.setName( "CUSTOMERNUMBER" );//$NON-NLS-1$		tableHandle.addColumnBinding( col, true );		// add duplicate name on table row data		ComputedColumn col2 = StructureFactory.createComputedColumn( );		col2.setName( "CUSTOMERNUMBER" ); //$NON-NLS-1$		col2.setExpression( "dataSetRow[\"CUSTOMERNUMBER\"]" ); //$NON-NLS-1$		try		{			tableHandle.addColumnBinding( col2, true );			fail( );		}		catch ( SemanticException e )		{			assertEquals( PropertyValueException.DESIGN_EXCEPTION_VALUE_EXISTS,					e.getErrorCode( ) );		}		col = StructureFactory.createComputedColumn( );		col.setName( "CUSTOMERNUMBER" ); //$NON-NLS-1$		col.setExpression( "dataSetRow[\"CUSTOMERNUMBER_TEST\"]" ); //$NON-NLS-1$		try		{			tableHandle.addColumnBinding( col, true );			fail( );		}		catch ( SemanticException e )		{			assertEquals( PropertyValueException.DESIGN_EXCEPTION_VALUE_EXISTS,					e.getErrorCode( ) );		}		col = StructureFactory.createComputedColumn( );		col.setName( "CUSTOMERNUMBER_TEST" ); //$NON-NLS-1$		col.setExpression( "dataSetRow[\"CUSTOMERNUMBER\"]" ); //$NON-NLS-1$		tableHandle.addColumnBinding( col, true );		col = (ComputedColumn) ( (ComputedColumnHandle) tableHandle				.columnBindingsIterator( ).next( ) ).getStructure( );		// replace		PropertyHandle propertyHandle = tableHandle				.getPropertyHandle( IReportItemModel.BOUND_DATA_COLUMNS_PROP );		ComputedColumn newCol = StructureFactory.createComputedColumn( );		newCol.setName( null );		newCol.setExpression( "dataSetRow[\"CUSTOMER\"]" ); //$NON-NLS-1$		// use empty name of computed column to replace old one.		try		{			propertyHandle.replaceItem( col, newCol );			fail( );		}		catch ( SemanticException e )		{			assertTrue( e instanceof PropertyValueException );		}		// replace duplicate name on table row data		newCol.setName( "CUSTOMERNUMBER" );//$NON-NLS-1$		try		{			propertyHandle.replaceItem( col, newCol );			fail( );		}		catch ( SemanticException e )		{			assertEquals( PropertyValueException.DESIGN_EXCEPTION_VALUE_EXISTS,					e.getErrorCode( ) );		}		// add computed column on table.		newCol.setName( "Number" );//$NON-NLS-1$		propertyHandle.replaceItem( col, newCol );	}