1 package compbio.controllers;
6 import org.springframework.stereotype.Controller;
7 import org.springframework.web.bind.annotation.RequestMapping;
8 import org.springframework.web.bind.annotation.RequestMethod;
9 import org.springframework.web.bind.annotation.RequestParam;
11 import compbio.cassandra.TotalByCounterBean;
12 import compbio.cassandra.UserBean;
13 import compbio.statistic.CassandraRequester;
16 * @author Alexander Sherstnev
17 * @author Natasha Sherstneva
20 public class IPDataController extends BasicController {
22 @RequestMapping(value = "/admin/ip/counts/query", method = RequestMethod.GET)
23 public String initStatisticsForm(Map<String, Object> model) {
24 model.put("username", getPrincipalName());
25 model.put("value", 5);
26 return "query/IPStatistics";
29 @RequestMapping(value = "/admin/ip/query", method = RequestMethod.GET)
30 public String initOneIPForm(Map<String, Object> model) {
31 model.put("username", getPrincipalName());
32 CassandraRequester cr = new CassandraRequester();
33 model.put("value", cr.getExample("ip"));
37 @RequestMapping(value = "/admin/ip/counts/results", method = RequestMethod.GET)
38 public String findIPwithCounter(@RequestParam("JobCounter") String counter, Map<String, Object> model) {
39 model.put("username", getPrincipalName());
40 if (counter.equals("")) {
41 model.put("error", "The value must not be empty");
42 model.put("value", counter);
43 return "query/IPStatistics";
48 realcounter = Integer.parseInt(counter.trim());
49 } catch (NumberFormatException e) {
50 model.put("error", "The value must be an integer number");
51 model.put("value", counter);
52 return "query/IPStatistics";
55 if (realcounter < 1) {
56 model.put("error", "The value must be greater than 0");
57 model.put("value", counter);
58 return "query/IPStatistics";
61 final long startTime = System.currentTimeMillis();
62 CassandraRequester cr = new CassandraRequester();
63 List<TotalByCounterBean> r = cr.readIpByCounter(realcounter);
64 model.put("results", r);
65 model.put("njobs", 0);
67 model.put("njobs", r.size());
69 final long endTime = System.currentTimeMillis();
70 model.put("timeExecution", (endTime - startTime));
71 model.put("counter", realcounter);
72 return "reportIPstatistics";
75 @RequestMapping(value = "/admin/ip/results", method = RequestMethod.GET)
76 public String findIP(@RequestParam("ip") String ip, Map<String, Object> model) {
77 model.put("username", getPrincipalName());
78 final long startTime = System.currentTimeMillis();
79 CassandraRequester cr = new CassandraRequester();
80 UserBean r = cr.readIp(ip);
81 model.put("results", r);
82 model.put("njobs", 0);
84 model.put("njobs", r.getMainInfo().size());
86 final long endTime = System.currentTimeMillis();
87 model.put("timeExecution", (endTime - startTime));