[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<String> section) and not from RequestBody - if this is a new section, no id in "Section<Indicator> sectionFull" yet.
This commit is contained in:
Konstantina Galouni 2020-05-13 13:25:02 +00:00
parent 8ef6abce47
commit f522d373ed
1 changed files with 6 additions and 6 deletions

View File

@ -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!");