<commit_before><%@ page import="org.mskcc.cbio.portal.servlet.ServletXssUtil" %>
<%@ page import="org.mskcc.cbio.portal.util.XssRequestWrapper" %>
<%@ page import="java.util.HashSet" %>
<%@ page import="org.mskcc.cbio.portal.servlet.QueryBuilder" %>
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%
    //Security Instance
    ServletXssUtil xssUtil = ServletXssUtil.getInstance();

    //Info about Genetic Profiles
    HashSet<String> geneticProfileIdSet = (HashSet<String>) request.getAttribute(QueryBuilder.GENETIC_PROFILE_IDS);
    String geneticProfiles = StringUtils.join(geneticProfileIdSet.iterator(), " ");
    geneticProfiles = xssUtil.getCleanerInput(geneticProfiles.trim());

    //Info about threshold settings
    String zScoreThreshold = String.valueOf(request.getAttribute(QueryBuilder.Z_SCORE_THRESHOLD));
    String rppaScoreThreshold = String.valueOf(request.getAttribute(QueryBuilder.RPPA_SCORE_THRESHOLD));

    //Onco Query Language Parser Instance
    String oql = request.getParameter(QueryBuilder.GENE_LIST);
    if (request instanceof XssRequestWrapper) {
        oql = ((XssRequestWrapper)request).getRawParameter(QueryBuilder.GENE_LIST);
    }
    oql = xssUtil.getCleanerInput(oql);

    String studySampleMapJson = (String)request.getAttribute("STUDY_SAMPLE_MAP");
    String sampleSetId = (String) request.getAttribute(QueryBuilder.CASE_SET_ID);
    String sampleSetName = request.getAttribute("case_set_name") != null ? (String) request.getAttribute("case_set_name") : "User-defined Patient List";
    String sampleSetDescription = request.getAttribute("case_set_description") != null ? (String) request.getAttribute("case_set_description") : "User-defined Patient List.";
    String sampleIdsKey = request.getAttribute(QueryBuilder.CASE_IDS_KEY) != null ? (String) request.getAttribute(QueryBuilder.CASE_IDS_KEY) : "";

    sampleSetName = sampleSetName.replaceAll("'", "\\'");
    sampleSetName = sampleSetName.replaceAll("\"", "\\\"");
    
    Integer dataPriority = (Integer) request.getAttribute(QueryBuilder.DATA_PRIORITY);
%>

