From: Sasha Sherstnev Date: Tue, 3 Dec 2013 14:04:05 +0000 (+0000) Subject: Add additional checks of input parameters X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8f30a2189dc9926985d82a113aba87711a91c244;p=proteocache.git Add additional checks of input parameters --- diff --git a/server/compbio/controllers/DailyStatisticsController.java b/server/compbio/controllers/DailyStatisticsController.java index edfe876..c9df6be 100644 --- a/server/compbio/controllers/DailyStatisticsController.java +++ b/server/compbio/controllers/DailyStatisticsController.java @@ -52,6 +52,7 @@ public class DailyStatisticsController { model.put("date2", date2); List res = cr.countJobs(date1, date2); model.put("result", res); + model.put("ndays", res.size()); final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); model.put("option", option); diff --git a/server/compbio/controllers/JobExecutionTimeController.java b/server/compbio/controllers/JobExecutionTimeController.java index 191a40c..6170078 100644 --- a/server/compbio/controllers/JobExecutionTimeController.java +++ b/server/compbio/controllers/JobExecutionTimeController.java @@ -1,6 +1,7 @@ package compbio.controllers; import java.util.Calendar; +import java.util.List; import java.util.Map; import org.springframework.stereotype.Controller; @@ -8,7 +9,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; + import compbio.statistic.CassandraRequester; +import compbio.cassandra.DataBase; import compbio.statistic.StatisticsProt; /** @@ -44,7 +47,9 @@ public class JobExecutionTimeController { model.put("date1", date1); model.put("date2", date2); model.put("option", option); - model.put("result", sp.extractExecutionTime(date1, date2)); + List res = sp.extractExecutionTime(date1, date2); + model.put("result", res); + model.put("ndays", res.size() - 1); final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); return "/reportTimeExecution"; diff --git a/server/compbio/controllers/SequenceController.java b/server/compbio/controllers/SequenceController.java index 2986312..0f154d3 100644 --- a/server/compbio/controllers/SequenceController.java +++ b/server/compbio/controllers/SequenceController.java @@ -2,6 +2,7 @@ package compbio.controllers; import java.util.List; import java.util.Map; +import java.util.regex.Pattern; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -10,14 +11,25 @@ import org.springframework.web.bind.annotation.RequestParam; import compbio.cassandra.ProteinBean; import compbio.cassandra.DataBase; +import compbio.data.sequence.SequenceUtil; import compbio.statistic.CassandraRequester; /** + * Spring controller for sequence search. This version works in the servlet style. + * * @author Alexander Sherstnev * @author Natasha Sherstneva + * + * @since 0.5 + * @version 1.0 December 2013 */ @Controller public class SequenceController { + + /** + * pattern for NON-protein alphabet symbols + */ + private final Pattern NONPROTEIN = Pattern.compile("[^ARNDCQEGHILKMFPSTWYV]+", Pattern.CASE_INSENSITIVE); @RequestMapping(value = "/sequence/query1", method = RequestMethod.GET) public String formSequenceQuery(Map model) { @@ -35,7 +47,19 @@ public class SequenceController { public String findSequence(@RequestParam("sequence") String sequence, @RequestParam("protein") String flag, Map model) { final long startTime = System.currentTimeMillis(); + // input checks String trimmedsequence = sequence.replaceAll("\\s", ""); + if (trimmedsequence.equalsIgnoreCase("")) { + model.put("error", "The sequence cann't be empty"); + model.put("value", sequence); + return "queryProteinSequence"; + } + if (NONPROTEIN.matcher(trimmedsequence).find()) { + model.put("error", "The sequence contains symbols not from the standard protein alphabet"); + model.put("value", sequence); + return "queryProteinSequence"; + } + model.put("njobs", 0); model.put("prot", trimmedsequence); model.put("flag", flag); diff --git a/webapp/view/queryProteinSequence.jsp b/webapp/view/queryProteinSequence.jsp index a0bde5a..7feeb4e 100644 --- a/webapp/view/queryProteinSequence.jsp +++ b/webapp/view/queryProteinSequence.jsp @@ -1,6 +1,7 @@ <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> @@ -10,18 +11,33 @@
+
Enter protein sequence
- -
-

-

search for the whole sequence
- search for partial sequence matching

- + + + +
+

+

search for the whole sequence
+ search for partial sequence matching

+ +
+
+ +
+

+

${error}

+

search for the whole sequence
+ search for partial sequence matching

+ +
+
+
diff --git a/webapp/view/reportJobStatistics.jsp b/webapp/view/reportJobStatistics.jsp index 5c707b7..59a0cb1 100644 --- a/webapp/view/reportJobStatistics.jsp +++ b/webapp/view/reportJobStatistics.jsp @@ -23,11 +23,11 @@
-

Jobs statistics for the whole period

+

Jobs statistics for the whole period (${ndays} days)

- Jobs statistics for the time period: to + Jobs statistics for the time period: to (${ndays} days)

diff --git a/webapp/view/reportTimeExecution.jsp b/webapp/view/reportTimeExecution.jsp index 907a578..fceb06e 100644 --- a/webapp/view/reportTimeExecution.jsp +++ b/webapp/view/reportTimeExecution.jsp @@ -23,10 +23,10 @@
-

Time execution for the whole period

+

Time execution for the whole period (${ndays} days)

-

Time execution for the interval: ${date1} - ${date2}

+

Time execution for the interval: ${date1} - ${date2} (${ndays} days)

@@ -63,7 +63,11 @@ Total numbers: - 0 + + + + + ${alldaytotal} ${total} @@ -77,7 +81,11 @@ ${res.date} - 0 + + + + + ${daytotal} ${time}