package code.smell.detection.controller;

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

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import code.smell.detection.textualAnalysis.FileHandler;
import code.smell.detection.textualAnalysis.MethodExtractor;

@Controller
public class UploadController {

	private final Logger log = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	private FileHandler fileHandler;
	
	@Autowired
	private MethodExtractor methodExtractor;
	
    @GetMapping("/uploadProject")
    public String index() {
    	log.info("Upload Project requested");
        return "upload";
    }

    @PostMapping("/upload") 
    public String singleFileUpload(@RequestParam("file") MultipartFile file,
                                   RedirectAttributes redirectAttributes) {

        if (file.isEmpty()) {
        	log.debug("file was empty");
            redirectAttributes.addFlashAttribute("message", "Please select a file to upload");
            return "redirect:/uploadStatus";
        }

        if(!file.getOriginalFilename().endsWith(".zip")){
        	log.warn("File extension was not zip");
        	redirectAttributes.addFlashAttribute("message", "Please upload '.zip' file");
            return "redirect:/uploadStatus";
        }

        List<String> javaFileList = fileHandler.getJavaFiles(file);
        
        List<ArrayList<String>> allMethods = methodExtractor.getMethods(javaFileList);
        
        
        redirectAttributes.addFlashAttribute("message", "Code Smell Result: Successful" );
        return "redirect:/uploadStatus";
    }

    @GetMapping("/uploadStatus")
    public String uploadStatus() {
    	log.info("Upload Status invoked");
        return "uploadStatus";
    }

}
@@ -618,24 +618,98 @@
 ileHandler;%0A
+import code.smell.detection.textualAnalysis.InformationRetrievalTemplate;%0A
 import code.
@@ -979,16 +979,98 @@
 ctor;%0A%09%0A
+%09@Autowired%0A%09private InformationRetrievalTemplate informationRetrievalTemplate;%0A%09%0A
     @Get
@@ -2015,32 +2015,236 @@
 List);%0A        %0A
+        informationRetrievalTemplate.setLists(javaFileList, allMethods);%0A        %0A        javaFileList = informationRetrievalTemplate.javaFiles;%0A        allMethods = informationRetrievalTemplate.methods;%0A
         %0A       
@@ -2522,8 +2522,9 @@
     %7D%0A%0A%7D
+%0A

Update UploadController.java