<script type="text/javascript">
    function jspToJs(val, processFn) {
        processFn = processFn || function(x){ return x; };
        if (val === "null") {
            return undefined;
        } else {
            return processFn(val);
        }
    }
    
    var molecularProfiles = '<%=geneticProfiles%>'.trim();
    if (molecularProfiles.length) {
        molecularProfiles = molecularProfiles.split(/\s+/);
    } else {
        molecularProfiles = undefined;
    }
    
    window.serverVars = {
    
        molecularProfiles : molecularProfiles,
        caseSetProperties :  {
                case_set_id: jspToJs('<%=sampleSetId%>'),
                case_ids_key: jspToJs('<%=sampleIdsKey%>'),
                case_set_name: jspToJs('<%=sampleSetName%>'),
                case_set_description: jspToJs('<%=sampleSetDescription%>')
            },
            

        zScoreThreshold:jspToJs('<%=zScoreThreshold%>', parseFloat),
        rppaScoreThreshold:jspToJs('<%=rppaScoreThreshold%>', parseFloat),
        dataPriority:jspToJs('<%=dataPriority%>', function(d) { return parseInt(d, 10); }),
        
        theQuery: jspToJs('<%=oql%>'.trim()) || "", 
        studySampleObj: jspToJs('<%=studySampleMapJson%>', JSON.parse)
       	
    };
    
    if (window.serverVars.studySampleObj) {
        window.serverVars.studySampleListMap = (function(){<commit_msg>move two props to serverVars for reading by new frontend<commit_after><%@ page import="org.mskcc.cbio.portal.servlet.ServletXssUtil" %>
<%@ page import="org.mskcc.cbio.portal.util.XssRequestWrapper" %>
<%@ page import="java.util.HashSet" %>
<%@ page import="org.mskcc.cbio.portal.servlet.QueryBuilder" %>
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%
    //Security Instance
    ServletXssUtil xssUtil = ServletXssUtil.getInstance();

    //Info about Genetic Profiles
    HashSet<String> geneticProfileIdSet = (HashSet<String>) request.getAttribute(QueryBuilder.GENETIC_PROFILE_IDS);
    String geneticProfiles = StringUtils.join(geneticProfileIdSet.iterator(), " ");
    geneticProfiles = xssUtil.getCleanerInput(geneticProfiles.trim());

    //Info about threshold settings
    String zScoreThreshold = String.valueOf(request.getAttribute(QueryBuilder.Z_SCORE_THRESHOLD));
    String rppaScoreThreshold = String.valueOf(request.getAttribute(QueryBuilder.RPPA_SCORE_THRESHOLD));

    //Onco Query Language Parser Instance
    String oql = request.getParameter(QueryBuilder.GENE_LIST);
    if (request instanceof XssRequestWrapper) {
        oql = ((XssRequestWrapper)request).getRawParameter(QueryBuilder.GENE_LIST);
    }
    oql = xssUtil.getCleanerInput(oql);

    String studySampleMapJson = (String)request.getAttribute("STUDY_SAMPLE_MAP");
    String sampleSetId = (String) request.getAttribute(QueryBuilder.CASE_SET_ID);
    String sampleSetName = request.getAttribute("case_set_name") != null ? (String) request.getAttribute("case_set_name") : "User-defined Patient List";
    String sampleSetDescription = request.getAttribute("case_set_description") != null ? (String) request.getAttribute("case_set_description") : "User-defined Patient List.";
    String sampleIdsKey = request.getAttribute(QueryBuilder.CASE_IDS_KEY) != null ? (String) request.getAttribute(QueryBuilder.CASE_IDS_KEY) : "";

    sampleSetName = sampleSetName.replaceAll("'", "\\'");
    sampleSetName = sampleSetName.replaceAll("\"", "\\\"");
    
    Integer dataPriority = (Integer) request.getAttribute(QueryBuilder.DATA_PRIORITY);
%>

<script type="text/javascript">
    function jspToJs(val, processFn) {
        processFn = processFn || function(x){ return x; };
        if (val === "null") {
            return undefined;
        } else {
            return processFn(val);
        }
    }
    
    var molecularProfiles = '<%=geneticProfiles%>'.trim();
    if (molecularProfiles.length) {
        molecularProfiles = molecularProfiles.split(/\s+/);
    } else {
        molecularProfiles = undefined;
    }
    
    window.serverVars = {
    
        molecularProfiles : molecularProfiles,
        caseSetProperties :  {
                case_set_id: jspToJs('<%=sampleSetId%>'),
                case_ids_key: jspToJs('<%=sampleIdsKey%>'),
                case_set_name: jspToJs('<%=sampleSetName%>'),
                case_set_description: jspToJs('<%=sampleSetDescription%>')
            },
            
        cohortIdsList : (cancerStudyIdList === 'null')? [cancerStudyId]: cancerStudyIdList.split(','),
        isVirtualStudy : <%=isVirtualStudy%>,
        zScoreThreshold:jspToJs('<%=zScoreThreshold%>', parseFloat),
        rppaScoreThreshold:jspToJs('<%=rppaScoreThreshold%>', parseFloat),
        dataPriority:jspToJs('<%=dataPriority%>', function(d) { return parseInt(d, 10); }),
        
        theQuery: jspToJs('<%=oql%>'.trim()) || "", 
        studySampleObj: jspToJs('<%=studySampleMapJson%>', JSON.parse)
       	
    };
    
    if (window.serverVars.studySampleObj) {
        window.serverVars.studySampleListMap = (function(){
{'fraction_non_alphanumeric': 0.13761080624736174, 'fraction_numerical': 0.0005628253834247924, 'mean_word_length': 3.8222523744911805, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 42, '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': '5214373', 'n_tokens_mistral': 2172, 'n_tokens_neox': 2125, 'n_words': 319}