Search in sources :

Example 1 with DocumentWorkflow

use of de.symeda.sormas.api.docgeneneration.DocumentWorkflow in project SORMAS-Project by hzi-braunschweig.

the class QuarantineOrderFacadeEjbTest method testBulkContactDocumentCreation.

@Test
public void testBulkContactDocumentCreation() throws DocumentTemplateException, IOException {
    ReferenceDto rootEntityReference = contactDto.toReference();
    Properties properties = new Properties();
    properties.setProperty("extraremark1", "the first remark");
    properties.setProperty("extra.remark.no3", "the third remark");
    DocumentWorkflow workflow = DocumentWorkflow.QUARANTINE_ORDER_CONTACT;
    Map<ReferenceDto, byte[]> documentContents = quarantineOrderFacadeEjb.getGeneratedDocuments("Quarantine.docx", workflow, Collections.singletonList(rootEntityReference), properties, false);
    verifyGeneratedDocument(rootEntityReference, workflow, "QuarantineContact.cmp", documentContents.get(rootEntityReference));
}
Also used : ReferenceDto(de.symeda.sormas.api.ReferenceDto) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) PathogenTestReferenceDto(de.symeda.sormas.api.sample.PathogenTestReferenceDto) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) SampleReferenceDto(de.symeda.sormas.api.sample.SampleReferenceDto) TravelEntryReferenceDto(de.symeda.sormas.api.travelentry.TravelEntryReferenceDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) DocumentWorkflow(de.symeda.sormas.api.docgeneneration.DocumentWorkflow) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with DocumentWorkflow

use of de.symeda.sormas.api.docgeneneration.DocumentWorkflow in project SORMAS-Project by hzi-braunschweig.

the class QuarantineOrderFacadeEjbTest method testBulkCaseDocumentCreation.

@Test
public void testBulkCaseDocumentCreation() throws DocumentTemplateException, IOException {
    ReferenceDto rootEntityReference = caseDataDto.toReference();
    Properties properties = new Properties();
    properties.setProperty("extraremark1", "the first remark");
    properties.setProperty("extra.remark.no3", "the third remark");
    DocumentWorkflow workflow = DocumentWorkflow.QUARANTINE_ORDER_CASE;
    Map<ReferenceDto, byte[]> documentContents = quarantineOrderFacadeEjb.getGeneratedDocuments("Quarantine.docx", workflow, Collections.singletonList(rootEntityReference), properties, false);
    verifyGeneratedDocument(rootEntityReference, workflow, "QuarantineCase.cmp", documentContents.get(rootEntityReference));
}
Also used : ReferenceDto(de.symeda.sormas.api.ReferenceDto) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) PathogenTestReferenceDto(de.symeda.sormas.api.sample.PathogenTestReferenceDto) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) SampleReferenceDto(de.symeda.sormas.api.sample.SampleReferenceDto) TravelEntryReferenceDto(de.symeda.sormas.api.travelentry.TravelEntryReferenceDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) DocumentWorkflow(de.symeda.sormas.api.docgeneneration.DocumentWorkflow) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Properties(java.util.Properties) Test(org.junit.Test)

Example 3 with DocumentWorkflow

use of de.symeda.sormas.api.docgeneneration.DocumentWorkflow in project SORMAS-Project by hzi-braunschweig.

the class DocumentTemplateFacadeEjb method getDocumentVariables.

