<commit_before>/*
 * Created on Jul 3, 2006
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

package edu.wustl.catissuecore.action;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.Vector;

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

import net.sf.ehcache.CacheException;

import org.apache.struts.Globals;
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.StorageContainerForm;
import edu.wustl.catissuecore.bizlogic.BizLogicFactory;
import edu.wustl.catissuecore.bizlogic.StorageContainerBizLogic;
import edu.wustl.catissuecore.bizlogic.UserBizLogic;
import edu.wustl.catissuecore.domain.Site;
import edu.wustl.catissuecore.domain.SpecimenArrayType;
import edu.wustl.catissuecore.domain.StorageContainer;
import edu.wustl.catissuecore.domain.StorageType;
import edu.wustl.catissuecore.util.StorageContainerUtil;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.catissuecore.util.global.Utility;
import edu.wustl.common.action.SecureAction;
import edu.wustl.common.beans.NameValueBean;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.bizlogic.IBizLogic;
import edu.wustl.common.util.global.ApplicationProperties;
import edu.wustl.common.util.logger.Logger;

/**
 * @author vaishali_khandelwal
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class SimilarContainersAction extends SecureAction
{

	/* (non-Javadoc)
	 * @see edu.wustl.common.action.SecureAction#executeSecureAction(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	protected ActionForward executeSecureAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
			throws Exception
	{
		Logger.out.debug("SimilarContainersAction : executeSecureAction() form: type " + form.getClass());
		
		List<NameValueBean> storagePositionListForTransferEvent = Utility.getStoragePositionTypeListForTransferEvent();
		request.setAttribute("storageListForTransferEvent", storagePositionListForTransferEvent);

		StorageContainerForm similarContainersForm = (StorageContainerForm) form;
		//boolean to indicate whether the suitable containers to be shown in dropdown 
		//is exceeding the max limit.
		String exceedingMaxLimit = "false";
		StorageContainerBizLogic bizLogic = (StorageContainerBizLogic) BizLogicFactory.getInstance().getBizLogic(Constants.STORAGE_CONTAINER_FORM_ID);
		String selectedParentContainer=similarContainersForm.getParentContainerSelected();
		if (similarContainersForm.getSpecimenOrArrayType() == null)
		{
			similarContainersForm.setSpecimenOrArrayType("Specimen");
		}
		Logger.out.info(" Map:---------------" + similarContainersForm.getSimilarContainersMap());
		IBizLogic ibizLogic = BizLogicFactory.getInstance().getBizLogic(Constants.DEFAULT_BIZ_LOGIC);
		
		//request = Utility.setCollectionProtocolList(request,similarContainersForm.getSiteId());
		if ("Site".equals(similarContainersForm.getParentContainerSelected()))
		{
			request = Utility.setCollectionProtocolList(request, similarContainersForm.getSiteId());
		}
		else if ("Auto".equals(similarContainersForm.getParentContainerSelected()))
		{
			Site site = bizLogic.getRelatedSite(similarContainersForm.getParentContainerId());
			if(site!=null)
			{
				request = Utility.setCollectionProtocolList(request, site.getId());
			}
		}
		else if ("Manual".equals(similarContainersForm.getParentContainerSelected()))
		{
			Site site = bizLogic.getRelatedSiteForManual(similarContainersForm.getSelectedContainerName());
			if(site!=null)
			{
				request = Utility.setCollectionProtocolList(request, site.getId());
			}
		}
		
		//Gets the Storage Type List and sets it in request 
		List list2 = ibizLogic.retrieve(StorageType.class.getName());<commit_msg>cpList is set in case of site is null for Auto or Manual parent Container selected<commit_after>/*
 * Created on Jul 3, 2006
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

package edu.wustl.catissuecore.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.Vector;

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

import net.sf.ehcache.CacheException;

import org.apache.struts.Globals;
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.StorageContainerForm;
import edu.wustl.catissuecore.bizlogic.BizLogicFactory;
import edu.wustl.catissuecore.bizlogic.StorageContainerBizLogic;
import edu.wustl.catissuecore.bizlogic.UserBizLogic;
import edu.wustl.catissuecore.domain.Site;
import edu.wustl.catissuecore.domain.SpecimenArrayType;
import edu.wustl.catissuecore.domain.StorageContainer;
import edu.wustl.catissuecore.domain.StorageType;
import edu.wustl.catissuecore.util.StorageContainerUtil;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.catissuecore.util.global.Utility;
import edu.wustl.common.action.SecureAction;
import edu.wustl.common.beans.NameValueBean;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.bizlogic.IBizLogic;
import edu.wustl.common.util.global.ApplicationProperties;
import edu.wustl.common.util.logger.Logger;

/**
 * @author vaishali_khandelwal
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class SimilarContainersAction extends SecureAction
{

	/* (non-Javadoc)
	 * @see edu.wustl.common.action.SecureAction#executeSecureAction(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	protected ActionForward executeSecureAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
			throws Exception
	{
		Logger.out.debug("SimilarContainersAction : executeSecureAction() form: type " + form.getClass());
		
		List<NameValueBean> storagePositionListForTransferEvent = Utility.getStoragePositionTypeListForTransferEvent();
		request.setAttribute("storageListForTransferEvent", storagePositionListForTransferEvent);

		StorageContainerForm similarContainersForm = (StorageContainerForm) form;
		//boolean to indicate whether the suitable containers to be shown in dropdown 
		//is exceeding the max limit.
		String exceedingMaxLimit = "false";
		StorageContainerBizLogic bizLogic = (StorageContainerBizLogic) BizLogicFactory.getInstance().getBizLogic(Constants.STORAGE_CONTAINER_FORM_ID);
		String selectedParentContainer=similarContainersForm.getParentContainerSelected();
		if (similarContainersForm.getSpecimenOrArrayType() == null)
		{
			similarContainersForm.setSpecimenOrArrayType("Specimen");
		}
		Logger.out.info(" Map:---------------" + similarContainersForm.getSimilarContainersMap());
		IBizLogic ibizLogic = BizLogicFactory.getInstance().getBizLogic(Constants.DEFAULT_BIZ_LOGIC);
		
		//request = Utility.setCollectionProtocolList(request,similarContainersForm.getSiteId());
		if ("Site".equals(similarContainersForm.getParentContainerSelected()))
		{
			request = Utility.setCollectionProtocolList(request, similarContainersForm.getSiteId());
		}
		else if ("Auto".equals(similarContainersForm.getParentContainerSelected()))
		{
			long parentContId = similarContainersForm.getParentContainerId();
			
			Site site = bizLogic.getRelatedSite(parentContId);
			if(site!=null)
			{
				request = Utility.setCollectionProtocolList(request, site.getId());
			}
			else
			{
				List<NameValueBean> cpList = new ArrayList<NameValueBean>();
				Map<Long,String> cpTitleMap = new HashMap<Long,String>();
				request.setAttribute(Constants.PROTOCOL_LIST, cpList);
				request.setAttribute(Constants.CP_ID_TITLE_MAP, cpTitleMap);
			}
		}
		else if ("Manual".equals(similarContainersForm.getParentContainerSelected()))
		{
			String selectedContName = similarContainersForm.getSelectedContainerName();
			
			Site site = bizLogic.getRelatedSiteForManual(selectedContName);
			if(site!=null)
			{
				request = Utility.setCollectionProtocolList(request, site.getId());
			}
			else
			{
				List<NameValueBean> cpList = new ArrayList<NameValueBean>();
				Map<Long,String> cpTitleMap = new HashMap<Long,String>();
				request.setAttribute(Constants.PROTOCOL_LIST, cpList);
				request.setAttribute(Constants.CP_ID_TITLE_MAP, cpTitleMap);
			}
		}
		
		//Gets the Storage Type List and sets it in request 
		List list2 = ibizLogic.retrieve(StorageType.class.getName());
{'fraction_non_alphanumeric': 0.10208399449910081, 'fraction_numerical': 0.0012694382735639479, 'mean_word_length': 5.84081041968162, 'pattern_counts': {'":': 0, '<': 13, '<?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': '1464654', 'n_tokens_mistral': 3066, 'n_tokens_neox': 2831, 'n_words': 500}