Search in sources :

Example 1 with PersonCriteria

use of de.symeda.sormas.api.person.PersonCriteria in project SORMAS-Project by hzi-braunschweig.

the class PersonFacadeEjb method getIndexList.

@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public List<PersonIndexDto> getIndexList(PersonCriteria criteria, Integer first, Integer max, List<SortProperty> sortProperties) {
    long startTime = DateHelper.startTime();
    final CriteriaBuilder cb = em.getCriteriaBuilder();
    final CriteriaQuery<PersonIndexDto> cq = cb.createQuery(PersonIndexDto.class);
    final Root<Person> person = cq.from(Person.class);
    final PersonQueryContext personQueryContext = new PersonQueryContext(cb, cq, person);
    final PersonJoins personJoins = (PersonJoins) personQueryContext.getJoins();
    personJoins.configure(criteria);
    final Join<Person, Location> location = personJoins.getAddress();
    final Join<Location, District> district = personJoins.getAddressJoins().getDistrict();
    final Subquery<String> phoneSubQuery = cq.subquery(String.class);
    final Root<PersonContactDetail> phoneRoot = phoneSubQuery.from(PersonContactDetail.class);
    phoneSubQuery.where(cb.and(cb.equal(phoneRoot.get(PersonContactDetail.PERSON), person), cb.isTrue(phoneRoot.get(PersonContactDetail.PRIMARY_CONTACT)), cb.equal(phoneRoot.get(PersonContactDetail.PERSON_CONTACT_DETAIL_TYPE), PersonContactDetailType.PHONE)));
    phoneSubQuery.select(phoneRoot.get(PersonContactDetail.CONTACT_INFORMATION));
    final Subquery<String> emailSubQuery = cq.subquery(String.class);
    final Root<PersonContactDetail> emailRoot = emailSubQuery.from(PersonContactDetail.class);
    emailSubQuery.where(cb.and(cb.equal(emailRoot.get(PersonContactDetail.PERSON), person), cb.isTrue(emailRoot.get(PersonContactDetail.PRIMARY_CONTACT)), cb.equal(emailRoot.get(PersonContactDetail.PERSON_CONTACT_DETAIL_TYPE), PersonContactDetailType.EMAIL)));
    emailSubQuery.select(emailRoot.get(PersonContactDetail.CONTACT_INFORMATION));
    // make sure to check the sorting by the multi-select order if you extend the selections here
    cq.multiselect(person.get(Person.UUID), person.get(Person.FIRST_NAME), person.get(Person.LAST_NAME), person.get(Person.APPROXIMATE_AGE), person.get(Person.APPROXIMATE_AGE_TYPE), person.get(Person.BIRTHDATE_DD), person.get(Person.BIRTHDATE_MM), person.get(Person.BIRTHDATE_YYYY), person.get(Person.SEX), district.get(District.NAME), location.get(Location.STREET), location.get(Location.HOUSE_NUMBER), location.get(Location.POSTAL_CODE), location.get(Location.CITY), phoneSubQuery.alias(PersonIndexDto.PHONE), emailSubQuery.alias(PersonIndexDto.EMAIL_ADDRESS), person.get(Person.CHANGE_DATE), JurisdictionHelper.booleanSelector(cb, personService.inJurisdictionOrOwned(personQueryContext)));
    Predicate filter = createIndexListFilter(criteria, personQueryContext);
    if (filter != null) {
        cq.where(filter);
    }
    cq.distinct(true);
    if (sortProperties != null && sortProperties.size() > 0) {
        List<Order> order = new ArrayList<Order>(sortProperties.size());
        for (SortProperty sortProperty : sortProperties) {
            Expression<?> expression;
            switch(sortProperty.propertyName) {
                case PersonIndexDto.UUID:
                case PersonIndexDto.FIRST_NAME:
                case PersonIndexDto.LAST_NAME:
                case PersonIndexDto.SEX:
                    expression = person.get(sortProperty.propertyName);
                    break;
                case PersonIndexDto.PHONE:
                    // order in the multiselect - Postgres limitation - needed to make sure it uses the same expression for ordering
                    expression = cb.literal(15);
                    break;
                case PersonIndexDto.EMAIL_ADDRESS:
                    // order in the multiselect - Postgres limitation - needed to make sure it uses the same expression for ordering
                    expression = cb.literal(16);
                    break;
                case PersonIndexDto.AGE_AND_BIRTH_DATE:
                    expression = person.get(Person.APPROXIMATE_AGE);
                    break;
                case PersonIndexDto.DISTRICT:
                    expression = district.get(District.NAME);
                    break;
                case PersonIndexDto.STREET:
                case PersonIndexDto.HOUSE_NUMBER:
                case PersonIndexDto.POSTAL_CODE:
                case PersonIndexDto.CITY:
                    expression = location.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.desc(person.get(Person.CHANGE_DATE)));
    }
    List<PersonIndexDto> persons = QueryHelper.getResultList(em, cq, first, max);
    Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
    pseudonymizer.pseudonymizeDtoCollection(PersonIndexDto.class, persons, p -> p.getInJurisdiction(), (p, isInJurisdiction) -> pseudonymizer.pseudonymizeDto(AgeAndBirthDateDto.class, p.getAgeAndBirthDate(), isInJurisdiction, null));
    logger.debug("getIndexList() finished. association={}, count={}, {}ms", Optional.ofNullable(criteria).orElse(new PersonCriteria()).getPersonAssociation().name(), persons.size(), DateHelper.durationMillies(startTime));
    return persons;
}
Also used : AgeAndBirthDateDto(de.symeda.sormas.api.caze.AgeAndBirthDateDto) Pseudonymizer(de.symeda.sormas.backend.util.Pseudonymizer) ArrayList(java.util.ArrayList) Predicate(javax.persistence.criteria.Predicate) SortProperty(de.symeda.sormas.api.utils.SortProperty) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Order(javax.persistence.criteria.Order) PersonIndexDto(de.symeda.sormas.api.person.PersonIndexDto) PersonCriteria(de.symeda.sormas.api.person.PersonCriteria) District(de.symeda.sormas.backend.infrastructure.district.District) Location(de.symeda.sormas.backend.location.Location)

Example 2 with PersonCriteria

use of de.symeda.sormas.api.person.PersonCriteria in project SORMAS-Project by hzi-braunschweig.

the class PersonFacadeEjb method count.

@Override
public long count(PersonCriteria criteria) {
    long startTime = DateHelper.startTime();
    final PersonCriteria nullSafeCriteria = Optional.ofNullable(criteria).orElse(new PersonCriteria());
    final long count;
    if (nullSafeCriteria.getPersonAssociation() == PersonAssociation.ALL) {
        // Fetch Person.id per association and find the distinct count.
        Set<Long> distinctPersonIds = new HashSet<>();
        boolean immunizationModuleReduced = featureConfigurationFacade.isPropertyValueTrue(FeatureType.IMMUNIZATION_MANAGEMENT, FeatureTypeProperty.REDUCED);
        Arrays.stream(PersonAssociation.getSingleAssociations()).filter(e -> !(immunizationModuleReduced && e == PersonAssociation.IMMUNIZATION)).map(e -> getPersonIds(SerializationUtils.clone(nullSafeCriteria).personAssociation(e))).forEach(distinctPersonIds::addAll);
        count = distinctPersonIds.size();
    } else {
        // Directly fetch the count for the only required association
        count = getPersonIds(criteria).size();
    }
    logger.debug("count() finished. association={}, count={}, {}ms", nullSafeCriteria.getPersonAssociation().name(), count, DateHelper.durationMillies(startTime));
    return count;
}
Also used : FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) Arrays(java.util.Arrays) DtoHelper(de.symeda.sormas.backend.util.DtoHelper) PersonAssociation(de.symeda.sormas.api.person.PersonAssociation) CommunityFacadeEjb(de.symeda.sormas.backend.infrastructure.community.CommunityFacadeEjb) ExternalDataUpdateException(de.symeda.sormas.api.externaldata.ExternalDataUpdateException) DistrictService(de.symeda.sormas.backend.infrastructure.district.DistrictService) StringUtils(org.apache.commons.lang3.StringUtils) PersonDto(de.symeda.sormas.api.person.PersonDto) Valid(javax.validation.Valid) PhoneNumberUtil(com.google.i18n.phonenumbers.PhoneNumberUtil) CaseOutcome(de.symeda.sormas.api.caze.CaseOutcome) Page(de.symeda.sormas.api.common.Page) TransactionAttributeType(javax.ejb.TransactionAttributeType) Predicate(javax.persistence.criteria.Predicate) Map(java.util.Map) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) JoinType(javax.persistence.criteria.JoinType) PersonContext(de.symeda.sormas.api.person.PersonContext) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) FacilityService(de.symeda.sormas.backend.infrastructure.facility.FacilityService) CommunityService(de.symeda.sormas.backend.infrastructure.community.CommunityService) LocationFacadeEjbLocal(de.symeda.sormas.backend.location.LocationFacadeEjb.LocationFacadeEjbLocal) PersonExportDto(de.symeda.sormas.api.person.PersonExportDto) Set(java.util.Set) NotNull(javax.validation.constraints.NotNull) DistrictFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.district.DistrictFacadeEjb.DistrictFacadeEjbLocal) UserService(de.symeda.sormas.backend.user.UserService) Stream(java.util.stream.Stream) User(de.symeda.sormas.backend.user.User) CaseLogic(de.symeda.sormas.api.caze.CaseLogic) ExternalDataDto(de.symeda.sormas.api.externaldata.ExternalDataDto) CaseFacadeEjbLocal(de.symeda.sormas.backend.caze.CaseFacadeEjb.CaseFacadeEjbLocal) JurisdictionHelper(de.symeda.sormas.backend.util.JurisdictionHelper) SymptomJournalStatus(de.symeda.sormas.api.person.SymptomJournalStatus) PersonSimilarityCriteria(de.symeda.sormas.api.person.PersonSimilarityCriteria) EventParticipant(de.symeda.sormas.backend.event.EventParticipant) Community(de.symeda.sormas.backend.infrastructure.community.Community) QueryHelper(de.symeda.sormas.backend.util.QueryHelper) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) EventParticipantCriteria(de.symeda.sormas.api.event.EventParticipantCriteria) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) PersonFacade(de.symeda.sormas.api.person.PersonFacade) FacilityFacadeEjb(de.symeda.sormas.backend.infrastructure.facility.FacilityFacadeEjb) SerializationUtils(org.apache.commons.lang3.SerializationUtils) EventParticipantFacadeEjbLocal(de.symeda.sormas.backend.event.EventParticipantFacadeEjb.EventParticipantFacadeEjbLocal) ArrayList(java.util.ArrayList) Case(de.symeda.sormas.backend.caze.Case) LocalBean(javax.ejb.LocalBean) EJB(javax.ejb.EJB) Root(javax.persistence.criteria.Root) DataHelper(de.symeda.sormas.api.utils.DataHelper) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) SormasToSormasOriginInfoService(de.symeda.sormas.backend.sormastosormas.origin.SormasToSormasOriginInfoService) UserFacadeEjbLocal(de.symeda.sormas.backend.user.UserFacadeEjb.UserFacadeEjbLocal) Collectors.maxBy(java.util.stream.Collectors.maxBy) EntityManager(javax.persistence.EntityManager) PersistenceContext(javax.persistence.PersistenceContext) AgeAndBirthDateDto(de.symeda.sormas.api.caze.AgeAndBirthDateDto) SortProperty(de.symeda.sormas.api.utils.SortProperty) Captions(de.symeda.sormas.api.i18n.Captions) Disease(de.symeda.sormas.api.Disease) ContactService(de.symeda.sormas.backend.contact.ContactService) Subquery(javax.persistence.criteria.Subquery) FeatureTypeProperty(de.symeda.sormas.api.feature.FeatureTypeProperty) SormasToSormasOriginInfo(de.symeda.sormas.backend.sormastosormas.origin.SormasToSormasOriginInfo) FeatureType(de.symeda.sormas.api.feature.FeatureType) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) ApproximateAgeType(de.symeda.sormas.api.person.ApproximateAgeType) Join(javax.persistence.criteria.Join) FollowUpStatusDto(de.symeda.sormas.api.contact.FollowUpStatusDto) AbstractDomainObject(de.symeda.sormas.backend.common.AbstractDomainObject) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) LoggerFactory(org.slf4j.LoggerFactory) CauseOfDeath(de.symeda.sormas.api.person.CauseOfDeath) CommunityFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.community.CommunityFacadeEjb.CommunityFacadeEjbLocal) CountryService(de.symeda.sormas.backend.infrastructure.country.CountryService) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) EventFacadeEjbLocal(de.symeda.sormas.backend.event.EventFacadeEjb.EventFacadeEjbLocal) Contact(de.symeda.sormas.backend.contact.Contact) Stateless(javax.ejb.Stateless) CaseService(de.symeda.sormas.backend.caze.CaseService) CountryFacadeEjb(de.symeda.sormas.backend.infrastructure.country.CountryFacadeEjb) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) SimilarPersonDto(de.symeda.sormas.api.person.SimilarPersonDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Region(de.symeda.sormas.backend.infrastructure.region.Region) PersonHelper(de.symeda.sormas.api.person.PersonHelper) District(de.symeda.sormas.backend.infrastructure.district.District) Pseudonymizer(de.symeda.sormas.backend.util.Pseudonymizer) Collectors(java.util.stream.Collectors) ImmunizationFacadeEjb(de.symeda.sormas.backend.immunization.ImmunizationFacadeEjb) PersonFollowUpEndDto(de.symeda.sormas.api.person.PersonFollowUpEndDto) Objects(java.util.Objects) List(java.util.List) BirthDateDto(de.symeda.sormas.api.caze.BirthDateDto) DistrictFacadeEjb(de.symeda.sormas.backend.infrastructure.district.DistrictFacadeEjb) PersonContactDetailType(de.symeda.sormas.api.person.PersonContactDetailType) Order(javax.persistence.criteria.Order) Optional(java.util.Optional) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) PersonIndexDto(de.symeda.sormas.api.person.PersonIndexDto) Location(de.symeda.sormas.backend.location.Location) FeatureConfigurationFacadeEjbLocal(de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb.FeatureConfigurationFacadeEjbLocal) ValidationRuntimeException(de.symeda.sormas.api.utils.ValidationRuntimeException) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) ContactFacadeEjbLocal(de.symeda.sormas.backend.contact.ContactFacadeEjb.ContactFacadeEjbLocal) ApproximateAgeHelper(de.symeda.sormas.api.person.ApproximateAgeType.ApproximateAgeHelper) DateHelper(de.symeda.sormas.api.utils.DateHelper) PersonContactDetailDto(de.symeda.sormas.api.person.PersonContactDetailDto) EventParticipantService(de.symeda.sormas.backend.event.EventParticipantService) HashSet(java.util.HashSet) CollectionUtils(org.apache.commons.collections.CollectionUtils) TransactionAttribute(javax.ejb.TransactionAttribute) IterableHelper(de.symeda.sormas.backend.util.IterableHelper) FacilityFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.facility.FacilityFacadeEjb.FacilityFacadeEjbLocal) Comparator.comparing(java.util.Comparator.comparing) Expression(javax.persistence.criteria.Expression) CriteriaBuilderHelper(de.symeda.sormas.backend.common.CriteriaBuilderHelper) ModelConstants(de.symeda.sormas.backend.util.ModelConstants) LocationDto(de.symeda.sormas.api.location.LocationDto) PersonCriteria(de.symeda.sormas.api.person.PersonCriteria) Logger(org.slf4j.Logger) JournalPersonDto(de.symeda.sormas.api.person.JournalPersonDto) Validations(de.symeda.sormas.api.i18n.Validations) LocationFacadeEjb(de.symeda.sormas.backend.location.LocationFacadeEjb) Pair(de.symeda.sormas.api.utils.DataHelper.Pair) RegionFacadeEjb(de.symeda.sormas.backend.infrastructure.region.RegionFacadeEjb) RegionService(de.symeda.sormas.backend.infrastructure.region.RegionService) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) PresentCondition(de.symeda.sormas.api.person.PresentCondition) NumberParseException(com.google.i18n.phonenumbers.NumberParseException) Country(de.symeda.sormas.backend.infrastructure.country.Country) ExternalJournalService(de.symeda.sormas.backend.externaljournal.ExternalJournalService) Comparator(java.util.Comparator) Collections(java.util.Collections) Phonenumber(com.google.i18n.phonenumbers.Phonenumber) PersonCriteria(de.symeda.sormas.api.person.PersonCriteria) HashSet(java.util.HashSet)

