Commit 7d484131 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1148-sbgn-reaction-with-no-reactants-crash-map-upload' into 'master'

Resolve "SBGN reaction with no reactants crash map upload"

Closes #1148

See merge request minerva/core!1101
parents b21ca3ac 491def44
......@@ -34,6 +34,7 @@ minerva (15.0.0~beta.2) stable; urgency=medium
desciption (#1107)
* Bug fix: label omim href with "www" prefix are parsed properly
* Bug fix: modification position imported from GPML file is preserved (#1107)
* Bug fix: SBGN reaction with no reactants crashed map upload (#1148)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 27 Feb 2020 14:00:00 +0200
......
......@@ -1509,7 +1509,6 @@ public class SbgnmlXmlParser {
}
Reaction reaction = getReactionFromProcessGlyphClazz(p.getCentralPoint().getClazz());
reaction.setIdReaction(p.getCentralPoint().getId());
reaction.setModel(model);
reaction.setReversible(p.isReversible());
......@@ -1592,6 +1591,10 @@ public class SbgnmlXmlParser {
}
splitOperator.getLine().getBeginPoint().setLocation(reaction.getProducts().get(0).getLine().getBeginPoint());
}
if (reaction.getReactants().size() == 0) {
logger.warn(new LogMarker(ProjectLogEntryType.PARSING_ISSUE, reaction), "At least one reactant is required");
return;
}
Point2D centerPointStart = reaction.getReactants().get(0).getLine().getEndPoint();
if (andOperator != null) {
......
......@@ -76,6 +76,15 @@ public class SbgnmlXmlParserTest2 extends SbgnmlTestFunctions {
assertNotNull(complex.getZ());
}
@Test
public void testReactionWithoutReactan() throws Exception {
Converter converter = new SbgnmlXmlConverter();
Model model = converter
.createModel(new ConverterParams().filename("testFiles/sbgnmlParserTestFiles/sbgnmlFiles/no_reactants.sbgn"));
assertEquals(0, model.getReactions().size());
}
@Test
public void testCoordinatesOfOperators() throws Exception {
Converter converter = new SbgnmlXmlConverter();
......@@ -276,7 +285,7 @@ public class SbgnmlXmlParserTest2 extends SbgnmlTestFunctions {
assertEquals(new ColorParser().parse("#c8d8ebff"), element.getFillColor());
}
@Test
public void testReactionToPhenotypeColor() throws Exception {
Converter converter = new SbgnmlXmlConverter();
......@@ -287,6 +296,7 @@ public class SbgnmlXmlParserTest2 extends SbgnmlTestFunctions {
assertEquals(2, model.getReactions().size());
}
@Test
public void testProcessWithoutNodes() 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">
<glyph id="nwtN_84c44d03-d0b2-4ebe-a3bf-38a86d65a4eb" class="macromolecule">
<label text="a"/>
<bbox x="646.9287343415558" y="366.959788062739" w="60" h="30"/>
</glyph>
<glyph id="nwtN_512a4a03-6252-4640-9f43-d1ee836080cc" class="macromolecule">
<label text="w"/>
<bbox x="1156.875048247307" y="366.959788062739" w="60" h="30"/>
</glyph>
<glyph id="nwtN_5d931f90-2884-4094-bb98-e700bfad6b0c" class="process">
<bbox x="836.7682976345036" y="462.80766743695256" w="14.285714285714286" h="14.285714285714286"/>
<port id="nwtN_5d931f90-2884-4094-bb98-e700bfad6b0c.1" x="833.9111547773607" y="469.9505245798097"/>
<port id="nwtN_5d931f90-2884-4094-bb98-e700bfad6b0c.2" x="853.9111547773607" y="469.9505245798097"/>
</glyph>
<glyph id="nwtN_218e3ff8-d6fe-49a6-b590-9e0495ffd62a" class="macromolecule">
<label text="q"/>
<bbox x="1100.880943190989" y="620.9330502824661" w="60" h="30"/>
</glyph>
<glyph id="nwtN_4c08dad7-9050-4c6a-9345-5d164f1defdb" class="process">
<bbox x="873.7644027609991" y="602.7929300777471" w="14.285714285714286" h="14.285714285714286"/>
<port id="nwtN_4c08dad7-9050-4c6a-9345-5d164f1defdb.1" x="870.9072599038562" y="609.9357872206042"/>
<port id="nwtN_4c08dad7-9050-4c6a-9345-5d164f1defdb.2" x="890.9072599038562" y="609.9357872206042"/>
</glyph>
<arc id="nwtE_ee7bf805-7643-4766-a078-3082518d6bd3" class="consumption" source="nwtN_512a4a03-6252-4640-9f43-d1ee836080cc" target="nwtN_5d931f90-2884-4094-bb98-e700bfad6b0c.1">
<start x="1156.250048247307" y="389.8169309198819"/>
<end x="854.5361547773607" y="467.22457705794386"/>
</arc>
<arc id="nwtE_df7ab06c-55a2-419d-9d19-83314148d219" class="production" source="nwtN_4c08dad7-9050-4c6a-9345-5d164f1defdb.2" target="nwtN_218e3ff8-d6fe-49a6-b590-9e0495ffd62a">
<start x="891.5322599038562" y="611.0407872206042"/>
<end x="1097.1477073222704" y="632.4247937521193"/>
</arc>
</map>
</sbgn>
\ No newline at end of file
......@@ -164,7 +164,7 @@ public class ConfigurationControllerIntegrationTest extends ControllerIntegratio
@Test
public void testRegisterExistingUser() throws Exception {
public void testRegisterExistingDapiUser() throws Exception {
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
UserDto user = new UserDto();
......
......@@ -33,7 +33,7 @@ import lcsb.mapviewer.common.UnitTestFailedWatcher;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.ProjectStatus;
import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.graphics.*;
import lcsb.mapviewer.model.map.Comment;
import lcsb.mapviewer.model.map.layout.ColorSchemaType;
import lcsb.mapviewer.model.map.layout.Layout;
......@@ -203,19 +203,14 @@ abstract public class ControllerIntegrationTest {
map.setWidth(100);
map.setHeight(100);
Element element = new GenericProtein("p1");
element.setWidth(100.0);
element.setHeight(20.0);
element.setX(10);
element.setX(20);
element.setZ(2);
Glyph g = new Glyph();
g.setFile(file);
element.setGlyph(g);
Element element = createProtein();
Glyph glyph = new Glyph();
glyph.setFile(file);
element.setGlyph(glyph);
map.addElement(element);
project.addModel(map);
project.addGlyph(g);
project.addGlyph(glyph);
projectDao.add(project);
return project;
}
......@@ -233,12 +228,7 @@ abstract public class ControllerIntegrationTest {
reaction.setZ(2);
reaction.setLine(new PolylineData(new Point2D.Double(0, 0), new Point2D.Double(10, 0)));
map.addReaction(reaction);
Element element = new GenericProtein("p1");
element.setWidth(100.0);
element.setHeight(20.0);
element.setX(10);
element.setX(20);
element.setZ(2);
Element element = createProtein();
map.addElement(element);
Reactant reactant = new Reactant(element);
......@@ -254,6 +244,19 @@ abstract public class ControllerIntegrationTest {
return project;
}
private GenericProtein createProtein() {
GenericProtein element = new GenericProtein("p1");
element.setWidth(100.0);
element.setHeight(20.0);
element.setX(10);
element.setX(20);
element.setZ(2);
element.setNamePoint(element.getCenter());
element.setNameHorizontalAlign(HorizontalAlign.CENTER);
element.setNameVerticalAlign(VerticalAlign.MIDDLE);
return element;
}
protected UploadedFileEntry createFile(String content, User user) {
return createFile(content.getBytes(), user);
}
......
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