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

export of model with invalid model id doesn't break export to sbml

parent 1deccb1f
...@@ -73,7 +73,12 @@ public class SbmlExporter { ...@@ -73,7 +73,12 @@ public class SbmlExporter {
*/ */
protected SBMLDocument toSbmlDocument(lcsb.mapviewer.model.map.model.Model model) throws InconsistentModelException { protected SBMLDocument toSbmlDocument(lcsb.mapviewer.model.map.model.Model model) throws InconsistentModelException {
SBMLDocument doc = new SBMLDocument(3, 2); SBMLDocument doc = new SBMLDocument(3, 2);
Model result = doc.createModel(model.getIdModel()); Model result = doc.createModel();
try {
result.setId(model.getIdModel());
} catch (IllegalArgumentException e) {
logger.warn("Invalid model identifier: \"" + model.getIdModel() + "\". Ignoring.");
}
result.setName(model.getName()); result.setName(model.getName());
try { try {
result.setNotes(NotesUtility.prepareEscapedXmlNotes(model.getNotes())); result.setNotes(NotesUtility.prepareEscapedXmlNotes(model.getNotes()));
......
...@@ -28,7 +28,7 @@ import lcsb.mapviewer.model.map.species.*; ...@@ -28,7 +28,7 @@ import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.field.*; import lcsb.mapviewer.model.map.species.field.*;
public class SbmlExporterTest extends SbmlTestFunctions { public class SbmlExporterTest extends SbmlTestFunctions {
Logger logger = LogManager.getLogger(SbmlExporterTest.class); Logger logger = LogManager.getLogger();
ModelComparator comparator = new ModelComparator(); ModelComparator comparator = new ModelComparator();
...@@ -612,4 +612,12 @@ public class SbmlExporterTest extends SbmlTestFunctions { ...@@ -612,4 +612,12 @@ public class SbmlExporterTest extends SbmlTestFunctions {
assertEquals(0, comparator.compare(model, originalModel)); assertEquals(0, comparator.compare(model, originalModel));
} }
@Test
public void testExportInvalidMapId() throws Exception {
Model originalModel = createEmptyModel();
originalModel.setIdModel("F006-ACLY-SBGNv02.sbgn");
String result = exporter.toXml(originalModel);
assertNotNull(result);
}
} }
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