Commit 4ba553e3 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

export notes to sbgn

parent d39a4b95
Pipeline #29738 passed with stage
in 11 minutes and 44 seconds
......@@ -27,7 +27,8 @@ minerva (15.1.0) unstable; urgency=medium
clickable (#1314)
* Small improvement: Modifier Reaction from CellDesigner are exported properly
to SBGN-ML PD (#1320)
* Small improvement: SBGN notes are imported properly
* Small improvement: SBGN notes are imported properly (#1319)
* Small improvement: SBGN notes are exported properly (#1319)
* Bug fix: export to image from selected polygon contained all elements
inside rectangle bounded by the polygon coordinates (#1096)
* Bug fix: continuous refreshing list of project when uploading/removing
......
......@@ -29,6 +29,7 @@ import lcsb.mapviewer.converter.ConverterException;
import lcsb.mapviewer.converter.annotation.XmlAnnotationParser;
import lcsb.mapviewer.converter.graphics.bioEntity.element.species.SpeciesConverter;
import lcsb.mapviewer.converter.graphics.bioEntity.reaction.ReactionConverter;
import lcsb.mapviewer.converter.model.celldesigner.CommonXmlParser;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.graphics.ArrowType;
......@@ -161,6 +162,26 @@ public class SbgnmlXmlExporter {
throw new ConverterException("Problem with providing render information");
}
try {
StringBuilder notes = new StringBuilder();
notes.append("<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title/></head><body>");
if (model.getNotes() != null) {
notes.append(new CommonXmlParser().getNotesXmlContent(model.getNotes()));
}
notes.append("</body></html>");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db;
db = dbf.newDocumentBuilder();
Document doc = db.parse(new ByteArrayInputStream(notes.toString().getBytes()));
map.setNotes(new SBGNBase.Notes());
map.getNotes().getAny().add((org.w3c.dom.Element) (doc.getFirstChild()));
} catch (Exception e) {
logger.warn("Problem with processing notes");
}
sbgnData.getMap().add(map);
return sbgnData;
}
......
......@@ -4,6 +4,7 @@ import static org.junit.Assert.*;
import java.awt.Color;
import java.awt.geom.Point2D;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.apache.logging.log4j.LogManager;
......@@ -16,6 +17,7 @@ import lcsb.mapviewer.converter.Converter;
import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelComparator;
import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.field.Residue;
......@@ -325,6 +327,9 @@ public class SbgnmlXmlParserTest2 extends SbgnmlTestFunctions {
Model model = converter.createModel(new ConverterParams().filename("testFiles/sbgnmlParserTestFiles/sbgnmlFiles/model_notes.sbgn"));
assertFalse(model.getNotes().isEmpty());
model.setIdModel(null);
Model model2 = converter.createModel(new ConverterParams().inputStream(new ByteArrayInputStream(converter.model2String(model).getBytes())));
assertEquals(0, new ModelComparator().compare(model, model2));
}
......
......@@ -81,8 +81,6 @@ public class ModelComparator extends Comparator<Model> {
}
if (stringComparator.compare(arg0.getNotes(), arg1.getNotes(), true) != 0) {
logger.debug(arg0.getNotes());
logger.debug(arg1.getNotes());
logger.debug("Notes different:\n" + arg0.getNotes() + "\n---\n" + arg1.getNotes() + "\n---");
return stringComparator.compare(arg0.getNotes(), arg1.getNotes(), true);
}
......
Supports Markdown
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