Commit eed3dca2 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge remote-tracking branch 'origin/master' into 1594-rewrite-api

parents b0dec521 e11fae10
Pipeline #57818 failed with stage
in 55 minutes and 30 seconds
......@@ -48,6 +48,18 @@ test:frontend:
before_script:
- mvn dependency:purge-local-repository -DmanualInclude="lcsb.mapviewer"
.jdk_17_template: &jdk_17_definition
image: maven:3.8.5-openjdk-17-slim
services:
- postgres:9.6
stage: test
coverage: '/(\d+.\d+) \% covered/'
before_script:
# java.desktop module does not export Sun Graphics implementation for mockito
- apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get install -y libxrender1 libxtst6 fontconfig libfreetype6
- mvn dependency:purge-local-repository -DmanualInclude="lcsb.mapviewer"
.hsql_template: &hsql_definition
image: maven:3.6.0-jdk-11
stage: test
......@@ -67,7 +79,7 @@ test:frontend:
- export DISPLAY=:99
- mvn -DskipTests=true clean install -pl commons -am
- mvn test -pl commons
- mvn test -pl commons
- awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' commons/target/site/jacoco/jacoco.csv
.test_backend_annotation_template:
......@@ -174,6 +186,10 @@ test:backend:commons:jdk-11:
<<: *jdk_11_definition
script: *test_backend_commons_definition
test:backend:commons:jdk-17:
<<: *jdk_17_definition
script: *test_backend_commons_definition
test:backend:annotation:jdk-8:
<<: *jdk_8_definition
script: *test_backend_annotation_definition
......@@ -186,6 +202,10 @@ test:backend:annotation:jdk-11-hsql:
<<: *hsql_definition
script: *test_backend_annotation_definition
test:backend:annotation:jdk-17:
<<: *jdk_17_definition
script: *test_backend_annotation_definition
test:backend:CellDesigner_plugin:jdk-8:
<<: *jdk_8_definition
script: *test_backend_CellDesigner_plugin_definition
......@@ -203,6 +223,10 @@ test:backend:converter:jdk-11:
<<: *jdk_11_definition
script: *test_backend_converter_definition
test:backend:converter:jdk-17:
<<: *jdk_17_definition
script: *test_backend_converter_definition
test:backend:converter_CellDesigner:jdk-8:
<<: *jdk_8_definition
script: *test_backend_converter_CellDesigner_definition
......@@ -211,6 +235,10 @@ test:backend:converter_CellDesigner:jdk-11:
<<: *jdk_11_definition
script: *test_backend_converter_CellDesigner_definition
test:backend:converter_CellDesigner:jdk-17:
<<: *jdk_17_definition
script: *test_backend_converter_CellDesigner_definition
test:backend:converter_graphics:jdk-8:
<<: *jdk_8_definition
script: *test_backend_converter_graphics_definition
......@@ -219,6 +247,10 @@ test:backend:converter_graphics:jdk-11:
<<: *jdk_11_definition
script: *test_backend_converter_graphics_definition
test:backend:converter_graphics:jdk-17:
<<: *jdk_17_definition
script: *test_backend_converter_graphics_definition
test:backend:converter_SBGNML:jdk-8:
<<: *jdk_8_definition
script: *test_backend_converter_SBGNML_definition
......@@ -227,6 +259,10 @@ test:backend:converter_SBGNML:jdk-11:
<<: *jdk_11_definition
script: *test_backend_converter_SBGNML_definition
test:backend:converter_SBGNML:jdk-17:
<<: *jdk_17_definition
script: *test_backend_converter_SBGNML_definition
test:backend:converter_SBGNML:jdk-11-hsql:
<<: *hsql_definition
script: *test_backend_converter_SBGNML_definition
......@@ -239,6 +275,10 @@ test:backend:converter_SBML:jdk-11:
<<: *jdk_11_definition
script: *test_backend_converter_SBML_definition
test:backend:converter_SBML:jdk-17:
<<: *jdk_17_definition
script: *test_backend_converter_SBML_definition
test:backend:model:jdk-8:
<<: *jdk_8_definition
script: *test_backend_model_definition
......@@ -247,6 +287,10 @@ test:backend:model:jdk-11:
<<: *jdk_11_definition
script: *test_backend_model_definition
test:backend:model:jdk-17:
<<: *jdk_17_definition
script: *test_backend_model_definition
test:backend:model_command:jdk-8:
<<: *jdk_8_definition
script: *test_backend_model_command_definition
......@@ -255,6 +299,10 @@ test:backend:model_command:jdk-11:
<<: *jdk_11_definition
script: *test_backend_model_command_definition
test:backend:model_command:jdk-17:
<<: *jdk_17_definition
script: *test_backend_model_command_definition
test:backend:pathvisio:jdk-8:
<<: *jdk_8_definition
script: *test_backend_pathvisio_definition
......@@ -263,6 +311,10 @@ test:backend:pathvisio:jdk-11:
<<: *jdk_11_definition
script: *test_backend_pathvisio_definition
test:backend:pathvisio:jdk-17:
<<: *jdk_17_definition
script: *test_backend_pathvisio_definition
test:backend:persist:jdk-8:
<<: *jdk_8_definition
script: *test_backend_persist_definition
......@@ -271,6 +323,10 @@ test:backend:persist:jdk-11:
<<: *jdk_11_definition
script: *test_backend_persist_definition
test:backend:persist:jdk-17:
<<: *jdk_17_definition
script: *test_backend_persist_definition
test:backend:persist:hsql:
<<: *hsql_definition
script: *test_backend_persist_definition
......@@ -283,6 +339,10 @@ test:backend:rest:jdk-11:
<<: *jdk_11_definition
script: *test_backend_rest_definition
test:backend:rest:jdk-17:
<<: *jdk_17_definition
script: *test_backend_rest_definition
test:backend:rest:hsql:
<<: *hsql_definition
script: *test_backend_rest_definition
......@@ -295,6 +355,10 @@ test:backend:service:jdk-11:
<<: *jdk_11_definition
script: *test_backend_service_definition
test:backend:service:jdk-17:
<<: *jdk_17_definition
script: *test_backend_service_definition
test:backend:service:hsql:
<<: *hsql_definition
script: *test_backend_service_definition
......@@ -307,6 +371,10 @@ test:backend:web:jdk-11:
<<: *jdk_11_definition
script: *test_backend_web_definition
test:backend:web:jdk-17:
<<: *jdk_17_definition
script: *test_backend_web_definition
test:backend:web:hsql:
<<: *jdk_11_definition
script: *test_backend_web_definition
......@@ -574,3 +642,18 @@ test_postgres_11_compatibility:
<<: *test_database_definition
services:
- postgres:11
test_postgres_12_compatibility:
<<: *test_database_definition
services:
- postgres:12
test_postgres_13_compatibility:
<<: *test_database_definition
services:
- postgres:13
test_postgres_14_compatibility:
<<: *test_database_definition
services:
- postgres:14
minerva (17.0.0~alpha.0) unstable; urgency=medium
* Backward incompatibility: generating of pdf does not use itext (#1043)
* Backward incompatibility: select mode removed (#1547)
* Backward incompatibility: Split semantic zoom removed (#1682)
* Backward incompatibility: support for TransparencyZoomLevelVisibility
......@@ -9,6 +10,7 @@ minerva (17.0.0~alpha.0) unstable; urgency=medium
will not be sent anymore (#1653)
* Backward incompatibility: CAN_CREATE_OVERLAYS permission removed - every
user has possibility to create accounts (#1658)
* Improvement: minerva is compatible with java 17
* Improvement: cached data is automatically refreshed after information is
expired, for example information from drug db (#1548)
* Small improvement: inchi and inchikey in chemiclas are repsented as
......@@ -23,9 +25,33 @@ minerva (17.0.0~alpha.0) unstable; urgency=medium
* Bug fix: when trying to remove default project API returns 403 (FORBIDDEN)
status code
* Bug fix: disable CORS works for all requests
* Bug fix: export as pdf map with some glyphs was broken (#1563)
-- Piotr Gawron <piotr.gawron@uni.lu> Tue, 8 Feb 2022 13:00:00 +0200
minerva (16.2.1) stable; urgency=medium
* Bug fix: Kegg annotator stopped working after kegg moved to https
* Bug fix: General overlays were marked as editable even though they should
not be (#1706, #1702)
* Bug fix: searching for non existing chemical caused an error to be thrown
(#1704)
* Bug fix: there was an unexpected error when project did not contain any
map (#1705)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 13 Jun 2022 14:00:00 +0200
minerva (16.2.0) stable; urgency=medium
* Small improvement: cookie policy is supported (#1697, #1700)
* Bug fix: after tomcat restart unfinished projects were not marked as
"FAIL" (#1699)
* Bug fix: 'LOAD' button in plugin panel becomes inactive after click to
prevent double click (#1504)
* Bug fix: data overlay rectangle for complex is put behind child rectangle
(#1698)
* Bug fix: properly logrotate logs when using tomcat9
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 1 Jun 2022 10:00:00 +0200
minerva (16.1.1) stable; urgency=medium
* Bug fix: search by reactionId with "_" did not return a reaction (#1696)
* Bug fix: backgrounds with owner different than project owner could not be
......
......@@ -68,6 +68,7 @@ When all the changes are ready tag commit and push it to the repository. Gitlab
echo 'PUT minerva_12.0.3_amd64.deb'| sftp -P 8022 repo-r3lab.lcsb.uni.lu
ssh repo 'sudo reprepro -b /var/www/html/debian includedeb test minerva_12.0.3_amd64.deb'
```
The password required for signing the package is available in LCSB sysdamins team.
Remember to use proper repository:
* stable - for production ready debian packages
......
......@@ -53,7 +53,7 @@ public class PubmedParserImpl extends CachableInterface implements PubmedParser
/**
* Version of the remote API that is supported by this connecting class.
*/
static final String SUPPORTED_VERSION = "6.7";
static final String SUPPORTED_VERSION = "6.8";
static final String API_URL = "https://www.ebi.ac.uk/europepmc/webservices/rest/";
......
......@@ -167,7 +167,7 @@ public class KeggAnnotatorImpl extends ElementAnnotator implements KeggAnnotator
@Override
public String getUrl() {
return "http://www.genome.jp/kegg/";
return "https://www.genome.jp/kegg/";
}
@Override
......@@ -207,7 +207,7 @@ public class KeggAnnotatorImpl extends ElementAnnotator implements KeggAnnotator
* @return url to KEGG restful API about given EC
*/
private String getKeggUrl(final String ecId) {
return "http://rest.kegg.jp/get/" + ecId;
return "https://rest.kegg.jp/get/" + ecId;
}
/**
......
......@@ -153,7 +153,7 @@ public class KeggAnnotatorTest extends AnnotationTestFunctions {
}
}
assertTrue("Invalid number of TAIR annotators from KEGG", cntTairs == 3);
assertEquals("Invalid number of TAIR annotators from KEGG", 3, cntTairs);
assertEquals("There should be warning about unsupported parameter", 1, getWarnings().size());
}
......
......@@ -27,7 +27,7 @@
<version>17.0.0~alpha.0</version>
</dependency>
<!-- Log4J2-->
<!-- Log4J2 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
......@@ -72,6 +72,22 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>${fop.version}</version>
<exclusions>
<exclusion>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
......@@ -86,19 +102,6 @@
<scope>test</scope>
</dependency>
<!-- iText library for generating pdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
......
package lcsb.mapviewer.converter.graphics;
import java.awt.Font;
import java.io.IOException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.itextpdf.awt.DefaultFontMapper;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.pdf.BaseFont;
public class PdfFontMapper extends DefaultFontMapper {
private static Logger logger = LogManager.getLogger();
@Override
public BaseFont awtToPdf(final Font font) {
BaseFont result = null;
String fontName = font.getName();
if (fontName.equalsIgnoreCase("DialogInput") || fontName.equalsIgnoreCase("Monospaced")
|| fontName.equalsIgnoreCase("Courier") || fontName.equalsIgnoreCase("Serif")
|| fontName.equalsIgnoreCase("TimesRoman") || fontName.equals("sanserif")
|| fontName.equalsIgnoreCase("Helvetica")) {
result = super.awtToPdf(font);
}
if (fontName.equalsIgnoreCase("SansSerif")) {
try {
result = resolveFont("/fonts/truetype/dejavu/DejaVuSans.ttf", font);
} catch (final Exception e) {
logger.error("Problem with getting font", e);
}
}
if (result == null) {
logger.warn("Unsupported font: " + fontName);
result = super.awtToPdf(font);
}
return result;
}
private BaseFont resolveFont(final String baseUrl, final Font font) throws DocumentException, IOException {
String url;
if (font.isItalic()) {
if (font.isBold()) {
url = baseUrl.replace(".ttf", "-BoldOblique.ttf");
} else {
url = baseUrl.replace(".ttf", "-Oblique.ttf");
}
} else {
if (font.isBold()) {
url = baseUrl.replace(".ttf", "-Bold.ttf");
} else {
url = baseUrl;
}
}
if (!FontFactory.isRegistered(url)) {
FontFactory.register(url);
}
return BaseFont.createFont(url, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
}
}
......@@ -3,38 +3,36 @@ package lcsb.mapviewer.converter.graphics;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import org.apache.batik.dom.GenericDOMImplementation;
import org.apache.batik.svggen.SVGGraphics2D;
import org.apache.batik.transcoder.Transcoder;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.commons.io.output.ByteArrayOutputStream;
import com.itextpdf.awt.PdfGraphics2D;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;
import org.apache.fop.svg.PDFTranscoder;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import lcsb.mapviewer.common.MimeType;
import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.common.exception.NotImplementedException;
/**
* This class implements PDF generator for the image object. This class uses
* itext library to create all converters.
* This class implements SVG generator for the image object.This class uses
* batik library to create all converters.
*
* @author Piotr Gawron
*
*/
public class PdfImageGenerator extends AbstractImageGenerator {
/**
* Stream where pdf data will be generated. When request to save pdf appears
* this stream is used to generate file.
*/
private ByteArrayOutputStream inMemoryOutputStream;
/**
* Object representing pdf document.
* Root dom element. We need it to be able to provide viewBox.
*/
private Document pdfDocument;
private Element root;
/**
* Default constructor. Create an image that is described by params. For more
......@@ -53,53 +51,64 @@ public class PdfImageGenerator extends AbstractImageGenerator {
@Override
protected void createImageObject(final double width, final double height) {
try {
inMemoryOutputStream = new ByteArrayOutputStream();
pdfDocument = new Document(new Rectangle((int) width, (int) height));
PdfWriter writer = PdfWriter.getInstance(pdfDocument, inMemoryOutputStream);
pdfDocument.open();
PdfContentByte cb = writer.getDirectContent();
PdfGraphics2D g2d = new PdfGraphics2D(cb, (float) width, (float) height, new PdfFontMapper());
setGraphics(g2d);
} catch (final DocumentException e) {
throw new InvalidStateException("Problem with initializing pdf generator", e);
}
// Get a DOMImplementation.
DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
// Create an instance of org.w3c.dom.Document.
String svgNS = "http://www.w3.org/2000/svg";
Document document = domImpl.createDocument(svgNS, "svg", null);
// Create an instance of the SVG Generator.
SVGGraphics2D graphics = new SVGGraphics2D(document);
root = graphics.getRoot();
root.setAttributeNS(null, "viewBox", "0 0 " + (int) width + " " + (int) height);
setGraphics(graphics);
}
@Override
protected void closeImageObject() {
getGraphics().dispose();
pdfDocument.close();
}
@Override
public void saveToFileImplementation(final String fileName) throws IOException {
FileOutputStream fos = new FileOutputStream(fileName);
saveToOutputStreamImplementation(fos);
fos.close();
saveToOutputStreamImplementation(new FileOutputStream(fileName));
}
@Override
public void saveToOutputStreamImplementation(final OutputStream os) throws IOException {
inMemoryOutputStream.writeTo(os);
// for some reason if you remove this line either viewbox is not define or
// content is not there
((SVGGraphics2D) getGraphics()).getRoot(root);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
((SVGGraphics2D) getGraphics()).stream(root, new OutputStreamWriter(baos));
TranscoderInput transcoderInput = new TranscoderInput(baos.toInputStream());
TranscoderOutput transcoderOutput = new TranscoderOutput(os);
Transcoder transcoder = new PDFTranscoder();
try {
transcoder.transcode(transcoderInput, transcoderOutput);
} catch (TranscoderException e) {
throw new IOException("Problem with translating to pdf", e);
}
}
@Override
public void savePartToFileImplementation(final int x, final int y, final int width, final int height, final String fileName) throws IOException {
throw new NotImplementedException("Partial save is not implemented in PNG image generator");
throw new NotImplementedException("Partial save is not implemented in PDF image generator");
}
@Override
public void savePartToOutputStreamImplementation(final int x, final int y, final int width, final int height, final OutputStream os)
throws IOException {
throw new NotImplementedException("Partial save is not implemented in PNG image generator");
throw new NotImplementedException("Partial save is not implemented in PDF image generator");
}
@Override
public String getFormatName() {
return "PDF";
return "PDF image";
}
@Override
......
package lcsb.mapviewer.converter.graphics;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.awt.Font;
import org.junit.Test;
import com.itextpdf.text.pdf.BaseFont;
public class PdfFontMapperTest {
@Test
public void testUnknownFont() {
PdfFontMapper mapper = new PdfFontMapper();
BaseFont font = mapper.awtToPdf(new Font("xxx", 0, 12));
BaseFont helveticaFont = mapper.awtToPdf(new Font("Helvetica", 0, 12));
assertEquals(helveticaFont.getPostscriptFontName(), font.getPostscriptFontName());
}
@Test
public void testSansSerifFont() {
PdfFontMapper mapper = new PdfFontMapper();
BaseFont font = mapper.awtToPdf(new Font("SansSerif", 0, 12));
BaseFont helveticaFont = mapper.awtToPdf(new Font("Helvetica", 0, 12));
assertFalse(helveticaFont.getPostscriptFontName().equalsIgnoreCase(font.getPostscriptFontName()));
}
}
......@@ -90,9 +90,6 @@ echo "Architecture: $arch" >>debian/control
#set manual file
echo minerva.txt.gz /usr/share/doc/minerva/minerva.txt.gz >> debian/install;
#logrotate configuration for minerva log4j connector
echo minerva /etc/logrotate.d >> debian/install;
#remove some sample file
rm debian/*.EX
rm debian/*.ex
......
/var/log/tomcat8/minerva.txt {
/var/log/tomcat9/minerva.txt {
copytruncate
size 32k
weekly
......@@ -6,5 +6,5 @@
rotate 52
compress
missingok
create 640 tomcat8 adm
create 640 tomcat adm
}