@Override
public DocumentVariables getDocumentVariables(DocumentWorkflow documentWorkflow, String templateName) throws DocumentTemplateException {
    File templateFile = getTemplateFile(documentWorkflow, templateName);
    DocumentVariables documentVariables = documentWorkflow.isDocx() ? getTemplateVariablesDocx(templateFile) : getTemplateVariablesTxt(templateFile);
    Set<String> propertyKeys = documentVariables.getVariables();
    documentVariables.setAdditionalVariables(propertyKeys.stream().filter(e -> !isEntityVariable(documentWorkflow, e)).sorted(String::compareTo).collect(Collectors.toList()));
    propertyKeys.stream().filter(e -> isEntityVariable(documentWorkflow, e)).forEach(e -> documentVariables.addUsedEntity(getVariableBaseName(e)));
    return documentVariables;
}
Also used : DocumentTemplateFacade(de.symeda.sormas.api.docgeneneration.DocumentTemplateFacade) Arrays(java.util.Arrays) DocumentWorkflow(de.symeda.sormas.api.docgeneneration.DocumentWorkflow) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) ReferenceDto(de.symeda.sormas.api.ReferenceDto) DocumentTemplateEntities(de.symeda.sormas.api.docgeneneration.DocumentTemplateEntities) StringUtils(org.apache.commons.lang3.StringUtils) CommunityFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.community.CommunityFacadeEjb.CommunityFacadeEjbLocal) TravelEntryFacadeEjbLocal(de.symeda.sormas.backend.travelentry.TravelEntryFacadeEjb.TravelEntryFacadeEjbLocal) Matcher(java.util.regex.Matcher) ByteArrayInputStream(java.io.ByteArrayInputStream) EventFacadeEjbLocal(de.symeda.sormas.backend.event.EventFacadeEjb.EventFacadeEjbLocal) Path(java.nio.file.Path) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) Stateless(javax.ejb.Stateless) DocumentTemplateException(de.symeda.sormas.api.docgeneneration.DocumentTemplateException) DocumentVariables(de.symeda.sormas.api.docgeneneration.DocumentVariables) Set(java.util.Set) SampleFacadeEjbLocal(de.symeda.sormas.backend.sample.SampleFacadeEjb.SampleFacadeEjbLocal) DistrictFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.district.DistrictFacadeEjb.DistrictFacadeEjbLocal) Collectors(java.util.stream.Collectors) EntityDtoAccessHelper(de.symeda.sormas.api.EntityDtoAccessHelper) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) List(java.util.List) CaseFacadeEjbLocal(de.symeda.sormas.backend.caze.CaseFacadeEjb.CaseFacadeEjbLocal) Pattern(java.util.regex.Pattern) FilenameUtils(org.apache.commons.io.FilenameUtils) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ContactFacadeEjbLocal(de.symeda.sormas.backend.contact.ContactFacadeEjb.ContactFacadeEjbLocal) RootEntityType(de.symeda.sormas.api.docgeneneration.RootEntityType) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) EventParticipantFacadeEjbLocal(de.symeda.sormas.backend.event.EventParticipantFacadeEjb.EventParticipantFacadeEjbLocal) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) SampleReferenceDto(de.symeda.sormas.api.sample.SampleReferenceDto) FacilityFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.facility.FacilityFacadeEjb.FacilityFacadeEjbLocal) LocalBean(javax.ejb.LocalBean) ConfigFacadeEjbLocal(de.symeda.sormas.backend.common.ConfigFacadeEjb.ConfigFacadeEjbLocal) EJB(javax.ejb.EJB) PersonFacadeEjbLocal(de.symeda.sormas.backend.person.PersonFacadeEjb.PersonFacadeEjbLocal) Properties(java.util.Properties) Files(java.nio.file.Files) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) HasUuid(de.symeda.sormas.api.HasUuid) FileOutputStream(java.io.FileOutputStream) UserFacadeEjbLocal(de.symeda.sormas.backend.user.UserFacadeEjb.UserFacadeEjbLocal) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) File(java.io.File) TravelEntryReferenceDto(de.symeda.sormas.api.travelentry.TravelEntryReferenceDto) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) Paths(java.nio.file.Paths) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) RegionFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.region.RegionFacadeEjb.RegionFacadeEjbLocal) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) Strings(de.symeda.sormas.api.i18n.Strings) PointOfEntryFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.pointofentry.PointOfEntryFacadeEjb.PointOfEntryFacadeEjbLocal) Collections(java.util.Collections) DocumentVariables(de.symeda.sormas.api.docgeneneration.DocumentVariables) File(java.io.File)

Example 4 with DocumentWorkflow

use of de.symeda.sormas.api.docgeneneration.DocumentWorkflow in project SORMAS-Project by hzi-braunschweig.

the class QuarantineOrderFacadeEjbTest method testBulkEventParticipantDocumentCreation.

@Test
public void testBulkEventParticipantDocumentCreation() throws DocumentTemplateException, IOException {
    EventParticipantReferenceDto rootEntityReference = eventParticipantDto.toReference();
    Properties properties = new Properties();
    properties.setProperty("extraremark1", "the first remark");
    properties.setProperty("extra.remark.no3", "the third remark");
    DocumentWorkflow workflow = DocumentWorkflow.QUARANTINE_ORDER_EVENT_PARTICIPANT;
    Map<ReferenceDto, byte[]> documentContents = quarantineOrderFacadeEjb.getGeneratedDocumentsForEventParticipants("Quarantine.docx", Collections.singletonList(rootEntityReference), eventDto.getDisease(), properties, false);
    verifyGeneratedDocument(rootEntityReference, workflow, "QuarantineEvent.cmp", documentContents.get(rootEntityReference));
}
Also used : ReferenceDto(de.symeda.sormas.api.ReferenceDto) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) PathogenTestReferenceDto(de.symeda.sormas.api.sample.PathogenTestReferenceDto) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) SampleReferenceDto(de.symeda.sormas.api.sample.SampleReferenceDto) TravelEntryReferenceDto(de.symeda.sormas.api.travelentry.TravelEntryReferenceDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) DocumentWorkflow(de.symeda.sormas.api.docgeneneration.DocumentWorkflow) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

ReferenceDto (de.symeda.sormas.api.ReferenceDto)4 CaseReferenceDto (de.symeda.sormas.api.caze.CaseReferenceDto)4 ContactReferenceDto (de.symeda.sormas.api.contact.ContactReferenceDto)4 DocumentWorkflow (de.symeda.sormas.api.docgeneneration.DocumentWorkflow)4 EventParticipantReferenceDto (de.symeda.sormas.api.event.EventParticipantReferenceDto)4 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)4 SampleReferenceDto (de.symeda.sormas.api.sample.SampleReferenceDto)4 TravelEntryReferenceDto (de.symeda.sormas.api.travelentry.TravelEntryReferenceDto)4 Properties (java.util.Properties)4 PathogenTestReferenceDto (de.symeda.sormas.api.sample.PathogenTestReferenceDto)3 Test (org.junit.Test)2 EntityDtoAccessHelper (de.symeda.sormas.api.EntityDtoAccessHelper)1 HasUuid (de.symeda.sormas.api.HasUuid)1 DocumentTemplateEntities (de.symeda.sormas.api.docgeneneration.DocumentTemplateEntities)1 DocumentTemplateException (de.symeda.sormas.api.docgeneneration.DocumentTemplateException)1 DocumentTemplateFacade (de.symeda.sormas.api.docgeneneration.DocumentTemplateFacade)1 DocumentVariables (de.symeda.sormas.api.docgeneneration.DocumentVariables)1 RootEntityType (de.symeda.sormas.api.docgeneneration.RootEntityType)1 EventReferenceDto (de.symeda.sormas.api.event.EventReferenceDto)1 Strings (de.symeda.sormas.api.i18n.Strings)1