Commit 31315a08 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '937-internal-server-error-when-parsing-sbgn' into 'master'

Resolve "Internal server error when parsing SBGN"

Closes #937

See merge request !966
parents a32f0b65 50633d74
Pipeline #15163 passed with stage
in 10 minutes and 51 seconds
......@@ -14,6 +14,8 @@ minerva (14.0.3) stable; urgency=medium
user provided data overlays (#975)
* Bug fix: changing order of data overlays is reflected in info window
* Bug fix: opening map with no available background crashed (#964)
* Bug fix: uploading SBGN file that does not pass xsd validation provides a
warning, but does not fail upload (#937)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 16 Oct 2019 9:00:00 +0200
......
......@@ -95,13 +95,11 @@ public class SbgnmlXmlParser {
// Check if input file has valid SBGN-ML data
try {
if (!SbgnUtil.isValid(inputSbgnmlFile)) {
throw new InvalidInputDataExecption("Given input is not a valid SBGN-ML file.");
logger.warn("Given input is not a valid SBGN-ML file.");
}
// Read data from file
sbgnData = SbgnUtil.readFromFile(inputSbgnmlFile);
} catch (InvalidInputDataExecption ex) {
throw ex;
} catch (Exception ex) {
throw new InvalidInputDataExecption("Unable to read given file.", ex);
}
......
package lcsb.mapviewer.converter.model.sbgnml;
import java.awt.*;
import java.awt.Desktop;
import java.io.File;
import java.nio.file.Files;
import java.util.List;
import org.junit.Rule;
import org.apache.logging.log4j.core.LogEvent;
import org.junit.*;
import lcsb.mapviewer.common.MinervaLoggerAppender;
import lcsb.mapviewer.common.UnitTestFailedWatcher;
import lcsb.mapviewer.converter.graphics.*;
import lcsb.mapviewer.model.map.model.Model;
......@@ -15,6 +18,23 @@ public class SbgnmlTestFunctions {
@Rule
public UnitTestFailedWatcher unitTestFailedWatcher = new UnitTestFailedWatcher();
private MinervaLoggerAppender appender;
@Before
public final void _setUp() throws Exception {
MinervaLoggerAppender.unregisterLogEventStorage(appender);
appender = MinervaLoggerAppender.createAppender();
}
@After
public final void _tearDown() throws Exception {
MinervaLoggerAppender.unregisterLogEventStorage(appender);
}
protected List<LogEvent> getWarnings() {
return appender.getWarnings();
}
protected void showImage(Model model) throws Exception {
String dir = Files.createTempDirectory("sbml-temp-images-dir").toFile().getAbsolutePath();
AbstractImageGenerator.Params params = new AbstractImageGenerator.Params().height(model.getHeight())
......
......@@ -55,6 +55,14 @@ public class SbgnmlXmlParserTest2 extends SbgnmlTestFunctions {
assertNull("Top compartment has not null compartment", compartment.getCompartment());
}
@Test
public void parseModelWithXSDProblems() throws Exception {
Converter converter = new SbgnmlXmlConverter();
converter.createModel(new ConverterParams().filename("testFiles/file_that_does_not_pass_xsd.sbgn"));
assertEquals(1, getWarnings().size());
}
@Test
public void createModelWithZIndex() throws Exception {
Converter converter = new SbgnmlXmlConverter();
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sbgn xmlns="http://sbgn.org/libsbgn/0.2">
<map language="process description">
<extension>
<renderInformation xmlns="http://www.sbml.org/sbml/level3/version1/render/version1" backgroundColor="#ffffff" id="renderInformation" programName="graphml2sbgn" programVersion="0.1">
<listOfColorDefinitions>
<colorDefinition id="color_1" value="#F2F4F8"/>
<colorDefinition id="color_2" value="#FFFFFF7F"/>
<colorDefinition id="color_3" value="#333333"/>
<colorDefinition id="color_4" value="#E4EAC4"/>
<colorDefinition id="color_5" value="#FFFFFF"/>
<colorDefinition id="color_6" value="#000000"/>
<colorDefinition id="color_7" value="#C2D4ED"/>
</listOfColorDefinitions>
<listOfStyles>
<style id="style_1.0FFFFFF7F14.0333333" idList="n13">
<g fill="color_2" fontSize="14.0" stroke="color_3" strokeWidth="1.0"/>
</style>
<style id="style_1.0FFFFFF14.0000000" idList="n26 n30 n21 n23 n22">
<g fill="color_5" fontSize="14.0" stroke="color_6" strokeWidth="1.0"/>
</style>
<style id="style_1.0C2D4ED14.0333333" idList="n24::n1 n2 n24::n0 n28::n0 n29::n1 n28::n1 n29::n0 n10 n31 n33::n0 n12 n11 n14 n25 n16 n15 n17 n27::n0">
<g fill="color_7" fontSize="14.0" stroke="color_3" strokeWidth="1.0"/>
</style>
<style id="style_1.0F2F4F812.0000000" idList="n24 n27 n29 n28 n33">
<g fill="color_1" fontSize="12.0" stroke="color_6" strokeWidth="1.0"/>
</style>
<style id="style_1.0FFFFFF14.0333333" idList="n18 n5 n19 n6 n8 n9">
<g fill="color_5" fontSize="14.0" stroke="color_3" strokeWidth="1.0"/>
</style>
<style id="style_1.0C2D4ED14.0000000" idList="n27::n1 n32 n20 n33::n1">
<g fill="color_7" fontSize="14.0" stroke="color_6" strokeWidth="1.0"/>
</style>
<style id="style_1.0E4EAC414.0333333" idList="n0 n1 n3 n4 n7">
<g fill="color_4" fontSize="14.0" stroke="color_3" strokeWidth="1.0"/>
</style>
<style id="style_1.0000000" idList="e31 e30 e11 e33 e10 e32 e13 e35 e12 e34 e15 e14 e17 e16 e19 e18 e20 e22 e21 e24 e23 e26 e25 e28 e0 e27 e1 e2 e29 e3 e4 e5 e6 e7 e8 e9">
<g fill="color_6" fontSize="10.0" stroke="color_6" strokeWidth="1.0"/>
</style>
</listOfStyles>
</renderInformation>
</extension>
<glyph class="complex" id="n24">
<bbox w="100.65368" h="126.69954" x="173.66068" y="134.19138"/>
<glyph class="macromolecule" id="n24::n0">
<extension>
<annotation xmlns:ns2="http://sbgn.org/libsbgn/0.2" xmlns="">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">https://www.uniprot.org/uniprot/P01133#PRO_0000007541</rdf:RDF>
</annotation>
</extension>
<label text="EGF"/>
<bbox w="80.0" h="40.0" x="184.31435" y="148.19138"/>
</glyph>
<glyph class="macromolecule" id="n24::n1">
<extension>
<annotation xmlns:ns2="http://sbgn.org/libsbgn/0.2" xmlns="">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">https://www.uniprot.org/uniprot/P00533</rdf:RDF>
</annotation>
</extension>
<label text="EGFR"/>
<bbox w="80.0" h="40.0" x="184.31435" y="198.39093"/>
<glyph class="state variable" id="3">
<state value="" variable="Y"/>
<bbox w="36.091797" h="15.0" x="222.24153" y="1195.1536"/>
</glyph>
</glyph>
</glyph>
</map>
</sbgn>
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