Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Given a parameter name, how can I find to which group it belongs?
Given a parameter name, how can I find to which group it belongs? [message #832564] Fri, 30 March 2012 09:36 Go to next message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
For a child parameter in a cascading group, task.getSelectionList(paramName)
returns an empty list for me (task is an IGetParameterDefinitionTask).

I can avoid it by iterating over all cascading groups returned by task.getParameterDefns(true), and within each group use group.getParameters().findPosn(paramDefn) to check if it contains my parameter, but is there a simpler way to tell if the parameter is in a cascading group?
Re: Given a parameter name, how can I find to which group it belongs? [message #832589 is a reply to message #832564] Fri, 30 March 2012 10:14 Go to previous messageGo to next message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
This is a working approach (which hopefully can be simplified):
			IReportRunnable report = context.getReportRunnable();
			IReportEngine engine = report.getReportEngine();
			IGetParameterDefinitionTask task = engine
					.createGetParameterDefinitionTask(report);
			Collection<IParameterSelectionChoice> selectionList = null;
			Collection<IParameterDefnBase> paramsAndGroups = task
					.getParameterDefns(true);
			for (IParameterDefnBase paramOrGroup : paramsAndGroups) {
				if (paramOrGroup instanceof CascadingParameterGroupDefn) {
					List<IParameterDefnBase> members = ((CascadingParameterGroupDefn) paramOrGroup)
							.getContents();
					int groupSize = members.size();
					int indexInGroup;
					for (indexInGroup = 0; indexInGroup < groupSize
							&& !parameterName.equals(members.get(indexInGroup)
									.getName()); indexInGroup++) {
					}
					if (indexInGroup < groupSize) {
						// found!
						Object[] prevChoices = new Object[indexInGroup];
						for (int i = 0; i < indexInGroup; i++) {
							prevChoices[i] = context.getParameterValue(members
									.get(i).getName());
						}
						selectionList = task.getSelectionListForCascadingGroup(
								paramOrGroup.getName(), prevChoices);
						break;
					}
				}
			}
			if (selectionList == null) {
				// parameter isn't in a cascading group
				selectionList = task.getSelectionList(parameterName);
			}
			Object parameterValue = context.getParameterValue(parameterName);
Re: Given a parameter name, how can I find to which group it belongs? [message #832948 is a reply to message #832589] Fri, 30 March 2012 19:28 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

If you have the parameter handle you should be able to do this:

if ( parameterHandle.getContainer( ) instanceof
CascadingParameterGroupHandle ){

String groupName = parameterHandle.getContainer( ).getName( );

Jason

On 3/30/2012 6:14 AM, Alexey Romanov wrote:
> This is a working approach (which hopefully can be simplified):
> IReportRunnable report = context.getReportRunnable();
> IReportEngine engine = report.getReportEngine();
> IGetParameterDefinitionTask task = engine
> .createGetParameterDefinitionTask(report);
> Collection<IParameterSelectionChoice> selectionList = null;
> Collection<IParameterDefnBase> paramsAndGroups = task
> .getParameterDefns(true);
> for (IParameterDefnBase paramOrGroup : paramsAndGroups) {
> if (paramOrGroup instanceof CascadingParameterGroupDefn) {
> List<IParameterDefnBase> members = ((CascadingParameterGroupDefn)
> paramOrGroup)
> .getContents();
> int groupSize = members.size();
> int indexInGroup;
> for (indexInGroup = 0; indexInGroup < groupSize
> && !parameterName.equals(members.get(indexInGroup)
> .getName()); indexInGroup++) {
> }
> if (indexInGroup < groupSize) {
> // found!
> Object[] prevChoices = new Object[indexInGroup];
> for (int i = 0; i < indexInGroup; i++) {
> prevChoices[i] = context.getParameterValue(members
> .get(i).getName());
> }
> selectionList = task.getSelectionListForCascadingGroup(
> paramOrGroup.getName(), prevChoices);
> break;
> }
> }
> }
> if (selectionList == null) {
> // parameter isn't in a cascading group
> selectionList = task.getSelectionList(parameterName);
> }
> Object parameterValue = context.getParameterValue(parameterName);
>
Re: Given a parameter name, how can I find to which group it belongs? [message #832952 is a reply to message #832948] Fri, 30 March 2012 19:34 Go to previous message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
Thanks! I seem to remember a getHandle() being there somewhere Smile will check after weekend.
Previous Topic:How does viewer use AJAX?
Next Topic:Problem with scatter charts
Goto Forum:
  


Current Time: Wed Oct 27 13:50:25 GMT 2021

Powered by FUDForum. Page generated in 0.01649 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top