Example 3 with PersonCriteria

use of de.symeda.sormas.api.person.PersonCriteria in project SORMAS-Project by hzi-braunschweig.

the class PersonGrid method setLazyDataProvider.

public void setLazyDataProvider() {
    DataProvider<PersonIndexDto, PersonCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getPersonFacade().getIndexList(query.getFilter().orElse(null), query.getOffset(), query.getLimit(), query.getSortOrders().stream().map(sortOrder -> new SortProperty(sortOrder.getSorted(), sortOrder.getDirection() == SortDirection.ASCENDING)).collect(Collectors.toList())).stream(), query -> (int) FacadeProvider.getPersonFacade().count(query.getFilter().orElse(null)));
    setDataProvider(dataProvider);
    setSelectionMode(SelectionMode.NONE);
}
Also used : SortProperty(de.symeda.sormas.api.utils.SortProperty) PersonIndexDto(de.symeda.sormas.api.person.PersonIndexDto) PersonCriteria(de.symeda.sormas.api.person.PersonCriteria)

Example 4 with PersonCriteria

use of de.symeda.sormas.api.person.PersonCriteria in project SORMAS-Project by hzi-braunschweig.

the class PersonFacadeEjbTest method testCountAndGetIndexListWithAssociations.

/**
 * Test all {@link PersonAssociation} variants if they work. Also serves to review the generated SQL.
 */
