From dd16e2dea49d45d5b55b401f89f5ea68e72d07eb Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Sat, 9 Mar 2024 14:24:53 +0100 Subject: [PATCH] test for empty singup inquiry pdf --- .../ctsms/service/proband/ProbandServiceImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/phoenixctms/ctsms/service/proband/ProbandServiceImpl.java b/core/src/main/java/org/phoenixctms/ctsms/service/proband/ProbandServiceImpl.java index 653b3d8e7b2a..1e12dd5d1900 100644 --- a/core/src/main/java/org/phoenixctms/ctsms/service/proband/ProbandServiceImpl.java +++ b/core/src/main/java/org/phoenixctms/ctsms/service/proband/ProbandServiceImpl.java @@ -2057,13 +2057,19 @@ protected InquiriesPDFVO handleRenderInquiriesSignup(AuthenticationVO auth, Long department = CheckIDUtil.checkDepartmentId(departmentId, this.getDepartmentDao()); } Collection trials = new ArrayList(); - Iterator trialIt = this.getTrialDao().findBySignup(department != null ? department.getId() : null, true, null).iterator(); + if (this.getTrialDao().findBySignup(departmentId, true, null).size() == 0) { + throw L10nUtil.initServiceException(ServiceExceptionCodes.MASS_MAIL_NO_PROBAND_LETTER_ATTACHMENT); + } + Iterator trialIt = this.getTrialDao().findBySignup(departmentId, true, null).iterator(); while (trialIt.hasNext()) { Trial trial = trialIt.next(); if (this.getInquiryValueDao().getCount(trial.getId(), null, activeSignup, proband.getId()) > 0) { trials.add(trial); } } + if (trials.size() == 0) { + throw L10nUtil.initServiceException(ServiceExceptionCodes.PROBAND_LETTER_NOT_FOR_ANIMAL_ENTRIES); + } InquiriesPDFVO result = ServiceUtil.renderInquiries(proband, probandVO, trials, null, activeSignup, false, this.getTrialDao(), this.getInquiryDao(), this.getInquiryValueDao(), this.getInputFieldDao(), this.getInputFieldSelectionSetValueDao(),