Skip to content

Commit 0acb4c9

Browse files
Merge pull request #13174 from SORMAS-Foundation/feature-#13160-disease-for-document-templates
Feature #13160 disease for document templates
2 parents 3f44faf + 7e54cf8 commit 0acb4c9

File tree

65 files changed

+1074
-448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1074
-448
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
3+
* Copyright © 2016-2024 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
14+
*/
15+
16+
package de.symeda.sormas.api.docgeneneration;
17+
18+
import javax.validation.constraints.NotNull;
19+
import javax.validation.constraints.Size;
20+
21+
import de.symeda.sormas.api.Disease;
22+
import de.symeda.sormas.api.EntityDto;
23+
import de.symeda.sormas.api.i18n.Validations;
24+
import de.symeda.sormas.api.utils.DataHelper;
25+
import de.symeda.sormas.api.utils.FieldConstraints;
26+
27+
public class DocumentTemplateDto extends EntityDto {
28+
29+
private static final long serialVersionUID = 8591649635400893169L;
30+
31+
public static final String I18N_PREFIX = "DocumentTemplate";
32+
public static final String DISEASE = "disease";
33+
public static final String FILE_NAME = "fileName";
34+
35+
@NotNull
36+
private DocumentWorkflow workflow;
37+
private Disease disease;
38+
@Size(max = FieldConstraints.CHARACTER_LIMIT_BIG, message = Validations.textTooLong)
39+
private String fileName;
40+
41+
public static DocumentTemplateDto build(DocumentWorkflow documentWorkflow, String fileName) {
42+
DocumentTemplateDto dto = new DocumentTemplateDto();
43+
dto.setUuid(DataHelper.createUuid());
44+
dto.setWorkflow(documentWorkflow);
45+
dto.setFileName(fileName);
46+
47+
return dto;
48+
}
49+
50+
public static DocumentTemplateDto build(DocumentWorkflow documentWorkflow, String fileName, Disease disease) {
51+
DocumentTemplateDto dto = build(documentWorkflow, fileName);
52+
dto.setDisease(disease);
53+
54+
return dto;
55+
}
56+
57+
public DocumentWorkflow getWorkflow() {
58+
return workflow;
59+
}
60+
61+
public void setWorkflow(DocumentWorkflow workflow) {
62+
this.workflow = workflow;
63+
}
64+
65+
public Disease getDisease() {
66+
return disease;
67+
}
68+
69+
public void setDisease(Disease disease) {
70+
this.disease = disease;
71+
}
72+
73+
public String getFileName() {
74+
return fileName;
75+
}
76+
77+
public void setFileName(String fileName) {
78+
this.fileName = fileName;
79+
}
80+
81+
public DocumentTemplateReferenceDto toReference() {
82+
return new DocumentTemplateReferenceDto(getUuid(), fileName);
83+
}
84+
}

sormas-api/src/main/java/de/symeda/sormas/api/docgeneneration/DocumentTemplateFacade.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,33 @@
55

66
import javax.ejb.Remote;
77

