Search in sources :

Example 1 with PointOfEntryReferenceDto

use of de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class CaseImportFacadeEjb method insertColumnEntryIntoData.

/**
 * Inserts the entry of a single cell into the case or its person.
 */
private void insertColumnEntryIntoData(CaseDataDto caze, PersonDto person, String entry, String[] entryHeaderPath) throws InvalidColumnException, ImportErrorException {
    Object currentElement = caze;
    for (int i = 0; i < entryHeaderPath.length; i++) {
        String headerPathElementName = entryHeaderPath[i];
        Language language = I18nProperties.getUserLanguage();
        try {
            if (i != entryHeaderPath.length - 1) {
                currentElement = new PropertyDescriptor(headerPathElementName, currentElement.getClass()).getReadMethod().invoke(currentElement);
                // Set the current element to the created person
                if (currentElement instanceof PersonReferenceDto) {
                    currentElement = person;
                }
            } else if (CaseExportDto.BIRTH_DATE.equals(headerPathElementName)) {
                BirthDateDto birthDateDto = PersonHelper.parseBirthdate(entry, language);
                if (birthDateDto != null) {
                    person.setBirthdateDD(birthDateDto.getDateOfBirthDD());
                    person.setBirthdateMM(birthDateDto.getDateOfBirthMM());
                    person.setBirthdateYYYY(birthDateDto.getDateOfBirthYYYY());
                }
            } else {
                PropertyDescriptor pd = new PropertyDescriptor(headerPathElementName, currentElement.getClass());
                Class<?> propertyType = pd.getPropertyType();
                // according to the types of the case or person fields
                if (importFacade.executeDefaultInvoke(pd, currentElement, entry, entryHeaderPath, false)) {
                    continue;
                } else if (propertyType.isAssignableFrom(DistrictReferenceDto.class)) {
                    List<DistrictReferenceDto> district = districtFacade.getByName(entry, ImportHelper.getRegionBasedOnDistrict(pd.getName(), caze, null, null, person, currentElement), false);
                    if (district.isEmpty()) {
                        throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrRegion, entry, buildEntityProperty(entryHeaderPath)));
                    } else if (district.size() > 1) {
                        throw new ImportErrorException(I18nProperties.getValidationError(Validations.importDistrictNotUnique, entry, buildEntityProperty(entryHeaderPath)));
                    } else {
                        pd.getWriteMethod().invoke(currentElement, district.get(0));
                    }
                } else if (propertyType.isAssignableFrom(CommunityReferenceDto.class)) {
                    List<CommunityReferenceDto> community = communityFacade.getByName(entry, ImportHelper.getDistrictBasedOnCommunity(pd.getName(), caze, person, currentElement), false);
                    if (community.isEmpty()) {
                        throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrDistrict, entry, buildEntityProperty(entryHeaderPath)));
                    } else if (community.size() > 1) {
                        throw new ImportErrorException(I18nProperties.getValidationError(Validations.importCommunityNotUnique, entry, buildEntityProperty(entryHeaderPath)));
                    } else {
                        pd.getWriteMethod().invoke(currentElement, community.get(0));
                    }
                } else if (propertyType.isAssignableFrom(FacilityReferenceDto.class)) {
                    DataHelper.Pair<DistrictReferenceDto, CommunityReferenceDto> infrastructureData = ImportHelper.getDistrictAndCommunityBasedOnFacility(pd.getName(), caze, person, currentElement);
                    if (I18nProperties.getPrefixCaption(FacilityDto.I18N_PREFIX, FacilityDto.OTHER_FACILITY).equals(entry)) {
                        entry = FacilityDto.OTHER_FACILITY;
                    }
                    if (I18nProperties.getPrefixCaption(FacilityDto.I18N_PREFIX, FacilityDto.NO_FACILITY).equals(entry)) {
                        entry = FacilityDto.NO_FACILITY;
                    }
                    List<FacilityReferenceDto> facilities = facilityFacade.getByNameAndType(entry, infrastructureData.getElement0(), infrastructureData.getElement1(), getTypeOfFacility(pd.getName(), currentElement), false);
                    if (facilities.isEmpty()) {
                        if (infrastructureData.getElement1() != null) {
                            throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrCommunity, entry, buildEntityProperty(entryHeaderPath)));
                        } else {
                            throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrDistrict, entry, buildEntityProperty(entryHeaderPath)));
                        }
                    } else if (facilities.size() > 1 && infrastructureData.getElement1() == null) {
                        throw new ImportErrorException(I18nProperties.getValidationError(Validations.importFacilityNotUniqueInDistrict, entry, buildEntityProperty(entryHeaderPath)));
                    } else if (facilities.size() > 1 && infrastructureData.getElement1() != null) {
                        throw new ImportErrorException(I18nProperties.getValidationError(Validations.importFacilityNotUniqueInCommunity, entry, buildEntityProperty(entryHeaderPath)));
                    } else {
                        pd.getWriteMethod().invoke(currentElement, facilities.get(0));
                    }
                } else if (propertyType.isAssignableFrom(PointOfEntryReferenceDto.class)) {
                    PointOfEntryReferenceDto pointOfEntryReference;
                    DistrictReferenceDto pointOfEntryDistrict = CaseLogic.getDistrictWithFallback(caze);
                    List<PointOfEntryReferenceDto> customPointsOfEntry = pointOfEntryFacade.getByName(entry, pointOfEntryDistrict, false);
                    if (customPointsOfEntry.isEmpty()) {
                        final String poeName = entry;
                        List<PointOfEntryDto> defaultPointOfEntries = pointOfEntryFacade.getByUuids(PointOfEntryDto.CONSTANT_POE_UUIDS);
                        Optional<PointOfEntryDto> defaultPointOfEntry = defaultPointOfEntries.stream().filter(defaultPoe -> InfrastructureHelper.buildPointOfEntryString(defaultPoe.getUuid(), defaultPoe.getName()).equals(poeName)).findFirst();
                        if (!defaultPointOfEntry.isPresent()) {
                            throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrDistrict, entry, buildEntityProperty(entryHeaderPath)));
                        }
                        pointOfEntryReference = defaultPointOfEntry.get().toReference();
                    } else if (customPointsOfEntry.size() > 1) {
                        throw new ImportErrorException(I18nProperties.getValidationError(Validations.importPointOfEntryNotUniqueInDistrict, entry, buildEntityProperty(entryHeaderPath)));
                    } else {
                        pointOfEntryReference = customPointsOfEntry.get(0);
                    }
                    pd.getWriteMethod().invoke(currentElement, pointOfEntryReference);
                } else {
                    throw new UnsupportedOperationException(I18nProperties.getValidationError(Validations.importCasesPropertyTypeNotAllowed, propertyType.getName()));
                }
            }
        } catch (IntrospectionException e) {
            throw new InvalidColumnException(buildEntityProperty(entryHeaderPath));
        } catch (InvocationTargetException | IllegalAccessException e) {
            throw new ImportErrorException(I18nProperties.getValidationError(Validations.importErrorInColumn, buildEntityProperty(entryHeaderPath)));
        } catch (IllegalArgumentException | EnumService.InvalidEnumCaptionException e) {
            throw new ImportErrorException(entry, buildEntityProperty(entryHeaderPath));
        } catch (ParseException e) {
            throw new ImportErrorException(I18nProperties.getValidationError(Validations.importInvalidDate, buildEntityProperty(entryHeaderPath), DateHelper.getAllowedDateFormats(language.getDateFormat())));
        } catch (ImportErrorException e) {
            throw e;
        } catch (Exception e) {
            LOGGER.error("Unexpected error when trying to import a case: " + e.getMessage(), e);
            throw new ImportErrorException(I18nProperties.getValidationError(Validations.importCasesUnexpectedError));
        }
    }
}
Also used : FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) IntrospectionException(java.beans.IntrospectionException) DataHelper(de.symeda.sormas.api.utils.DataHelper) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) Language(de.symeda.sormas.api.Language) List(java.util.List) ArrayList(java.util.ArrayList) PropertyDescriptor(java.beans.PropertyDescriptor) ImportErrorException(de.symeda.sormas.api.importexport.ImportErrorException) Optional(java.util.Optional) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvalidColumnException(de.symeda.sormas.api.importexport.InvalidColumnException) ParseException(java.text.ParseException) ImportErrorException(de.symeda.sormas.api.importexport.ImportErrorException) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ValidationRuntimeException(de.symeda.sormas.api.utils.ValidationRuntimeException) InvalidColumnException(de.symeda.sormas.api.importexport.InvalidColumnException) BirthDateDto(de.symeda.sormas.api.caze.BirthDateDto) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) ParseException(java.text.ParseException)

