Commit 397db307 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1429-problem-with-downloading-map' into 'devel_15.1.x'

copy of the map is synchronized due to untracked side effects happening during copy process

See merge request !1263
parents d232fd34 3c09221a
Pipeline #36159 passed with stage
in 19 minutes and 15 seconds
...@@ -2,6 +2,8 @@ minerva (15.1.2) stable; urgency=medium ...@@ -2,6 +2,8 @@ minerva (15.1.2) stable; urgency=medium
* Bug fix: automatic annotations are sometimes missing after project upload * Bug fix: automatic annotations are sometimes missing after project upload
(#1434) (#1434)
* Bug fix: export to SBML failed if reactant/product line had length=0 * Bug fix: export to SBML failed if reactant/product line had length=0
* Bug fix: downloading submap from big project as a map quite often resulted
in error (#1440)
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 7 Jan 2021 15:00:00 +0200 -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 7 Jan 2021 15:00:00 +0200
......
...@@ -47,48 +47,50 @@ public class CopyCommand extends NewModelCommand { ...@@ -47,48 +47,50 @@ public class CopyCommand extends NewModelCommand {
Model model = getModel(); Model model = getModel();
if (model.getModelData().getParentModels().size() > 0) { synchronized (model) {
ModelSubmodelConnection parent = null;
for (SubmodelConnection connection : model.getModelData().getParentModels()) { if (model.getModelData().getParentModels().size() > 0) {
if (connection instanceof ModelSubmodelConnection) { ModelSubmodelConnection parent = null;
if (parent != null) { for (SubmodelConnection connection : model.getModelData().getParentModels()) {
throw new InvalidArgumentException( if (connection instanceof ModelSubmodelConnection) {
"It looks like the model is a submodel, but has more than one parent..."); if (parent != null) {
} else { throw new InvalidArgumentException(
parent = (ModelSubmodelConnection) connection; "It looks like the model is a submodel, but has more than one parent...");
} else {
parent = (ModelSubmodelConnection) connection;
}
} }
} }
} if (parent != null) {
if (parent != null) { CopyCommand copyParentCommand = new CopyCommand(parent.getParentModel().getModel());
CopyCommand copyParentCommand = new CopyCommand(parent.getParentModel().getModel()); Model copy = copyParentCommand.execute();
Model copy = copyParentCommand.execute(); for (ModelSubmodelConnection submodel : copy.getSubmodelConnections()) {
for (ModelSubmodelConnection submodel : copy.getSubmodelConnections()) { if (submodel.getName().equals(parent.getName())) {
if (submodel.getName().equals(parent.getName())) { return submodel.getSubmodel().getModel();
return submodel.getSubmodel().getModel(); }
} }
throw new InvalidStateException("Problem with copying submodel of a model");
} }
throw new InvalidStateException("Problem with copying submodel of a model");
} }
}
Model result = createNotNestedCopy(model); Model result = createNotNestedCopy(model);
copies.put(model, result); copies.put(model, result);
for (ModelSubmodelConnection submodelConnection : model.getSubmodelConnections()) { for (ModelSubmodelConnection submodelConnection : model.getSubmodelConnections()) {
Model submodel = submodelConnection.getSubmodel().getModel(); Model submodel = submodelConnection.getSubmodel().getModel();
Model submodelCopy = createNotNestedCopy(submodel); Model submodelCopy = createNotNestedCopy(submodel);
copies.put(submodel, submodelCopy); copies.put(submodel, submodelCopy);
} }
for (Model modelCopy : copies.values()) { for (Model modelCopy : copies.values()) {
try { try {
assignModelCopies(modelCopy, copies); assignModelCopies(modelCopy, copies);
} catch (InvalidModelException e) { } catch (InvalidModelException e) {
throw new InvalidArgumentException(e); throw new InvalidArgumentException(e);
}
} }
return result;
} }
return result;
} }
/** /**
......
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