8+
import de.symeda.sormas.api.Disease;
9+
810
@Remote
911
public interface DocumentTemplateFacade {
1012

1113
byte[] generateDocumentDocxFromEntities(
12-
DocumentWorkflow documentWorkflow,
13-
String templateName,
14+
DocumentTemplateReferenceDto templateReference,
1415
DocumentTemplateEntities entities,
1516
Properties extraProperties)
1617
throws DocumentTemplateException;
1718

1819
String generateDocumentTxtFromEntities(
19-
DocumentWorkflow documentWorkflow,
20-
String templateName,
20+
DocumentTemplateReferenceDto templateReference,
2121
DocumentTemplateEntities entities,
2222
Properties extraProperties)
2323
throws DocumentTemplateException;
2424

25-
List<String> getAvailableTemplates(DocumentWorkflow documentWorkflow);
25+
List<DocumentTemplateDto> getAvailableTemplates(DocumentWorkflow documentWorkflow, Disease disease);
2626

27-
DocumentVariables getDocumentVariables(DocumentWorkflow documentWorkflow, String templateName) throws DocumentTemplateException;
27+
boolean isExistingTemplateFile(DocumentWorkflow documentWorkflow, Disease disease, String templateName);
2828

29-
boolean isExistingTemplate(DocumentWorkflow documentWorkflow, String templateName);
29+
DocumentVariables getDocumentVariables(DocumentTemplateReferenceDto templateReference) throws DocumentTemplateException;
3030

31-
void writeDocumentTemplate(DocumentWorkflow documentWorkflow, String templateName, byte[] document) throws DocumentTemplateException;
31+
DocumentTemplateDto saveDocumentTemplate(DocumentTemplateDto template, byte[] document)
32+
throws DocumentTemplateException;
3233

33-
boolean deleteDocumentTemplate(DocumentWorkflow documentWorkflow, String templateName) throws DocumentTemplateException;
34+
boolean deleteDocumentTemplate(DocumentTemplateReferenceDto templateReference) throws DocumentTemplateException;
3435

35-
byte[] getDocumentTemplate(DocumentWorkflow documentWorkflow, String templateName) throws DocumentTemplateException;
36+
byte[] getDocumentTemplateContent(DocumentTemplateReferenceDto templateReference) throws DocumentTemplateException;
3637
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
3+
* Copyright © 2016-2024 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
14+
*/
15+
16+
package de.symeda.sormas.api.docgeneneration;
17+
18+
import de.symeda.sormas.api.ReferenceDto;
19+
20+
public class DocumentTemplateReferenceDto extends ReferenceDto {
21+
22+
public DocumentTemplateReferenceDto(String uuid, String caption) {
23+
super(uuid, caption);
24+
}
25+
}

sormas-api/src/main/java/de/symeda/sormas/api/docgeneneration/EventDocumentFacade.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,28 @@
2121

2222
import javax.ejb.Remote;
2323

24+
import de.symeda.sormas.api.Disease;
2425
import de.symeda.sormas.api.ReferenceDto;
2526
import de.symeda.sormas.api.event.EventReferenceDto;
2627

2728
@Remote
2829
public interface EventDocumentFacade {
2930

30-
String getGeneratedDocument(String templateName, EventReferenceDto eventReference, Properties extraProperties, Boolean shouldUploadGeneratedDoc)
31+
String getGeneratedDocument(
32+
DocumentTemplateReferenceDto templateReferenceDto,
33+
EventReferenceDto eventReference,
34+
Properties extraProperties,
35+
Boolean shouldUploadGeneratedDoc)
3136
throws DocumentTemplateException;
3237

3338
Map<ReferenceDto, byte[]> getGeneratedDocuments(
34-
String templateName,
39+
DocumentTemplateReferenceDto templateReference,
3540
List<EventReferenceDto> eventReferences,
3641
Properties extraProperties,
3742
Boolean shouldUploadGeneratedDoc)
3843
throws DocumentTemplateException;
3944

40-
List<String> getAvailableTemplates();
45+
List<DocumentTemplateDto> getAvailableTemplates(Disease disease);
4146

42-
DocumentVariables getDocumentVariables(String templateName) throws DocumentTemplateException;
47+
DocumentVariables getDocumentVariables(DocumentTemplateReferenceDto templateReference) throws DocumentTemplateException;
4348
}

sormas-api/src/main/java/de/symeda/sormas/api/docgeneneration/QuarantineOrderDocumentOptionsDto.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package de.symeda.sormas.api.docgeneneration;
22

3+
import java.io.Serializable;
4+
import java.util.Properties;
5+
36
import de.symeda.sormas.api.sample.PathogenTestReferenceDto;
47
import de.symeda.sormas.api.sample.SampleReferenceDto;
58
import de.symeda.sormas.api.vaccination.VaccinationReferenceDto;
69

7-
import javax.validation.constraints.NotNull;
8-
import java.io.Serializable;
9-
import java.util.Properties;
10-
1110
public class QuarantineOrderDocumentOptionsDto implements Serializable {
1211

13-
private String templateFile;
12+
private DocumentTemplateReferenceDto template;
1413
private SampleReferenceDto sample;
1514
private PathogenTestReferenceDto pathogenTest;
1615
private VaccinationReferenceDto vaccinationReference;
@@ -19,12 +18,12 @@ public class QuarantineOrderDocumentOptionsDto implements Serializable {
1918
private DocumentWorkflow documentWorkflow;
2019

2120

22-
public String getTemplateFile() {
23-
return templateFile;
21+
public DocumentTemplateReferenceDto getTemplate() {
22+
return template;
2423
}
2524

26-
public void setTemplateFile(String templateFile) {
27-
this.templateFile = templateFile;
25+
public void setTemplate(DocumentTemplateReferenceDto template) {
26+
this.template = template;
2827
}
2928

3029
public SampleReferenceDto getSample() {

sormas-api/src/main/java/de/symeda/sormas/api/docgeneneration/QuarantineOrderFacade.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
public interface QuarantineOrderFacade {
3333

3434
byte[] getGeneratedDocument(
35-
String templateName,
36-
DocumentWorkflow workflow,
35+
DocumentTemplateReferenceDto templateReference,
3736
RootEntityType rootEntityType,
3837
ReferenceDto rootEntityReference,
3938
SampleReferenceDto sampleReference,
@@ -44,22 +43,21 @@ byte[] getGeneratedDocument(
4443
throws DocumentTemplateException;
4544

4645
Map<ReferenceDto, byte[]> getGeneratedDocuments(
47-
String templateName,
48-
DocumentWorkflow workflow,
46+
DocumentTemplateReferenceDto templateReference,
4947
List<ReferenceDto> rootEntityReferences,
5048
Properties extraProperties,
5149
Boolean shouldUploadGeneratedDoc)
5250
throws DocumentTemplateException;
5351

5452
Map<ReferenceDto, byte[]> getGeneratedDocumentsForEventParticipants(
55-
String templateName,
56-
List<EventParticipantReferenceDto> rootEntityReferences,
57-
Disease eventDisease,
58-
Properties extraProperties,
59-
Boolean shouldUploadGeneratedDoc)
60-
throws DocumentTemplateException;
53+
DocumentTemplateReferenceDto templateReference,
54+
List<EventParticipantReferenceDto> rootEntityReferences,
55+
Disease eventDisease,
56+
Properties extraProperties,
57+
Boolean shouldUploadGeneratedDoc)
58+
throws DocumentTemplateException;
6159

62-
List<String> getAvailableTemplates(DocumentWorkflow workflow);
60+
List<DocumentTemplateDto> getAvailableTemplates(DocumentWorkflow workflow, Disease disease);
6361

64-
DocumentVariables getDocumentVariables(DocumentWorkflow documentWorkflow, String templateName) throws DocumentTemplateException;
62+
DocumentVariables getDocumentVariables(DocumentTemplateReferenceDto templateReference) throws DocumentTemplateException;
6563
}

sormas-api/src/main/java/de/symeda/sormas/api/externalemail/ExternalEmailFacade.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import de.symeda.sormas.api.ReferenceDto;
2626
import de.symeda.sormas.api.common.progress.ProcessedEntity;
27+
import de.symeda.sormas.api.docgeneneration.DocumentTemplateDto;
2728
import de.symeda.sormas.api.docgeneneration.DocumentTemplateException;
2829
import de.symeda.sormas.api.docgeneneration.DocumentWorkflow;
2930
import de.symeda.sormas.api.document.DocumentReferenceDto;
@@ -33,7 +34,7 @@
3334
@Remote
3435
public interface ExternalEmailFacade {
3536

36-
List<String> getTemplateNames(DocumentWorkflow documentWorkflow);
37+
List<DocumentTemplateDto> getTemplates(DocumentWorkflow documentWorkflow);
3738

3839
List<DocumentReferenceDto> getAttachableDocuments(DocumentWorkflow documentWorkflow, String relatedEntityUuid);
3940

sormas-api/src/main/java/de/symeda/sormas/api/externalemail/ExternalEmailOptionsDto.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import de.symeda.sormas.api.ReferenceDto;
2525
import de.symeda.sormas.api.audit.AuditedClass;
26+
import de.symeda.sormas.api.docgeneneration.DocumentTemplateReferenceDto;
2627
import de.symeda.sormas.api.docgeneneration.DocumentWorkflow;
2728
import de.symeda.sormas.api.docgeneneration.QuarantineOrderDocumentOptionsDto;
2829
import de.symeda.sormas.api.docgeneneration.RootEntityType;
@@ -36,7 +37,7 @@ public class ExternalEmailOptionsDto implements Serializable {
3637

3738
public static final String I18N_PREFIX = "ExternalEmailOptions";
3839

39-
public static final String TEMPLATE_NAME = "templateName";
40+
public static final String TEMPLATE = "template";
4041
public static final String RECIPIENT_EMAIL = "recipientEmail";
4142
public static final String ATTACHED_DOCUMENTS = "attachedDocuments";
4243

@@ -47,8 +48,7 @@ public class ExternalEmailOptionsDto implements Serializable {
4748
@NotNull(message = Validations.requiredField)
4849
private ReferenceDto rootEntityReference;
4950
@NotNull(message = Validations.requiredField)
50-
@Size(min = 1, message = Validations.requiredField)
51-
private String templateName;
51+
private DocumentTemplateReferenceDto template;
5252
@NotNull(message = Validations.requiredField)
5353
@Size(min = 1, message = Validations.requiredField)
5454
private String recipientEmail;
@@ -78,12 +78,12 @@ public void setRootEntityReference(ReferenceDto rootEntityReference) {
7878
this.rootEntityReference = rootEntityReference;
7979
}
8080

81-
public String getTemplateName() {
82-
return templateName;
81+
public DocumentTemplateReferenceDto getTemplate() {
82+
return template;
8383
}
8484

85-
public void setTemplateName(String templateName) {
86-
this.templateName = templateName;
85+
public void setTemplate(DocumentTemplateReferenceDto template) {
86+
this.template = template;
8787
}
8888

8989
public String getRecipientEmail() {

sormas-api/src/main/java/de/symeda/sormas/api/externalemail/ExternalEmailOptionsWithAttachmentsDto.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
package de.symeda.sormas.api.externalemail;
2222

2323
import java.io.Serializable;
24-
import java.util.Properties;
2524
import java.util.Set;
2625

27-
import javax.validation.Valid;
2826
import javax.validation.constraints.NotNull;
29-
import javax.validation.constraints.Size;
3027

3128
import de.symeda.sormas.api.audit.AuditedClass;
29+
import de.symeda.sormas.api.docgeneneration.DocumentTemplateReferenceDto;
3230
import de.symeda.sormas.api.docgeneneration.DocumentWorkflow;
3331
import de.symeda.sormas.api.docgeneneration.EmailAttachementDto;
3432
import de.symeda.sormas.api.docgeneneration.QuarantineOrderDocumentOptionsDto;
@@ -51,8 +49,7 @@ public class ExternalEmailOptionsWithAttachmentsDto implements Serializable {
5149
@NotNull(message = Validations.requiredField)
5250
private final RootEntityType rootEntityType;
5351
@NotNull(message = Validations.requiredField)
54-
@Size(min = 1, message = Validations.requiredField)
55-
private String templateName;
52+
private DocumentTemplateReferenceDto template;
5653
private Set<EmailAttachementDto> attachedDocuments;
5754

5855
private QuarantineOrderDocumentOptionsDto quarantineOrderDocumentOptionsDto;
@@ -70,12 +67,12 @@ public RootEntityType getRootEntityType() {
7067
return rootEntityType;
7168
}
7269

73-
public String getTemplateName() {
74-
return templateName;
70+
public DocumentTemplateReferenceDto getTemplate() {
71+
return template;
7572
}
7673

77-
public void setTemplateName(String templateName) {
78-
this.templateName = templateName;
74+
public void setTemplate(DocumentTemplateReferenceDto template) {
75+
this.template = template;
7976
}
8077

8178
public Set<EmailAttachementDto> getAttachedDocuments() {

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,7 @@ public interface Captions {
13941394
String documentNoDocuments = "documentNoDocuments";
13951395
String DocumentTemplate = "DocumentTemplate";
13961396
String DocumentTemplate_buttonUploadTemplate = "DocumentTemplate.buttonUploadTemplate";
1397+
String DocumentTemplate_disease = "DocumentTemplate.disease";
13971398
String DocumentTemplate_documentTemplateGuide = "DocumentTemplate.documentTemplateGuide";
13981399
String DocumentTemplate_documentUploadWarning = "DocumentTemplate.documentUploadWarning";
13991400
String DocumentTemplate_EventHandout = "DocumentTemplate.EventHandout";
@@ -1407,6 +1408,7 @@ public interface Captions {
14071408
String DocumentTemplate_exampleTemplateEventParticipants = "DocumentTemplate.exampleTemplateEventParticipants";
14081409
String DocumentTemplate_exampleTemplateTravelEntries = "DocumentTemplate.exampleTemplateTravelEntries";
14091410
String DocumentTemplate_exampleTemplateTravelEntryEmail = "DocumentTemplate.exampleTemplateTravelEntryEmail";
1411+
String DocumentTemplate_fileName = "DocumentTemplate.fileName";
14101412
String DocumentTemplate_fileTooBig = "DocumentTemplate.fileTooBig";
14111413
String DocumentTemplate_notUploaded = "DocumentTemplate.notUploaded";
14121414
String DocumentTemplate_plural = "DocumentTemplate.plural";

0 commit comments

Comments
 (0)