Skip to content
Snippets Groups Projects
Commit a9740fef authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when exporting notes to sbml, the notes string is escaped first

parent 5346cba2
No related branches found
No related tags found
1 merge request!293Resolve "Error when exporting ReconMap to SBML"
Pipeline #
......@@ -6,6 +6,7 @@ import java.util.Map;
import javax.xml.stream.XMLStreamException;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.log4j.Logger;
import org.sbml.jsbml.Model;
import org.sbml.jsbml.ext.layout.AbstractReferenceGlyph;
......@@ -72,7 +73,7 @@ public abstract class SbmlBioEntityExporter<T extends BioEntity, S extends org.s
}
sbmlElement.setName(element.getName());
try {
sbmlElement.setNotes(element.getNotes());
sbmlElement.setNotes(StringEscapeUtils.escapeXml(element.getNotes()));
} catch (XMLStreamException e) {
throw new InvalidStateException(e);
}
......
......@@ -261,4 +261,17 @@ public class SbmlExporterTest {
assertEquals(0, comparator.compare(model, model2));
}
@Test
public void testExportProblematicNotes() throws Exception {
Model model = createModelWithReaction();
Reaction reaction = model.getReactions().iterator().next();
reaction.setNotes("X=Y<Z");
Model deserializedModel = getModelAfterSerializing(model);
Reaction deserializedReaction = deserializedModel.getReactions().iterator().next();
assertEquals(reaction.getNotes(), deserializedReaction.getNotes());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment