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
* Bug fix: automatic annotations are sometimes missing after project upload
(#1434)
* 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
......
......@@ -47,48 +47,50 @@ public class CopyCommand extends NewModelCommand {
Model model = getModel();
if (model.getModelData().getParentModels().size() > 0) {
ModelSubmodelConnection parent = null;
for (SubmodelConnection connection : model.getModelData().getParentModels()) {
if (connection instanceof ModelSubmodelConnection) {
if (parent != null) {
throw new InvalidArgumentException(
"It looks like the model is a submodel, but has more than one parent...");
} else {
parent = (ModelSubmodelConnection) connection;
synchronized (model) {
if (model.getModelData().getParentModels().size() > 0) {
ModelSubmodelConnection parent = null;
for (SubmodelConnection connection : model.getModelData().getParentModels()) {
if (connection instanceof ModelSubmodelConnection) {
if (parent != null) {
throw new InvalidArgumentException(
"It looks like the model is a submodel, but has more than one parent...");
} else {
parent = (ModelSubmodelConnection) connection;
}
}
}
}
if (parent != null) {
CopyCommand copyParentCommand = new CopyCommand(parent.getParentModel().getModel());
Model copy = copyParentCommand.execute();
for (ModelSubmodelConnection submodel : copy.getSubmodelConnections()) {
if (submodel.getName().equals(parent.getName())) {
return submodel.getSubmodel().getModel();
if (parent != null) {
CopyCommand copyParentCommand = new CopyCommand(parent.getParentModel().getModel());
Model copy = copyParentCommand.execute();
for (ModelSubmodelConnection submodel : copy.getSubmodelConnections()) {
if (submodel.getName().equals(parent.getName())) {
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()) {
Model submodel = submodelConnection.getSubmodel().getModel();
Model submodelCopy = createNotNestedCopy(submodel);
copies.put(submodel, submodelCopy);
}
for (Model modelCopy : copies.values()) {
try {
assignModelCopies(modelCopy, copies);
} catch (InvalidModelException e) {
throw new InvalidArgumentException(e);
for (ModelSubmodelConnection submodelConnection : model.getSubmodelConnections()) {
Model submodel = submodelConnection.getSubmodel().getModel();
Model submodelCopy = createNotNestedCopy(submodel);
copies.put(submodel, submodelCopy);
}
for (Model modelCopy : copies.values()) {
try {
assignModelCopies(modelCopy, copies);
} catch (InvalidModelException 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