Search in sources :

Example 6 with MapCaseDto

use of de.symeda.sormas.api.caze.MapCaseDto in project SORMAS-Project by hzi-braunschweig.

the class CaseService method getCasesForMap.

public List<MapCaseDto> getCasesForMap(Region region, District district, Disease disease, Date from, Date to, NewCaseDateType dateType) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<MapCaseDto> cq = cb.createQuery(MapCaseDto.class);
    Root<Case> caze = cq.from(getElementClass());
    CaseQueryContext caseQueryContext = new CaseQueryContext(cb, cq, caze);
    CaseJoins<Case> joins = (CaseJoins<Case>) caseQueryContext.getJoins();
    Predicate filter = createMapCasesFilter(cb, cq, caze, joins, region, district, disease, from, to, dateType);
    List<MapCaseDto> result;
    if (filter != null) {
        cq.where(filter);
        cq.multiselect(caze.get(Case.UUID), caze.get(Case.REPORT_DATE), caze.get(Case.CASE_CLASSIFICATION), caze.get(Case.DISEASE), joins.getPerson().get(Person.UUID), joins.getPerson().get(Person.FIRST_NAME), joins.getPerson().get(Person.LAST_NAME), joins.getFacility().get(Facility.UUID), joins.getFacility().get(Facility.LATITUDE), joins.getFacility().get(Facility.LONGITUDE), caze.get(Case.REPORT_LAT), caze.get(Case.REPORT_LON), joins.getPersonAddress().get(Location.LATITUDE), joins.getPersonAddress().get(Location.LONGITUDE), JurisdictionHelper.booleanSelector(cb, inJurisdictionOrOwned(caseQueryContext)));
        result = em.createQuery(cq).getResultList();
    } else {
        result = Collections.emptyList();
    }
    return result;
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) CaseJoins(de.symeda.sormas.utils.CaseJoins) Predicate(javax.persistence.criteria.Predicate)

Example 7 with MapCaseDto

use of de.symeda.sormas.api.caze.MapCaseDto in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjb method getCasesForMap.

@Override
public List<MapCaseDto> getCasesForMap(RegionReferenceDto regionRef, DistrictReferenceDto districtRef, Disease disease, Date from, Date to, NewCaseDateType dateType) {
    Region region = regionService.getByReferenceDto(regionRef);
    District district = districtService.getByReferenceDto(districtRef);
    List<MapCaseDto> cases = service.getCasesForMap(region, district, disease, from, to, dateType);
    Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight);
    pseudonymizer.pseudonymizeDtoCollection(MapCaseDto.class, cases, c -> c.getInJurisdiction(), (c, isInJurisdiction) -> pseudonymizer.pseudonymizeDto(PersonReferenceDto.class, c.getPerson(), isInJurisdiction, null));
    return cases;
}
Also used : MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) Pseudonymizer(de.symeda.sormas.backend.util.Pseudonymizer) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) Region(de.symeda.sormas.backend.infrastructure.region.Region) District(de.symeda.sormas.backend.infrastructure.district.District)

Aggregations

MapCaseDto (de.symeda.sormas.api.caze.MapCaseDto)7 FacilityReferenceDto (de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto)3 CaseClassification (de.symeda.sormas.api.caze.CaseClassification)2 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)2 ArrayList (java.util.ArrayList)2 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Window (com.vaadin.ui.Window)1 CaseFacade (de.symeda.sormas.api.caze.CaseFacade)1 CasePersonDto (de.symeda.sormas.api.caze.CasePersonDto)1 MapContactDto (de.symeda.sormas.api.contact.MapContactDto)1 DashboardEventDto (de.symeda.sormas.api.dashboard.DashboardEventDto)1 FacilityDto (de.symeda.sormas.api.infrastructure.facility.FacilityDto)1 PersonDto (de.symeda.sormas.api.person.PersonDto)1 PersonReferenceDto (de.symeda.sormas.api.person.PersonReferenceDto)1 UserDto (de.symeda.sormas.api.user.UserDto)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)1 District (de.symeda.sormas.backend.infrastructure.district.District)1 Region (de.symeda.sormas.backend.infrastructure.region.Region)1 Pseudonymizer (de.symeda.sormas.backend.util.Pseudonymizer)1