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());
}
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);
}
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;
}
Aggregations