/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.mskcc.cbio.oncokb.controller;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.mskcc.cbio.oncokb.bo.EvidenceBo;
import org.mskcc.cbio.oncokb.bo.GeneBo;
import org.mskcc.cbio.oncokb.model.Evidence;
import org.mskcc.cbio.oncokb.model.Gene;
import org.mskcc.cbio.oncokb.util.ApplicationContextSingleton;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 *
 * @author jgao
 */
@Controller
public class EvidenceController {
    
    @RequestMapping(value="/evidence.json")
    public @ResponseBody List<Evidence> getEvidence(
            @RequestParam(value="entrezGeneId", required=false) Integer entrezGeneId,
            @RequestParam(value="hugoSymbol", required=false) String hugoSymbol) {
        
        GeneBo geneBo = ApplicationContextSingleton.getGeneBo();
        
        Gene gene = null; 
        if (entrezGeneId!=null) {
            gene = geneBo.findGeneByEntrezGeneId(entrezGeneId);
        } else if (hugoSymbol!=null) {
            gene = geneBo.findGeneByHugoSymbol(hugoSymbol);
        }
        
        EvidenceBo evidenceBo = ApplicationContextSingleton.getEvidenceBo();
        
        if (gene == null) {
            return evidenceBo.findAll();
        }
        
        return evidenceBo.findEvidencesByGene(gene);
    }
}

@@ -160,24 +160,53 @@
 .ArrayList;%0A
+import java.util.Collection;%0A
 import java.
@@ -363,21 +363,214 @@
 okb.
-model.Evidenc
+bo.AlterationBo;%0Aimport org.mskcc.cbio.oncokb.model.Alteration;%0Aimport org.mskcc.cbio.oncokb.model.AlterationType;%0Aimport org.mskcc.cbio.oncokb.model.Evidence;%0Aimport org.mskcc.cbio.oncokb.model.EvidenceTyp
 e;%0Ai
@@ -1249,16 +1249,167 @@
 goSymbol
+,%0A            @RequestParam(value=%22alteration%22, required=false) String alt,%0A            @RequestParam(value=%22type%22, required=false) String evidenceType
 ) %7B%0A    
@@ -1742,104 +1742,946 @@
     
-EvidenceBo evidenceBo = ApplicationContextSingleton.getEvidenceBo();%0A        %0A        if (gene =
+AlterationBo alterationBo = ApplicationContextSingleton.getAlterationBo();%0A        List%3CAlteration%3E alteration = new ArrayList%3CAlteration%3E();%0A        if (alt != null && gene != null) %7B%0A            Alteration alterationDatum = alterationBo.findAlteration(gene, AlterationType.MUTATION, alt);%0A            if(alterationDatum != null) %7B%0A                alteration.add(alterationDatum);%0A            %7D%0A        %7D%0A        EvidenceBo evidenceBo = ApplicationContextSingleton.getEvidenceBo();%0A        %0A        EvidenceType type = null;%0A        if(evidenceType != null) %7B%0A            EvidenceType%5B%5D types = EvidenceType.values();%0A            for (EvidenceType type1 : types) %7B%0A                if (evidenceType.toLowerCase().equals(type1.label().toLowerCase())) %7B%0A                    type = type1;%0A                    break;%0A                %7D%0A            %7D%0A        %7D%0A        %0A        if (gene != null && !alteration.isEmpty()) %7B%0A            if(type !
 = nu
@@ -2678,32 +2678,36 @@
 type != null) %7B%0A
+    
             retu
@@ -2728,15 +2728,151 @@
 find
-All();%0A
+EvidencesByAlteration(alteration, type);%0A            %7Delse %7B%0A                return evidenceBo.findEvidencesByAlteration(alteration);     %0A    
     
@@ -2868,32 +2868,39 @@
   %0A            %7D
+       
 %0A        %0A      
@@ -2896,61 +2896,316 @@
     
-%0A        return evidenceBo.findEvidencesByGene(gene);
+%7Delse if(gene != null && alteration.isEmpty()) %7B%0A            if(type != null) %7B%0A                return evidenceBo.findEvidencesByGene(gene, type);%0A            %7Delse %7B%0A                return evidenceBo.findEvidencesByGene(gene);%0A            %7D%0A        %7Delse %7B%0A            return evidenceBo.findAll();%0A        %7D
 %0A   

Add evidenceType and alteration support in EvidenceController