// Path: src/main/java/com/tfsinc/ilabs/olap/OlapClientManager.java
// public class OlapClientManager {
// 
// 	/**
// 	 * Root logger instance.
// 	 */
// 	private static final Logger LOGGER = Logger.getLogger(
// 			OlapClientManager.class);
// 
// 	/**
// 	 * Initializes everything.
// 	 * @param configFile Name and path of configuration file.
// 	 */
// 	public static final void initialize(final String configFile) {
// 		OlapConfigReferences.initialize(configFile);
// 		OlapConnectionPoolManager.initialize(configFile);
// 	}
// 
// 	/**
// 	 * Shuts down everything.
// 	 * @param forceClose Whether to close active connections forcibly.
// 	 */
// 	public static final void shutdown(final boolean forceClose) {
// 		OlapConnectionPoolManager.shutdown(forceClose);
// 	}
// 
// 	/**
// 	 * @return An OLAP connection from the POOL.
// 	 */
// 	public static WrappedOlapConnection getConnection() {
// 		return OlapConnectionPoolManager.getConnection();
// 	}
// 
// 	/**
// 	 * @param connection OLAP connection to be returned to the pool.
// 	 * @return Whether the connection was returned successfully.
// 	 */
// 	public static final boolean returnConnection(
// 			final WrappedOlapConnection connection) {
// 		return OlapConnectionPoolManager.returnConnection(connection);
// 	}
// 
// 	/**
// 	 * @param query String MDX query to be executed.
// 	 * @return Cell set of the query.
// 	 */
// 	public static final CellSet executeMdxQuery(final String query) {
// 		final WrappedOlapConnection connection = getConnection();
// 		try {
// 			final long start = System.currentTimeMillis();
// 			final CellSet cellSet = connection.getResource()
// 					.createStatement().executeOlapQuery(query);
// 			if (LOGGER.isDebugEnabled()) {
// 				LOGGER.debug("Query execution time: " + (System.currentTimeMillis() - start) + " ms.");
// 			}
// 
// 			returnConnection(connection);
// 			return cellSet;
// 		} catch (OlapException e) {
// 			LOGGER.error("Unable to execute query.", e);
// 			returnConnection(connection);
// 			return null;
// 		}
// 	}
// 
// 	/**
// 	 * @param query Parsed select MDX query.
// 	 * @return Cell set of the query.
// 	 */
// 	public static final CellSet executeMdxQuery(final SelectNode query) {
// 		final WrappedOlapConnection connection = getConnection();
// 		try {
// 			final long start = System.currentTimeMillis();
// 			final CellSet cellSet = connection.getResource()
// 					.createStatement().executeOlapQuery(query);
// 			if (LOGGER.isDebugEnabled()) {
// 				LOGGER.debug("Query execution time: " + (System.currentTimeMillis() - start) + " ms.");
// 			}
// 			returnConnection(connection);
// 			return cellSet;
// 		} catch (OlapException e) {
// 			LOGGER.error("Unable to execute query.", e);
// 			returnConnection(connection);
// 			return null;
// 		}
// 	}
// 
// }
// 
// Path: src/main/java/com/tfsinc/ilabs/olap/WrappedOlapConnection.java
// public final class WrappedOlapConnection implements WrappedResource<OlapConnection> {
// 
// 	/**
// 	 * OLAP connection which is wrapped.
// 	 */
// 	private final OlapConnection connection;
// 
// 	/**
// 	 * Root logger instance.
// 	 */
// 	private static final Logger LOGGER = Logger.getLogger(
// 			WrappedOlapConnection.class);
// 
// 	// Constructor.
// 	public WrappedOlapConnection(final OlapConnection olapConnection) {
// 		connection = olapConnection;
// 	}
// 
// 	/* (non-Javadoc)
// 	 * @see com.awesome.pro.pool.WrappedResource#close()
// 	 */
// 	public void close() {
// 		try {
// 			connection.close();
// 		} catch (SQLException e) {
// 			LOGGER.error("Error in closing OLAP connection.");
// 			System.exit(1);
// 		}
// 	}
// 
// 	/* (non-Javadoc)
// 	 * @see com.awesome.pro.pool.WrappedResource#isClosed()
// 	 */
// 	public boolean isClosed() {
// 		try {
// 			return connection.isClosed();
// 		} catch (SQLException e) {
// 			return true;
// 		}
// 	}
// 
// 	/* (non-Javadoc)
// 	 * @see com.awesome.pro.pool.WrappedResource#getResource()
// 	 */
// 	public OlapConnection getResource() {
// 		return connection;
// 	}
// 
// }


import org.apache.log4j.Logger;
import org.olap4j.OlapException;
import org.olap4j.mdx.SelectNode;
import org.olap4j.mdx.parser.MdxParser;
import org.olap4j.mdx.parser.MdxValidator;
import com.tfsinc.ilabs.olap.OlapClientManager;
import com.tfsinc.ilabs.olap.WrappedOlapConnection;
package com.tfsinc.ilabs.mdx.builder;



/**
 * Validates an MDX query.
 * @author siddharth.s
 */
public class MDXValidator {

	/**
	 * Root logger instance.
	 */
	private static final Logger LOGGER = Logger.getLogger(MDXValidator.class);