Example 2 with PointOfEntryReferenceDto

use of de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class CaseCreateForm method updatePOEs.

private void updatePOEs() {
    ComboBox comboBoxPOE = (ComboBox) getField(CaseDataDto.POINT_OF_ENTRY);
    if (!comboBoxPOE.isReadOnly()) {
        DistrictReferenceDto districtDto;
        if (Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue())) {
            districtDto = (DistrictReferenceDto) pointOfEntryDistrictCombo.getValue();
        } else if (Boolean.TRUE.equals(differentPlaceOfStayJurisdiction.getValue())) {
            districtDto = (DistrictReferenceDto) districtCombo.getValue();
        } else {
            districtDto = (DistrictReferenceDto) responsibleDistrictCombo.getValue();
        }
        List<PointOfEntryReferenceDto> POEs = districtDto == null ? Collections.emptyList() : FacadeProvider.getPointOfEntryFacade().getAllActiveByDistrict(districtDto.getUuid(), true);
        FieldHelper.updateItems(comboBoxPOE, POEs);
    }
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Example 3 with PointOfEntryReferenceDto

use of de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class InfrastructureValidator method lookupPointOfEntry.

private WithDetails<PointOfEntryReferenceDto> lookupPointOfEntry(PointOfEntryReferenceDto pointOfEntry, String pointOfEntryDetails) {
    String pointOfEntryUuid = pointOfEntry.getUuid();
    if (PointOfEntryDto.CONSTANT_POE_UUIDS.contains(pointOfEntryUuid)) {
        PointOfEntryReferenceDto localPointOfEntry = pointOfEntryDetails != null ? pointOfEntryFacade.getByName(pointOfEntryDetails.trim(), null, false).stream().findFirst().orElse(null) : null;
        if (localPointOfEntry == null) {
            localPointOfEntry = pointOfEntryFacade.getByUuid(pointOfEntryUuid).toReference();
        } else {
            pointOfEntryDetails = null;
        }
        return new WithDetails<>(localPointOfEntry, pointOfEntryDetails);
    } else {
        Optional<PointOfEntryReferenceDto> localPointOfEntry = pointOfEntry.getExternalId() != null ? pointOfEntryFacade.getByExternalId(pointOfEntry.getExternalId(), false).stream().findFirst() : Optional.empty();
        if (!localPointOfEntry.isPresent()) {
            localPointOfEntry = pointOfEntryFacade.getByName(pointOfEntry.getCaption(), null, false).stream().findFirst();
        }
        final String details;
        if (!localPointOfEntry.isPresent()) {
            details = pointOfEntry.getCaption();
            localPointOfEntry = Optional.of(pointOfEntryFacade.getByUuid(PointOfEntryDto.getOtherPointOfEntryUuid(pointOfEntry.getPointOfEntryType())).toReference());
        } else {
            details = pointOfEntryDetails;
        }
        return localPointOfEntry.map(p -> new WithDetails<>(p, details)).orElse(null);
    }
}
Also used : PointOfEntryFacadeEjb(de.symeda.sormas.backend.infrastructure.pointofentry.PointOfEntryFacadeEjb) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) ContinentFacadeEjb(de.symeda.sormas.backend.infrastructure.continent.ContinentFacadeEjb) ValidationErrors(de.symeda.sormas.api.sormastosormas.validation.ValidationErrors) ValidationDirection(de.symeda.sormas.backend.sormastosormas.data.validation.ValidationDirection) ValidationErrorGroup(de.symeda.sormas.api.sormastosormas.validation.ValidationErrorGroup) FacilityFacadeEjb(de.symeda.sormas.backend.infrastructure.facility.FacilityFacadeEjb) CommunityFacadeEjb(de.symeda.sormas.backend.infrastructure.community.CommunityFacadeEjb) InfrastructureDto(de.symeda.sormas.api.infrastructure.InfrastructureDto) CountryReferenceDto(de.symeda.sormas.api.infrastructure.country.CountryReferenceDto) ValidationErrorMessage(de.symeda.sormas.api.sormastosormas.validation.ValidationErrorMessage) LocalBean(javax.ejb.LocalBean) SampleFacadeEjb(de.symeda.sormas.backend.sample.SampleFacadeEjb) EJB(javax.ejb.EJB) PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto) Stateless(javax.ejb.Stateless) Validations(de.symeda.sormas.api.i18n.Validations) CountryFacadeEjb(de.symeda.sormas.backend.infrastructure.country.CountryFacadeEjb) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) RegionFacadeEjb(de.symeda.sormas.backend.infrastructure.region.RegionFacadeEjb) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) Serializable(java.io.Serializable) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) BaseCriteria(de.symeda.sormas.api.utils.criteria.BaseCriteria) Consumer(java.util.function.Consumer) InfrastructureFacade(de.symeda.sormas.api.infrastructure.InfrastructureFacade) UserService(de.symeda.sormas.backend.user.UserService) DistrictFacadeEjb(de.symeda.sormas.backend.infrastructure.district.DistrictFacadeEjb) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) Optional(java.util.Optional) SubcontinentReferenceDto(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentReferenceDto) InfrastructureDataReferenceDto(de.symeda.sormas.api.InfrastructureDataReferenceDto) ContinentReferenceDto(de.symeda.sormas.api.infrastructure.continent.ContinentReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) SubcontinentFacadeEjb(de.symeda.sormas.backend.infrastructure.subcontinent.SubcontinentFacadeEjb) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto)

