Commit 2a65dc71 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

updating default coordinates and zoom lvel for submap fixed

parent 69718976
Pipeline #5873 passed with stage
in 1 minute and 56 seconds
......@@ -5,7 +5,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.apache.log4j.Logger;
import org.springframework.transaction.annotation.Transactional;
......@@ -82,25 +81,20 @@ public class ModelRestImpl extends BaseRestImpl {
public Map<String, Object> updateModel(String projectId, String modelId, Map<String, Object> data, String token)
throws SecurityException, QueryException {
Project project = getProjectService().getProjectByProjectId(projectId, token);
if (project == null) {
throw new ObjectNotFoundException("Project with given id doesn't exist");
}
boolean canModify = getUserService().userHasPrivilege(token, PrivilegeType.ADD_MAP);
if (!canModify) {
throw new SecurityException("You cannot update projects");
}
ModelData model = null;
Integer id = Integer.valueOf(modelId);
for (ModelData m : project.getModels()) {
if (m.getId().equals(id)) {
model = m;
}
if (modelId.equals("*")) {
throw new QueryException("Invalid model id: " + modelId);
}
if (model == null) {
List<Model> models = super.getModels(projectId, modelId, token);
if (models.size() != 1) {
throw new ObjectNotFoundException("Model with given id doesn't exist");
}
ModelData model = models.get(0).getModelData();
Set<String> fields = data.keySet();
for (String fieldName : fields) {
Object value = data.get(fieldName);
......
......@@ -19,11 +19,14 @@ import lcsb.mapviewer.commands.CopyCommand;
import lcsb.mapviewer.common.IProgressUpdater;
import lcsb.mapviewer.common.Pair;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.model.ModelSubmodelConnection;
import lcsb.mapviewer.model.map.model.SubmodelConnection;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.user.PrivilegeType;
......@@ -389,7 +392,19 @@ public class ModelService implements IModelService {
@Override
public void updateModel(ModelData model, String token) throws lcsb.mapviewer.services.SecurityException {
Model topCachedData = getLastModelByProjectId(model.getProject().getProjectId(), token);
Project project = model.getProject();
if (project == null) {
for (SubmodelConnection sc : model.getParentModels()) {
if (sc instanceof ModelSubmodelConnection) {
project = ((ModelSubmodelConnection) sc).getParentModel().getModel().getProject();
if (project != null) {
break;
}
}
}
}
Model topCachedData = getLastModelByProjectId(project.getProjectId(), token);
Model cachedData = topCachedData.getSubmodelById(model.getId());
cachedData.setDefaultCenterX(model.getDefaultCenterX());
cachedData.setDefaultCenterY(model.getDefaultCenterY());
......
Markdown is supported
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