From 6bb095a62d293c4afb5f418afd7d5c24e0096177 Mon Sep 17 00:00:00 2001 From: "CITE\\amentis" Date: Wed, 31 Jul 2024 16:21:20 +0300 Subject: [PATCH] small fix --- .../DescriptionCommonModelBuilder.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java index 7a3dcebc4..f8fbb106b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java @@ -157,8 +157,29 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder itemMap = new HashMap<>(); - PlanDescriptionTemplateQuery q = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getPlanDescriptionTemplateId).distinct().collect(Collectors.toList())); - List items = q.collectAs(new BaseFieldSet().ensure(PlanDescriptionTemplate._id).ensure(PlanDescriptionTemplate._sectionId)); + PlanDescriptionTemplateQuery q = null; + List items; + if (this.isPublic) { + try { + this.entityManager.disableTenantFilters(); + q =this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getPlanDescriptionTemplateId).distinct().collect(Collectors.toList())); + items = q.collectAs(new BaseFieldSet().ensure(PlanDescriptionTemplate._id).ensure(PlanDescriptionTemplate._sectionId)); + try { + this.entityManager.reloadTenantFilters(); + } catch (InvalidApplicationException e) { + throw new RuntimeException(e); + } + } finally { + try { + this.entityManager.reloadTenantFilters(); + } catch (InvalidApplicationException e) { + throw new RuntimeException(e); + } + } + } else { + q =this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getPlanDescriptionTemplateId).distinct().collect(Collectors.toList())); + items = q.collectAs(new BaseFieldSet().ensure(PlanDescriptionTemplate._id).ensure(PlanDescriptionTemplate._sectionId)); + } for (PlanDescriptionTemplateEntity item : items){ itemMap.put(item.getId(), item.getSectionId()); }