package compbio.controllers; import java.util.List; import java.util.Map; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import compbio.cassandra.DataBase; import compbio.statistic.CassandraRequester; /** * @author Alexander Sherstnev * @author Natasha Sherstneva */ @Controller public class IPDataController { @RequestMapping(value = "/ip/stat", method = RequestMethod.GET) public String initStatisticsForm(Map model) { model.put("value", 5); return "queryIPStatistics"; } @RequestMapping(value = "/ip", method = RequestMethod.GET) public String initOneIPForm(Map model) { model.put("value", "127.0.0.1"); return "queryIP"; } @RequestMapping(value = "/ip/stat/querycounter", method = RequestMethod.GET) public String findIPwithCounter(@RequestParam("JobCounter") int counter, Map model) { if (counter < 1) { model.put("error", "The value must be greater than 0"); model.put("value", counter); return "queryIPStatistics"; } final long startTime = System.currentTimeMillis(); CassandraRequester cr = new CassandraRequester(); List r = cr.readIpByCounter(counter); model.put("results", r); model.put("njobs", 0); if (null != r) { model.put("njobs", r.size()); } final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); model.put("counter", counter); return "reportIPstatistics"; } @RequestMapping(value = "/ip/query", method = RequestMethod.GET) public String findIP(@RequestParam("ip") String ip, Map model) { final long startTime = System.currentTimeMillis(); CassandraRequester cr = new CassandraRequester(); List r = cr.readIp(ip); model.put("results", r); model.put("njobs", 0); if (null != r) { model.put("njobs", r.size()); } final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); model.put("ip", ip); return "reportIP"; } }