From 6e8eccecb1857aa647234801a43582f0430d165f Mon Sep 17 00:00:00 2001 From: "CITE\\spapacharalampous" Date: Thu, 29 Aug 2024 18:03:06 +0300 Subject: [PATCH] fixed description template code validation --- .../descriptiontemplate/DescriptionTemplateServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java index 1d952afa3..d6e88467e 100644 --- a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java @@ -226,6 +226,9 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic .groupIds(data.getGroupId()) .count(); if (activeDescriptionTemplatesForTheGroup > 0) throw new MyApplicationException("Description template group id is in use please use new version endpoint"); + + Long descriptionTemplateCodes = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().codes(model.getCode()).count(); + if (descriptionTemplateCodes > 0) throw new MyValidationException(this.errors.getDescriptionTemplateCodeExists().getCode(), this.errors.getDescriptionTemplateCodeExists().getMessage()); } this.updateVersionStatusAndSave(data, previousStatus, data.getStatus());