@RequestMapping(value = "/GenerateReports", method = RequestMethod.POST) public String prWelc(ModelMap model, HttpServletRequest request) throws Exception { int user_id = (Integer) request.getSession().getAttribute("UserID"); List<stockportfolio> myportfolio = stockPortfolioIInterfaceService.liststock(user_id); model.addAttribute("myportfolio", myportfolio); model.addAttribute("sellStocks", new SellStocks()); List<SellStocks> sellstocks = sellingTableInterfaceService.listsellshares(user_id); model.addAttribute("sellstocks", sellstocks); ArrayList<String> as = new ArrayList<String>(); for (stockportfolio s : myportfolio) { as.add(s.getStockname()); System.out.println(s.getStockname()); } ArrayList<String> gh = new ArrayList<String>(); gh.add("nb"); // OrderPDF of = new OrderPDF(as, String.valueOf(user_id), "Automatcic Portfolio Mangement"); model.addAttribute("pdf", "PDF File Generated"); stockportfolio sp = new stockportfolio(); model.addAttribute("stockportfolio", sp); return "clientPortfolio"; }
@RequestMapping(value = "/AddStock", method = RequestMethod.POST) public String printWelco( @Valid stockportfolio stockportfolio, BindingResult result, HttpServletRequest request, ModelMap model) { /* if(result.hasErrors()) { stocksearchhelper ssh=new stocksearchhelper(); model.addAttribute("StockSearchHelper",ssh); List<stock> x=stockServiceInterface.liststock("NASDAQ"); List<stock> y=stockServiceInterface.liststock("NASDAQCOMPOSITE"); List<stock> z=stockServiceInterface.liststock("DOWJONES"); List<stock> a=stockServiceInterface.liststock("GOLD"); List<stock> b=stockServiceInterface.liststock("SANDP"); List<stock> c=stockServiceInterface.liststock("OIL"); model.addAttribute("NASDAQ",x.get(0).getPrice()); model.addAttribute("NASDAQCOMPOSITE",y.get(0).getPrice()); model.addAttribute("DOWJONES",z.get(0).getPrice()); model.addAttribute("GOLD",a.get(0).getPrice()); model.addAttribute("SANDP",b.get(0).getPrice()); model.addAttribute("OIL",c.get(0).getPrice()); model.addAttribute("stockerror", "Please enter all the values"); System.out.println("sajkasja"); //** Main Page **/ /* int user_id=(Integer) request.getSession().getAttribute("UserID"); //int user_id=(Integer) request.getAttribute("UserID"); List<stockportfolio> myportfolio=stockPortfolioIInterfaceService.liststock(user_id); model.addAttribute("myportfolio",myportfolio); model.addAttribute("sellStocks",new SellStocks()); List<SellStocks> sellstocks=sellingTableInterfaceService.listsellshares(user_id); model.addAttribute("sellstocks",sellstocks); System.out.println("controller"+String.valueOf(sellstocks.size())); stockportfolio sp=new stockportfolio(); model.addAttribute("stockportfolio", sp); return "clientPortfolio"; //return "redirect:/Client/viewmyaccount"; // } //else //{ */ int user_id = (Integer) request.getSession().getAttribute("UserID"); users user = (users) request.getSession().getAttribute("Users"); stockportfolio.setUser(user); int res = stockPortfolioIInterfaceService.addStockPortfolio(stockportfolio); stocksearchhelper ssh = new stocksearchhelper(); model.addAttribute("StockSearchHelper", ssh); List<stock> x = stockServiceInterface.liststock("NASDAQ"); List<stock> y = stockServiceInterface.liststock("NASDAQCOMPOSITE"); List<stock> z = stockServiceInterface.liststock("DOWJONES"); List<stock> a = stockServiceInterface.liststock("GOLD"); List<stock> b = stockServiceInterface.liststock("SANDP"); List<stock> c = stockServiceInterface.liststock("OIL"); model.addAttribute("NASDAQ", x.get(0).getPrice()); model.addAttribute("NASDAQCOMPOSITE", y.get(0).getPrice()); model.addAttribute("DOWJONES", z.get(0).getPrice()); model.addAttribute("GOLD", a.get(0).getPrice()); model.addAttribute("SANDP", b.get(0).getPrice()); model.addAttribute("OIL", c.get(0).getPrice()); List<SellStocks> sellstocks = sellingTableInterfaceService.listsellshares(user_id); // model.addAttribute("sellstocks",sellstocks); return "redirect:/Client/viewmyaccount"; // } }