From f522d373ed1623193dbf691ea308c142a4999e6a Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Wed, 13 May 2020 13:25:02 +0000 Subject: [PATCH] [Trunk | Monitor Service]: SectionController: [Bug fix] In method "saveSection()" (/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/save/{index}) a. Pathvariable "index" is required - if index == -1, ignore it and add section in the end of the list. b. Use id from saved section (Section section) and not from RequestBody - if this is a new section, no id in "Section sectionFull" yet. --- .../controllers/SectionController.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/controllers/SectionController.java b/src/main/java/eu/dnetlib/uoamonitorservice/controllers/SectionController.java index 9828fa6..a3b8189 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/controllers/SectionController.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/controllers/SectionController.java @@ -79,10 +79,10 @@ public class SectionController { // this section belongs in default profile and it is new or it is updated if(stakeholder.getDefaultId() == null) { if(sectionId == null) { - onSaveDefaultSection(sectionFull, topicId, categoryId, subcategoryId, stakeholder); + onSaveDefaultSection(section, topicId, categoryId, subcategoryId, stakeholder); } else { - onUpdateDefaultSection(sectionFull, stakeholder); + onUpdateDefaultSection(section, stakeholder); } } @@ -93,12 +93,12 @@ public class SectionController { sections = subCategory.getNumbers(); } - int existing_index = sections.indexOf(sectionFull.getId()); + int existing_index = sections.indexOf(section.getId()); if (existing_index == -1) { - if(index != null) { - sections.add(Integer.parseInt(index), sectionFull.getId()); + if(Integer.parseInt(index) != -1) { + sections.add(Integer.parseInt(index), section.getId()); } else { - sections.add(sectionFull.getId()); + sections.add(section.getId()); } subCategoryDAO.save(subCategory); log.debug("Section saved!");