From db87c7b4e3df850d6bdbe63d819771590c5b6617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Fri, 28 Jul 2023 11:03:21 +0200 Subject: [PATCH] Fix invalid study after update to v8.7.0 - Add default group to existing BCs (#1462) * [UPDATER] Fix invalid study after update to v8.7.0 - Starting from v8.7.0, all binding constraints should have a 'group' attribute with a non-empty group - Before this change, the updater produced wrong constraints * Use group "default" instead of "legacy_study_group" --- .../study/binding_constraint/BindingConstraintLoader.cpp | 4 ++-- .../study/binding_constraint/BindingConstraintSaver.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintLoader.cpp b/src/libs/antares/study/binding_constraint/BindingConstraintLoader.cpp index 657a0284f6..6858d9c036 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintLoader.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintLoader.cpp @@ -160,9 +160,9 @@ std::vector> BindingConstraintLoader::load(En << "]: Missing mandatory binding constraint group"; return {}; } - else + else // In studies versions < 870, binding constraints have no group. From version 870, antares requires constraints to have a group. { - bc->group_ = "legacy_study_group"; + bc->group_ = "default"; } } diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintSaver.cpp b/src/libs/antares/study/binding_constraint/BindingConstraintSaver.cpp index 28e949654d..bdc9efb741 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintSaver.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintSaver.cpp @@ -21,6 +21,9 @@ bool BindingConstraintSaver::saveToEnv(EnvForSaving& env, const BindingConstrain env.section->add("filter-year-by-year", datePrecisionIntoString(bindingConstraint->pFilterYearByYear)); env.section->add("filter-synthesis", datePrecisionIntoString(bindingConstraint->pFilterSynthesis)); + if (!bindingConstraint->group().empty()) + env.section->add("group", bindingConstraint->group()); + if (!bindingConstraint->pComments.empty()) env.section->add("comments", bindingConstraint->pComments);