Search in sources :

Example 1 with SubcontinentIndexDto

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

the class ContinentFacadeEjbTest method testSubcontinent.

@Test
public void testSubcontinent() {
    final Continent continent = creator.createContinent("EUROPE");
    final SubcontinentDto subcontinentDto = new SubcontinentDto();
    subcontinentDto.setDefaultName("CENTRAL_EUROPE");
    subcontinentDto.setContinent(continent.toReference());
    getSubcontinentFacade().save(subcontinentDto);
    final List<SubcontinentReferenceDto> subcontinents = getSubcontinentFacade().getByDefaultName("CENTRAL_EUROPE", false);
    assertEquals(1, subcontinents.size());
    final SubcontinentDto savedSubcontinentDto = getSubcontinentFacade().getByUuid(subcontinents.get(0).getUuid());
    assertEquals("CENTRAL_EUROPE", savedSubcontinentDto.getDefaultName());
    assertEquals(I18nProperties.getContinentName("EUROPE"), savedSubcontinentDto.getContinent().getCaption());
    final List<SubcontinentIndexDto> indexList = getSubcontinentFacade().getIndexList(new SubcontinentCriteria().continent(continent.toReference()), null, null, null);
    assertEquals(1, indexList.size());
    final SubcontinentIndexDto subcontinentIndexDto = indexList.get(0);
    assertEquals("CENTRAL_EUROPE", subcontinentIndexDto.getDefaultName());
    assertEquals(I18nProperties.getContinentName("EUROPE"), subcontinentIndexDto.getContinent().getCaption());
    assertEquals("Central Europe", subcontinentIndexDto.getDisplayName());
}
Also used : Continent(de.symeda.sormas.backend.infrastructure.continent.Continent) SubcontinentIndexDto(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentIndexDto) SubcontinentReferenceDto(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentReferenceDto) SubcontinentDto(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentDto) SubcontinentCriteria(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentCriteria) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 2 with SubcontinentIndexDto

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

the class SubcontinentsGrid method createFilteredStream.

private Stream<SubcontinentIndexDto> createFilteredStream() {
    // get all filter properties
    String nameLike = getCriteria().getNameLike() != null ? getCriteria().getNameLike().toLowerCase() : null;
    String continentUuid = getCriteria().getContinent() != null ? getCriteria().getContinent().getUuid() : null;
    EntityRelevanceStatus relevanceStatus = getCriteria().getRelevanceStatus();
    // "empty" basefilter
    Predicate<SubcontinentIndexDto> filters = x -> true;
    // name filter
    if (!StringUtils.isEmpty(nameLike)) {
        filters = filters.and(subcontinent -> (subcontinent.getDefaultName().toLowerCase().contains(nameLike) || subcontinent.getDisplayName().toLowerCase().contains(nameLike)));
    }
    // continent filter
    if (continentUuid != null) {
        filters = filters.and(subcontinent -> (subcontinent.getContinent() != null && subcontinent.getContinent().getUuid().equals(continentUuid)));
    }
    // relevancestatus filter (active/archived/all)
    if (relevanceStatus != null) {
        switch(relevanceStatus) {
            case ACTIVE:
                filters = filters.and(subcontinent -> (!subcontinent.isArchived()));
                break;
            case ARCHIVED:
                filters = filters.and(subcontinent -> (subcontinent.isArchived()));
                break;
        }
    }
    // apply filters
    return allSubcontinents.stream().filter(filters);
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) Predicate(java.util.function.Predicate) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) StringUtils(org.apache.commons.lang3.StringUtils) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) UserRight(de.symeda.sormas.api.user.UserRight) List(java.util.List) Stream(java.util.stream.Stream) ViewConfiguration(de.symeda.sormas.ui.utils.ViewConfiguration) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) SubcontinentCriteria(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentCriteria) SubcontinentIndexDto(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentIndexDto) UserProvider(de.symeda.sormas.ui.UserProvider) SubcontinentIndexDto(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentIndexDto) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus)

Example 3 with SubcontinentIndexDto

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

the class SubcontinentFacadeEjb method toIndexDto.

public SubcontinentIndexDto toIndexDto(Subcontinent entity) {
    if (entity == null) {
        return null;
    }
    SubcontinentIndexDto dto = new SubcontinentIndexDto();
    DtoHelper.fillDto(dto, entity);
    dto.setDefaultName(entity.getDefaultName());
    dto.setDisplayName(I18nProperties.getSubcontinentName(entity.getDefaultName()));
    dto.setArchived(entity.isArchived());
    dto.setExternalId(entity.getExternalId());
    dto.setUuid(entity.getUuid());
    dto.setContinent(ContinentFacadeEjb.toReferenceDto(entity.getContinent()));
    return dto;
}
Also used : SubcontinentIndexDto(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentIndexDto)

Aggregations

SubcontinentIndexDto (de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentIndexDto)3 SubcontinentCriteria (de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentCriteria)2 EntityRelevanceStatus (de.symeda.sormas.api.EntityRelevanceStatus)1 FacadeProvider (de.symeda.sormas.api.FacadeProvider)1 FeatureType (de.symeda.sormas.api.feature.FeatureType)1 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)1 SubcontinentDto (de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentDto)1 SubcontinentReferenceDto (de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentReferenceDto)1 UserRight (de.symeda.sormas.api.user.UserRight)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 Continent (de.symeda.sormas.backend.infrastructure.continent.Continent)1 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)1 UserProvider (de.symeda.sormas.ui.UserProvider)1 ViewModelProviders (de.symeda.sormas.ui.ViewModelProviders)1 FilteredGrid (de.symeda.sormas.ui.utils.FilteredGrid)1 ViewConfiguration (de.symeda.sormas.ui.utils.ViewConfiguration)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 Stream (java.util.stream.Stream)1 StringUtils (org.apache.commons.lang3.StringUtils)1