
/*******************************************************************************
 * Copyright (c) 2004, 2005 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.sort;

import java.util.logging.Logger;

import org.eclipse.birt.data.engine.olap.data.api.DimLevel;

/**
 * 
 */

public class AggrSortDefinition
{
	private DimLevel[] aggrLevels;
	private String aggrName;
	private DimLevel[] axisQualifierLevel;
	private Object[] axisQualifierValue;
	private DimLevel targetLevel;
	private boolean direction;
	private static Logger logger = Logger.getLogger( AggrSortDefinition.class.getName( ) );
	
	/**
	 * 
	 * @param aggrLevels
	 * @param aggrName
	 * @param axisQualifierLevel
	 * @param axisQualifierValue
	 * @param targetLevel
	 * @param direction
	 */
	public AggrSortDefinition( DimLevel[] aggrLevels, String aggrName,
			DimLevel[] axisQualifierLevel, Object[] axisQualifierValue,
			DimLevel targetLevel, boolean direction )
	{
		Object[] params = {
				aggrLevels,
				aggrName,
				axisQualifierLevel,
				axisQualifierValue,
				targetLevel,
				new Boolean( direction )
		};
		logger.entering( AggrSortDefinition.class.getName( ),
				"AggrSortDefinition",
				params );
		this.aggrLevels = aggrLevels;
		this.aggrName = aggrName;
		this.axisQualifierLevel = axisQualifierLevel;
		this.axisQualifierValue = axisQualifierValue;
		this.targetLevel = targetLevel;
		this.direction = direction;
		logger.exiting( AggrSortDefinition.class.getName( ),
				"AggrSortDefinition" );
	}
	
	/**
	 * 
	 * @return
	 */
	public DimLevel[] getAggrLevels( )
	{
		return this.aggrLevels;
	}
	
	/**
	 * 
	 * @return
	 */
	public String getAggrName( )
	{
		return this.aggrName;
	}
	
	/**
	 * 
	 * @return
	 */
	public DimLevel[] getAxisQualifierLevel()
	{
		return this.axisQualifierLevel;
	}
	
	/**
	 * 
	 * @return
	 */
	public Object[] getAxisQualifierValue()
	{
		return this.axisQualifierValue;
	}
	
	/**
	 * 
	 * @return
	 */
	public DimLevel getTargetLevel()
	{
		return this.targetLevel;
	}
	
	/**
	 * 
	 * @return
	 */
	public boolean getDirection()
	{
		return this.direction;
	}
	
}

@@ -635,16 +635,132 @@
 ogger;%0A%0A
+import org.eclipse.birt.data.engine.core.DataException;%0Aimport org.eclipse.birt.data.engine.i18n.ResourceConstants;%0A
 import o
@@ -811,16 +811,16 @@
 mLevel;%0A
-
 %0A/**%0A * 
@@ -1301,16 +1301,43 @@
 rection%0A
+%09 * @throws DataException %0A
 %09 */%0A%09pu
@@ -1508,16 +1508,37 @@
 ection )
+ throws DataException
 %0A%09%7B%0A%09%09Ob
@@ -1780,16 +1780,79 @@
 rams );%0A
+%09%09checkAxisAgrument( axisQualifierLevel, axisQualifierValue );%0A
 %09%09this.a
@@ -2110,32 +2110,32 @@
 ass.getName( ),%0A
-
 %09%09%09%09%22AggrSortDef
@@ -2144,24 +2144,650 @@
 ition%22 );%0A%09%7D
+%0A%0A%09/**%0A%09 * @param axisQualifierLevel%0A%09 * @param axisQualifierValue%0A%09 * @throws DataException%0A%09 */%0A%09private void checkAxisAgrument( DimLevel%5B%5D axisLevels,%0A%09%09%09Object%5B%5D axisValues ) throws DataException%0A%09%7B%0A%09%09if ( axisLevels != null%0A%09%09%09%09&& axisValues != null && axisLevels.length == axisValues.length )%0A%09%09%7B%0A%09%09%09for ( int i = 0; i %3C axisLevels.length; i++ )%0A%09%09%09%7B%0A%09%09%09%09if ( axisLevels%5Bi%5D == null )%0A%09%09%09%09%09throw new DataException( ResourceConstants.AXIS_LEVEL_CANNOT_BE_NULL );%0A%09%09%09%09if ( axisValues%5Bi%5D == null )%0A%09%09%09%09%09throw new DataException( ResourceConstants.AXIS_VALUE_CANNOT_BE_NULL,%0A%09%09%09%09%09%09%09axisLevels%5Bi%5D.getLevelName( ) );%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D
 %0A%09%0A%09/**%0A%09 * 

Fix bugzilla bug 192562. NPE throws out in preview when left one requied column member value empty in sorting of crosstab[1102]