Home » Archived » BIRT » Custom aggregation through the plugin via eclipse data extension point(Can not get the custom aggregatin working)
Custom aggregation through the plugin via eclipse data extension point [message #898982] |
Mon, 30 July 2012 01:18 |
andrew smith Messages: 43 Registered: February 2012 |
Member |
|
|
Hello,
I am trying to create a custom aggregation that could be available within BIRT as a plugin via the eclipse's data extension point concept. I am having some problems getting it recognized by BIRT. I encounter an error when I open the aggregation tool. I followed the BIRT Aggregate Extension Example at
(eclipse.org/birt/phoenix/examples/extending/aggregate/) and created even a simpler plugin, but it the BIRT throws a JavaNullException error. Sounds like I may not be declaring a variable. But the example below is so simple that there is nothing to declare pretty much.
I am listing the code below. There are 3 classes. The Activator was built by Eclipse automatically, so I did not touch it. The myPluginAccumulator should essentially return number 2 ie there is no aggregation on the input data whatsoever.
I am listing the error below the classes.
Do you guys know what I am doing wrong?
Thanks!!!
//===========================================================
public class myPluginAccumulator extends Accumulator {
@SuppressWarnings("unused")
@Override
public void onRow(Object[] args) throws DataException {
int number = 0;
}
@Override
public Object getValue() throws DataException {
return new Double(2);
}
}
//===========================================================
@SuppressWarnings("deprecation")
public class myPlugin extends Aggregation {
@Override
public String getName() {
return "Cumulative_Product";
}
@Override
public int getType() {
return SUMMARY_AGGR;
}
@Override
public boolean[] getParameterDefn() {
return new boolean[]{true};
}
@Override
public Accumulator newAccumulator() {
// TODO Auto-generated method stub
return new myPluginAccumulator();
}
}
//===========================================================
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "ExamplePlugIn"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
//===========================================================
Jul 29, 2012 8:12:13 PM org.eclipse.birt.data.engine.api.aggregation.AggrFunctionWrapper populateDep
recatedAggregations
WARNING: Exception in aggregation extension loading.
java.lang.NullPointerException
at org.eclipse.birt.data.engine.api.aggregation.AggregationManager.populateExtendedAggrInfo(
AggregationManager.java:255)
at org.eclipse.birt.data.engine.api.aggregation.AggregationManager.populateDeprecatedAggrega
tions(AggregationManager.java:216)
at org.eclipse.birt.data.engine.api.aggregation.AggregationManager.populateAggregations(Aggr
egationManager.java:155)
at org.eclipse.birt.data.engine.api.aggregation.AggregationManager.<init>(AggregationManager
.java:123)
at org.eclipse.birt.data.engine.api.aggregation.AggregationManager.getInstance(AggregationMa
nager.java:110)
at org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.getAggregationManager(Da
taRequestSessionImpl.java:1921)
at org.eclipse.birt.report.designer.data.ui.util.DataUtil.getAggregationManager(DataUtil.jav
a:69)
at org.eclipse.birt.report.designer.internal.ui.dialogs.BindingDialogHelper.getFunctions(Bin
dingDialogHelper.java:613)
at org.eclipse.birt.report.designer.internal.ui.dialogs.BindingDialogHelper.getFunctionDispl
ayNames(BindingDialogHelper.java:565)
at org.eclipse.birt.report.designer.internal.ui.dialogs.BindingDialogHelper.initFunction(Bin
dingDialogHelper.java:517)
at org.eclipse.birt.report.designer.internal.ui.dialogs.BindingDialogHelper.initDialog(Bindi
ngDialogHelper.java:356)
at org.eclipse.birt.report.designer.internal.ui.dialogs.DataColumnBindingDialog.initDialog(D
ataColumnBindingDialog.java:404)
at org.eclipse.birt.report.designer.ui.dialogs.BaseDialog.open(BaseDialog.java:103)
at org.eclipse.birt.report.designer.internal.ui.AggDataDropAdapter.performDrop(AggDataDropAd
apter.java:127)
at org.eclipse.birt.report.designer.internal.ui.dnd.DNDService.performDrop(DNDService.java:1
69)
at org.eclipse.birt.report.designer.internal.ui.palette.ReportTemplateTransferDropTargetList
ener.handleDrop(ReportTemplateTransferDropTargetListener.java:126)
at org.eclipse.gef.dnd.AbstractTransferDropTargetListener.drop(AbstractTransferDropTargetLis
tener.java:183)
at org.eclipse.jface.util.DelegatingDropAdapter$3.run(DelegatingDropAdapter.java:211)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.util.DelegatingDropAdapter.drop(DelegatingDropAdapter.java:209)
at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
at org.eclipse.swt.dnd.DropTarget.Drop(DropTarget.java:456)
at org.eclipse.swt.dnd.DropTarget$3.method6(DropTarget.java:258)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:119)
at org.eclipse.swt.internal.ole.win32.COM.DoDragDrop(Native Method)
at org.eclipse.swt.dnd.DragSource.drag(DragSource.java:363)
at org.eclipse.swt.dnd.DragSource.access$0(DragSource.java:289)
at org.eclipse.swt.dnd.DragSource$1.handleEvent(DragSource.java:172)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLau
ncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.jav
a:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
...
[Updated on: Mon, 30 July 2012 01:18] Report message to a moderator
|
|
|
Re: Custom aggregation through the plugin via eclipse data extension point [message #899157 is a reply to message #898982] |
Mon, 30 July 2012 17:13 |
|
What version of BIRT are you using? Can you post the project? You need
to make sure you implement the IAggrFunction interface.
Take a look at this post:
http://birtworld.blogspot.com/2010/10/birt-duplicate-rows.html
I also am attaching the preval aggregation extension point example.
Jason
On 7/29/2012 9:18 PM, andrew smith wrote:
> Hello,
> I am trying to create a custom aggregation that could be available
> within BIRT as a plugin via the eclipse's data extension point concept.
> I am having some problems getting it recognized by BIRT. I encounter an
> error when I open the aggregation tool. I followed the BIRT Aggregate
> Extension Example at
> (eclipse.org/birt/phoenix/examples/extending/aggregate/) and created
> even a simpler plugin, but it the BIRT throws a JavaNullException
> error. Sounds like I may not be declaring a variable. But the example
> below is so simple that there is nothing to declare pretty much.
> I am listing the code below. There are 3 classes. The Activator was
> built by Eclipse automatically, so I did not touch it. The
> myPluginAccumulator should essentially return number 2 ie there is no
> aggregation on the input data whatsoever. I am listing the error below
> the classes. Do you guys know what I am doing wrong?
> //===========================================================
> public class myPluginAccumulator extends Accumulator {
>
> @SuppressWarnings("unused")
> @Override
> public void onRow(Object[] args) throws DataException {
> int number = 0;
> }
>
> @Override
> public Object getValue() throws DataException {
> return new Double(2);
> }
>
> }
> //===========================================================
> @SuppressWarnings("deprecation")
> public class myPlugin extends Aggregation {
>
> @Override
> public String getName() {
> return "Cumulative_Product";
> }
>
> @Override
> public int getType() {
> return SUMMARY_AGGR;
> }
>
> @Override
> public boolean[] getParameterDefn() {
> return new boolean[]{true};
> }
>
> @Override
> public Accumulator newAccumulator() {
> // TODO Auto-generated method stub
> return new myPluginAccumulator();
> }
>
> }
>
> //===========================================================
> /**
> * The activator class controls the plug-in life cycle
> */
> public class Activator extends AbstractUIPlugin {
>
> // The plug-in ID
> public static final String PLUGIN_ID = "ExamplePlugIn"; //$NON-NLS-1$
>
> // The shared instance
> private static Activator plugin;
>
> /**
> * The constructor
> */
> public Activator() {
> }
>
> /*
> * (non-Javadoc)
> * @see
> org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
>
> */
> public void start(BundleContext context) throws Exception {
> super.start(context);
> plugin = this;
> }
>
> /*
> * (non-Javadoc)
> * @see
> org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
>
> */
> public void stop(BundleContext context) throws Exception {
> plugin = null;
> super.stop(context);
> }
>
> /**
> * Returns the shared instance
> *
> * @return the shared instance
> */
> public static Activator getDefault() {
> return plugin;
> }
>
> }
> //===========================================================
>
> Jul 29, 2012 8:12:13 PM
> org.eclipse.birt.data.engine.api.aggregation.AggrFunctionWrapper
> populateDep
> recatedAggregations
> WARNING: Exception in aggregation extension loading.
> java.lang.NullPointerException
> at
> org.eclipse.birt.data.engine.api.aggregation.AggregationManager.populateExtendedAggrInfo(
>
> AggregationManager.java:255)
> at
> org.eclipse.birt.data.engine.api.aggregation.AggregationManager.populateDeprecatedAggrega
>
> tions(AggregationManager.java:216)
> at
> org.eclipse.birt.data.engine.api.aggregation.AggregationManager.populateAggregations(Aggr
>
> egationManager.java:155)
> at
> org.eclipse.birt.data.engine.api.aggregation.AggregationManager.<init>(AggregationManager
>
> java:123)
> at
> org.eclipse.birt.data.engine.api.aggregation.AggregationManager.getInstance(AggregationMa
>
> nager.java:110)
> at
> org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.getAggregationManager(Da
>
> taRequestSessionImpl.java:1921)
> at
> org.eclipse.birt.report.designer.data.ui.util.DataUtil.getAggregationManager(DataUtil.jav
>
> a:69)
> at
> org.eclipse.birt.report.designer.internal.ui.dialogs.BindingDialogHelper.getFunctions(Bin
>
> dingDialogHelper.java:613)
> at
> org.eclipse.birt.report.designer.internal.ui.dialogs.BindingDialogHelper.getFunctionDispl
>
> ayNames(BindingDialogHelper.java:565)
> at
> org.eclipse.birt.report.designer.internal.ui.dialogs.BindingDialogHelper.initFunction(Bin
>
> dingDialogHelper.java:517)
> at
> org.eclipse.birt.report.designer.internal.ui.dialogs.BindingDialogHelper.initDialog(Bindi
>
> ngDialogHelper.java:356)
> at
> org.eclipse.birt.report.designer.internal.ui.dialogs.DataColumnBindingDialog.initDialog(D
>
> ataColumnBindingDialog.java:404)
> at
> org.eclipse.birt.report.designer.ui.dialogs.BaseDialog.open(BaseDialog.java:103)
>
> at
> org.eclipse.birt.report.designer.internal.ui.AggDataDropAdapter.performDrop(AggDataDropAd
>
> apter.java:127)
> at
> org.eclipse.birt.report.designer.internal.ui.dnd.DNDService.performDrop(DNDService.java:1
>
> 69)
> at
> org.eclipse.birt.report.designer.internal.ui.palette.ReportTemplateTransferDropTargetList
>
> ener.handleDrop(ReportTemplateTransferDropTargetListener.java:126)
> at
> org.eclipse.gef.dnd.AbstractTransferDropTargetListener.drop(AbstractTransferDropTargetLis
>
> tener.java:183)
> at
> org.eclipse.jface.util.DelegatingDropAdapter$3.run(DelegatingDropAdapter.java:211)
>
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
> at
> org.eclipse.jface.util.DelegatingDropAdapter.drop(DelegatingDropAdapter.java:209)
>
> at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:90)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
> at org.eclipse.swt.dnd.DropTarget.Drop(DropTarget.java:456)
> at org.eclipse.swt.dnd.DropTarget$3.method6(DropTarget.java:258)
> at
> org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:119)
> at org.eclipse.swt.internal.ole.win32.COM.DoDragDrop(Native Method)
> at org.eclipse.swt.dnd.DragSource.drag(DragSource.java:363)
> at org.eclipse.swt.dnd.DragSource.access$0(DragSource.java:289)
> at
> org.eclipse.swt.dnd.DragSource$1.handleEvent(DragSource.java:172)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
> at
> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
> at
> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
> at
> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
> at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
> at
> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLau
>
> ncher.java:110)
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.jav
>
> a:79)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> ...
|
|
| | | |
Re: Custom aggregation through the plugin via eclipse data extension point [message #899382 is a reply to message #899367] |
Tue, 31 July 2012 15:59 |
|
Andrew
You are using the older style of implementing an aggregation extension.
This was changed a couple of years ago. I started a new project in
4.2 and imported the project I posted a couple of days ago. In the Java
perspective I then double clicked on the plugin.xml to open the manifest
editor for my plugin. In the overview tab I used option4 to export the
plugin (Export Wizard) and it worked fine. Your activator is fine, but
you do need to implement the aggregationfactory.
Jason
On 7/31/2012 10:53 AM, andrew smith wrote:
> Hi, Jason:
>
> Yes I imported the project and looked at what is there. Unfortunately,
> the project does not compile into the plug-in for some reason, when
> using the export function. The EXPORT>>Deployable Plugin and
> fragments>>Available Plugins and Fragments window is empty. Couple other
> things that I noted too:
> 1) your Activator() implements BundleActivator, whereas my Activator()
> extends AbstractUIPlugin. my Activator() was created automatically by
> Eclipse and I did not touch it thinking that the Eclipse knows what to
> extend and implement when it comes to making a skeleton code to work
> off. Should I change to BundleActivator() manually?
> 2) Also, you are using the AggregationFactory(), but its not mandatory
> to use it, right?
> Thanks!!
> Andrew
>
>
>
>
>
>
|
|
| | |
Re: Custom aggregation through the plugin via eclipse data extension point [message #899394 is a reply to message #899387] |
Tue, 31 July 2012 16:32 |
|
Andrew,
I need to get a revised tutorial up, but currently there is not one. Do
not create a new project. Just create a new workspace and import the
project. If you create a new project you can just specify the extension
you want to implement and then copy over the code if you prefer. It
should not be a project in a project. In the manifest editor you can
also select the extensions tab and click on
org.eclipse.birt.data.aggregation and then click on the show extension
point description to see what is required and what has been deprecated.
Jason
On 7/31/2012 12:24 PM, andrew smith wrote:
> Jason,
> On your comment...
> "- I started a new project in 4.2 and imported the project I posted a
> couple of days ago." Just to make sure I do things correctly, I would
> have to 1) create a plugin project with an arbitraty name,
> (com.my.test.plugin)
> 2) import the project you posted earlier into the com.my.test.plugin.
>
> So the result will be a project within a project. Am I understanding
> this correctly? Thanks!!
|
|
|
Re: Custom aggregation through the plugin via eclipse data extension point [message #899459 is a reply to message #899394] |
Tue, 31 July 2012 23:55 |
andrew smith Messages: 43 Registered: February 2012 |
Member |
|
|
Jason,
Ok, I think I am stuck.
I understand the logic of steps in the example at http://www.eclipse.org/birt/phoenix/examples/extending/aggregate/, but the thing does not work, as we've observed before.
I do not quite understand (my own fault) the logic flow in the PREVVAL example, but it DOES work.
Could we go over some the methods in PREVVAL example, please?
file: ACTIVATOR.JAVA
--What calls this method? what exactly goes into the bundleContext variable? Is this parameter at all dependent on the design of the plugin? Do I have to worry about it?
file: PREVVAL.JAVA
public static final int[] CALCULATABLE = new int[]{
DataType.BOOLEAN_TYPE,
DataType.INTEGER_TYPE,
DataType.DOUBLE_TYPE,
DataType.DECIMAL_TYPE,
DataType.STRING_TYPE,
DataType.DATE_TYPE,
DataType.SQL_DATE_TYPE,
DataType.SQL_TIME_TYPE };
--Where is this array used/called? I looked through all the files and did not find any calls to this array...
--What does this name reference? is it what could go onto the output screen or is it an internal name of an aggregation tool that can later be used to identify an aggregator?
--Where is this method called, by what object?
return DataType.ANY_TYPE;
--Why ANY_TYPE being returned? Can I return NULL here? or Double?
--Where will this method be called in BIRT or in Eclipse?
--What does the Parameter Definition mean in this example? Is is a column over which an aggregation occurs or is it just one number in that column or something else?
--What does this method do?
--What calls this method?
--Under what circumstances the return array of type IPArameterDefn[] will have length of one, two or three or more?
--What calls all of the methods contained in the PrevValParm() object and when?
file: PREVVALACUM.JAVA
--Under what condition will args[] have length of 0? Does AggregationFactory's Map's name affect whether or not args[].length will be zero?
--what does it mean if the length of args[] is 3, for example. Does it mean, that I am looking simultaneously at 3 columns?
file: PREVVALPARM.JAVA
--When is this method called and what calls it?
--When is this method called and what calls it?
--When is this method called and what calls it?
--When is this method called and what calls it?
--When is this method called and what calls it? What does 'Optional' mean?
--When is this method called and what calls it?
--Looks to me that this method will always return TRUE. Under what conditions will it return FALSE? Does Data.UNKNOWN_TYPE cover all the data that is not
DataType.BOOLEAN_TYPE,
DataType.INTEGER_TYPE,
DataType.DOUBLE_TYPE,
DataType.DECIMAL_TYPE,
DataType.STRING_TYPE,
DataType.DATE_TYPE,
DataType.SQL_DATE_TYPE,
DataType.SQL_TIME_TYPE
?
PVAGGREGATIONFACTORY.JAVA
--why are we creating Maps here? A programming choice or an expectation by Eclipse/BIRT?
--Why can I not use Aggregation() and have to use AggregationFactory?
--Can the name in the aggrMap.put("_the_name_", prevval) be anything or does it have to match with previously defined names?
--When is this method called? What calls this method?
Apologies for throwing so many questions out there and thank you!!
Andrew
[Updated on: Wed, 01 August 2012 14:45] Report message to a moderator
|
|
|
Re: Custom aggregation through the plugin via eclipse data extension point [message #899627 is a reply to message #899459] |
Wed, 01 August 2012 15:49 |
|
First the Activator should not matter. I created the extension with an
earlier version of Eclipse. If you create a default plugin that does
not contribute to the ui (checkbox in the wizard) what it creates is fine.
When the designer access aggregation functions like when you place an
aggregation report item on a report it looks for implementers of the the
org.eclipse.birt.data.aggregation extension point. To populate the list
of available functions. For each implementation of this extension point
it specifically looks for the AggregationFactory class. In the case of
this example it is PVAggregationFactory. This class must implement the
IAggregationFactory interface. This interface only has two real
methods, one to list all the Aggregation functions that that the plugin
provides and a get function to return one specific aggregation function
(public IAggrFunction getAggregation( String name );). Note that the
getAggregation function must return an object that implements the
IAggrFunction interface. In this example we only have one aggregate
function in the plugin.
PrevVal implements IAggrFunction
In PrevVal.java
public static final int[] CALCULATABLE = new int[]{
DataType.BOOLEAN_TYPE,
DataType.INTEGER_TYPE,
DataType.DOUBLE_TYPE,
DataType.DECIMAL_TYPE,
DataType.STRING_TYPE,
DataType.DATE_TYPE,
DataType.SQL_DATE_TYPE,
DataType.SQL_TIME_TYPE
};
This code can be deleted. It was left over from change but was
originally used to determine what parameter types the function could
take. The getName method is the unique name that the engine will use.
For example when writing out the report design, the aggregate function
name will be written into the xml. getDisplayName is what is displayed
in the Aggregation ui in the designer. the getDataType returns the type
for this aggregation, I choose any because a previous value could be a
double or a string. It is up to the designer to set it correctly. The
getDescription is supposed to be called when a tooltip is shown over the
aggregation function name like in the computed column builder in the
data set.
After writing this response I realized that I wrote an Article on this a
while back:
http://www.informit.com/articles/article.aspx?p=1748986&seqNum=1
The aggregate extension point is defined on page 4. Read over that and
then let me know what questions the article does not answer.
Jason
On 7/31/2012 7:55 PM, andrew smith wrote:
> Jason,
> Ok, I think I am stuck. I understand the logic of steps in the example
> at http://www.eclipse.org/birt/phoenix/examples/extending/aggregate/,
> but the thing does not work, as we've observed before. I do not quite
> understand (my own fault) the logic flow in the PREVVAL example, but it
> DOES work. Could we go over some the methods in PREVVAL example, please?
> file: ACTIVATOR.JAVA
> start()
> --What calls this method? what exactly goes into the bundleContext
> variable? Is this parameter at all dependent on the design of the
> plugin? Do I have to worry about it?
> file: PREVVAL.JAVA
> public static final int[] CALCULATABLE = new int[]{
> DataType.BOOLEAN_TYPE,
> DataType.INTEGER_TYPE, DataType.DOUBLE_TYPE,
> DataType.DECIMAL_TYPE, DataType.STRING_TYPE,
> DataType.DATE_TYPE,
> DataType.SQL_DATE_TYPE,
> DataType.SQL_TIME_TYPE
> };
> --Where is this array used/called? I looked through all the files and
> did not find any calls to this array...
>
> getName()
> --What does this name reference? is it what could go onto the output
> screen or is it an internal name of an aggregation tool that can later
> be used to identify an aggregator? --Where is this method called, by
> what object?
>
> getDataType()
> return DataType.ANY_TYPE;
> --Why ANY_TYPE being returned? Can I return NULL here? or Double?
> getDescription()
> --Where will this method be called in BIRT or in Eclipse?
> getParameterDefn()
> --What does the Parameter Definition mean in this example? Is is a
> column over which an aggregation occurs or is it just one number in that
> column or something else?
> --What does this method do? --What calls this method? --Under what
> circumstances the return array of type IPArameterDefn[] will have length
> of one, two or three or more? --What calls all of the methods contained
> in the PrevValParm() object and when?
>
> PREVVALACUM.JAVA
> onRow(Object args[])
> --Under what condition will args[] have length of 0? Does
> AggregationFactory's Map's name affect whether or not args[].length will
> be zero?
> --what does it mean if the length of args[] is 3, for example. Does it
> mean, that I am looking simultaneously at 3 columns?
> PREVVALPARM.JAVA
> getDescription()
> --When is this method called and what calls it?
> getDisplayName()
> --When is this method called and what calls it?
> getName()
> --When is this method called and what calls it?
> isDataField()
> --When is this method called and what calls it?
> isOptional()
> --When is this method called and what calls it? What does 'Optional' mean?
> isDataField()
> --When is this method called and what calls it?
> supportDataType()
> --Looks to me that this method will always return TRUE. Under what
> conditions will it return FALSE? Does Data.UNKNOWN_TYPE cover all the
> data that is not DataType.BOOLEAN_TYPE,
> DataType.INTEGER_TYPE, DataType.DOUBLE_TYPE,
> DataType.DECIMAL_TYPE, DataType.STRING_TYPE,
> DataType.DATE_TYPE,
> DataType.SQL_DATE_TYPE,
> DataType.SQL_TIME_TYPE
> ?
>
> PVAGGREGATIONFACTORY.JAVA
> --why are we creating Maps here? A programming choicae or an
> expectation by Eclipse/BIRT?
> populateAggregation()
> --Can the name in the aggrMap.put("_the_name_", prevval) be anything or
> does it have to match with previously defined names?
>
> getAggregation()
> --When is this method called? What calls this method?
>
> Apologies for throwing so many questions out there and thank you!!
> Andrew
>
>
|
|
| |
Re: Custom aggregation through the plugin via eclipse data extension point [message #899920 is a reply to message #899912] |
Thu, 02 August 2012 20:56 |
|
1 - yes
2 - This question made me think about why would we even need the method
if we have its name and the list of aggregates. I took a look through
the code and I do not think the getAggregation( string ) is even called.
It appears the birt data plugin keeps a map of all aggregations
available and it is keyed by the getName function. The method has not
been deprecated in the code, so I would implement it. I would also
match the name that getName returns. It might be a good idea to log a
bugzilla entry to have it deprecated.
Jason
On 8/2/2012 3:21 PM, andrew smith wrote:
> Jason,
> Thanks a lot for explaining what happens when the custom aggregation is
> called. Things make perfect sense and I was able to get my plugin
> working!! Thanks again!
>
> Just couple more question:
>
> 1)
> When my plugin has more than one custom aggregations, would the
> aggregationFactory() look something like this:
> ...
> public MyAggregationFactory() {
> final Agg_01 agg_01 = new Agg_01();
> final Agg_02 agg_02 = new Agg_02();
> aggrMap.put("My custom Agg Function 01", agg_01);
> aggrMap.put("My custom Agg Function 02", agg_02);
> aggregations.add(agg_01);
> aggregations.add(agg_02);
> }
> ...
>
> 2) Since the .getName() methods returns the name that the internal
> engine is using, does this mean that whatever string I put in
> aggrMap.put("My custom Agg Function 01", agg_01), it must match the
> return string of a getName() method? So in this case:
>
> public String getName() {
> return "My custom Agg Function 01";
> }
>
>
> Thank you!!
>
> Andrew
|
|
| |
Goto Forum:
Current Time: Thu Dec 05 10:14:20 GMT 2024
Powered by FUDForum. Page generated in 0.26443 seconds
|