<commit_before>/**
 * <p>Title: SimpleSearchAction Class>
 * <p>Description:	SimpleSearchAction takes the conditions from the user, prepares, 
 * executes the query and shows the result in a spreadsheet view.</p>
 * Copyright:    Copyright (c) year
 * Company: Washington University, School of Medicine, St. Louis.
 * @author <NAME>
 * @version 1.00
 */
package edu.wustl.catissuecore.action;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;

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.SimpleQueryInterfaceForm;
import edu.wustl.catissuecore.bizlogic.SimpleQueryBizLogic;
import edu.wustl.catissuecore.query.Query;
import edu.wustl.catissuecore.query.QueryFactory;
import edu.wustl.catissuecore.query.SimpleQuery;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.common.util.MapDataParser;
import edu.wustl.common.util.logger.Logger;

/**
 * SimpleSearchAction takes the conditions from the user, prepares, 
 * executes the query and shows the result in a spreadsheet view.      
 * @author gautam_shetty
 */
public class SimpleSearchAction extends BaseAction {

	public ActionForward executeAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		SimpleQueryInterfaceForm simpleQueryInterfaceForm = (SimpleQueryInterfaceForm) form;
		// -------- set the selected menu ------- start
		String strMenu = simpleQueryInterfaceForm.getMenuSelected();
		request.setAttribute(Constants.MENU_SELECTED, strMenu);
		Logger.out.debug(Constants.MENU_SELECTED
				+ " set in SimpleSearch Action : -- " + strMenu);
		// -------- set the selected menu ------- end
		HttpSession session = request.getSession();

		String target = Constants.SUCCESS;

		Map map = simpleQueryInterfaceForm.getValuesMap();

		//If map from session is null get the map values from form.
		if (map.size() == 0) 
			map = (Map) session.getAttribute(Constants.SIMPLE_QUERY_MAP);

		session.setAttribute(Constants.SIMPLE_QUERY_MAP, map);
		Logger.out.debug("map after setting in session"+map);
		

		MapDataParser parser = new MapDataParser("edu.wustl.catissuecore.query");
		Collection simpleConditionNodeCollection = parser.generateData(map,
				true);

		Map queryResultObjectDataMap = new HashMap();

		SimpleQueryBizLogic simpleQueryBizLogic = new SimpleQueryBizLogic();

		// Get the alias name of the first object in the condition.
		String viewAliasName = (String) map
				.get("SimpleConditionsNode:1_Condition_DataElement_table");

		// Instantiating the query object.
		Query query = QueryFactory.getInstance().newQuery(Query.SIMPLE_QUERY,
				viewAliasName);

		// Puts the single quotes for attributes of type string and date and
		// returns the Set of objects to which the attributes belong.
		Set fromTables = new HashSet();
		simpleQueryBizLogic.handleStringAndDateConditions(
				simpleConditionNodeCollection, fromTables);

		

		// Get the configured result view columns else is null.
		String[] selectedColumns = simpleQueryInterfaceForm
				.getSelectedColumnNames();

		// Set the result view for the query.
		List columnNames = new ArrayList();
		Vector selectDataElements = simpleQueryBizLogic.getSelectDataElements(
				selectedColumns, fromTables, columnNames);
		query.setResultView(selectDataElements);

		// Set the from tables in the query.
		query.setTableSet(fromTables);

		// Checks and gets the activity status conditions for all the objects in
		// the from clause
		// and adds it in the simple conditions node collection.
		simpleQueryBizLogic.addActivityStatusConditions(
				simpleConditionNodeCollection, fromTables);

		// Sets the condition objects from user in the query object.
		((SimpleQuery) query).addConditions(simpleConditionNodeCollection);

