Commit 49be893f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1306-text-area-in-convert-api' into 'devel_15.0.x'

conversion api process model in the same way as map upload

See merge request !1212
parents f6e6b319 8d0ca687
Pipeline #29188 passed with stage
in 14 minutes and 52 seconds
......@@ -11,6 +11,7 @@ minerva (15.0.2) stable; urgency=medium
* Bug fix: user data overlays were not removed when user was deleted (#1301)
* Bug fix: kinetic parameters exported to SBML created invalid SBML file
(#1305)
* Bug fix: text area were not converted to GPML using conversion API (#1306)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 29 Jun 2020 11:00:00 +0200
......
......@@ -40,29 +40,26 @@ public class ConvertRestImpl extends BaseRestImpl {
QueryException {
ConverterParams params = createConvertParams(input);
MinervaLoggerAppender appender = MinervaLoggerAppender.createAppender();
Model model;
Model original;
try {
model = getModelParserByNameOrClass(fromFormat).createModel(params);
StringBuilder notes = new StringBuilder(model.getNotes());
original = getModelParserByNameOrClass(fromFormat).createModel(params);
StringBuilder notes = new StringBuilder(original.getNotes());
if (!appender.getWarnings().isEmpty()) {
for (String entry : new LogFormatter().createFormattedWarnings(appender.getWarnings())) {
notes.append("\n" + entry);
}
}
model.setNotes(notes.toString());
original.setNotes(notes.toString());
} finally {
MinervaLoggerAppender.unregisterLogEventStorage(appender);
}
Model model = getModelWithPathwayAndCompartment(original);
Converter exporter = getModelParserByNameOrClass(toFormat);
return IOUtils.toString(exporter.model2InputStream(model), StandardCharsets.UTF_8);
}
public ByteArrayOutputStream converToImage(String fromFormat, String toFormat, byte[] input,
Double targetWidth, Double targetHeight)
throws InvalidInputDataExecption, SBMLException, IOException, ConverterException, DrawingException,
QueryException {
Model original = getModelParserByNameOrClass(fromFormat).createModel(createConvertParams(input));
private Model getModelWithPathwayAndCompartment(Model original) {
Model model = new CopyCommand(original).execute();
try {
new CreateHierarchyCommand(model, 10, 1024).execute();
......@@ -73,6 +70,16 @@ public class ConvertRestImpl extends BaseRestImpl {
logger.error("Problem with creating pathways", e);
model = original;
}
return model;
}
public ByteArrayOutputStream converToImage(String fromFormat, String toFormat, byte[] input,
Double targetWidth, Double targetHeight)
throws InvalidInputDataExecption, SBMLException, IOException, ConverterException, DrawingException,
QueryException {
Model original = getModelParserByNameOrClass(fromFormat).createModel(createConvertParams(input));
Model model = getModelWithPathwayAndCompartment(original);
AbstractImageGenerator generator = getImageGenerator(toFormat, createImageParams(model, targetWidth, targetHeight));
ByteArrayOutputStream os = new ByteArrayOutputStream();
......
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