Commit fa0c6b78 authored by Andrey Lugovskiy's avatar Andrey Lugovskiy
Browse files

end

parent bf2e677e
Pipeline #492 passed with stage
in 49 seconds
...@@ -43,6 +43,7 @@ public class ApplicationController { ...@@ -43,6 +43,7 @@ public class ApplicationController {
model.addAttribute("result", processService.process(file, separator, quoteChar, escapeChar, coyFromExcel, toCurrentTaxa).toString()); model.addAttribute("result", processService.process(file, separator, quoteChar, escapeChar, coyFromExcel, toCurrentTaxa).toString());
model.addAttribute("newLineSymbol", "\n"); model.addAttribute("newLineSymbol", "\n");
model.addAttribute("symbolQuote", "\""); model.addAttribute("symbolQuote", "\"");
model.addAttribute("separator", separator);
return "result"; return "result";
} }
} }
...@@ -44,8 +44,8 @@ public class ProcessServiceImpl implements ProcessService { ...@@ -44,8 +44,8 @@ public class ProcessServiceImpl implements ProcessService {
@Override @Override
public StringWriter process(MultipartFile file, Character separator, Character quoteChar, Character escapeChar, public StringWriter process(MultipartFile file, Character separator, Character quoteChar, Character escapeChar,
String coyFromExcel, Boolean toCurrentTaxa) throws ParseException, IOException, TaxonomyException { String coyFromExcel, Boolean toCurrentTaxa) throws ParseException, IOException, TaxonomyException {
LOG.info("Start process with file: '{}', separator: '{}', coyFromExcel: '{}', toCurrentTaxa: '{}'", LOG.info("Start process with file: '{}', separator: '{}', toCurrentTaxa: '{}'",
file.getOriginalFilename(), separator, coyFromExcel, toCurrentTaxa); file.getOriginalFilename(), separator, toCurrentTaxa);
readDatabase(applicationProperties.getDatabaseFolderPath()); readDatabase(applicationProperties.getDatabaseFolderPath());
return run(file.getInputStream(), separator, quoteChar, escapeChar, coyFromExcel, toCurrentTaxa); return run(file.getInputStream(), separator, quoteChar, escapeChar, coyFromExcel, toCurrentTaxa);
} }
...@@ -80,10 +80,18 @@ public class ProcessServiceImpl implements ProcessService { ...@@ -80,10 +80,18 @@ public class ProcessServiceImpl implements ProcessService {
taxonomyChecker.setTaxonomyDatabase(taxonomyDatabase); taxonomyChecker.setTaxonomyDatabase(taxonomyDatabase);
LOG.info("Running the validation against {}", taxonomyDatabase); LOG.info("Running the validation against {}", taxonomyDatabase);
try (CSVReader reader = new CSVReader(new InputStreamReader(inputStream, "UTF-8"), separator, Reader reader;
if (coyFromExcel != null && !coyFromExcel.isEmpty()){
reader = new StringReader(coyFromExcel);
}else{
reader = new InputStreamReader(inputStream, "UTF-8");
}
try (CSVReader csvReader = new CSVReader(reader, separator,
quoteChar, escapeChar, 0, false, true, false)) { quoteChar, escapeChar, 0, false, true, false)) {
String[] headers = reader.readNext(); String[] headers = csvReader.readNext();
LOG.debug("Input CSV headers: {}", Arrays.toString(headers)); LOG.debug("Input CSV headers: {}", Arrays.toString(headers));
{ {
...@@ -181,7 +189,7 @@ public class ProcessServiceImpl implements ProcessService { ...@@ -181,7 +189,7 @@ public class ProcessServiceImpl implements ProcessService {
String[] sourceLine; String[] sourceLine;
while ((sourceLine = reader.readNext()) != null) { while ((sourceLine = csvReader.readNext()) != null) {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("\n\n"); LOG.debug("\n\n");
......
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
...@@ -7,17 +7,21 @@ ...@@ -7,17 +7,21 @@
<head> <head>
<title><spring:message code="label.title"/></title> <title><spring:message code="label.title"/></title>
<style> <style>
.div1 { display: inline; .div1 {
display: inline;
min-width: 90px; min-width: 90px;
width: 90px;} width: 90px;
}
</style> </style>
</head> </head>
<body> <body>
<c:forEach items='${fn:split(result, newLineSymbol )}' var="row"> <c:forEach items='${fn:split(result, newLineSymbol )}' var="row">
<div class=""> <div class="">
<c:forEach items='${fn:split(row, ",")}' var="element"> <c:forEach items="${fn:split(fn:replace(row, ',', ' , '), ',')}" var="element">
<div class="div1"><c:out value="${fn:replace(element, symbolQuote, '')}"/></div> <div class="div1">
</c:forEach> <c:out value="${element}"/>
</div>
</c:forEach>;
</div> </div>
</c:forEach> </c:forEach>
</body> </body>
......
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