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.DataBase;
12 import compbio.statistic.CassandraRequester;
15 * @author Alexander Sherstnev
16 * @author Natasha Sherstneva
19 public class IPDataController {
21 @RequestMapping(value = "/ip/stat", method = RequestMethod.GET)
22 public String initStatisticsForm(Map<String, Object> model) {
23 model.put("value", 5);
24 return "queryIPStatistics";
27 @RequestMapping(value = "/ip", method = RequestMethod.GET)
28 public String initOneIPForm(Map<String, Object> model) {
29 model.put("value", "127.0.0.1");
33 @RequestMapping(value = "/ip/stat/querycounter", method = RequestMethod.GET)
34 public String findIPwithCounter(@RequestParam("JobCounter") String counter, Map<String, Object> model) {
36 if (counter.equals("")) {
37 model.put("error", "The value must not be empty");
38 model.put("value", counter);
39 return "queryIPStatistics";
44 realcounter = Integer.parseInt(counter.trim());
45 } catch (NumberFormatException e) {
46 model.put("error", "The value must be an integer number");
47 model.put("value", counter);
48 return "queryIPStatistics";
51 if (realcounter < 1) {
52 model.put("error", "The value must be greater than 0");
53 model.put("value", counter);
54 return "queryIPStatistics";
57 final long startTime = System.currentTimeMillis();
58 CassandraRequester cr = new CassandraRequester();
59 List<DataBase> r = cr.readIpByCounter(realcounter);
60 model.put("results", r);
61 model.put("njobs", 0);
63 model.put("njobs", r.size());
65 final long endTime = System.currentTimeMillis();
66 model.put("timeExecution", (endTime - startTime));
67 model.put("counter", realcounter);
68 return "reportIPstatistics";
71 @RequestMapping(value = "/ip/query", method = RequestMethod.GET)
72 public String findIP(@RequestParam("ip") String ip, Map<String, Object> model) {
73 final long startTime = System.currentTimeMillis();
74 CassandraRequester cr = new CassandraRequester();
75 List<DataBase> r = cr.readIp(ip);
76 model.put("results", r);
77 model.put("njobs", 0);
79 model.put("njobs", r.size());
81 final long endTime = System.currentTimeMillis();
82 model.put("timeExecution", (endTime - startTime));