<commit_before>/**
 * 
 */

package edu.wustl.catissuecore.action.querysuite;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import edu.wustl.catissuecore.actionForm.querysuite.SaveQueryForm;
import edu.wustl.catissuecore.applet.AppletConstants;
import edu.wustl.catissuecore.bizlogic.querysuite.CreateQueryObjectBizLogic;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.common.action.BaseAction;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.bizlogic.IBizLogic;
import edu.wustl.common.exception.BizLogicException;
import edu.wustl.common.factory.AbstractBizLogicFactory;
import edu.wustl.common.querysuite.queryobject.IOutputAttribute;
import edu.wustl.common.querysuite.queryobject.IParameterizedQuery;
import edu.wustl.common.querysuite.queryobject.IQuery;
import edu.wustl.common.querysuite.queryobject.impl.ParameterizedQuery;
import edu.wustl.common.querysuite.queryobject.impl.metadata.SelectedColumnsMetadata;
import edu.wustl.common.security.exceptions.UserNotAuthorizedException;
import edu.wustl.common.util.global.ApplicationProperties;
import edu.wustl.common.util.logger.Logger;

/**
 * This class saves the Query in Dag into database.
 * 
 * @author chetan_patil
 * @created Sep 11, 2007, 3:50:16 PM
 */
public class SaveQueryAction extends BaseAction
{

	protected ActionForward executeAction(ActionMapping actionMapping, ActionForm actionForm,
			HttpServletRequest request, HttpServletResponse response) throws Exception
	{ 
		HttpSession session = request.getSession();
		IQuery query = (IQuery) session.getAttribute(AppletConstants.QUERY_OBJECT);
		String target = Constants.FAILURE;
		if (query != null)
		{
			/**
			 * Name: <NAME>
			 * Reviewer Name : Deepti 
			 * Bug ID: 5661
			 * Patch ID: 5661_3
			 * See also: 1-4 
			 * Description : Calling bizlogic insert and update
			 */
			
			IParameterizedQuery parameterizedQuery = populateParameterizedQueryData(query,
					actionForm, request);
			try
			{
				IBizLogic bizLogic = AbstractBizLogicFactory.getBizLogic(ApplicationProperties
						.getValue("app.bizLogicFactory"), "getBizLogic",
						Constants.CATISSUECORE_QUERY_INTERFACE_ID);
				if (query.getId() != null && query instanceof ParameterizedQuery)
				{
					bizLogic.update(parameterizedQuery, Constants.HIBERNATE_DAO);
					Logger.out.info(ApplicationProperties.getValue("query.update.info"));
				}
				else
				{
					bizLogic.insert(parameterizedQuery, Constants.HIBERNATE_DAO);
					Logger.out.info(ApplicationProperties.getValue("query.saved.info"));
				}
				target = Constants.SUCCESS;
				ActionErrors errors = new ActionErrors();
				ActionError error = new ActionError("query.saved.success");
				errors.add(ActionErrors.GLOBAL_ERROR, error);
				saveErrors(request, errors);
				
				request.setAttribute(Constants.QUERY_SAVED, Constants.TRUE);
			}
			catch (BizLogicException bizLogicException)
			{
				setActionError(request, bizLogicException.getMessage());
				Logger.out.error(bizLogicException.getMessage(), bizLogicException);
			}
			catch (UserNotAuthorizedException userNotAuthorizedException)
			{
				SessionDataBean sessionDataBean = getSessionData(request);
				String userName = "";
				if (sessionDataBean != null)
				{
					userName = sessionDataBean.getUserName();
				}

				ActionErrors errors = new ActionErrors();
				ActionError error = new ActionError("access.addedit.object.denied", userName,
						parameterizedQuery.getClass().getName());
				errors.add(ActionErrors.GLOBAL_ERROR, error);
				saveErrors(request, errors);

				Logger.out.error(userNotAuthorizedException.getMessage(),
						userNotAuthorizedException);
			}
		}
		else
		{
			// Handle null query 
			String errorMsg = ApplicationProperties.getValue("query.noLimit.error");
			setActionError(request,errorMsg);
		}
		return actionMapping.findForward(target);
	}

