Skip to content
Snippets Groups Projects

Resolve "newt catalysis protein-phenotype is not drawn in MINERVA"

10 files
+ 312
147
Compare changes
  • Side-by-side
  • Inline
Files
10
@@ -3,7 +3,11 @@ package lcsb.mapviewer.converter.model.sbgnml;
import java.io.*;
import javax.xml.bind.JAXBException;
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.logging.log4j.core.LogEvent;
import org.sbgn.SbgnUtil;
@@ -23,7 +27,7 @@ public class SbgnmlXmlConverter extends Converter {
SbgnmlXmlParser parser = new SbgnmlXmlParser();
File inputFile = null;
try {
inputFile = inputStream2File(params.getInputStream());
inputFile = createFileWithModifiedStyleIdList(params.getInputStream());
return parser.createModel(params.getFilename(), inputFile);
} catch (IOException e) {
throw new ConverterException("Failed to convert input stream to file.", e);
@@ -32,6 +36,33 @@ public class SbgnmlXmlConverter extends Converter {
}
}
private File createFileWithModifiedStyleIdList(InputStream inputStream) throws ConverterException, IOException {
try {
TransformerFactory factory = TransformerFactory.newInstance();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// Use the factory to create a template containing the xsl file that deals with these issues:
// https://github.com/iVis-at-Bilkent/newt/issues/536
// https://git-r3lab.uni.lu/minerva/core/issues/1127
Templates template = factory
.newTemplates(new StreamSource(classLoader.getResourceAsStream("rename_id_list_attribute.xsl")));
Transformer xformer = template.newTransformer();
ByteArrayOutputStream output = new ByteArrayOutputStream();
Source source = new StreamSource(inputStream);
Result result = new StreamResult(output);
xformer.transform(source, result);
return inputStream2File(output.toInputStream());
} catch (Exception e) {
throw new ConverterException(e);
}
}
@Override
public String model2String(Model model) throws ConverterException {
MinervaLoggerAppender appender = MinervaLoggerAppender.createAppender();
Loading