@Test
public void testCountAndGetIndexListWithAssociations() {
    PersonFacade cut = getPersonFacade();
    Integer offset = null;
    Integer limit = null;
    List<SortProperty> sortProperties = null;
    RDCF rdcf = creator.createRDCF();
    UserDto user = creator.createUser(rdcf.region.getUuid(), null, null, null, "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    loginWith(user);
    // 1a. Test for all available PersonAssociations
    for (PersonAssociation pa : PersonAssociation.values()) {
        PersonCriteria criteria = new PersonCriteria().personAssociation(pa);
        assertThat("Failed for testing association on count: " + pa.name(), cut.count(criteria), equalTo(0L));
        assertThat(criteria.getPersonAssociation(), equalTo(pa));
        assertThat("Failed for testing association on getIndexList: " + pa.name(), cut.getIndexList(criteria, offset, limit, sortProperties), is(empty()));
        assertThat(criteria.getPersonAssociation(), equalTo(pa));
    }
    // 1b. Test that calling with "null" as criteria also works
    assertThat(cut.count(null), equalTo(0L));
    assertThat(cut.getIndexList(null, offset, limit, sortProperties), is(empty()));
    // 2. Test paging windows
    final PersonDto person1 = creator.createPerson("James", "Smith", Sex.MALE, 1920, 1, 1);
    final CaseDataDto case1 = creator.createCase(user.toReference(), person1.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    final PersonDto person2 = creator.createPerson("Maria", "Garcia", Sex.FEMALE, 1920, 1, 1);
    final ContactDto contact2 = creator.createContact(user.toReference(), user.toReference(), person2.toReference(), null, new Date(), new Date(), Disease.EVD, rdcf);
    // 2a. count
    assertThat(cut.count(new PersonCriteria().personAssociation(PersonAssociation.ALL)), equalTo(2L));
    assertThat(cut.count(new PersonCriteria().personAssociation(PersonAssociation.CASE)), equalTo(1L));
    assertThat(cut.count(new PersonCriteria().personAssociation(PersonAssociation.CONTACT)), equalTo(1L));
    // 2b. getIndexList with all persons in the paging window
    assertPersonsFound(case1, contact2, cut, offset, limit, sortProperties);
    offset = 0;
    limit = 2;
    assertPersonsFound(case1, contact2, cut, offset, limit, sortProperties);
    offset = 0;
    limit = 1;
    assertPersonsFound(case1, contact2, cut, offset, limit, sortProperties);
    // 2c. getIndexList [PersonAssociation.ALL] with only the contact person in the paging window (default sorting by changeDate)
    offset = 1;
    limit = 2;
    assertPersonsFound(null, null, Arrays.asList(contact2.getPerson()), cut, offset, limit, sortProperties);
}
Also used : SortProperty(de.symeda.sormas.api.utils.SortProperty) RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) JournalPersonDto(de.symeda.sormas.api.person.JournalPersonDto) PersonFacade(de.symeda.sormas.api.person.PersonFacade) UserDto(de.symeda.sormas.api.user.UserDto) PersonCriteria(de.symeda.sormas.api.person.PersonCriteria) ContactDto(de.symeda.sormas.api.contact.ContactDto) PersonAssociation(de.symeda.sormas.api.person.PersonAssociation) Date(java.util.Date) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 5 with PersonCriteria

use of de.symeda.sormas.api.person.PersonCriteria in project SORMAS-Project by hzi-braunschweig.

the class PersonFacadeEjbTest method assertPersonsFound.

private static void assertPersonsFound(CaseDataDto caze, ContactDto contact, List<PersonReferenceDto> allPersons, PersonFacade cut, Integer offset, Integer limit, List<SortProperty> sortProperties) {
    List<String> casePersonUuids = caze == null ? Collections.emptyList() : Collections.singletonList(caze.getPerson().getUuid());
    List<String> contactPersonUuids = contact == null ? Collections.emptyList() : Collections.singletonList(contact.getPerson().getUuid());
    int allCount = Math.min(allPersons.size(), limit != null ? limit : Integer.MAX_VALUE);
    // single association
    List<PersonIndexDto> caseList = cut.getIndexList(new PersonCriteria().personAssociation(PersonAssociation.CASE), offset, limit, sortProperties);
    assertThat(caseList, hasSize(casePersonUuids.size()));
    List<PersonIndexDto> contactList = cut.getIndexList(new PersonCriteria().personAssociation(PersonAssociation.CONTACT), offset, limit, sortProperties);
    assertThat(contactList, hasSize(contactPersonUuids.size()));
    assertThat(cut.getIndexList(new PersonCriteria().personAssociation(PersonAssociation.EVENT_PARTICIPANT), offset, limit, sortProperties), is(empty()));
    assertThat(cut.getIndexList(new PersonCriteria().personAssociation(PersonAssociation.IMMUNIZATION), offset, limit, sortProperties), is(empty()));
    assertThat(cut.getIndexList(new PersonCriteria().personAssociation(PersonAssociation.TRAVEL_ENTRY), offset, limit, sortProperties), is(empty()));
    // ALL
    List<PersonIndexDto> allList = cut.getIndexList(new PersonCriteria().personAssociation(PersonAssociation.ALL), offset, limit, sortProperties);
    assertThat(allList, hasSize(allCount));
}
Also used : PersonIndexDto(de.symeda.sormas.api.person.PersonIndexDto) PersonCriteria(de.symeda.sormas.api.person.PersonCriteria) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString)

Aggregations

PersonCriteria (de.symeda.sormas.api.person.PersonCriteria)16 Date (java.util.Date)12 PersonDto (de.symeda.sormas.api.person.PersonDto)11 Test (org.junit.Test)10 PersonIndexDto (de.symeda.sormas.api.person.PersonIndexDto)8 UserDto (de.symeda.sormas.api.user.UserDto)8 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)7 JournalPersonDto (de.symeda.sormas.api.person.JournalPersonDto)7 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)7 ContactDto (de.symeda.sormas.api.contact.ContactDto)5 Collections (java.util.Collections)5 PersonAssociation (de.symeda.sormas.api.person.PersonAssociation)4 PersonExportDto (de.symeda.sormas.api.person.PersonExportDto)4 SortProperty (de.symeda.sormas.api.utils.SortProperty)4 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)4 Predicate (javax.persistence.criteria.Predicate)4 Disease (de.symeda.sormas.api.Disease)3 AgeAndBirthDateDto (de.symeda.sormas.api.caze.AgeAndBirthDateDto)3 CaseClassification (de.symeda.sormas.api.caze.CaseClassification)3