<commit_before>/*******************************************************************************
 * Copyright 2015 EMBL - European Bioinformatics Institute
 *
 * Licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific
 * language governing permissions and limitations under the
 * License.
 *******************************************************************************/
package uk.ac.ebi.phenotype.web.controller;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotNull;

import org.mousephenotype.cda.utilities.HttpProxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;
import uk.ac.ebi.phenotype.generic.util.SolrIndex2;

@Controller
public class AllelesController {

    private final Logger log = LoggerFactory.getLogger(AllelesController.class);
    // TODO: get rid!
    private static final String VERSIONDATE = "Mon Oct 20 2014";

    @Autowired
    SolrIndex2 solrIndex2;

//    @RequestMapping("/alleles/project_id")
//    public String alleles1(
//            @RequestParam (value = "ikmc_project_id", required = true) String ikmc_project_id,
//            @RequestParam(value = "bare", required = false, defaultValue = "false") Boolean bare,
//            Model model,
//            HttpServletRequest request,
//            RedirectAttributes attributes) throws Exception {
//
//        Map<String, Object> gene;
//
//        if ( request.getParameter("bare") != null && request.getParameter("bare").equals("true")) {
//                log.info("Call SolrIndex2 with pipeline = Cre");
//        	gene = solrIndex2.getGeneByIkmcProjectId("cre", ikmc_project_id);
//        }
//        else {
//                log.info("Call SolrIndex2 with pipeline = impc");
//        	gene = solrIndex2.getGeneByIkmcProjectId("impc", ikmc_project_id);
//        }
//        log.info("GENE" + gene);
//        String acc = "MGI:1";
//        if (gene != null){
//            acc = gene.get("mgi_accession_id").toString();
//        }
//
//        model.addAttribute("acc", acc);
//
//        return geneAllelesCommon(acc, ikmc_project_id, null, null, bare, model, request, attributes);
//
//    }
//    
//
//
    @RequestMapping("/alleles/{acc}")
    public String alleles1(
            @PathVariable String acc,
            @RequestParam (value = "ikmc_project_id", required = false) String ikmc_project_id,
            @RequestParam (value = "allele_type", required = false) String allele_type,
            @RequestParam (value = "pipeline", required = false) String pipeline,
            @RequestParam(value = "bare", required = false, defaultValue = "false") Boolean bare,
            Model model,
            HttpServletRequest request,
            RedirectAttributes attributes) throws Exception {

        log.info("#### alleles1...");
        List<Map<String, Object>> list;
        String redirectUrl="redirect:search";
        if ( request.getParameter("bare") != null && request.getParameter("bare").equals("true")) {
                log.info("redirect to search with pipeline = Cre");
                redirectUrl=redirectUrl+"?creLine=true";
        }
        return redirectUrl;
    }


    @RequestMapping("/alleles/{acc}/{allele_name:.*}")
    public String alleles2(<commit_msg>search redirect from allele page working<commit_after>/*******************************************************************************
 * Copyright 2015 EMBL - European Bioinformatics Institute
 *
 * Licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific
 * language governing permissions and limitations under the
 * License.
 *******************************************************************************/
package uk.ac.ebi.phenotype.web.controller;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotNull;

import org.mousephenotype.cda.utilities.HttpProxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;
import uk.ac.ebi.phenotype.generic.util.SolrIndex2;

@Controller
public class AllelesController {

    private final Logger log = LoggerFactory.getLogger(AllelesController.class);
    // TODO: get rid!
    private static final String VERSIONDATE = "Mon Oct 20 2014";

    @Autowired
    SolrIndex2 solrIndex2;

//    @RequestMapping("/alleles/project_id")
//    public String alleles1(
//            @RequestParam (value = "ikmc_project_id", required = true) String ikmc_project_id,
//            @RequestParam(value = "bare", required = false, defaultValue = "false") Boolean bare,
//            Model model,
//            HttpServletRequest request,
//            RedirectAttributes attributes) throws Exception {
//
//        Map<String, Object> gene;
//
//        if ( request.getParameter("bare") != null && request.getParameter("bare").equals("true")) {
//                log.info("Call SolrIndex2 with pipeline = Cre");
//        	gene = solrIndex2.getGeneByIkmcProjectId("cre", ikmc_project_id);
//        }
//        else {
//                log.info("Call SolrIndex2 with pipeline = impc");
//        	gene = solrIndex2.getGeneByIkmcProjectId("impc", ikmc_project_id);
//        }
//        log.info("GENE" + gene);
//        String acc = "MGI:1";
//        if (gene != null){
//            acc = gene.get("mgi_accession_id").toString();
//        }
//
//        model.addAttribute("acc", acc);
//
//        return geneAllelesCommon(acc, ikmc_project_id, null, null, bare, model, request, attributes);
//
//    }
//    
//
//
    @RequestMapping("/alleles/{acc}")
    public String alleles1(
            @PathVariable String acc,
            @RequestParam (value = "ikmc_project_id", required = false) String ikmc_project_id,
            @RequestParam (value = "allele_type", required = false) String allele_type,
            @RequestParam (value = "pipeline", required = false) String pipeline,
            @RequestParam(value = "bare", required = false, defaultValue = "false") Boolean bare,
            Model model,
            HttpServletRequest request,
            RedirectAttributes attributes) throws Exception {

        log.info("#### alleles1...");
        String redirectUrl="redirect:/search";
        if ( request.getParameter("bare") != null && request.getParameter("bare").equals("true")) {
                log.info("redirect to search with pipeline = Cre");
                redirectUrl=redirectUrl+"?creLine=true";
        }
        return redirectUrl;
    }


    @RequestMapping("/alleles/{acc}/{allele_name:.*}")
    public String alleles2(
{'fraction_non_alphanumeric': 0.14870832413336277, 'fraction_numerical': 0.0061823802163833074, 'mean_word_length': 3.367888138862102, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6002361', 'n_tokens_mistral': 2510, 'n_tokens_neox': 2422, 'n_words': 611}