Skip to content

Commit 043df68

Browse files
sergiupacurariuSergiuPacurariu
andauthored
Feature 13192 add doc and email template to survey (#13271)
* #13252 - Create Survey pages * #13252 - Create Survey pages * #13252 - Create Survey pages - changes after review * #13252 - Create Survey pages - changes after review * #13252 - Create Survey pages - changes after review * #13192 - Add upload of Document and email template for Survey * #13192 - Add upload of Document and email template for Survey * #13192 - Add upload of Document and email template for Survey * #13192 - Add upload of Document and email template for Survey * #13192 - Add upload of Document and email template for Survey * #13192 - Add upload of Document and email template for Survey * #13192 - Add upload of Document and email template for Survey --------- Co-authored-by: SergiuPacurariu <sergiu.pacurariu@she.ro>
1 parent bb20ce0 commit 043df68

Some content is hidden

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

41 files changed

+568
-105
lines changed

sormas-api/src/main/java/de/symeda/sormas/api/audit/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class Constants {
99

1010
public static final Set<String> createPrefix =
11-
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("create", "generate", "build", "clone", "calculate")));
11+
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("create", "generate", "build", "clone", "calculate", "upload")));
1212
public static final Set<String> readPrefix = Collections.unmodifiableSet(
1313
new HashSet<>(
1414
Arrays.asList(
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package de.symeda.sormas.api.docgeneneration;
2+
3+
import javax.annotation.Nullable;
4+
5+
import de.symeda.sormas.api.Disease;
6+
import de.symeda.sormas.api.survey.SurveyReferenceDto;
7+
import de.symeda.sormas.api.utils.criteria.BaseCriteria;
8+
9+
public class DocumentTemplateCriteria extends BaseCriteria {
10+
11+
public static final String DOCUMENT_WORKFLOW = "documentWorkflow";
12+
public static final String DISEASE = "disease";
13+
public static final String SURVEY = "surveyReference";
14+
15+
private DocumentWorkflow documentWorkflow;
16+
@Nullable
17+
private Disease disease;
18+
private SurveyReferenceDto surveyReference;
19+
20+
public DocumentTemplateCriteria(DocumentWorkflow documentWorkflow, Disease disease, SurveyReferenceDto surveyReference) {
21+
this.documentWorkflow = documentWorkflow;
22+
this.disease = disease;
23+
this.surveyReference = surveyReference;
24+
}
25+
26+
public DocumentWorkflow getDocumentWorkflow() {
27+
return documentWorkflow;
28+
}
29+
30+
public DocumentTemplateCriteria setDocumentWorkflow(DocumentWorkflow documentWorkflow) {
31+
this.documentWorkflow = documentWorkflow;
32+
return this;
33+
}
34+
35+
public Disease getDisease() {
36+
return disease;
37+
}
38+
39+
public DocumentTemplateCriteria setDisease(Disease disease) {
40+
this.disease = disease;
41+
return this;
42+
}
43+
44+
public SurveyReferenceDto getSurveyReference() {
45+
return surveyReference;
46+
}
47+
48+
public DocumentTemplateCriteria setSurveyReference(SurveyReferenceDto surveyReference) {
49+
this.surveyReference = surveyReference;
50+
return this;
51+
}
52+
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ String generateDocumentTxtFromEntities(
2222
Properties extraProperties)
2323
throws DocumentTemplateException;
2424

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

2727
boolean isExistingTemplateFile(DocumentWorkflow documentWorkflow, Disease disease, String templateName);
2828

2929
DocumentVariables getDocumentVariables(DocumentTemplateReferenceDto templateReference) throws DocumentTemplateException;
3030

31-
DocumentTemplateDto saveDocumentTemplate(DocumentTemplateDto template, byte[] document)
32-
throws DocumentTemplateException;
31+
DocumentTemplateDto saveDocumentTemplate(DocumentTemplateDto template, byte[] document) throws DocumentTemplateException;
3332

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

3636
byte[] getDocumentTemplateContent(DocumentTemplateReferenceDto templateReference) throws DocumentTemplateException;
3737
}

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,23 @@ public enum DocumentWorkflow {
126126
UserRight.EMAIL_TEMPLATE_MANAGEMENT,
127127
ROOT_TRAVEL_ENTRY,
128128
ROOT_PERSON,
129-
ROOT_USER);
129+
ROOT_USER),
130+
SURVEY_DOCUMENT(DocumentWorkflowType.DOCUMENT,
131+
"survey",
132+
DOCX,
133+
UserRight.SURVEY_EDIT,
134+
ROOT_CASE,
135+
ROOT_PERSON,
136+
ROOT_USER,
137+
ROOT_SAMPLE),
138+
SURVEY_EMAIL(DocumentWorkflowType.EMAIL,
139+
Constants.EMAIL_TEMPLATES_FOLDER + "/surveys",
140+
TXT,
141+
UserRight.SURVEY_EDIT,
142+
ROOT_CASE,
143+
ROOT_PERSON,
144+
ROOT_USER,
145+
ROOT_SAMPLE),;
130146

131147
private final DocumentWorkflowType type;
132148
private final String templateDirectory;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ExternalEmailOptionsWithAttachmentsDto implements Serializable {
4040

4141
public static final String I18N_PREFIX = "ExternalEmailOptionsWithAttachments";
4242

43-
public static final String TEMPLATE_NAME = "templateName";
43+
public static final String TEMPLATE_NAME = "template";
4444
public static final String RECIPIENT_EMAIL = "recipientEmail";
4545
public static final String ATTACHED_DOCUMENTS = "attachedDocuments";
4646

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
@@ -1408,6 +1408,8 @@ public interface Captions {
14081408
String DocumentTemplate_exampleTemplateEventHandout = "DocumentTemplate.exampleTemplateEventHandout";
14091409
String DocumentTemplate_exampleTemplateEventParticipantEmail = "DocumentTemplate.exampleTemplateEventParticipantEmail";
14101410
String DocumentTemplate_exampleTemplateEventParticipants = "DocumentTemplate.exampleTemplateEventParticipants";
1411+
String DocumentTemplate_exampleTemplateSurveyDocument = "DocumentTemplate.exampleTemplateSurveyDocument";
1412+
String DocumentTemplate_exampleTemplateSurveyEmail = "DocumentTemplate.exampleTemplateSurveyEmail";
14111413
String DocumentTemplate_exampleTemplateTravelEntries = "DocumentTemplate.exampleTemplateTravelEntries";
14121414
String DocumentTemplate_exampleTemplateTravelEntryEmail = "DocumentTemplate.exampleTemplateTravelEntryEmail";
14131415
String DocumentTemplate_fileName = "DocumentTemplate.fileName";

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ public interface Strings {
981981
String infoDeveloperOptionsSeedUsage = "infoDeveloperOptionsSeedUsage";
982982
String infoDisplayNetworkDiagram = "infoDisplayNetworkDiagram";
983983
String infoDocumentAlreadyExists = "infoDocumentAlreadyExists";
984+
String infoDocumentAlreadyExistsCannotUploadAnotherOne = "infoDocumentAlreadyExistsCannotUploadAnotherOne";
984985
String infoDocumentOverride = "infoDocumentOverride";
985986
String infoDontShareCheckboxAlreadyShared = "infoDontShareCheckboxAlreadyShared";
986987
String infoDownloadCaseImportTemplate = "infoDownloadCaseImportTemplate";

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ public interface Validations {
260260
String specifySex = "specifySex";
261261
String specifyYear = "specifyYear";
262262
String statisticsIncidenceOnlyNumbersAllowed = "statisticsIncidenceOnlyNumbersAllowed";
263+
String surveyDocumentTemplateMissingTokenVariable = "surveyDocumentTemplateMissingTokenVariable";
263264
String taskMissingCaseLink = "taskMissingCaseLink";
264265
String taskMissingContactLink = "taskMissingContactLink";
265266
String taskMissingEventLink = "taskMissingEventLink";

sormas-api/src/main/java/de/symeda/sormas/api/survey/SurveyDto.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,8 @@ public DocumentTemplateReferenceDto getEmailTemplate() {
8484
public void setEmailTemplate(DocumentTemplateReferenceDto emailTemplate) {
8585
this.emailTemplate = emailTemplate;
8686
}
87+
88+
public SurveyReferenceDto toReferenceDto() {
89+
return new SurveyReferenceDto(this.getUuid(), this.getName());
90+
};
8791
}

sormas-api/src/main/java/de/symeda/sormas/api/survey/SurveyFacade.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@
1919

2020
import javax.ejb.Remote;
2121
import javax.validation.Valid;
22+
import javax.validation.constraints.NotNull;
2223

24+
import de.symeda.sormas.api.docgeneneration.DocumentTemplateDto;
25+
import de.symeda.sormas.api.docgeneneration.DocumentTemplateException;
2326
import de.symeda.sormas.api.utils.SortProperty;
2427

2528
@Remote
2629
public interface SurveyFacade {
2730

2831
SurveyDto save(@Valid SurveyDto dto);
2932

30-
SurveyDto getByUuid(String uuid);
33+
void uploadDocumentTemplate(@NotNull SurveyReferenceDto surveyRef, DocumentTemplateDto uploadedDocumentTemplate, byte[] fileContent)
34+
throws DocumentTemplateException;
35+
36+
SurveyDto getByUuid(String uuid);
3137

3238
long count(SurveyCriteria criteria);
3339

@@ -39,5 +45,8 @@ public interface SurveyFacade {
3945

4046
SurveyReferenceDto getReferenceByUuid(String uuid);
4147

42-
Boolean isEditAllowed(String uuid);
48+
Boolean isEditAllowed(String uuid);
49+
50+
void uploadEmailTemplate(@NotNull SurveyReferenceDto surveyReference, DocumentTemplateDto uploadedDocumentTemplateDto, byte[] fileContent)
51+
throws DocumentTemplateException;
4352
}

0 commit comments

Comments
 (0)