<commit_before>package edu.wustl.query.util.querysuite;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import edu.common.dynamicextensions.domaininterface.EntityInterface;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.query.CiderQuery;
import edu.wustl.common.querysuite.exceptions.MultipleRootsException;
import edu.wustl.common.querysuite.exceptions.SqlException;
import edu.wustl.common.querysuite.queryobject.IQuery;
import edu.wustl.common.util.dbManager.DAOException;
import edu.wustl.query.querymanager.CiderQueryManager;
import edu.wustl.query.querymanager.Count;
import edu.wustl.query.util.global.Constants;


/**
 *   This class is Cider Specific implementation of AbstractQueryUIManager.
 */
public class CiderQueryUIManager extends QueryUIManager {

	
	private CiderQuery ciderQuery;
	
	public CiderQueryUIManager() 
	{


	}

	/**
	 * @param request
	 * @param query
	 */
	public CiderQueryUIManager(HttpServletRequest request, IQuery query) {

		
		this.request = request;
		this.session = request.getSession();
		SessionDataBean sessionDataBean = ((SessionDataBean) session.getAttribute(Constants.SESSION_DATA));
		long user_id = sessionDataBean.getUserId();
	    long project_id = 1;
		this.ciderQuery = new CiderQuery(query,-1,null,user_id, project_id);
		isSavedQuery = Boolean.valueOf((String) session.getAttribute(Constants.IS_SAVED_QUERY));
		queryDetailsObj = new QueryDetails(session);
	}


	/**
	 * This method Processes the Query by calling execute method of CiderQueryManager.
	 * 
	 * @throws QueryModuleException
	 */
	public int processQuery() throws QueryModuleException
	{
		CiderQueryManager queryManager = new CiderQueryManager();
		QueryModuleException queryModExp;
		int query_execution_id ;
		try
		{
			query_execution_id = queryManager.execute(ciderQuery);

		}
		catch (MultipleRootsException e)
		{
			queryModExp = new QueryModuleException(e.getMessage(), QueryModuleError.MULTIPLE_ROOT);
			throw queryModExp;
		}
		catch (SqlException e)
		{
			queryModExp = new QueryModuleException(e.getMessage(), QueryModuleError.SQL_EXCEPTION);
			throw queryModExp;
		}
		return query_execution_id;
	}
	
	public Count getCount(int query_execution_id) throws QueryModuleException
	{  
		CiderQueryManager queryManager = new CiderQueryManager();
		Count queryCount;
		try
		{
			queryCount = queryManager.getQueryCount(query_execution_id);
		}
		catch (DAOException e)
		{
			QueryModuleException queryModExp = new QueryModuleException(e.getMessage(), QueryModuleError.SQL_EXCEPTION);
			throw queryModExp;
		}
		catch (SQLException e)
		{
			QueryModuleException queryModExp = new QueryModuleException(e.getMessage(), QueryModuleError.SQL_EXCEPTION);
			throw queryModExp;
		}
		return queryCount;
	}
}
<commit_msg>supriya's changes for passing upi as output attribute to pass one xquery<commit_after>package edu.wustl.query.util.querysuite;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;

import edu.common.dynamicextensions.domaininterface.AttributeInterface;
import edu.common.dynamicextensions.domaininterface.EntityInterface;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.query.AbstractQuery;
import edu.wustl.common.query.CiderQuery;
import edu.wustl.common.querysuite.exceptions.MultipleRootsException;
import edu.wustl.common.querysuite.exceptions.SqlException;
import edu.wustl.common.querysuite.factory.QueryObjectFactory;
import edu.wustl.common.querysuite.queryobject.IConstraints;
import edu.wustl.common.querysuite.queryobject.IExpression;
import edu.wustl.common.querysuite.queryobject.IOutputAttribute;
import edu.wustl.common.querysuite.queryobject.IQuery;
import edu.wustl.common.querysuite.queryobject.impl.ParameterizedQuery;
import edu.wustl.common.util.dbManager.DAOException;
import edu.wustl.query.querymanager.CiderQueryManager;
import edu.wustl.query.querymanager.Count;
import edu.wustl.query.util.global.Constants;


