From aae220d9d9df11a3f79463c3d77f912105ec3c53 Mon Sep 17 00:00:00 2001 From: pkupczyk <piotr.kupczyk@id.ethz.ch> Date: Fri, 9 Jun 2023 14:51:47 +0200 Subject: [PATCH] SSDM-13730 : Admin UI : update of unofficial term made it official --- .../vocabulary/UpdateVocabularyTermExecutor.java | 10 ++++++---- .../systemtest/asapi/v3/UpdateVocabularyTermTest.java | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/vocabulary/UpdateVocabularyTermExecutor.java b/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/vocabulary/UpdateVocabularyTermExecutor.java index ce0e66536ed..a4a4b8dca06 100644 --- a/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/vocabulary/UpdateVocabularyTermExecutor.java +++ b/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/vocabulary/UpdateVocabularyTermExecutor.java @@ -155,11 +155,13 @@ public class UpdateVocabularyTermExecutor implements IUpdateVocabularyTermExecut if (termPE.isOfficial() && Boolean.FALSE.equals(update.isOfficial().getValue())) { throw new UserFailureException( - "Offical vocabulary term " + update.getVocabularyTermId() + " cannot be updated to be unofficial."); + "Official vocabulary term " + update.getVocabularyTermId() + " cannot be updated to be unofficial."); + } else if (!termPE.isOfficial() && Boolean.TRUE.equals(update.isOfficial().getValue())) + { + VocabularyTerm term = new VocabularyTerm(); + term.setId(termPE.getId()); + termBO.makeOfficial(Arrays.asList(term)); } - VocabularyTerm term = new VocabularyTerm(); - term.setId(termPE.getId()); - termBO.makeOfficial(Arrays.asList(term)); } } diff --git a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateVocabularyTermTest.java b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateVocabularyTermTest.java index 403b0637a00..97ad242f72e 100644 --- a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateVocabularyTermTest.java +++ b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateVocabularyTermTest.java @@ -91,6 +91,7 @@ public class UpdateVocabularyTermTest extends AbstractVocabularyTest VocabularyTermUpdate update = new VocabularyTermUpdate(); update.setVocabularyTermId(permIds.get(0)); + update.setDescription("updated description"); update.setOfficial(true); assertExceptionMessage(new IDelegatedAction() @@ -183,7 +184,7 @@ public class UpdateVocabularyTermTest extends AbstractVocabularyTest updateTerms(TEST_USER, PASSWORD, update); } - @Test(expectedExceptions = UserFailureException.class, expectedExceptionsMessageRegExp = ".*Offical vocabulary term DOG \\(ORGANISM\\) cannot be updated to be unofficial.*") + @Test(expectedExceptions = UserFailureException.class, expectedExceptionsMessageRegExp = ".*Official vocabulary term DOG \\(ORGANISM\\) cannot be updated to be unofficial.*") public void testUpdateWithOfficialTermMadeUnofficial() { VocabularyTermUpdate update = new VocabularyTermUpdate(); -- GitLab