From 39e7d79de1fd4062182d18019826cb805dea2625 Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Mon, 27 Jan 2014 14:51:18 +0000 Subject: [PATCH] Add simple statistics to the project home page --- server/compbio/controllers/MainController.java | 99 ++++++++++++++++++++++++ webapp/view/home.jsp | 14 +++- webapp/view/public.jsp | 14 +++- 3 files changed, 119 insertions(+), 8 deletions(-) diff --git a/server/compbio/controllers/MainController.java b/server/compbio/controllers/MainController.java index d555d36..d9e0cf0 100644 --- a/server/compbio/controllers/MainController.java +++ b/server/compbio/controllers/MainController.java @@ -1,47 +1,146 @@ package compbio.controllers; +import java.util.Calendar; + import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import compbio.beans.Total; +import compbio.beans.TotalJobsStatisticBean; +import compbio.cassandra.DateFormatter; +import compbio.cassandra.readers.DailyStatisticsReader; + +/** + * The main system controller with most general functionality (home page, login + * and logout pages) + * + * @author Alexander Sherstnev + * @author Natasha Sherstneva + * + * @version 1.0 + * @since Dec 2013 + */ @Controller public class MainController extends BasicController { + /** + * Form the project home page + * + * @param model + * MVC model object + * + * @return JSP template for the page + */ @RequestMapping(value = "/index", method = RequestMethod.GET) public String printPublicHome(ModelMap model) { model.addAttribute("username", getPrincipalName()); + model = getStatistics(model); if (isUserRole()) return "home"; return "public"; } + /** + * Form login page + * + * @param model + * MVC model object + * + * @return JSP template for the page + */ @RequestMapping(value = "/login", method = RequestMethod.GET) public String login(ModelMap model) { return "login"; } + /** + * Form a page with failed login + * + * @param model + * MVC model object + * + * @return JSP template for the page + */ @RequestMapping(value = "/loginfailed", method = RequestMethod.GET) public String loginerror(ModelMap model) { model.addAttribute("error", "Wrong user name or password"); return "login"; } + /** + * Form a page after log out + * + * @param model + * MVC model object + * + * @return JSP template for the page + */ @RequestMapping(value = "/logout", method = RequestMethod.GET) public String logout(ModelMap model) { + model = getStatistics(model); return "public"; } + /** + * Form a page with denial of service + * + * @param model + * MVC model object + * + * @return JSP template for the page + */ @RequestMapping(value = "/denied", method = RequestMethod.GET) public String denied(ModelMap model) { model.put("username", getPrincipalName()); return "support/Denied"; } + /** + * Form the project home page + * + * @param model + * MVC model object + * + * @return JSP template for the page + */ @RequestMapping(value = "/home", method = RequestMethod.GET) public String printHome(ModelMap model) { model.addAttribute("username", getPrincipalName()); + model = getStatistics(model); return "home"; } + /** + * collect job execution statiustics for the last 7 days. + * + * @param model + * MVC model object + * + * @return the the same model, but with additional parameters with the job + * statistics + */ + private ModelMap getStatistics(ModelMap model) { + int ndays = 7; + model.addAttribute("ndays", ndays); + + Calendar cal = Calendar.getInstance(); + String date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); + long longDate2 = DateFormatter.DateParsing(date2, formaterYYMMDD); + cal.add(Calendar.DATE, -ndays); + String date1 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); + long longDate1 = DateFormatter.DateParsing(date1, formaterYYMMDD); + + DailyStatisticsReader reader = new DailyStatisticsReader(); + TotalJobsStatisticBean res = reader.query(longDate1, longDate2); + Total total = res.getWholeTotal(); + model.addAttribute("total", total.getTotal()); + model.addAttribute("totalOK", total.getTotalOK()); + model.addAttribute("totalTimeout", total.getTotalOK()); + model.addAttribute("totalError", total.getTotalError()); + model.addAttribute("totalStopped", total.getTotalStopped()); + return model; + } + } diff --git a/webapp/view/home.jsp b/webapp/view/home.jsp index db9857c..3c40ea7 100644 --- a/webapp/view/home.jsp +++ b/webapp/view/home.jsp @@ -13,7 +13,13 @@
Execution statistics for the last days
- Statistics plot +

${total} jobs have been calculated with Jped over the last ${ndays} days:

+
    +
  • ${totalOK} jobs have been done without problems (status: OK)
  • +
  • ${totalStopped} jobs have been stopped (status: Stopped)
  • +
  • ${totalTimeout} jobs haven't had enough time to complete (status: Time Out)
  • +
  • ${totalError} jobs have been failed (status: Internal Error)
  • +
@@ -21,9 +27,9 @@
Overview
- ProteoCache is as a repository of the result of running all tools in the Dundee Resource on - complete proteomes. The data are updated on a regular basis as tools are improved and genomes newly - sequenced or updated. + ProteoCache is as a repository and a caching system for Jpred and other tools of the Dundee Resource. + ProteoCache deals with both single proteins and complete proteomes. The internal data are updated + on a regular basis as the tools are improved and proteomes are published and updated.
diff --git a/webapp/view/public.jsp b/webapp/view/public.jsp index 4017906..2c63a3c 100644 --- a/webapp/view/public.jsp +++ b/webapp/view/public.jsp @@ -13,7 +13,13 @@
Execution statistics for the last days
- bla-bla +

${total} jobs have been calculated with Jped over the last ${ndays} days:

+
    +
  • ${totalOK} jobs have been done without problems (status: OK)
  • +
  • ${totalStopped} jobs have been stopped (status: Stopped)
  • +
  • ${totalTimeout} jobs haven't had enough time to complete (status: Time Out)
  • +
  • ${totalError} jobs have been failed (status: Internal Error)
  • +
@@ -21,9 +27,9 @@
Overview
- ProteoCache is as a repository of the result of running all tools in the Dundee Resource on - complete proteomes. The data are updated on a regular basis as tools are improved and genomes newly - sequenced or updated. + ProteoCache is as a repository and a caching system for Jpred and other tools of the Dundee Resource. + ProteoCache deals with both single proteins and complete proteomes. The internal data are updated + on a regular basis as the tools are improved and proteomes are published and updated.
-- 1.7.10.2