From: Sasha Sherstnev Date: Fri, 29 Nov 2013 12:16:00 +0000 (+0000) Subject: Convert servlets into Spring controllers X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ea4836a9172d18c6d2917d829a808b4935400aa2;p=proteocache.git Convert servlets into Spring controllers --- diff --git a/server/compbio/controllers/DBUpdateController.java b/server/compbio/controllers/DBUpdateController.java new file mode 100644 index 0000000..1d84026 --- /dev/null +++ b/server/compbio/controllers/DBUpdateController.java @@ -0,0 +1,65 @@ +package compbio.controllers; + +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.CassandraRemover; + +/** + * @author Alexander Sherstnev + * @author Natasha Sherstneva + */ +@Controller +public class DBUpdateController { + + @RequestMapping(value = "/database/remove", method = RequestMethod.GET) + public String initRemoveForm(Map model) { + return "queryRemoveJobs"; + } + + @RequestMapping(value = "/database/state", method = RequestMethod.GET) + public String initDBStatRequest(Map model) { + // return "queryDBState"; + return "support/Notimplemented"; + } + + @RequestMapping(value = "/database/remove/goreal", method = RequestMethod.GET) + public String findIPwithCounter(@RequestParam("byId") String flagId, @RequestParam("id") String jobId, + @RequestParam("byDate") String flagDate, @RequestParam("date1") String date1, @RequestParam("date2") String date2, + @RequestParam("byIp") String flagIp, @RequestParam("ip") String ip, @RequestParam("bySequence") String flagSeq, + @RequestParam("seq") String seq, Map model) { + + CassandraRemover cr = new CassandraRemover(); + int numberRemover = 0; + if (flagId != null) + numberRemover = cr.RemoveJobById(jobId); + if (flagDate != null) + numberRemover = cr.RemoveJobByDate(date1, date2); + if (flagIp != null) + numberRemover = cr.RemoveJobByIp(ip); + if (flagSeq != null) + numberRemover = cr.RemoveJobBySequence(seq); + model.put("result", numberRemover); + return "reportRemoveData"; + } + + @RequestMapping(value = "/database/remove/go", method = RequestMethod.GET) + public String findIPwithCounter(@RequestParam("id") String jobId, @RequestParam("date1") String date1, + @RequestParam("date2") String date2, @RequestParam("ip") String ip, @RequestParam("seq") String seq, Map model) { + + /* + * CassandraRemover cr = new CassandraRemover(); int numberRemover = 0; + * if (flagId != null) numberRemover = cr.RemoveJobById(jobId); if + * (flagDate != null) numberRemover = cr.RemoveJobByDate(date1, date2); + * if (flagIp != null) numberRemover = cr.RemoveJobByIp(ip); if (flagSeq + * != null) numberRemover = cr.RemoveJobBySequence(seq); + * model.put("result", numberRemover); return "reportRemoveData"; + */ + return "support/Blocked"; + } + +} diff --git a/server/compbio/controllers/DayStatisticsController.java b/server/compbio/controllers/DayStatisticsController.java index da4538d..206a6df 100644 --- a/server/compbio/controllers/DayStatisticsController.java +++ b/server/compbio/controllers/DayStatisticsController.java @@ -7,13 +7,7 @@ import java.util.Date; import java.util.List; import java.util.Map; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.InitBinder; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -32,16 +26,16 @@ public class DayStatisticsController { @RequestMapping(value = "/stat", method = RequestMethod.GET) public String initFindForm(Map model) { - return "QueryJobsByDate"; + return "queryJobStatistics"; } @RequestMapping(value = "/stat/query", method = RequestMethod.GET) - public String findJobsInPeriod(@RequestParam("data1") String date1, @RequestParam("data2") String date2, + public String findJobsInPeriod(@RequestParam("date1") String date1, @RequestParam("date2") String date2, @RequestParam("option") String option, Map model) { final long startTime = System.currentTimeMillis(); CassandraRequester cr = new CassandraRequester(); - if (option.equals("AllDates")) { + if (option.equals("AllDates,off")) { Calendar cal = Calendar.getInstance(); date1 = StatisticsProt.DateFormatYYMMDD(cr.earliestDate()); date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); @@ -53,7 +47,7 @@ public class DayStatisticsController { final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); model.put("flag", option); - return "/ReportJobsByDate"; + return "/reportJobStatistics"; } @RequestMapping(value = "/stat/oneday", method = RequestMethod.GET) @@ -65,7 +59,7 @@ public class DayStatisticsController { String date1 = formaterYYMMDD.format(new Date(formaterDDMMYY.parse(date).getTime())); CassandraRequester cr = new CassandraRequester(); - List r1 = cr.countJobs(date1, date1); + //List r1 = cr.countJobs(date1, date1); List r = cr.readJobByDay(date); model.put("results", r); model.put("njobs", r.size()); @@ -73,6 +67,6 @@ public class DayStatisticsController { final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); System.out.println("Request for date = " + date1 + ": " + r.size() + " jobs found"); - return "/ReportJobsOfOneDay"; + return "/reportJobStatisticsOneDay"; } } diff --git a/server/compbio/controllers/HelpController.java b/server/compbio/controllers/HelpController.java new file mode 100644 index 0000000..cd16fff --- /dev/null +++ b/server/compbio/controllers/HelpController.java @@ -0,0 +1,38 @@ +package compbio.controllers; + +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; + +/** + * @author Alexander Sherstnev + * @author Natasha Sherstneva + */ +@Controller +public class HelpController { + + @RequestMapping(value = "/help/overview", method = RequestMethod.GET) + public String formOverviewPage(Map model) { + return "help/Overview"; + } + + @RequestMapping(value = "/help/howto", method = RequestMethod.GET) + public String formHowtoPage(Map model) { + return "support/Notimplemented"; + } + + + @RequestMapping(value = "/help/doc", method = RequestMethod.GET) + public String formDocPage(Map model) { + return "support/Notimplemented"; + } + + + @RequestMapping(value = "/help/javadoc", method = RequestMethod.GET) + public String formJavadoc(Map model) { + return "support/Notimplemented"; + } +} diff --git a/server/compbio/controllers/JobExecutionTimeController.java b/server/compbio/controllers/JobExecutionTimeController.java index feee0dd..0917bde 100644 --- a/server/compbio/controllers/JobExecutionTimeController.java +++ b/server/compbio/controllers/JobExecutionTimeController.java @@ -3,19 +3,11 @@ package compbio.controllers; import java.util.Calendar; import java.util.Map; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.InitBinder; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; 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; import compbio.statistic.StatisticsProt; @@ -28,7 +20,7 @@ public class JobExecutionTimeController { @RequestMapping(value = "/exectime", method = RequestMethod.GET) public String initFindForm(Map model) { - return "QueryTimeExecution"; + return "queryTimeExecution"; } @RequestMapping(value = "/exectime/query", method = RequestMethod.GET) @@ -48,6 +40,6 @@ public class JobExecutionTimeController { model.put("flag", option); final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); - return "/ReportTimeExecution"; + return "/reportTimeExecution"; } } diff --git a/server/compbio/controllers/JobLogController.java b/server/compbio/controllers/JobLogController.java index 874e046..e207e4e 100644 --- a/server/compbio/controllers/JobLogController.java +++ b/server/compbio/controllers/JobLogController.java @@ -18,7 +18,7 @@ public class JobLogController { @RequestMapping(value = "/joblog", method = RequestMethod.GET) public String initFindForm(Map model) { - return "QueryJobLog"; + return "queryJobLog"; } @RequestMapping(value = "/joblog/query", method = RequestMethod.GET) @@ -29,6 +29,6 @@ public class JobLogController { final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); model.put("IdJob", jobid); - return "ReportJobLog"; + return "reportJobLog"; } } diff --git a/server/compbio/controllers/SequenceSearchController.java b/server/compbio/controllers/SequenceSearchController.java index a1642ee..53bfcfc 100644 --- a/server/compbio/controllers/SequenceSearchController.java +++ b/server/compbio/controllers/SequenceSearchController.java @@ -1,17 +1,9 @@ - package compbio.controllers; - import java.util.List; import java.util.Map; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.InitBinder; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -27,34 +19,54 @@ import compbio.statistic.CassandraRequester; @Controller public class SequenceSearchController { - @RequestMapping(value = "/sequence", method = RequestMethod.GET) - public String initFindForm(Map model) { - return "QuerySequenceProtein"; + @RequestMapping(value = "/sequence/query1", method = RequestMethod.GET) + public String formSequenceQuery(Map model) { + return "queryProteinSequence"; } - @RequestMapping(value = "/sequence/query", method = RequestMethod.GET) - public String findSequence(@RequestParam("prot") String prot, @RequestParam("protein") String flag, - @RequestParam("Search") String search, @RequestParam("counterJob") int counter, Map model) { + @RequestMapping(value = "/sequence/query2", method = RequestMethod.GET) + public String formCounterQuery(Map model) { + return "queryProteinSequenceCounter"; + } + + @RequestMapping(value = "/sequence/querysequence", method = RequestMethod.GET) + public String findSequence(@RequestParam("sequence") String sequence, @RequestParam("protein") String flag, Map model) { final long startTime = System.currentTimeMillis(); - CassandraRequester cr = new CassandraRequester(); - if (search.equals("SearchCounter")) { - List r = cr.readProteinByCounter(counter); - model.put("results", r); - model.put("njobs", r.size()); - System.out.println("Search counter = " + counter + ": " + r.size() + " proteins found"); - } else { - List r = cr.readProteins(prot, flag); + + String trimmedsequence = sequence.replaceAll("\\s", ""); + model.put("njobs", 0); + model.put("prot", trimmedsequence); + model.put("flag", flag); + + if (0 < trimmedsequence.length()) { + CassandraRequester cr = new CassandraRequester(); + List r = cr.readProteins(trimmedsequence, flag); model.put("results", r); + if (null != r) { + System.out.println("result size = " + r.size()); + model.put("njobs", r.size()); + } + } + final long endTime = System.currentTimeMillis(); + model.put("timeExecution", (endTime - startTime)); + return "reportProteinSequences"; + } + + @RequestMapping(value = "/sequence/querycounter", method = RequestMethod.GET) + public String countSequences(@RequestParam("counterJob") int counter, Map model) { + final long startTime = System.currentTimeMillis(); + + CassandraRequester cr = new CassandraRequester(); + List r = cr.readProteinByCounter(counter); + model.put("results", r); + model.put("njobs", 0); + if (null != r) { model.put("njobs", r.size()); - //System.out.println("Search sequence: " + r.size() + " proteins found"); } final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); - model.put("prot", prot); - model.put("flag", flag); - model.put("search", search); model.put("counter", counter); - return "ReportSequenceProtein"; + return "reportProteinSequencesCounter"; } }