// Path: backend-java/src/main/java/com/stocks/sample/dto/StockDto.java
// public class StockDto {
//     private Long id;
//     private String name;
//     private String symbol;
// 
//     public StockDto() {}
// 
//     public StockDto( Stock entity ) {
//         this.id = entity.getId();
//         this.name = entity.getName();
//         this.symbol = entity.getSymbol();
//     }
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getSymbol() {
//         return symbol;
//     }
// 
//     public void setSymbol(String symbol) {
//         this.symbol = symbol;
//     }
// }
// 
// Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
//     List<StockDto> importStocksByCSVFile(String file) throws Exception;
// 
//     List<StockDto> findStocksByWildCard(String phrase);
// 
//     String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }


import com.stocks.sample.dto.StockDto;
import com.stocks.sample.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
package com.stocks.sample.controller;



@Controller
public class StockController extends AbstractController {

    @Autowired
    private StockService stockService;

    /**
     * @param q
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/service/stocks"}, method = {RequestMethod.GET}, produces = "application/json")
    public List<StockDto> findStocksByWildCard(@RequestParam("q") String q) {
        List<StockDto> stocks = stockService.findStocksByWildCard(q);
        return stocks;
    }

    /**
     *
     * @param symbol
     * @return
     * @throws IOException
     */
    @ResponseBody
    @RequestMapping(value = {"/service/stockhistory/{symbol}"}, method = {RequestMethod.GET}, produces = "application/json")
    public ResponseEntity<Object> getHistoricalStockData(@PathVariable String symbol) throws IOException {
        String result = stockService.getHistoricalStockData( symbol );
        Object node = this.getFormattedRepresentation(MediaType.APPLICATION_JSON_VALUE, result);
        HttpHeaders httpHeaders = this.getHttpHeadersForEncoding(MediaType.APPLICATION_JSON_VALUE);
// Path: backend-java/src/main/java/com/stocks/sample/dto/StockDto.java
// public class StockDto {
//     private Long id;
//     private String name;
//     private String symbol;
// 
//     public StockDto() {}
// 
//     public StockDto( Stock entity ) {
//         this.id = entity.getId();
//         this.name = entity.getName();
//         this.symbol = entity.getSymbol();
//     }
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getSymbol() {
//         return symbol;
//     }
// 
//     public void setSymbol(String symbol) {
//         this.symbol = symbol;
//     }
// }
// 
// Path: backend-java/src/main/java/com/stocks/sample/service/StockService.java
// public interface StockService {
//     List<StockDto> importStocksByCSVFile(String file) throws Exception;
// 
//     List<StockDto> findStocksByWildCard(String phrase);
// 
//     String getHistoricalStockData( String symbol ) throws JsonProcessingException;
// }


// Path: backend-java/src/main/java/com/stocks/sample/controller/StockController.java
import com.stocks.sample.dto.StockDto;
import com.stocks.sample.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;

package com.stocks.sample.controller;



@Controller
public class StockController extends AbstractController {

    @Autowired
    private StockService stockService;

    /**
     * @param q
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/service/stocks"}, method = {RequestMethod.GET}, produces = "application/json")
    public List<StockDto> findStocksByWildCard(@RequestParam("q") String q) {
        List<StockDto> stocks = stockService.findStocksByWildCard(q);
        return stocks;
    }

    /**
     *
     * @param symbol
     * @return
     * @throws IOException
     */
    @ResponseBody
    @RequestMapping(value = {"/service/stockhistory/{symbol}"}, method = {RequestMethod.GET}, produces = "application/json")
    public ResponseEntity<Object> getHistoricalStockData(@PathVariable String symbol) throws IOException {
        String result = stockService.getHistoricalStockData( symbol );
        Object node = this.getFormattedRepresentation(MediaType.APPLICATION_JSON_VALUE, result);
        HttpHeaders httpHeaders = this.getHttpHeadersForEncoding(MediaType.APPLICATION_JSON_VALUE);
        ResponseEntity<Object> response = new ResponseEntity<Object>(node, httpHeaders, HttpStatus.OK);