Skip to content

Commit

Permalink
Merge pull request #13174 from SORMAS-Foundation/feature-#13160-disea…
Browse files Browse the repository at this point in the history
…se-for-document-templates

Feature #13160 disease for document templates
  • Loading branch information
leventegal-she authored Oct 30, 2024
2 parents 3f44faf + 7e54cf8 commit 0acb4c9
Show file tree
Hide file tree
Showing 65 changed files with 1,074 additions and 448 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2024 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package de.symeda.sormas.api.docgeneneration;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.EntityDto;
import de.symeda.sormas.api.i18n.Validations;
import de.symeda.sormas.api.utils.DataHelper;
import de.symeda.sormas.api.utils.FieldConstraints;

public class DocumentTemplateDto extends EntityDto {

private static final long serialVersionUID = 8591649635400893169L;

public static final String I18N_PREFIX = "DocumentTemplate";
public static final String DISEASE = "disease";
public static final String FILE_NAME = "fileName";

@NotNull
private DocumentWorkflow workflow;
private Disease disease;
@Size(max = FieldConstraints.CHARACTER_LIMIT_BIG, message = Validations.textTooLong)
private String fileName;

public static DocumentTemplateDto build(DocumentWorkflow documentWorkflow, String fileName) {
DocumentTemplateDto dto = new DocumentTemplateDto();
dto.setUuid(DataHelper.createUuid());
dto.setWorkflow(documentWorkflow);
dto.setFileName(fileName);

return dto;
}

public static DocumentTemplateDto build(DocumentWorkflow documentWorkflow, String fileName, Disease disease) {
DocumentTemplateDto dto = build(documentWorkflow, fileName);
dto.setDisease(disease);

return dto;
}

public DocumentWorkflow getWorkflow() {
return workflow;
}

public void setWorkflow(DocumentWorkflow workflow) {
this.workflow = workflow;
}

public Disease getDisease() {
return disease;
}

public void setDisease(Disease disease) {
this.disease = disease;
}

public String getFileName() {
return fileName;
}

public void setFileName(String fileName) {
this.fileName = fileName;
}

public DocumentTemplateReferenceDto toReference() {
return new DocumentTemplateReferenceDto(getUuid(), fileName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,33 @@

import javax.ejb.Remote;

import de.symeda.sormas.api.Disease;

@Remote
public interface DocumentTemplateFacade {

byte[] generateDocumentDocxFromEntities(
DocumentWorkflow documentWorkflow,
String templateName,
DocumentTemplateReferenceDto templateReference,
DocumentTemplateEntities entities,
Properties extraProperties)
throws DocumentTemplateException;

String generateDocumentTxtFromEntities(
DocumentWorkflow documentWorkflow,
String templateName,
DocumentTemplateReferenceDto templateReference,
DocumentTemplateEntities entities,
Properties extraProperties)
throws DocumentTemplateException;

List<String> getAvailableTemplates(DocumentWorkflow documentWorkflow);
List<DocumentTemplateDto> getAvailableTemplates(DocumentWorkflow documentWorkflow, Disease disease);

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

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

void writeDocumentTemplate(DocumentWorkflow documentWorkflow, String templateName, byte[] document) throws DocumentTemplateException;
DocumentTemplateDto saveDocumentTemplate(DocumentTemplateDto template, byte[] document)
throws DocumentTemplateException;

boolean deleteDocumentTemplate(DocumentWorkflow documentWorkflow, String templateName) throws DocumentTemplateException;
boolean deleteDocumentTemplate(DocumentTemplateReferenceDto templateReference) throws DocumentTemplateException;

byte[] getDocumentTemplate(DocumentWorkflow documentWorkflow, String templateName) throws DocumentTemplateException;
byte[] getDocumentTemplateContent(DocumentTemplateReferenceDto templateReference) throws DocumentTemplateException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2024 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package de.symeda.sormas.api.docgeneneration;

import de.symeda.sormas.api.ReferenceDto;

public class DocumentTemplateReferenceDto extends ReferenceDto {

public DocumentTemplateReferenceDto(String uuid, String caption) {
super(uuid, caption);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,28 @@

import javax.ejb.Remote;

import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.ReferenceDto;
import de.symeda.sormas.api.event.EventReferenceDto;

@Remote
public interface EventDocumentFacade {

String getGeneratedDocument(String templateName, EventReferenceDto eventReference, Properties extraProperties, Boolean shouldUploadGeneratedDoc)
String getGeneratedDocument(
DocumentTemplateReferenceDto templateReferenceDto,
EventReferenceDto eventReference,
Properties extraProperties,
Boolean shouldUploadGeneratedDoc)
throws DocumentTemplateException;

Map<ReferenceDto, byte[]> getGeneratedDocuments(
String templateName,
DocumentTemplateReferenceDto templateReference,
List<EventReferenceDto> eventReferences,
Properties extraProperties,
Boolean shouldUploadGeneratedDoc)
throws DocumentTemplateException;

List<String> getAvailableTemplates();
List<DocumentTemplateDto> getAvailableTemplates(Disease disease);

DocumentVariables getDocumentVariables(String templateName) throws DocumentTemplateException;
DocumentVariables getDocumentVariables(DocumentTemplateReferenceDto templateReference) throws DocumentTemplateException;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package de.symeda.sormas.api.docgeneneration;

import java.io.Serializable;
import java.util.Properties;

import de.symeda.sormas.api.sample.PathogenTestReferenceDto;
import de.symeda.sormas.api.sample.SampleReferenceDto;
import de.symeda.sormas.api.vaccination.VaccinationReferenceDto;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Properties;

public class QuarantineOrderDocumentOptionsDto implements Serializable {

private String templateFile;
private DocumentTemplateReferenceDto template;
private SampleReferenceDto sample;
private PathogenTestReferenceDto pathogenTest;
private VaccinationReferenceDto vaccinationReference;
Expand All @@ -19,12 +18,12 @@ public class QuarantineOrderDocumentOptionsDto implements Serializable {
private DocumentWorkflow documentWorkflow;


public String getTemplateFile() {
return templateFile;
public DocumentTemplateReferenceDto getTemplate() {
return template;
}

public void setTemplateFile(String templateFile) {
this.templateFile = templateFile;
public void setTemplate(DocumentTemplateReferenceDto template) {
this.template = template;
}

public SampleReferenceDto getSample() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
public interface QuarantineOrderFacade {

byte[] getGeneratedDocument(
String templateName,
DocumentWorkflow workflow,
DocumentTemplateReferenceDto templateReference,
RootEntityType rootEntityType,
ReferenceDto rootEntityReference,
SampleReferenceDto sampleReference,
Expand All @@ -44,22 +43,21 @@ byte[] getGeneratedDocument(
throws DocumentTemplateException;

Map<ReferenceDto, byte[]> getGeneratedDocuments(
String templateName,
DocumentWorkflow workflow,
DocumentTemplateReferenceDto templateReference,
List<ReferenceDto> rootEntityReferences,
Properties extraProperties,
Boolean shouldUploadGeneratedDoc)
throws DocumentTemplateException;

Map<ReferenceDto, byte[]> getGeneratedDocumentsForEventParticipants(
String templateName,
List<EventParticipantReferenceDto> rootEntityReferences,
Disease eventDisease,
Properties extraProperties,
Boolean shouldUploadGeneratedDoc)
throws DocumentTemplateException;
DocumentTemplateReferenceDto templateReference,
List<EventParticipantReferenceDto> rootEntityReferences,
Disease eventDisease,
Properties extraProperties,
Boolean shouldUploadGeneratedDoc)
throws DocumentTemplateException;

List<String> getAvailableTemplates(DocumentWorkflow workflow);
List<DocumentTemplateDto> getAvailableTemplates(DocumentWorkflow workflow, Disease disease);

DocumentVariables getDocumentVariables(DocumentWorkflow documentWorkflow, String templateName) throws DocumentTemplateException;
DocumentVariables getDocumentVariables(DocumentTemplateReferenceDto templateReference) throws DocumentTemplateException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import de.symeda.sormas.api.ReferenceDto;
import de.symeda.sormas.api.common.progress.ProcessedEntity;
import de.symeda.sormas.api.docgeneneration.DocumentTemplateDto;
import de.symeda.sormas.api.docgeneneration.DocumentTemplateException;
import de.symeda.sormas.api.docgeneneration.DocumentWorkflow;
import de.symeda.sormas.api.document.DocumentReferenceDto;
Expand All @@ -33,7 +34,7 @@
@Remote
public interface ExternalEmailFacade {

List<String> getTemplateNames(DocumentWorkflow documentWorkflow);
List<DocumentTemplateDto> getTemplates(DocumentWorkflow documentWorkflow);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import de.symeda.sormas.api.ReferenceDto;
import de.symeda.sormas.api.audit.AuditedClass;
import de.symeda.sormas.api.docgeneneration.DocumentTemplateReferenceDto;
import de.symeda.sormas.api.docgeneneration.DocumentWorkflow;
import de.symeda.sormas.api.docgeneneration.QuarantineOrderDocumentOptionsDto;
import de.symeda.sormas.api.docgeneneration.RootEntityType;
Expand All @@ -36,7 +37,7 @@ public class ExternalEmailOptionsDto implements Serializable {

public static final String I18N_PREFIX = "ExternalEmailOptions";

public static final String TEMPLATE_NAME = "templateName";
public static final String TEMPLATE = "template";
public static final String RECIPIENT_EMAIL = "recipientEmail";
public static final String ATTACHED_DOCUMENTS = "attachedDocuments";

Expand All @@ -47,8 +48,7 @@ public class ExternalEmailOptionsDto implements Serializable {
@NotNull(message = Validations.requiredField)
private ReferenceDto rootEntityReference;
@NotNull(message = Validations.requiredField)
@Size(min = 1, message = Validations.requiredField)
private String templateName;
private DocumentTemplateReferenceDto template;
@NotNull(message = Validations.requiredField)
@Size(min = 1, message = Validations.requiredField)
private String recipientEmail;
Expand Down Expand Up @@ -78,12 +78,12 @@ public void setRootEntityReference(ReferenceDto rootEntityReference) {
this.rootEntityReference = rootEntityReference;
}

public String getTemplateName() {
return templateName;
public DocumentTemplateReferenceDto getTemplate() {
return template;
}

public void setTemplateName(String templateName) {
this.templateName = templateName;
public void setTemplate(DocumentTemplateReferenceDto template) {
this.template = template;
}

public String getRecipientEmail() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
package de.symeda.sormas.api.externalemail;

import java.io.Serializable;
import java.util.Properties;
import java.util.Set;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import de.symeda.sormas.api.audit.AuditedClass;
import de.symeda.sormas.api.docgeneneration.DocumentTemplateReferenceDto;
import de.symeda.sormas.api.docgeneneration.DocumentWorkflow;
import de.symeda.sormas.api.docgeneneration.EmailAttachementDto;
import de.symeda.sormas.api.docgeneneration.QuarantineOrderDocumentOptionsDto;
Expand All @@ -51,8 +49,7 @@ public class ExternalEmailOptionsWithAttachmentsDto implements Serializable {
@NotNull(message = Validations.requiredField)
private final RootEntityType rootEntityType;
@NotNull(message = Validations.requiredField)
@Size(min = 1, message = Validations.requiredField)
private String templateName;
private DocumentTemplateReferenceDto template;
private Set<EmailAttachementDto> attachedDocuments;

private QuarantineOrderDocumentOptionsDto quarantineOrderDocumentOptionsDto;
Expand All @@ -70,12 +67,12 @@ public RootEntityType getRootEntityType() {
return rootEntityType;
}

public String getTemplateName() {
return templateName;
public DocumentTemplateReferenceDto getTemplate() {
return template;
}

public void setTemplateName(String templateName) {
this.templateName = templateName;
public void setTemplate(DocumentTemplateReferenceDto template) {
this.template = template;
}

public Set<EmailAttachementDto> getAttachedDocuments() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,7 @@ public interface Captions {
String documentNoDocuments = "documentNoDocuments";
String DocumentTemplate = "DocumentTemplate";
String DocumentTemplate_buttonUploadTemplate = "DocumentTemplate.buttonUploadTemplate";
String DocumentTemplate_disease = "DocumentTemplate.disease";
String DocumentTemplate_documentTemplateGuide = "DocumentTemplate.documentTemplateGuide";
String DocumentTemplate_documentUploadWarning = "DocumentTemplate.documentUploadWarning";
String DocumentTemplate_EventHandout = "DocumentTemplate.EventHandout";
Expand All @@ -1407,6 +1408,7 @@ public interface Captions {
String DocumentTemplate_exampleTemplateEventParticipants = "DocumentTemplate.exampleTemplateEventParticipants";
String DocumentTemplate_exampleTemplateTravelEntries = "DocumentTemplate.exampleTemplateTravelEntries";
String DocumentTemplate_exampleTemplateTravelEntryEmail = "DocumentTemplate.exampleTemplateTravelEntryEmail";
String DocumentTemplate_fileName = "DocumentTemplate.fileName";
String DocumentTemplate_fileTooBig = "DocumentTemplate.fileTooBig";
String DocumentTemplate_notUploaded = "DocumentTemplate.notUploaded";
String DocumentTemplate_plural = "DocumentTemplate.plural";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ public interface Strings {
String errorDeletingDocumentTemplate = "errorDeletingDocumentTemplate";
String errorDocumentGeneration = "errorDocumentGeneration";
String errorDocumentGenerationMultipleDiseasses = "errorDocumentGenerationMultipleDiseasses";
String errorDocumentTemplateWorkflowChangeNotAllowed = "errorDocumentTemplateWorkflowChangeNotAllowed";
String errorEntityNotEditable = "errorEntityNotEditable";
String errorEntityOutdated = "errorEntityOutdated";
String errorEnvironmentSampleNoDispatchRight = "errorEnvironmentSampleNoDispatchRight";
Expand Down
Loading

0 comments on commit 0acb4c9

Please sign in to comment.