Bug 131186 Enhance birt.data.aggregation extension point to support multipass
The current org.eclipse.birt.data.aggregation extension point ( and associated org.eclipse.birt.data.engine.api.aggregation classes) can only support single-pass aggregates. We need to extend this framework to support custom multi-pass aggregates. One example: a percentage-to-total aggregate ( x/SUM(x) ) will require two passes over the series. A prelimary design of the new extension point: Introduce a new Aggregation abstract class in birt.data.engine.api: public abstract class Aggregation implements IAggregation { /** Returns the number of passes over the data series that the accumulator of this aggregate requires. For SUMMARY aggregates, the accumulator returns a value after all passes are complete. For RUNNING aggregates, the accumulator returns data in the last pass. */ public int getNumberOfPasses() { return 1; } } The Accumulator class can remain as is. However the comment to indicate that for multipass aggregates, start() and finish() will be called at the beginning and end of each pass. The aggregation extension point's aggregateClass element should indicate that the class needs to subclass Aggregation. Also, this element's kind should be changed to "java" and its "Based On" changed to "org.eclipse.birt.data.engine.api.aggregation.Aggregation".
data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/aggregation/Accumulator.java
*/
    public void	finish() throws DataException
    {}
    
    /**
     * This method is called on every data row to supply arguments to the aggregation. The args[] argument
     * provides an array of argument values that this aggregation expected. The number of arguments and
     * their types are defined by the Aggregation.getParameterDefn() method. <p>
     * 
     * Each argument can have type java.lang.Integer, java.lang.Double, java.lang.Boolean, java.lang.String, java.util.Date, 
     * java.math.BigDecimal or java.sql.Blob. It can also be null. <p>
     * If an argument is not of an expected type (e.g., a String is passed in to a SUM 
     * accumulator), the method should make reasonable efforts to convert the argument to its expected
     * type. If no reasonable conversion can be made, this method may throw an RuntimeException or its
     * subclass to indicate such an error.<p>
     * @param rowValue 	Argument to the aggregate function calculated based on current data row. 
     * @throws DataException data type conversion will throw <code>DteException</code>
     */
    abstract public void onRow( Object[] args ) throws DataException;
    
    /**
     * This method is called after the finish() method to obtain the aggregate value. The return value
     * can be of class   java.lang.Integer, java.lang.Double, java.lang.Boolean, java.lang.String, java.util.Date, 
     * java.math.BigDecimal or java.sql.Blob. Or it can be null to indicate a null aggregate value.
     * @return Aggregate value calculated over the processed rows  
     */
    abstract public Object getValue() throws DataException;
    
}