diff --git a/CHANGELOG b/CHANGELOG index 4acc6470a73577ea9acaf60e83b313b7d3ae144b..75c5efb092566e19cc69519ce76c836e34eb3c60 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java index 59866a2253c5d6c9f3aa6a209f26de943805a20d..9423bb9f7c6c77d64b303c5dccd1ff232d4fa6f6 100644 --- a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java +++ b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java @@ -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); } diff --git a/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlTestFunctions.java b/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlTestFunctions.java index 0e3dd16e2c831992afa9de8be3dbd2595ec085c4..b7033bff00e6a41ef9e629f061a49da525238b17 100644 --- a/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlTestFunctions.java +++ b/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlTestFunctions.java @@ -1,11 +1,14 @@ 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()) diff --git a/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParserTest2.java b/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParserTest2.java index e7dc097e0c1457b99a62a62573c6d009a883ee68..b0168dd398917446e98f54b24cb183f0502116ad 100644 --- a/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParserTest2.java +++ b/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParserTest2.java @@ -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(); diff --git a/converter-SBGNML/testFiles/file_that_does_not_pass_xsd.sbgn b/converter-SBGNML/testFiles/file_that_does_not_pass_xsd.sbgn new file mode 100644 index 0000000000000000000000000000000000000000..8d31226eda026797df0ca288dc0ec51af9dbcf46 --- /dev/null +++ b/converter-SBGNML/testFiles/file_that_does_not_pass_xsd.sbgn @@ -0,0 +1,69 @@ +<?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>