package org.pdxfinder.web.controllers;

import org.pdxfinder.services.GraphService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/*
 * Created by csaba on 02/02/2018.
 */
@RestController
public class AutoSuggestController {

    private GraphService graphService;

    public AutoSuggestController(GraphService graphService) {
        this.graphService = graphService;
    }



    @RequestMapping(value = "/autosuggests")
    List<AutoSuggestOption> getAutoSuggestList(){
        List<AutoSuggestOption> autoSuggestList = new ArrayList<>();

        Set<String> ncitTerms = graphService.getMappedNCITTerms();

        for(String term:ncitTerms){
            autoSuggestList.add(new AutoSuggestOption(term, "OntologyTerm"));
        }

        return autoSuggestList;

    }



}

@@ -63,28 +63,131 @@
 ervices.
-GraphService
+AutoCompleteService;%0Aimport org.pdxfinder.services.GraphService;%0Aimport org.pdxfinder.services.ds.AutoSuggestOption
 ;%0Aimport
@@ -489,34 +489,48 @@
 private 
-GraphService graph
+AutoCompleteService autoComplete
 Service;
@@ -568,70 +568,98 @@
 ler(
-GraphService graphService) %7B%0A        this.graphService = graph
+AutoCompleteService autoCompleteService) %7B%0A        this.autoCompleteService = autoComplete
 Serv
@@ -670,18 +670,16 @@
 %0A    %7D%0A%0A
-%0A%0A
     @Req
@@ -765,24 +765,26 @@
 List()%7B%0A
+%0A%0A
         
 List%3CAut
@@ -779,293 +779,55 @@
     
-List%3CAutoSuggestOption%3E autoSuggestList = new ArrayList%3C%3E();%0A%0A        Set%3CString%3E ncitTerms = graphService.getMappedNCITTerms();%0A%0A        for(String term:ncitTerms)%7B%0A            autoSuggestList.add(new AutoSuggestOption(term, %22OntologyTerm%22));%0A        %7D%0A%0A        return autoSuggestList
+return autoCompleteService.getAutoSuggestions()
 ;%0A%0A 

Refactor controller