Search in sources :

Example 1 with PointOfEntryDto

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

the class PointOfEntryFacadeEjb method toDto.

@Override
public PointOfEntryDto toDto(PointOfEntry entity) {
    if (entity == null) {
        return null;
    }
    PointOfEntryDto dto = new PointOfEntryDto();
    DtoHelper.fillDto(dto, entity);
    dto.setName(entity.getName());
    dto.setPointOfEntryType(entity.getPointOfEntryType());
    dto.setActive(entity.isActive());
    dto.setLatitude(entity.getLatitude());
    dto.setLongitude(entity.getLongitude());
    dto.setRegion(RegionFacadeEjb.toReferenceDto(entity.getRegion()));
    dto.setDistrict(DistrictFacadeEjb.toReferenceDto(entity.getDistrict()));
    dto.setArchived(entity.isArchived());
    dto.setExternalID(entity.getExternalID());
    dto.setCentrallyManaged(entity.isCentrallyManaged());
    return dto;
}
Also used : PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto)

Example 2 with PointOfEntryDto

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

the class PointOfEntryFacadeEjbTest method testGetAllAfter.

@Test
public void testGetAllAfter() throws InterruptedException {
    Region region = creator.createRegion("region");
    District district = creator.createDistrict("district", region);
    creator.createPointOfEntry("pointOfEntry1", region, district);
    getPointOfEntryService().doFlush();
    Date date = new Date();
    List<PointOfEntryDto> results = getPointOfEntryFacade().getAllAfter(date);
    // List should be empty
    assertEquals(0, results.size());
    // delay to ignore known rounding issues in change date filter
    Thread.sleep(1);
    String pointOfEntryName = "pointOfEntry2";
    creator.createPointOfEntry(pointOfEntryName, region, district);
    results = getPointOfEntryFacade().getAllAfter(date);
    // List should have one entry
    assertEquals(1, results.size());
    assertEquals(pointOfEntryName, results.get(0).getName());
    assertEquals(district.getUuid(), results.get(0).getDistrict().getUuid());
    assertEquals(region.getUuid(), results.get(0).getRegion().getUuid());
}
Also used : PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto) Region(de.symeda.sormas.backend.infrastructure.region.Region) District(de.symeda.sormas.backend.infrastructure.district.District) Date(java.util.Date) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 3 with PointOfEntryDto

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

the class TestDataCreator method createRDP.

public RDP createRDP() {
    RegionDto region = createRegion("Region");
    DistrictDto district = createDistrict("District", region.toReference());
    PointOfEntryDto pointOfEntry = createPointOfEntry("POE", region.toReference(), district.toReference());
    return new RDP(region, district, pointOfEntry);
}
Also used : DistrictDto(de.symeda.sormas.api.infrastructure.district.DistrictDto) PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto) RegionDto(de.symeda.sormas.api.infrastructure.region.RegionDto)

Example 4 with PointOfEntryDto

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

the class TestDataCreator method createPointOfEntry.

public PointOfEntryDto createPointOfEntry(String pointOfEntryName, RegionReferenceDto region, DistrictReferenceDto district) {
    PointOfEntryDto pointOfEntry = PointOfEntryDto.build();
    pointOfEntry.setUuid(DataHelper.createUuid());
    pointOfEntry.setPointOfEntryType(PointOfEntryType.AIRPORT);
    pointOfEntry.setName(pointOfEntryName);
    pointOfEntry.setDistrict(district);
    pointOfEntry.setRegion(region);
    beanTest.getPointOfEntryFacade().save(pointOfEntry);
    return pointOfEntry;
}
Also used : PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto)

Example 5 with PointOfEntryDto

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

the class InfrastructureController method archiveOrDearchiveAllSelectedItems.