	/**
	 * @param mdx MDX query to be validated.
	 * @return Parsed select node of the query;
	 * @throws OlapException When there is an error in validating the query.
	 */
	public static final SelectNode validateQuery(final String mdx) throws OlapException {
// Path: src/main/java/com/tfsinc/ilabs/olap/OlapClientManager.java
// public class OlapClientManager {
// 
// 	/**
// 	 * Root logger instance.
// 	 */
// 	private static final Logger LOGGER = Logger.getLogger(
// 			OlapClientManager.class);
// 
// 	/**
// 	 * Initializes everything.
// 	 * @param configFile Name and path of configuration file.
// 	 */
// 	public static final void initialize(final String configFile) {
// 		OlapConfigReferences.initialize(configFile);
// 		OlapConnectionPoolManager.initialize(configFile);
// 	}
// 
// 	/**
// 	 * Shuts down everything.
// 	 * @param forceClose Whether to close active connections forcibly.
// 	 */
// 	public static final void shutdown(final boolean forceClose) {
// 		OlapConnectionPoolManager.shutdown(forceClose);
// 	}
// 
// 	/**
// 	 * @return An OLAP connection from the POOL.
// 	 */
// 	public static WrappedOlapConnection getConnection() {
// 		return OlapConnectionPoolManager.getConnection();
// 	}
// 
// 	/**
// 	 * @param connection OLAP connection to be returned to the pool.
// 	 * @return Whether the connection was returned successfully.
// 	 */
// 	public static final boolean returnConnection(
// 			final WrappedOlapConnection connection) {
// 		return OlapConnectionPoolManager.returnConnection(connection);
// 	}
// 
// 	/**
// 	 * @param query String MDX query to be executed.
// 	 * @return Cell set of the query.
// 	 */
// 	public static final CellSet executeMdxQuery(final String query) {
// 		final WrappedOlapConnection connection = getConnection();
// 		try {
// 			final long start = System.currentTimeMillis();
// 			final CellSet cellSet = connection.getResource()
// 					.createStatement().executeOlapQuery(query);
// 			if (LOGGER.isDebugEnabled()) {
// 				LOGGER.debug("Query execution time: " + (System.currentTimeMillis() - start) + " ms.");
// 			}
// 
// 			returnConnection(connection);
// 			return cellSet;
// 		} catch (OlapException e) {
// 			LOGGER.error("Unable to execute query.", e);
// 			returnConnection(connection);
// 			return null;
// 		}
// 	}
// 
// 	/**
// 	 * @param query Parsed select MDX query.
// 	 * @return Cell set of the query.
// 	 */
// 	public static final CellSet executeMdxQuery(final SelectNode query) {
// 		final WrappedOlapConnection connection = getConnection();
// 		try {
// 			final long start = System.currentTimeMillis();
// 			final CellSet cellSet = connection.getResource()
// 					.createStatement().executeOlapQuery(query);
// 			if (LOGGER.isDebugEnabled()) {
// 				LOGGER.debug("Query execution time: " + (System.currentTimeMillis() - start) + " ms.");
// 			}
// 			returnConnection(connection);
// 			return cellSet;
// 		} catch (OlapException e) {
// 			LOGGER.error("Unable to execute query.", e);
// 			returnConnection(connection);
// 			return null;
// 		}
// 	}
// 
// }
// 
// Path: src/main/java/com/tfsinc/ilabs/olap/WrappedOlapConnection.java
// public final class WrappedOlapConnection implements WrappedResource<OlapConnection> {
// 
// 	/**
// 	 * OLAP connection which is wrapped.
// 	 */
// 	private final OlapConnection connection;
// 
// 	/**
// 	 * Root logger instance.
// 	 */
// 	private static final Logger LOGGER = Logger.getLogger(
// 			WrappedOlapConnection.class);
// 
// 	// Constructor.
// 	public WrappedOlapConnection(final OlapConnection olapConnection) {
// 		connection = olapConnection;
// 	}
// 
// 	/* (non-Javadoc)
// 	 * @see com.awesome.pro.pool.WrappedResource#close()
// 	 */
// 	public void close() {
// 		try {
// 			connection.close();
// 		} catch (SQLException e) {
// 			LOGGER.error("Error in closing OLAP connection.");
// 			System.exit(1);
// 		}
// 	}
// 
// 	/* (non-Javadoc)
// 	 * @see com.awesome.pro.pool.WrappedResource#isClosed()
// 	 */
// 	public boolean isClosed() {
// 		try {
// 			return connection.isClosed();
// 		} catch (SQLException e) {
// 			return true;
// 		}
// 	}
// 
// 	/* (non-Javadoc)
// 	 * @see com.awesome.pro.pool.WrappedResource#getResource()
// 	 */
// 	public OlapConnection getResource() {
// 		return connection;
// 	}
// 
// }


// Path: src/main/java/com/tfsinc/ilabs/mdx/builder/MDXValidator.java
import org.apache.log4j.Logger;
import org.olap4j.OlapException;
import org.olap4j.mdx.SelectNode;
import org.olap4j.mdx.parser.MdxParser;
import org.olap4j.mdx.parser.MdxValidator;
import com.tfsinc.ilabs.olap.OlapClientManager;
import com.tfsinc.ilabs.olap.WrappedOlapConnection;

package com.tfsinc.ilabs.mdx.builder;



/**
 * Validates an MDX query.
 * @author siddharth.s
 */
public class MDXValidator {

	/**
	 * Root logger instance.
	 */
	private static final Logger LOGGER = Logger.getLogger(MDXValidator.class);

	/**
	 * @param mdx MDX query to be validated.
	 * @return Parsed select node of the query;
	 * @throws OlapException When there is an error in validating the query.
	 */
	public static final SelectNode validateQuery(final String mdx) throws OlapException {
		final WrappedOlapConnection connection = OlapClientManager