Commit deea319b authored by Matija Obreza's avatar Matija Obreza

Upgrade POI to 3.17

parent 29a3b548
......@@ -412,7 +412,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
<version>4.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
......@@ -480,7 +480,7 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.10.1</version>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.prettytime</groupId>
......
......@@ -29,9 +29,11 @@ import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
......@@ -40,18 +42,24 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
// NOTE Excel 2016 has a limit of 66,530 hyperlinks
// import org.apache.poi.xssf.usermodel.XSSFHyperlink;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.genesys2.server.model.genesys.*;
import org.genesys2.server.model.genesys.AccessionRef;
import org.genesys.catalog.model.dataset.Dataset;
import org.genesys.catalog.model.dataset.DatasetCreator;
import org.genesys.catalog.model.dataset.DatasetLocation;
import org.genesys.catalog.model.traits.Descriptor;
import org.genesys.catalog.model.vocab.VocabularyTerm;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionAlias;
import org.genesys2.server.model.genesys.AccessionCollect;
import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.AccessionId;
import org.genesys2.server.model.genesys.AccessionRef;
import org.genesys2.server.model.genesys.AccessionRemark;
import org.genesys2.server.model.genesys.PDCI;
import org.genesys2.server.model.genesys.Taxonomy2;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.mvc.JspHelper;
import org.genesys2.server.service.DownloadService;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.filter.AccessionFilter;
import org.genesys2.server.service.worker.AccessionProcessor;
import org.genesys2.util.MCPDUtil;
......@@ -114,9 +122,6 @@ public class DownloadServiceImpl implements DownloadService {
private static final int COL_ACCEURL = 40;
private static final int COL_REMARKS = 41;
@Autowired
private GenesysService genesysService;
@Autowired
private AccessionProcessor accessionProcessor;
......@@ -137,7 +142,7 @@ public class DownloadServiceImpl implements DownloadService {
CellStyle dateStyle = wb.createCellStyle();
dateStyle.setDataFormat(wb.createDataFormat().getFormat("dd/mm/yyyy"));
dateStyle.setAlignment(CellStyle.ALIGN_LEFT);
dateStyle.setAlignment(HorizontalAlignment.LEFT);
Sheet legal = wb.getSheet("Legal information");
Row r;
......@@ -181,6 +186,7 @@ public class DownloadServiceImpl implements DownloadService {
LOG.info("Writing to output stream");
wb.write(outputStream);
wb.close();
wb.dispose();
outputStream.flush();
LOG.info("Done");
......@@ -371,6 +377,7 @@ public class DownloadServiceImpl implements DownloadService {
((SXSSFSheet) creatorsSheet).flushRows();
workbook.write(outputStream);
workbook.close();
workbook.dispose();
outputStream.flush();
}
......@@ -541,6 +548,7 @@ public class DownloadServiceImpl implements DownloadService {
((SXSSFSheet) descriptorSheet).flushRows();
workbook.write(outputStream);
workbook.close();
workbook.dispose();
outputStream.flush();
}
......@@ -584,7 +592,7 @@ public class DownloadServiceImpl implements DownloadService {
CellStyle dateStyle = wb.createCellStyle();
dateStyle.setDataFormat(wb.createDataFormat().getFormat("dd/mm/yyyy"));
dateStyle.setAlignment(CellStyle.ALIGN_LEFT);
dateStyle.setAlignment(HorizontalAlignment.LEFT);
Sheet legal = wb.getSheet("Legal information");
Row r;
......@@ -627,6 +635,7 @@ public class DownloadServiceImpl implements DownloadService {
LOG.info("Writing to output stream");
wb.write(outputStream);
wb.close();
wb.dispose();
outputStream.flush();
LOG.info("Done");
......@@ -750,7 +759,7 @@ public class DownloadServiceImpl implements DownloadService {
c = row.createCell(column);
CreationHelper createHelper = row.getSheet().getWorkbook().getCreationHelper();
Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_EMAIL);
Hyperlink link = createHelper.createHyperlink(HyperlinkType.EMAIL);
link.setAddress("mailto:"+value);
c.setHyperlink(link);
c.setCellValue(value);
......@@ -766,7 +775,7 @@ public class DownloadServiceImpl implements DownloadService {
c = row.createCell(column);
CreationHelper createHelper = row.getSheet().getWorkbook().getCreationHelper();
Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL);
Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL);
link.setAddress(value);
c.setHyperlink(link);
c.setCellValue(value);
......
Markdown is supported
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