package uk.ac.ebi.atlas.widget;

import org.springframework.context.annotation.Scope;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJacksonJsonView;
import uk.ac.ebi.atlas.search.analyticsindex.baseline.BaselineAnalyticsSearchService;
import uk.ac.ebi.atlas.trader.cache.OrganismsCache;
import uk.ac.ebi.atlas.search.SemanticQuery;

import javax.inject.Inject;

@Controller
@Scope("request")
public final class ExpressionDataController {

    private BaselineAnalyticsSearchService baselineAnalyticsSearchService;
    private OrganismsCache organismsCache;

    @Inject
    public ExpressionDataController(BaselineAnalyticsSearchService baselineAnalyticsSearchService,
                                    OrganismsCache organismsCache) {
        this.baselineAnalyticsSearchService = baselineAnalyticsSearchService;
        this.organismsCache = organismsCache;
    }

    @RequestMapping(value = "/json/expressionData", method = RequestMethod.GET, produces = "application/json")
    @ResponseStatus(HttpStatus.OK)
    public ModelAndView existGeneIdentifier(@RequestParam(value = "geneId", required = true) String geneId ) {
        ModelAndView mav = new ModelAndView(new MappingJacksonJsonView());
        boolean results = baselineAnalyticsSearchService.tissueExpressionAvailableFor(SemanticQuery.create(geneId));
        mav.addObject(geneId, results);
        return mav;
    }

    @RequestMapping(value = "/json/expressionData/species", method = RequestMethod.GET, produces = "application/json")
    @ResponseStatus(HttpStatus.OK)
    public ModelAndView existSpeciesForGeneIdentifier() {
        ModelAndView mav = new ModelAndView(new MappingJacksonJsonView());
        mav.addObject("species", organismsCache.getOrganismsList());
        return mav;
    }

}

@@ -597,25 +597,8 @@
 dex.
-baseline.Baseline
 Anal
@@ -833,24 +833,16 @@
 private 
-Baseline
 Analytic
@@ -852,33 +852,25 @@
 archService 
-baselineA
+a
 nalyticsSear
@@ -976,16 +976,8 @@
 ler(
-Baseline
 Anal
@@ -995,25 +995,17 @@
 Service 
-baselineA
+a
 nalytics
@@ -1101,25 +1101,17 @@
    this.
-baselineA
+a
 nalytics
@@ -1126,25 +1126,17 @@
 rvice = 
-baselineA
+a
 nalytics
@@ -1427,25 +1427,8 @@
 eId%22
-, required = true
 ) St
@@ -1548,17 +1548,9 @@
 s = 
-baselineA
+a
 naly

Use new method in AnalyticsClient to show available expression data in tissues