	/**
	 * This method sets the error action 
	 * @param request
	 * @param errorMessage
	 */
	private void setActionError(HttpServletRequest request, String errorMessage)
	{
		ActionErrors errors = new ActionErrors();
		ActionError error = new ActionError("errors.item", errorMessage);
		errors.add(ActionErrors.GLOBAL_ERROR, error);
		saveErrors(request, errors);
	}
<commit_msg>Made temporal query related changes<commit_after>/**
 * 
 */

package edu.wustl.catissuecore.action.querysuite;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import edu.wustl.catissuecore.actionForm.querysuite.SaveQueryForm;
import edu.wustl.catissuecore.applet.AppletConstants;
import edu.wustl.catissuecore.bizlogic.querysuite.CreateQueryObjectBizLogic;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.common.action.BaseAction;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.bizlogic.IBizLogic;
import edu.wustl.common.exception.BizLogicException;
import edu.wustl.common.factory.AbstractBizLogicFactory;
import edu.wustl.common.querysuite.queryobject.IOutputAttribute;
import edu.wustl.common.querysuite.queryobject.IParameterizedQuery;
import edu.wustl.common.querysuite.queryobject.IQuery;
import edu.wustl.common.querysuite.queryobject.impl.ParameterizedQuery;
import edu.wustl.common.querysuite.queryobject.impl.metadata.SelectedColumnsMetadata;
import edu.wustl.common.security.exceptions.UserNotAuthorizedException;
import edu.wustl.common.util.global.ApplicationProperties;
import edu.wustl.common.util.logger.Logger;

/**
 * This class saves the Query in Dag into database.
 * 
 * @author chetan_patil
 * @created Sep 11, 2007, 3:50:16 PM
 */
public class SaveQueryAction extends BaseAction
{

	protected ActionForward executeAction(ActionMapping actionMapping, ActionForm actionForm,
			HttpServletRequest request, HttpServletResponse response) throws Exception
	{ 
		HttpSession session = request.getSession();
		IQuery query = (IQuery) session.getAttribute(AppletConstants.QUERY_OBJECT);
		String target = Constants.FAILURE;
		if (query != null)
		{
			/**
			 * Name: <NAME>
			 * Reviewer Name : Deepti 
			 * Bug ID: 5661
			 * Patch ID: 5661_3
			 * See also: 1-4 
			 * Description : Calling bizlogic insert and update
			 */
			
			IParameterizedQuery parameterizedQuery = populateParameterizedQueryData(query,
					actionForm, request);
			if(parameterizedQuery != null)
			{
			try
			{
				IBizLogic bizLogic = AbstractBizLogicFactory.getBizLogic(ApplicationProperties
						.getValue("app.bizLogicFactory"), "getBizLogic",
						Constants.CATISSUECORE_QUERY_INTERFACE_ID);
				if (query.getId() != null && query instanceof ParameterizedQuery)
				{
					bizLogic.update(parameterizedQuery, Constants.HIBERNATE_DAO);
					Logger.out.info(ApplicationProperties.getValue("query.update.info"));
				}
				else
				{
					bizLogic.insert(parameterizedQuery, Constants.HIBERNATE_DAO);
					Logger.out.info(ApplicationProperties.getValue("query.saved.info"));
				}
				target = Constants.SUCCESS;
				ActionErrors errors = new ActionErrors();
				ActionError error = new ActionError("query.saved.success");
				errors.add(ActionErrors.GLOBAL_ERROR, error);
				saveErrors(request, errors);
				
				request.setAttribute(Constants.QUERY_SAVED, Constants.TRUE);
			}
			catch (BizLogicException bizLogicException)
			{
				setActionError(request, bizLogicException.getMessage());
				Logger.out.error(bizLogicException.getMessage(), bizLogicException);
			}
			catch (UserNotAuthorizedException userNotAuthorizedException)
			{
				SessionDataBean sessionDataBean = getSessionData(request);
				String userName = "";
				if (sessionDataBean != null)
				{
					userName = sessionDataBean.getUserName();
				}

				ActionErrors errors = new ActionErrors();
				ActionError error = new ActionError("access.addedit.object.denied", userName,
						parameterizedQuery.getClass().getName());
				errors.add(ActionErrors.GLOBAL_ERROR, error);
				saveErrors(request, errors);

				Logger.out.error(userNotAuthorizedException.getMessage(),
						userNotAuthorizedException);
			}
		}else
		{
			String errorMessage = ApplicationProperties.getValue("save.query.tq.error");
			setActionError(request,errorMessage);
		}
	}
		else
		{
			// Handle null query 
			String errorMsg = ApplicationProperties.getValue("query.noLimit.error");
			setActionError(request,errorMsg);
		}
		return actionMapping.findForward(target);
	}

	/**
	 * This method sets the error action 
	 * @param request
	 * @param errorMessage
	 */
	private void setActionError(HttpServletRequest request, String errorMessage)
	{
		ActionErrors errors = new ActionErrors();
		ActionError error = new ActionError("errors.item", errorMessage);
		errors.add(ActionErrors.GLOBAL_ERROR, error);
		saveErrors(request, errors);
	}

{'fraction_non_alphanumeric': 0.10176206860598477, 'fraction_numerical': 0.00458763424043374, 'mean_word_length': 4.820388349514563, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1920388', 'n_tokens_mistral': 3378, 'n_tokens_neox': 2938, 'n_words': 503}