Commit dfaf8482 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

handle project without top map

parent 9ce0700f
Pipeline #43279 passed with stage
in 18 minutes and 3 seconds
...@@ -113,15 +113,17 @@ public class ModelRestImpl extends BaseRestImpl { ...@@ -113,15 +113,17 @@ public class ModelRestImpl extends BaseRestImpl {
private List<Map<String, Object>> createData(Project project) throws QueryException { private List<Map<String, Object>> createData(Project project) throws QueryException {
List<Map<String, Object>> result = new ArrayList<>(); List<Map<String, Object>> result = new ArrayList<>();
Collection<ModelData> originalModels = getModelService().getModelsByProjectId(project.getProjectId()); Collection<ModelData> originalModels = getModelService().getModelsByProjectId(project.getProjectId());
ModelData topModel = project.getTopModel().getModelData();
List<ModelData> models = new ArrayList<>(); List<ModelData> models = new ArrayList<>();
for (ModelData model: originalModels) { if (project.getTopModel() != null) {
ModelData topModel = project.getTopModel().getModelData();
for (ModelData model : originalModels) {
if (!Objects.equals(model.getId(), topModel.getId())) { if (!Objects.equals(model.getId(), topModel.getId())) {
models.add(model); models.add(model);
} }
} }
models.sort(ModelData.ID_COMPARATOR);
result.add(getModel(topModel)); result.add(getModel(topModel));
}
models.sort(ModelData.ID_COMPARATOR);
for (ModelData model2 : models) { for (ModelData model2 : models) {
result.add(getModel(model2)); result.add(getModel(model2));
} }
......
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