/**
 *   This class is Cider Specific implementation of AbstractQueryUIManager.
 */
public class CiderQueryUIManager extends QueryUIManager {

	
	private CiderQuery ciderQuery;
	
	public CiderQueryUIManager() 
	{


	}

	/**
	 * @param request
	 * @param query
	 */
	public CiderQueryUIManager(HttpServletRequest request, IQuery query) {

		
		this.request = request;
		this.session = request.getSession();
		SessionDataBean sessionDataBean = ((SessionDataBean) session.getAttribute(Constants.SESSION_DATA));
		long user_id = sessionDataBean.getUserId();
	    long project_id = 1;
		this.ciderQuery = new CiderQuery(query,-1,null,user_id, project_id);
		isSavedQuery = Boolean.valueOf((String) session.getAttribute(Constants.IS_SAVED_QUERY));
		queryDetailsObj = new QueryDetails(session);
	}


	/**
	 * This method Processes the Query by calling execute method of CiderQueryManager.
	 * 
	 * @throws QueryModuleException
	 */
	public int processQuery() throws QueryModuleException
	{
		CiderQueryManager queryManager = new CiderQueryManager();
		QueryModuleException queryModExp;
		int query_execution_id ;
		try
		{
			updateQueryWithSelectedAttributes(ciderQuery);
			query_execution_id = queryManager.execute(ciderQuery);

		}
		catch (MultipleRootsException e)
		{
			queryModExp = new QueryModuleException(e.getMessage(), QueryModuleError.MULTIPLE_ROOT);
			throw queryModExp;
		}
		catch (SqlException e)
		{
			queryModExp = new QueryModuleException(e.getMessage(), QueryModuleError.SQL_EXCEPTION);
			throw queryModExp;
		}
		return query_execution_id;
	}
	
	public Count getCount(int query_execution_id) throws QueryModuleException
	{  
		CiderQueryManager queryManager = new CiderQueryManager();
		Count queryCount;
		try
		{
			queryCount = queryManager.getQueryCount(query_execution_id);
		}
		catch (DAOException e)
		{
			QueryModuleException queryModExp = new QueryModuleException(e.getMessage(), QueryModuleError.SQL_EXCEPTION);
			throw queryModExp;
		}
		catch (SQLException e)
		{
			QueryModuleException queryModExp = new QueryModuleException(e.getMessage(), QueryModuleError.SQL_EXCEPTION);
			throw queryModExp;
		}
		return queryCount;
	}
	
	private void updateQueryWithSelectedAttributes(AbstractQuery query)throws QueryModuleException
	{
		List<IOutputAttribute> selectedOutputAttributeList = new ArrayList<IOutputAttribute>();
		ParameterizedQuery parameterizedQuery = (ParameterizedQuery)query.getQuery();
		IConstraints constraints = parameterizedQuery.getConstraints();
		IExpression rootExpression;
		try
		{
			rootExpression = constraints.getRootExpression();

			Collection<AttributeInterface> allAttributes = rootExpression.getQueryEntity()
					.getDynamicExtensionsEntity().getAllAttributes();
			for (AttributeInterface attributeInterface : allAttributes)
			{
				if (attributeInterface.getName().equalsIgnoreCase("personUpi"))
				{
					IOutputAttribute createOutputAttribute = QueryObjectFactory
							.createOutputAttribute(rootExpression, attributeInterface);
					selectedOutputAttributeList.add(createOutputAttribute);
				}
			}
			parameterizedQuery.setOutputAttributeList(selectedOutputAttributeList);
		}
		catch (MultipleRootsException e)
		{
			QueryModuleException queryModuleException = new QueryModuleException(e.getMessage(),QueryModuleError.MULTIPLE_ROOT);
			throw queryModuleException;
		}
}
}

{'fraction_non_alphanumeric': 0.08453074433656958, 'fraction_numerical': 0.000517799352750809, 'mean_word_length': 4.550287356321839, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5564042', 'n_tokens_mistral': 2514, 'n_tokens_neox': 2319, 'n_words': 410}