Example 4 with PointOfEntryReferenceDto

use of de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasCaseFacadeEjbTest method testSaveReturnedCaseWithKnownOtherPointOfEntry.

@Test
public void testSaveReturnedCaseWithKnownOtherPointOfEntry() throws SormasToSormasException {
    UserReferenceDto officer = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference();
    PersonDto person = creator.createPerson();
    CaseDataDto caze = creator.createCase(officer, rdcf, c -> {
        c.setPerson(person.toReference());
        c.setCaseOrigin(CaseOrigin.POINT_OF_ENTRY);
        c.setPointOfEntry(new PointOfEntryReferenceDto(PointOfEntryDto.OTHER_SEAPORT_UUID, null, null, null));
        c.setPointOfEntryDetails("Test Seaport");
    });
    User officerUser = getUserService().getByReferenceDto(officer);
    getSormasToSormasShareInfoService().persist(createShareInfo(DEFAULT_SERVER_ID, true, i -> i.setCaze(getCaseService().getByReferenceDto(caze.toReference()))));
    caze.setPointOfEntryDetails(rdcf.pointOfEntry.getCaption());
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(caze.getChangeDate());
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    caze.setChangeDate(calendar.getTime());
    SormasToSormasOriginInfoDto originInfo = createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, true);
    SormasToSormasDto shareData = new SormasToSormasDto();
    shareData.setOriginInfo(originInfo);
    shareData.setCases(Collections.singletonList(new SormasToSormasCaseDto(person, caze)));
    SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
    try {
        getSormasToSormasCaseFacade().saveSharedEntities(encryptedData);
    } catch (Exception e) {
        e.printStackTrace();
    }
    CaseDataDto returnedCase = getCaseFacade().getCaseDataByUuid(caze.getUuid());
    assertThat(returnedCase.getPointOfEntry(), is(rdcf.pointOfEntry));
    assertThat(returnedCase.getPointOfEntryDetails(), is(nullValue()));
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) Arrays(java.util.Arrays) SormasToSormasShareTree(de.symeda.sormas.api.sormastosormas.SormasToSormasShareTree) ArgumentMatchers(org.mockito.ArgumentMatchers) SormasToSormasOriginInfoDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Date(java.util.Date) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SormasToSormasOptionsDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto) ExposureType(de.symeda.sormas.api.exposure.ExposureType) PersonDto(de.symeda.sormas.api.person.PersonDto) PortHealthInfoDto(de.symeda.sormas.api.caze.porthealthinfo.PortHealthInfoDto) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) Matchers.nullValue(org.hamcrest.Matchers.nullValue) PointOfEntryType(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryType) UserRole(de.symeda.sormas.api.user.UserRole) AnimalContactType(de.symeda.sormas.api.exposure.AnimalContactType) PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) SormasToSormasShareInfoCriteria(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoCriteria) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) SormasToSormasException(de.symeda.sormas.api.sormastosormas.SormasToSormasException) ShareTreeCriteria(de.symeda.sormas.api.sormastosormas.ShareTreeCriteria) List(java.util.List) User(de.symeda.sormas.backend.user.User) Response(javax.ws.rs.core.Response) EpiDataDto(de.symeda.sormas.api.epidata.EpiDataDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) Matchers.is(org.hamcrest.Matchers.is) ShareRequestInfo(de.symeda.sormas.backend.sormastosormas.share.shareinfo.ShareRequestInfo) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) SamplePurpose(de.symeda.sormas.api.sample.SamplePurpose) SormasServerDescriptor(de.symeda.sormas.api.sormastosormas.SormasServerDescriptor) Matchers.arrayWithSize(org.hamcrest.Matchers.arrayWithSize) MockProducer(de.symeda.sormas.backend.MockProducer) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) SormasToSormasValidationException(de.symeda.sormas.api.sormastosormas.validation.SormasToSormasValidationException) SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) RunWith(org.junit.runner.RunWith) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) ArrayList(java.util.ArrayList) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) QuarantineType(de.symeda.sormas.api.contact.QuarantineType) SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) Calendar(java.util.Calendar) SymptomState(de.symeda.sormas.api.symptoms.SymptomState) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DataHelper(de.symeda.sormas.api.utils.DataHelper) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) SormasToSormasShareRequestDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto) UserDto(de.symeda.sormas.api.user.UserDto) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Test(org.junit.Test) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin) ShareRequestStatus(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestStatus) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) SormasToSormasConfig(de.symeda.sormas.api.sormastosormas.SormasToSormasConfig) SampleMaterial(de.symeda.sormas.api.sample.SampleMaterial) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) Mockito(org.mockito.Mockito) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) Disease(de.symeda.sormas.api.Disease) SampleDto(de.symeda.sormas.api.sample.SampleDto) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) Collections(java.util.Collections) SormasToSormasCaseDto(de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto) SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) User(de.symeda.sormas.backend.user.User) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) Calendar(java.util.Calendar) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) SormasToSormasOriginInfoDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto) SormasToSormasCaseDto(de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto) SormasToSormasException(de.symeda.sormas.api.sormastosormas.SormasToSormasException) SormasToSormasValidationException(de.symeda.sormas.api.sormastosormas.validation.SormasToSormasValidationException) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 5 with PointOfEntryReferenceDto

