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

when exporting custom properties strings are properly escaped as xml parameters

parent f3278201
No related branches found
No related tags found
2 merge requests!730some bugfixes from 12.2.2 into master,!729Resolve "annotating protein created model that cannot be exported properly"
......@@ -160,8 +160,9 @@ public class RestAnnotationParser extends XmlParser {
return "";
}
} else if (value instanceof String) {
if (!((String) value).trim().isEmpty() || forceFullInfo) {
return type.getCommonName() + ": " + value + "\n";
String string =(String) value;
if (!(string.trim().isEmpty()) || forceFullInfo) {
return type.getCommonName() + ": " + super.escapeXml(string) + "\n";
} else {
return "";
}
......@@ -178,7 +179,7 @@ public class RestAnnotationParser extends XmlParser {
if (object instanceof MiriamData) {
result += ((MiriamData) object).getResource();
} else {
result += object;
result += super.escapeXml(object.toString());
}
}
......
......@@ -54,6 +54,8 @@ import lcsb.mapviewer.model.map.species.Species;
public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
Logger logger = Logger.getLogger(CellDesignerXmlParserTest.class);
ModelComparator modelComparator = new ModelComparator();
@Before
public void setUp() throws Exception {
}
......@@ -422,8 +424,6 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
InputStream is = new ByteArrayInputStream(xmlString.getBytes());
Model model2 = parser.createModel(new ConverterParams().inputStream(is).sizeAutoAdjust(false));
ModelComparator modelComparator = new ModelComparator();
assertEquals(0, modelComparator.compare(model, model2));
} catch (Exception e) {
......@@ -1012,6 +1012,34 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
}
}
@Test
public void testSpeciesWithSpecialSynonym() throws Exception {
try {
Model model = new ModelFullIndexed(null);
model.setIdModel("as");
model.setWidth(10);
model.setHeight(10);
Species protein = new GenericProtein("id1");
protein.setWidth(10);
protein.setHeight(10);
protein.setName("ROS");
protein.addSynonym("&");
model.addElement(protein);
CellDesignerXmlParser parser = new CellDesignerXmlParser();
String xmlString = parser.toXml(model);
InputStream is = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
Model model2 = parser.createModel(new ConverterParams().inputStream(is));
assertEquals(0, modelComparator.compare(model, model2));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testReactionCoordsEqual() throws Exception {
try {
......
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