		// List of results the query will return on execution.
		List list = null;
		if (simpleQueryInterfaceForm.getPageOf().equals(
				Constants.PAGEOF_SIMPLE_QUERY_INTERFACE)<commit_msg>Session Attribute for configure select columns is set<commit_after>/**
 * <p>Title: SimpleSearchAction Class>
 * <p>Description:	SimpleSearchAction takes the conditions from the user, prepares, 
 * executes the query and shows the result in a spreadsheet view.</p>
 * Copyright:    Copyright (c) year
 * Company: Washington University, School of Medicine, St. Louis.
 * @author <NAME>
 * @version 1.00
 */
package edu.wustl.catissuecore.action;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;

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.SimpleQueryInterfaceForm;
import edu.wustl.catissuecore.bizlogic.SimpleQueryBizLogic;
import edu.wustl.catissuecore.query.Query;
import edu.wustl.catissuecore.query.QueryFactory;
import edu.wustl.catissuecore.query.SimpleQuery;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.common.util.MapDataParser;
import edu.wustl.common.util.logger.Logger;

/**
 * SimpleSearchAction takes the conditions from the user, prepares, 
 * executes the query and shows the result in a spreadsheet view.      
 * @author gautam_shetty
 */
public class SimpleSearchAction extends BaseAction {

	public ActionForward executeAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		SimpleQueryInterfaceForm simpleQueryInterfaceForm = (SimpleQueryInterfaceForm) form;
		// -------- set the selected menu ------- start
		String strMenu = simpleQueryInterfaceForm.getMenuSelected();
		request.setAttribute(Constants.MENU_SELECTED, strMenu);
		Logger.out.debug(Constants.MENU_SELECTED
				+ " set in SimpleSearch Action : -- " + strMenu);
		// -------- set the selected menu ------- end
		HttpSession session = request.getSession();

		String target = Constants.SUCCESS;

		Map map = simpleQueryInterfaceForm.getValuesMap();

		//If map from session is null get the map values from form.
		if (map.size() == 0) 
			map = (Map) session.getAttribute(Constants.SIMPLE_QUERY_MAP);

		session.setAttribute(Constants.SIMPLE_QUERY_MAP, map);
		Logger.out.debug("map after setting in session"+map);
		

		MapDataParser parser = new MapDataParser("edu.wustl.catissuecore.query");
		Collection simpleConditionNodeCollection = parser.generateData(map,
				true);

		Map queryResultObjectDataMap = new HashMap();

		SimpleQueryBizLogic simpleQueryBizLogic = new SimpleQueryBizLogic();

		// Get the alias name of the first object in the condition.
		String viewAliasName = (String) map
				.get("SimpleConditionsNode:1_Condition_DataElement_table");

		// Instantiating the query object.
		Query query = QueryFactory.getInstance().newQuery(Query.SIMPLE_QUERY,
				viewAliasName);

		// Puts the single quotes for attributes of type string and date and
		// returns the Set of objects to which the attributes belong.
		Set fromTables = new HashSet();
		simpleQueryBizLogic.handleStringAndDateConditions(
				simpleConditionNodeCollection, fromTables);

		

		// Get the configured result view columns else is null.
		String[] selectedColumns = simpleQueryInterfaceForm
				.getSelectedColumnNames();
		if(selectedColumns!=null)
			session.setAttribute(Constants.CONFIGURED_SELECT_COLUMN_LIST,selectedColumns);
			

		// Set the result view for the query.
		List columnNames = new ArrayList();
		Vector selectDataElements = simpleQueryBizLogic.getSelectDataElements(
				selectedColumns, fromTables, columnNames);
		query.setResultView(selectDataElements);

		// Set the from tables in the query.
		query.setTableSet(fromTables);

		// Checks and gets the activity status conditions for all the objects in
		// the from clause
		// and adds it in the simple conditions node collection.
		simpleQueryBizLogic.addActivityStatusConditions(
				simpleConditionNodeCollection, fromTables);

		// Sets the condition objects from user in the query object.
		((SimpleQuery) query).addConditions(simpleConditionNodeCollection);

		// List of results the query will return on execution.
		List list = null;
		if (simpleQueryInterfaceForm.getPageOf().equals(
				Constants.PAGEOF_SIMPLE_QUERY_INTERFACE)
{'fraction_non_alphanumeric': 0.09125055236411843, 'fraction_numerical': 0.001104728236853734, 'mean_word_length': 4.682988072818581, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '5527095', 'n_tokens_mistral': 2744, 'n_tokens_neox': 2508, 'n_words': 706}