use of de.symeda.sormas.backend.infrastructure.continent.Continent in project SORMAS-Project by hzi-braunschweig.
the class DefaultEntitiesCreator method createDefaultContinent.
public Continent createDefaultContinent(boolean randomUuid) {
Continent continent = new Continent();
continent.setUuid(createUuid(randomUuid, DefaultEntityHelper.DefaultInfrastructureUuidSeed.CONTINENT));
continent.setDefaultName(I18nProperties.getCaption(Captions.Continent, "Default Continent"));
continent.setExternalId("CONT");
return continent;
}
use of de.symeda.sormas.backend.infrastructure.continent.Continent in project SORMAS-Project by hzi-braunschweig.
the class InfraValidationSoundnessTest method setUpInfra.
protected void setUpInfra(boolean randomUuid) {
DefaultEntitiesCreator defaultEntitiesCreator = getDefaultEntitiesCreator();
Continent continent = defaultEntitiesCreator.createDefaultContinent(randomUuid);
getContinentService().ensurePersisted(continent);
Subcontinent subcontinent = defaultEntitiesCreator.createDefaultSubcontinent(continent, randomUuid);
getSubcontinentService().ensurePersisted(subcontinent);
Country country = defaultEntitiesCreator.createDefaultCountry(subcontinent, randomUuid);
getCountryService().ensurePersisted(country);
Region region = defaultEntitiesCreator.createDefaultRegion(randomUuid);
getRegionService().ensurePersisted(region);
District district = defaultEntitiesCreator.createDefaultDistrict(region, randomUuid);
getDistrictService().ensurePersisted(district);
Community community = defaultEntitiesCreator.createDefaultCommunity(district, randomUuid);
getCommunityService().ensurePersisted(community);
assert !getRegionService().getAll().isEmpty();
}
use of de.symeda.sormas.backend.infrastructure.continent.Continent in project SORMAS-Project by hzi-braunschweig.
the class SubcontinentFacadeEjb method getIndexList.
@Override
public List<SubcontinentIndexDto> getIndexList(SubcontinentCriteria criteria, Integer first, Integer max, List<SortProperty> sortProperties) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Subcontinent> cq = cb.createQuery(Subcontinent.class);
Root<Subcontinent> subcontinent = cq.from(Subcontinent.class);
Join<Subcontinent, Continent> continent = subcontinent.join(Subcontinent.CONTINENT, JoinType.LEFT);
Predicate filter = null;
if (criteria != null) {
filter = service.buildCriteriaFilter(criteria, cb, subcontinent);
}
if (filter != null) {
cq.where(filter);
}
if (CollectionUtils.isNotEmpty(sortProperties)) {
List<Order> order = new ArrayList<>(sortProperties.size());
for (SortProperty sortProperty : sortProperties) {
Expression<?> expression;
switch(sortProperty.propertyName) {
case SubcontinentIndexDto.DISPLAY_NAME:
expression = subcontinent.get(Subcontinent.DEFAULT_NAME);
break;
case SubcontinentDto.CONTINENT:
expression = continent.get(Continent.DEFAULT_NAME);
break;
case SubcontinentDto.EXTERNAL_ID:
expression = subcontinent.get(sortProperty.propertyName);
break;
default:
throw new IllegalArgumentException(sortProperty.propertyName);
}
order.add(sortProperty.ascending ? cb.asc(expression) : cb.desc(expression));
}
cq.orderBy(order);
} else {
cq.orderBy(cb.asc(subcontinent.get(Subcontinent.DEFAULT_NAME)));
}
cq.select(subcontinent);
return QueryHelper.getResultList(em, cq, first, max, this::toIndexDto);
}
use of de.symeda.sormas.backend.infrastructure.continent.Continent 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.backend.infrastructure.continent.Continent in project SORMAS-Project by hzi-braunschweig.
the class TestDataCreator method createContinent.
public Continent createContinent(String name) {
Continent continent = new Continent();
continent.setUuid(DataHelper.createUuid());
continent.setDefaultName(name);
beanTest.getContinentService().persist(continent);
return continent;
}
Aggregations