use of de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasTest method createRDCF.

protected MappableRdcf createRDCF(boolean withExternalId) {
    String regionName = "Region";
    String districtName = "District";
    String communityName = "Community";
    String facilityName = "Facility";
    String pointOfEntryName = "Point of Entry";
    String regionExternalId = null;
    String districtExternalId = null;
    String communityExternalId = null;
    String facilityExternalId = null;
    String pointOfEntryExternalId = null;
    if (withExternalId) {
        regionExternalId = "RegionExtId";
        districtExternalId = "DistrictExtId";
        communityExternalId = "CommunityExtId";
        facilityExternalId = "FacilityExtId";
        pointOfEntryExternalId = "Point of EntryExtId";
    }
    MappableRdcf rdcf = new MappableRdcf();
    rdcf.invalidLocalRdcf = new TestDataCreator.RDCF(new RegionReferenceDto(DataHelper.createUuid(), withExternalId ? null : regionName, regionExternalId), new DistrictReferenceDto(DataHelper.createUuid(), withExternalId ? null : districtName, districtExternalId), new CommunityReferenceDto(DataHelper.createUuid(), withExternalId ? null : communityName, communityExternalId), new FacilityReferenceDto(DataHelper.createUuid(), withExternalId ? null : facilityName, facilityExternalId), new PointOfEntryReferenceDto(DataHelper.createUuid(), withExternalId ? null : pointOfEntryName, PointOfEntryType.AIRPORT, pointOfEntryExternalId));
    Region region = creator.createRegionCentrally(regionName + "Central", regionExternalId);
    District district = creator.createDistrictCentrally(districtName + "Central", region, districtExternalId);
    Community community = creator.createCommunityCentrally(communityName + "Central", district, communityExternalId);
    Facility facility = creator.createFacility(facilityName + "Central", FacilityType.HOSPITAL, region, district, community, facilityExternalId);
    PointOfEntry pointOfEntry = creator.createPointOfEntry(pointOfEntryName + "Central", region, district, pointOfEntryExternalId);
    rdcf.centralRdcf = new TestDataCreator.RDCF(new RegionReferenceDto(region.getUuid(), region.getName(), region.getExternalID()), new DistrictReferenceDto(district.getUuid(), district.getName(), district.getExternalID()), new CommunityReferenceDto(community.getUuid(), community.getName(), community.getExternalID()), new FacilityReferenceDto(facility.getUuid(), facility.getName(), facility.getExternalID()), new PointOfEntryReferenceDto(pointOfEntry.getUuid(), pointOfEntry.getName(), PointOfEntryType.AIRPORT, pointOfEntry.getExternalID()));
    return rdcf;
}
Also used : FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) Region(de.symeda.sormas.backend.infrastructure.region.Region) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) PointOfEntry(de.symeda.sormas.backend.infrastructure.pointofentry.PointOfEntry) District(de.symeda.sormas.backend.infrastructure.district.District) Community(de.symeda.sormas.backend.infrastructure.community.Community)

Aggregations

PointOfEntryReferenceDto (de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto)12 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)7 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)6 FacilityReferenceDto (de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto)6 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Language (de.symeda.sormas.api.Language)3 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)3 PointOfEntryDto (de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto)3 Community (de.symeda.sormas.backend.infrastructure.community.Community)3 District (de.symeda.sormas.backend.infrastructure.district.District)3 PointOfEntry (de.symeda.sormas.backend.infrastructure.pointofentry.PointOfEntry)3 Region (de.symeda.sormas.backend.infrastructure.region.Region)3 Disease (de.symeda.sormas.api.Disease)2 PortHealthInfoDto (de.symeda.sormas.api.caze.porthealthinfo.PortHealthInfoDto)2 ImportErrorException (de.symeda.sormas.api.importexport.ImportErrorException)2 InvalidColumnException (de.symeda.sormas.api.importexport.InvalidColumnException)2 FacilityDto (de.symeda.sormas.api.infrastructure.facility.FacilityDto)2 FacilityType (de.symeda.sormas.api.infrastructure.facility.FacilityType)2