Search in sources :

Example 16 with SormasToSormasEventDto

use of de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto in project SORMAS-Project by hzi-braunschweig.

the class ReceivedEntitiesProcessor method processReceivedData.

public List<ValidationErrors> processReceivedData(SormasToSormasDto receivedData, ShareDataExistingEntities existingEntities) {
    List<ValidationErrors> validationErrors = new ArrayList<>();
    SormasToSormasOriginInfoDto originInfo = receivedData.getOriginInfo();
    originInfo.setUuid(DataHelper.createUuid());
    originInfo.setChangeDate(new Date());
    ValidationErrors originInfoErrors = validateOriginInfo(originInfo, Captions.sormasToSormasOriginInfo);
    if (originInfoErrors.hasError()) {
        validationErrors.add(originInfoErrors);
    }
    List<SormasToSormasCaseDto> cases = receivedData.getCases();
    if (CollectionUtils.isNotEmpty(cases)) {
        cases.forEach(c -> {
            ValidationErrors caseErrors = caseProcessor.processReceivedData(c, existingEntities.getCases().get(c.getEntity().getUuid()));
            if (caseErrors.hasError()) {
                validationErrors.add(new ValidationErrors(ValidationHelper.buildCaseValidationGroupName(c.getEntity()), caseErrors));
            }
        });
    }
    List<SormasToSormasContactDto> contacts = receivedData.getContacts();
    if (CollectionUtils.isNotEmpty(contacts)) {
        contacts.forEach(c -> {
            ValidationErrors contactErrors = contactProcessor.processReceivedData(c, existingEntities.getContacts().get(c.getEntity().getUuid()));
            if (contactErrors.hasError()) {
                validationErrors.add(new ValidationErrors(ValidationHelper.buildContactValidationGroupName(c.getEntity()), contactErrors));
            }
        });
    }
    List<SormasToSormasEventDto> events = receivedData.getEvents();
    if (CollectionUtils.isNotEmpty(events)) {
        events.forEach(e -> {
            ValidationErrors eventErrors = eventProcessor.processReceivedData(e, existingEntities.getEvents().get(e.getEntity().getUuid()));
            if (eventErrors.hasError()) {
                validationErrors.add(new ValidationErrors(ValidationHelper.buildEventValidationGroupName(e.getEntity()), eventErrors));
            }
        });
    }
    List<SormasToSormasEventParticipantDto> eventParticipants = receivedData.getEventParticipants();
    if (CollectionUtils.isNotEmpty(eventParticipants)) {
        eventParticipants.forEach(ep -> {
            ValidationErrors eventParticipantErrors = eventParticipantProcessor.processReceivedData(ep, existingEntities.getEventParticipants().get(ep.getEntity().getUuid()));
            if (eventParticipantErrors.hasError()) {
                validationErrors.add(new ValidationErrors(ValidationHelper.buildEventParticipantValidationGroupName(ep.getEntity()), eventParticipantErrors));
            }
        });
    }
    List<SormasToSormasSampleDto> samples = receivedData.getSamples();
    if (CollectionUtils.isNotEmpty(samples)) {
        samples.forEach(s -> {
            ValidationErrors contactErrors = sampleProcessor.processReceivedData(s, existingEntities.getSamples().get(s.getEntity().getUuid()));
            if (contactErrors.hasError()) {
                validationErrors.add(new ValidationErrors(ValidationHelper.buildSampleValidationGroupName(s.getEntity()), contactErrors));
            }
        });
    }
    List<SormasToSormasImmunizationDto> immunizations = receivedData.getImmunizations();
    if (CollectionUtils.isNotEmpty(immunizations)) {
        immunizations.forEach(s -> {
            ValidationErrors immunizationErrors = immunizationProcessor.processReceivedData(s, existingEntities.getImmunizations().get(s.getEntity().getUuid()));
            if (immunizationErrors.hasError()) {
                validationErrors.add(new ValidationErrors(ValidationHelper.buildImmunizationValidationGroupName(s.getEntity()), immunizationErrors));
            }
        });
    }
    return validationErrors;
}
Also used : SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) ValidationErrors(de.symeda.sormas.api.sormastosormas.validation.ValidationErrors) ArrayList(java.util.ArrayList) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SormasToSormasOriginInfoDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) Date(java.util.Date) SormasToSormasCaseDto(de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto) SormasToSormasEventParticipantDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto) SormasToSormasImmunizationDto(de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto)

Aggregations

SormasToSormasEventDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto)16 EventDto (de.symeda.sormas.api.event.EventDto)11 SormasToSormasEventParticipantDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto)9 SormasToSormasDto (de.symeda.sormas.api.sormastosormas.SormasToSormasDto)8 Test (org.junit.Test)8 SormasToSormasSampleDto (de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto)7 SormasToSormasTest (de.symeda.sormas.backend.sormastosormas.SormasToSormasTest)7 SormasToSormasEncryptedDataDto (de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto)6 Date (java.util.Date)6 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)5 SormasToSormasOriginInfoDto (de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto)4 SormasToSormasCaseDto (de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto)4 SormasToSormasContactDto (de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto)4 SormasToSormasImmunizationDto (de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto)4 FacilityDto (de.symeda.sormas.api.infrastructure.facility.FacilityDto)3 AdditionalTestDto (de.symeda.sormas.api.sample.AdditionalTestDto)3 PathogenTestDto (de.symeda.sormas.api.sample.PathogenTestDto)3 SampleDto (de.symeda.sormas.api.sample.SampleDto)3 ShareTreeCriteria (de.symeda.sormas.api.sormastosormas.ShareTreeCriteria)3 SormasServerDescriptor (de.symeda.sormas.api.sormastosormas.SormasServerDescriptor)3