@SuppressWarnings("unchecked")
public void archiveOrDearchiveAllSelectedItems(boolean archive, Collection<?> selectedRows, InfrastructureType infrastructureType, Runnable callback) {
    // Check that at least one entry is selected
    if (selectedRows.isEmpty()) {
        new Notification(I18nProperties.getString(Strings.headingNoRowsSelected), I18nProperties.getString(Strings.messageNoRowsSelected), Type.WARNING_MESSAGE, false).show(Page.getCurrent());
        return;
    }
    // Check if archiving/dearchiving is allowed concerning the hierarchy
    Set<String> selectedRowsUuids = selectedRows.stream().map(row -> ((HasUuid) row).getUuid()).collect(Collectors.toSet());
    if (InfrastructureType.AREA.equals(infrastructureType) && FacadeProvider.getAreaFacade().isUsedInOtherInfrastructureData(selectedRowsUuids) || InfrastructureType.CONTINENT.equals(infrastructureType) && FacadeProvider.getContinentFacade().isUsedInOtherInfrastructureData(selectedRowsUuids) || InfrastructureType.SUBCONTINENT.equals(infrastructureType) && FacadeProvider.getSubcontinentFacade().isUsedInOtherInfrastructureData(selectedRowsUuids) || InfrastructureType.REGION.equals(infrastructureType) && FacadeProvider.getRegionFacade().isUsedInOtherInfrastructureData(selectedRowsUuids) || InfrastructureType.DISTRICT.equals(infrastructureType) && FacadeProvider.getDistrictFacade().isUsedInOtherInfrastructureData(selectedRowsUuids) || InfrastructureType.COMMUNITY.equals(infrastructureType) && FacadeProvider.getCommunityFacade().isUsedInOtherInfrastructureData(selectedRowsUuids)) {
        showArchivingNotPossibleWindow(infrastructureType, true);
        return;
    }
    if (InfrastructureType.COUNTRY.equals(infrastructureType) && FacadeProvider.getCountryFacade().hasArchivedParentInfrastructure(selectedRowsUuids) || InfrastructureType.SUBCONTINENT.equals(infrastructureType) && FacadeProvider.getSubcontinentFacade().hasArchivedParentInfrastructure(selectedRowsUuids) || InfrastructureType.DISTRICT.equals(infrastructureType) && FacadeProvider.getDistrictFacade().hasArchivedParentInfrastructure(selectedRowsUuids) || InfrastructureType.COMMUNITY.equals(infrastructureType) && FacadeProvider.getCommunityFacade().hasArchivedParentInfrastructure(selectedRowsUuids) || InfrastructureType.FACILITY.equals(infrastructureType) && FacadeProvider.getFacilityFacade().hasArchivedParentInfrastructure(selectedRowsUuids) || InfrastructureType.POINT_OF_ENTRY.equals(infrastructureType) && FacadeProvider.getPointOfEntryFacade().hasArchivedParentInfrastructure(selectedRowsUuids)) {
        showDearchivingNotPossibleWindow(infrastructureType, false);
        return;
    }
    final String confirmationMessage;
    final String notificationMessage;
    switch(infrastructureType) {
        case CONTINENT:
            confirmationMessage = archive ? I18nProperties.getString(Strings.confirmationArchiveContinents) : I18nProperties.getString(Strings.confirmationDearchiveContinents);
            notificationMessage = archive ? I18nProperties.getString(Strings.messageContinentsArchived) : I18nProperties.getString(Strings.messageContinentsDearchived);
            break;
        case SUBCONTINENT:
            confirmationMessage = archive ? I18nProperties.getString(Strings.confirmationArchiveSubcontinents) : I18nProperties.getString(Strings.confirmationDearchiveSubcontinents);
            notificationMessage = archive ? I18nProperties.getString(Strings.messageSubcontinentsArchived) : I18nProperties.getString(Strings.messageSubcontinentsDearchived);
            break;
        case AREA:
            confirmationMessage = archive ? I18nProperties.getString(Strings.confirmationArchiveAreas) : I18nProperties.getString(Strings.confirmationDearchiveAreas);
            notificationMessage = archive ? I18nProperties.getString(Strings.messageAreasArchived) : I18nProperties.getString(Strings.messageAreasDearchived);
            break;
        case COUNTRY:
            confirmationMessage = archive ? I18nProperties.getString(Strings.confirmationArchiveCountries) : I18nProperties.getString(Strings.confirmationDearchiveCountries);
            notificationMessage = archive ? I18nProperties.getString(Strings.messageCountriesArchived) : I18nProperties.getString(Strings.messageCountriesDearchived);
            break;
        case REGION:
            confirmationMessage = archive ? I18nProperties.getString(Strings.confirmationArchiveRegions) : I18nProperties.getString(Strings.confirmationDearchiveRegions);
            notificationMessage = archive ? I18nProperties.getString(Strings.messageRegionsArchived) : I18nProperties.getString(Strings.messageRegionsDearchived);
            break;
        case DISTRICT:
            confirmationMessage = archive ? I18nProperties.getString(Strings.confirmationArchiveDistricts) : I18nProperties.getString(Strings.confirmationDearchiveDistricts);
            notificationMessage = archive ? I18nProperties.getString(Strings.messageDistrictsArchived) : I18nProperties.getString(Strings.messageDistrictsDearchived);
            break;
        case COMMUNITY:
            confirmationMessage = archive ? I18nProperties.getString(Strings.confirmationArchiveCommunities) : I18nProperties.getString(Strings.confirmationDearchiveCommunities);
            notificationMessage = archive ? I18nProperties.getString(Strings.messageCommunitiesArchived) : I18nProperties.getString(Strings.messageCommunitiesDearchived);
            break;
        case FACILITY:
            confirmationMessage = archive ? I18nProperties.getString(Strings.confirmationArchiveFacilities) : I18nProperties.getString(Strings.confirmationDearchiveFacilities);
            notificationMessage = archive ? I18nProperties.getString(Strings.messageFacilitiesArchived) : I18nProperties.getString(Strings.messageFacilitiesDearchived);
            break;
        case POINT_OF_ENTRY:
            confirmationMessage = archive ? I18nProperties.getString(Strings.confirmationArchivePointsOfEntry) : I18nProperties.getString(Strings.confirmationDearchivePointsOfEntry);
            notificationMessage = archive ? I18nProperties.getString(Strings.messagePointsOfEntryArchived) : I18nProperties.getString(Strings.messagePointsOfEntryDearchived);
            break;
        default:
            throw new IllegalArgumentException(infrastructureType.name());
    }
    VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingConfirmArchiving), new Label(String.format(confirmationMessage, selectedRows.size())), I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), null, e -> {
        if (e.booleanValue()) {
            switch(infrastructureType) {
                case CONTINENT:
                    for (ContinentDto selectedRow : (Collection<ContinentDto>) selectedRows) {
                        if (archive) {
                            FacadeProvider.getContinentFacade().archive(selectedRow.getUuid());
                        } else {
                            FacadeProvider.getContinentFacade().dearchive(selectedRow.getUuid());
                        }
                    }
                    break;
                case SUBCONTINENT:
                    for (SubcontinentDto selectedRow : (Collection<SubcontinentDto>) selectedRows) {
                        if (archive) {
                            FacadeProvider.getSubcontinentFacade().archive(selectedRow.getUuid());
                        } else {
                            FacadeProvider.getSubcontinentFacade().dearchive(selectedRow.getUuid());
                        }
                    }
                    break;
                case AREA:
                    for (AreaDto selectedRow : (Collection<AreaDto>) selectedRows) {
                        if (archive) {
                            FacadeProvider.getAreaFacade().archive(selectedRow.getUuid());
                        } else {
                            FacadeProvider.getAreaFacade().dearchive(selectedRow.getUuid());
                        }
                    }
                    break;
                case COUNTRY:
                    for (CountryIndexDto selectedRow : (Collection<CountryIndexDto>) selectedRows) {
                        if (archive) {
                            FacadeProvider.getCountryFacade().archive(selectedRow.getUuid());
                        } else {
                            FacadeProvider.getCountryFacade().dearchive(selectedRow.getUuid());
                        }
                    }
                    break;
                case REGION:
                    for (RegionIndexDto selectedRow : (Collection<RegionIndexDto>) selectedRows) {
                        if (archive) {
                            FacadeProvider.getRegionFacade().archive(selectedRow.getUuid());
                        } else {
                            FacadeProvider.getRegionFacade().dearchive(selectedRow.getUuid());
                        }
                    }
                    break;
                case DISTRICT:
                    for (DistrictIndexDto selectedRow : (Collection<DistrictIndexDto>) selectedRows) {
                        if (archive) {
                            FacadeProvider.getDistrictFacade().archive(selectedRow.getUuid());
                        } else {
                            FacadeProvider.getDistrictFacade().dearchive(selectedRow.getUuid());
                        }
                    }
                    break;
                case COMMUNITY:
                    for (CommunityDto selectedRow : (Collection<CommunityDto>) selectedRows) {
                        if (archive) {
                            FacadeProvider.getCommunityFacade().archive(selectedRow.getUuid());
                        } else {
                            FacadeProvider.getCommunityFacade().dearchive(selectedRow.getUuid());
                        }
                    }
                    break;
                case FACILITY:
                    for (FacilityIndexDto selectedRow : (Collection<FacilityIndexDto>) selectedRows) {
                        if (archive) {
                            FacadeProvider.getFacilityFacade().archive(selectedRow.getUuid());
                        } else {
                            FacadeProvider.getFacilityFacade().dearchive(selectedRow.getUuid());
                        }
                    }
                    break;
                case POINT_OF_ENTRY:
                    for (PointOfEntryDto selectedRow : (Collection<PointOfEntryDto>) selectedRows) {
                        if (archive) {
                            FacadeProvider.getPointOfEntryFacade().archive(selectedRow.getUuid());
                        } else {
                            FacadeProvider.getPointOfEntryFacade().dearchive(selectedRow.getUuid());
                        }
                    }
                    break;
                default:
                    throw new IllegalArgumentException(infrastructureType.name());
            }
            callback.run();
            Notification.show(notificationMessage, Type.ASSISTIVE_NOTIFICATION);
        }
    });
}
Also used : AreaDto(de.symeda.sormas.api.infrastructure.area.AreaDto) Arrays(java.util.Arrays) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) CountryDto(de.symeda.sormas.api.infrastructure.country.CountryDto) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) RegionDto(de.symeda.sormas.api.infrastructure.region.RegionDto) CommitListener(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.CommitListener) CommunityDto(de.symeda.sormas.api.infrastructure.community.CommunityDto) Notification(com.vaadin.ui.Notification) SormasUI(de.symeda.sormas.ui.SormasUI) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) Page(com.vaadin.server.Page) Label(com.vaadin.ui.Label) ContinentDto(de.symeda.sormas.api.infrastructure.continent.ContinentDto) RegionIndexDto(de.symeda.sormas.api.infrastructure.region.RegionIndexDto) SubcontinentDto(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentDto) UserProvider(de.symeda.sormas.ui.UserProvider) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) Collection(java.util.Collection) HasUuid(de.symeda.sormas.api.HasUuid) InfrastructureType(de.symeda.sormas.api.infrastructure.InfrastructureType) Set(java.util.Set) CountryIndexDto(de.symeda.sormas.api.infrastructure.country.CountryIndexDto) Collectors(java.util.stream.Collectors) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) Type(com.vaadin.ui.Notification.Type) DistrictIndexDto(de.symeda.sormas.api.infrastructure.district.DistrictIndexDto) FacilityIndexDto(de.symeda.sormas.api.infrastructure.facility.FacilityIndexDto) DistrictDto(de.symeda.sormas.api.infrastructure.district.DistrictDto) Strings(de.symeda.sormas.api.i18n.Strings) DistrictIndexDto(de.symeda.sormas.api.infrastructure.district.DistrictIndexDto) FacilityIndexDto(de.symeda.sormas.api.infrastructure.facility.FacilityIndexDto) Label(com.vaadin.ui.Label) CountryIndexDto(de.symeda.sormas.api.infrastructure.country.CountryIndexDto) AreaDto(de.symeda.sormas.api.infrastructure.area.AreaDto) Notification(com.vaadin.ui.Notification) RegionIndexDto(de.symeda.sormas.api.infrastructure.region.RegionIndexDto) ContinentDto(de.symeda.sormas.api.infrastructure.continent.ContinentDto) HasUuid(de.symeda.sormas.api.HasUuid) SubcontinentDto(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentDto) CommunityDto(de.symeda.sormas.api.infrastructure.community.CommunityDto) PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto) Collection(java.util.Collection)

Aggregations

PointOfEntryDto (de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto)12 CommunityDto (de.symeda.sormas.api.infrastructure.community.CommunityDto)2 DistrictDto (de.symeda.sormas.api.infrastructure.district.DistrictDto)2 FacilityDto (de.symeda.sormas.api.infrastructure.facility.FacilityDto)2 RegionDto (de.symeda.sormas.api.infrastructure.region.RegionDto)2 UserDto (de.symeda.sormas.api.user.UserDto)2 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)2 Page (com.vaadin.server.Page)1 Alignment (com.vaadin.ui.Alignment)1 Button (com.vaadin.ui.Button)1 Label (com.vaadin.ui.Label)1 Notification (com.vaadin.ui.Notification)1 Type (com.vaadin.ui.Notification.Type)1 ValoTheme (com.vaadin.ui.themes.ValoTheme)1 EntityDto (de.symeda.sormas.api.EntityDto)1 FacadeProvider (de.symeda.sormas.api.FacadeProvider)1 HasUuid (de.symeda.sormas.api.HasUuid)1 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 Captions (de.symeda.sormas.api.i18n.Captions)1 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)1