Using Eclipse Birt Extension points: Aggregation

Source: Internet
Author: User

Introduction: Learn about the Birt extension point model and create a basic aggregation extension in Birt using the new v2.3+ extension model.

This article describes the business intelligence and reporting tools (Business Intelligence and Reporting tools,birt) extension point model and actually creates an aggregation extension in BIRT v2.3.x and v2.5.x. In earlier BIRT versions, the way to create an aggregation extension is to extend the org.eclipse.birt.data.aggregation extension point, which adds a small function to a global object named Total, which you can use in any expression in the entire report. It works like a script function extension point.

However, from BIRT V2.2 to V2.3, the aggregation extension has changed. The new approach is more complex, but you can get a nice aggregation in the Aggregation Widgets drop-down list and provide a nice text box for parameters and expressions. When you create this extension, you can access the results in a column-bound form in your table.

Overall, the new aggregation extension points contain an object that is an extension of the Iaggregationfactory interface. You can overload methods in this interface to do 3 things:

Initialize your factory (in constructors)

Provides a set of aggregations provided by the factory (provided in a list, with actual instances of aggregated objects)

Returns a single instance of an aggregate object

Each instance of the aggregation needs to implement the Iaggrfunction interface. Many of the more meaningful methods, such as GetName, Getdatatype, and getparmaeterdefn, need to be implemented, as well as other less obvious methods. For example, the getnumberofpasses () and GetType () methods are related. The GetType () method is used to develop the way and type of execution for this aggregator. There are two types of aggregation: Summary_aggr represents the aggregation (such as the table header or footer) for a summary, RUNNING_AGGR for each row in the table or the footer of a calculation aggregation. The Getnumberofpasses () method displays the number of pass required to obtain the result. All rating-based aggregators, such as Topnpercent, percentsum, and percentile, return a value of 2 and the remainder of the aggregator returns a value of 1.

The actual implementation of the Iaggrfunction interface must return an extension of the accumulator class in its Newaccumulator () method. Accumulator is responsible for performing the actual calculations. There are some default methods that require overloading, most importantly onrow (), and each row in the table needs to call the method. Using this method, you can parse the parameters of a function and perform calculations. For SUM, you can add to a stored number, and for Ave, you can either save to a list for storage or add to a cumulative total and track the number of calls. No matter how you perform the calculation, the actual calculation needs to be done here. GetValue () Gets the final value or current value of your calculation. Therefore, for the SUM operation, you will return the total/count operation. In a running aggregator, only the value being calculated is returned.

The example in the next section shows how to create a simple Word Count aggregator. This aggregate gets all the sentences in a column and calculates the number of words, returning an integer value that contains the number of words in the column. There is little demand for this aggregation, so there is no such aggregation. For the exercises in this article, it is recommended that you use the Eclipse BIRT all-in-one distribution.

Create a new aggregation plug-in

To create a new aggregation plug-in:

Click File > New > Other to create a new plug-in project. Expand the Plug-In Development folder, and then click Plug-In Project.

In the New Plug-in Project window (shown in Figure 1), provide a unique name for the project in the ID field and use the appropriate information to complete the Version, Name, and Provider fields.

Figure 1. Project Properties

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.