Search in sources :

Example 1 with Continent

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;
}
Also used : Continent(de.symeda.sormas.backend.infrastructure.continent.Continent)

Example 2 with 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();
}
Also used : Continent(de.symeda.sormas.backend.infrastructure.continent.Continent) Country(de.symeda.sormas.backend.infrastructure.country.Country) Region(de.symeda.sormas.backend.infrastructure.region.Region) DefaultEntitiesCreator(de.symeda.sormas.backend.common.DefaultEntitiesCreator) Subcontinent(de.symeda.sormas.backend.infrastructure.subcontinent.Subcontinent) District(de.symeda.sormas.backend.infrastructure.district.District) Community(de.symeda.sormas.backend.infrastructure.community.Community)

Example 3 with Continent

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);
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Order(javax.persistence.criteria.Order) ArrayList(java.util.ArrayList) Predicate(javax.persistence.criteria.Predicate) Continent(de.symeda.sormas.backend.infrastructure.continent.Continent) SortProperty(de.symeda.sormas.api.utils.SortProperty)

Example 4 with Continent

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());
}
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 5 with Continent

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;
}
Also used : Continent(de.symeda.sormas.backend.infrastructure.continent.Continent)

Aggregations

Continent (de.symeda.sormas.backend.infrastructure.continent.Continent)7 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 Test (org.junit.Test)2 ContinentDto (de.symeda.sormas.api.infrastructure.continent.ContinentDto)1 SubcontinentCriteria (de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentCriteria)1 SubcontinentDto (de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentDto)1 SubcontinentIndexDto (de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentIndexDto)1 SubcontinentReferenceDto (de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentReferenceDto)1 SortProperty (de.symeda.sormas.api.utils.SortProperty)1 DefaultEntitiesCreator (de.symeda.sormas.backend.common.DefaultEntitiesCreator)1 Community (de.symeda.sormas.backend.infrastructure.community.Community)1 Country (de.symeda.sormas.backend.infrastructure.country.Country)1 District (de.symeda.sormas.backend.infrastructure.district.District)1 Region (de.symeda.sormas.backend.infrastructure.region.Region)1 Subcontinent (de.symeda.sormas.backend.infrastructure.subcontinent.Subcontinent)1 ArrayList (java.util.ArrayList)1 Order (javax.persistence.criteria.Order)1 Predicate (javax.persistence.criteria.Predicate)1