Commit f7559171 authored by Matija Obreza's avatar Matija Obreza
Browse files

GUI option to download results as CSV

parent 97d90d1f
...@@ -102,6 +102,20 @@ public class ValidatorController { ...@@ -102,6 +102,20 @@ public class ValidatorController {
return "result"; return "result";
} }
@RequestMapping(value = "process", method = RequestMethod.POST, params = { "csvText", "download" })
public void processStringToCSV1(@RequestParam(name = "separator", required = false, defaultValue = ",") final Character separator,
@RequestParam(name = "separatorOther", required = false, defaultValue = "") final Character separatorOther,
@RequestParam(name = "quoteChar", required = false, defaultValue = "\"") final Character quoteChar,
@RequestParam(name = "escapeChar", required = false, defaultValue = "\0") final Character escapeChar,
@RequestParam(name = "csvText", required = true) final String csvText,
@RequestParam(name = "toCurrentTaxa", required = false) final Boolean toCurrentTaxa,
@RequestParam(name = "validateType", defaultValue = "") final String validateType,
@RequestParam(name = "decimalMark", defaultValue = ".") final Character decimalMark,
final HttpServletResponse response) throws IOException, ParseException, TaxonomyException {
processStringToCSV(separator, separatorOther, quoteChar, escapeChar, csvText, toCurrentTaxa, validateType, decimalMark, response);
}
/** /**
* Process string. * Process string.
* *
...@@ -116,7 +130,7 @@ public class ValidatorController { ...@@ -116,7 +130,7 @@ public class ValidatorController {
* @throws ParseException the parse exception * @throws ParseException the parse exception
* @throws TaxonomyException the taxonomy exception * @throws TaxonomyException the taxonomy exception
*/ */
@RequestMapping(value = "process", method = RequestMethod.POST, params = "csvText", produces = "text/csv") @RequestMapping(value = "process", method = RequestMethod.POST, params = { "csvText" }, produces = "text/csv")
public void processStringToCSV(@RequestParam(name = "separator", required = false, defaultValue = ",") final Character separator, public void processStringToCSV(@RequestParam(name = "separator", required = false, defaultValue = ",") final Character separator,
@RequestParam(name = "separatorOther", required = false, defaultValue = "") final Character separatorOther, @RequestParam(name = "separatorOther", required = false, defaultValue = "") final Character separatorOther,
@RequestParam(name = "quoteChar", required = false, defaultValue = "\"") final Character quoteChar, @RequestParam(name = "quoteChar", required = false, defaultValue = "\"") final Character quoteChar,
......
...@@ -20,6 +20,7 @@ label.separator.other=Other ...@@ -20,6 +20,7 @@ label.separator.other=Other
label.quote-char=Quote character label.quote-char=Quote character
hint.quote-char=Quote character is used to mark the start and end of a column. Commonly the double quote: " hint.quote-char=Quote character is used to mark the start and end of a column. Commonly the double quote: "
label.other=Other label.other=Other
label.download=Download results as CSV
label.escape-char=Escape character label.escape-char=Escape character
hint.escape-char=If the quote character is used in column text, it must be escaped: "This is: a \\\"column\\\"" hint.escape-char=If the quote character is used in column text, it must be escaped: "This is: a \\\"column\\\""
......
...@@ -128,6 +128,13 @@ ...@@ -128,6 +128,13 @@
<label for="toCurrentTaxaNo"><spring:message code="label.no"/></label> <label for="toCurrentTaxaNo"><spring:message code="label.no"/></label>
</div> </div>
<h2>4. Preview or Download</h2>
<p class="hint">Tick the box if you want to download results as CSV file. Leave unticked to see results in the browser.</p>
<div>
<input type="checkbox" id="download" name="download" value="1" />
<label for="download"><spring:message code="label.download"/></label>
</div>
<div style="margin: 2em 0;"> <div style="margin: 2em 0;">
<button class="btn" type="submit" value="" name="validateType"> <button class="btn" type="submit" value="" name="validateType">
<spring:message code="label.run-check"/> <spring:message code="label.run-check"/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment