Skip to content

Commit

Permalink
Merge pull request #445 from ravikirankatneni/master
Browse files Browse the repository at this point in the history
Made changes to return correct arguments in Binding.
  • Loading branch information
Gary Xue committed Apr 6, 2018
2 parents ffc9ec1 + d25315b commit f20067c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public Binding( String name, IBaseExpression expr )
this.expr = expr;
this.aggregateOn = new ArrayList<String>();
this.argument = new LinkedHashMap<String, IBaseExpression>();
this.orderedArgument = new ArrayList<IBaseExpression>();
if ( expr != null )
this.dataType = expr.getDataType( );
else
Expand All @@ -78,10 +77,17 @@ public void addAggregateOn( String levelName ) throws DataException
* (non-Javadoc)
* @see org.eclipse.birt.data.engine.api.IBinding#addArgument(org.eclipse.birt.data.engine.api.IBaseExpression)
*/
@Deprecated
public void addArgument( IBaseExpression expr )
{
if( expr!= null )
if ( expr != null )
{
if ( orderedArgument == null )
{
orderedArgument = new ArrayList<IBaseExpression>( );
}
this.orderedArgument.add( expr );
}

}

Expand All @@ -95,6 +101,15 @@ public void addArgument( String name, IBaseExpression expr )
{
this.argument.put( name, expr );
}
// orderedArgument list needs to be regenerated
orderedArgument = null;
}

public void removeArgument(IBaseExpression expr)
{
this.argument.values().remove( expr );
// orderedArgument list needs to be regenerated
orderedArgument = null;
}

/*
Expand All @@ -121,19 +136,20 @@ public List getAggregatOns( )
*/
public List getArguments( ) throws DataException
{
if( this.aggrFunc == null )
if( this.orderedArgument != null)
// ordered list already computed;
return this.orderedArgument;

orderedArgument = new ArrayList<IBaseExpression>();

if( this.orderedArgument.size() > 0 )
if( this.aggrFunc == null )
return this.orderedArgument;

IAggrFunction info = AggregationManager.getInstance().getAggregation( this.aggrFunc );

if( info == null )
return this.orderedArgument;

IParameterDefn[] parameters = info.getParameterDefn();

if( parameters!= null )
{
for( int i = 0; i < parameters.length; i++ )
Expand Down Expand Up @@ -306,10 +322,15 @@ public IBinding clone( )
{
n.aggregateOn.add( o );
}
for ( IBaseExpression o : this.orderedArgument )

if ( orderedArgument != null )
{
n.orderedArgument.add( o );
for ( IBaseExpression o : this.orderedArgument )
{
n.orderedArgument.add( o );
}
}

for ( Map.Entry<String, IBaseExpression> o : this.argument.entrySet( ) )
{
n.argument.put( o.getKey( ), o.getValue( ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,10 @@ private String getDataSetExpr( String rowExpr ) throws DataException
Object binding = this.baseQueryDefn.getBindings( ).get( bindingName );
if( binding != null )
{
if ( ( (IBinding) binding ).getAggrFunction( ) != null )
{
return null;
}
IBaseExpression expr = ( (IBinding) binding ).getExpression( );
if( expr != null && expr instanceof IScriptExpression )
{
Expand Down

0 comments on commit f20067c

Please sign in to comment.