Search in sources :

Example 11 with TrackedEntityInstanceCriteria

use of org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria in project dhis2-core by dhis2.

the class TrackedEntityCriteriaMapper method validateTrackedEntityType.

private TrackedEntityType validateTrackedEntityType(TrackedEntityInstanceCriteria criteria) {
    Function<String, TrackedEntityType> getTeiType = uid -> {
        if (isNotEmpty(uid)) {
            return trackedEntityTypeService.getTrackedEntityType(uid);
        }
        return null;
    };
    final TrackedEntityType trackedEntityType = getTeiType.apply(criteria.getTrackedEntityType());
    if (isNotEmpty(criteria.getTrackedEntityType()) && trackedEntityType == null) {
        throw new IllegalQueryException("Tracked entity type does not exist: " + criteria.getTrackedEntityType());
    }
    return trackedEntityType;
}
Also used : OrderColumn.isStaticColumn(org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.OrderColumn.isStaticColumn) QueryItem(org.hisp.dhis.common.QueryItem) TrackedEntityTypeService(org.hisp.dhis.trackedentity.TrackedEntityTypeService) TrackerTrackedEntityCriteria(org.hisp.dhis.webapi.controller.event.webrequest.tracker.TrackerTrackedEntityCriteria) Date(java.util.Date) OrganisationUnitService(org.hisp.dhis.organisationunit.OrganisationUnitService) IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) Function(java.util.function.Function) Program(org.hisp.dhis.program.Program) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) TrackedEntityAttributeService(org.hisp.dhis.trackedentity.TrackedEntityAttributeService) HashSet(java.util.HashSet) TrackerTrackedEntityCriteriaMapper(org.hisp.dhis.webapi.controller.event.webrequest.tracker.mapper.TrackerTrackedEntityCriteriaMapper) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Map(java.util.Map) User(org.hisp.dhis.user.User) Mappers(org.mapstruct.factory.Mappers) OrganisationUnitSelectionMode(org.hisp.dhis.common.OrganisationUnitSelectionMode) TrackedEntityInstanceQueryParams(org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) QueryOperator(org.hisp.dhis.common.QueryOperator) Set(java.util.Set) TrackedEntityInstanceCriteria(org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria) Collectors(java.util.stream.Collectors) ProgramStage(org.hisp.dhis.program.ProgramStage) OrderParamsHelper.toOrderParams(org.hisp.dhis.webapi.controller.event.mapper.OrderParamsHelper.toOrderParams) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) List(java.util.List) Component(org.springframework.stereotype.Component) DimensionalObject(org.hisp.dhis.common.DimensionalObject) CurrentUserService(org.hisp.dhis.user.CurrentUserService) AssignedUserSelectionMode(org.hisp.dhis.common.AssignedUserSelectionMode) TrackedEntityType(org.hisp.dhis.trackedentity.TrackedEntityType) QueryFilter(org.hisp.dhis.common.QueryFilter) ProgramService(org.hisp.dhis.program.ProgramService) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) Transactional(org.springframework.transaction.annotation.Transactional) TrackedEntityType(org.hisp.dhis.trackedentity.TrackedEntityType) IllegalQueryException(org.hisp.dhis.common.IllegalQueryException)

Aggregations

IllegalQueryException (org.hisp.dhis.common.IllegalQueryException)11 TrackedEntityInstanceCriteria (org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria)11 DhisWebSpringTest (org.hisp.dhis.webapi.DhisWebSpringTest)8 Test (org.junit.jupiter.api.Test)8 HashSet (java.util.HashSet)4 AssignedUserSelectionMode (org.hisp.dhis.common.AssignedUserSelectionMode)4 OrganisationUnitSelectionMode (org.hisp.dhis.common.OrganisationUnitSelectionMode)4 QueryOperator (org.hisp.dhis.common.QueryOperator)4 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)4 OrganisationUnitService (org.hisp.dhis.organisationunit.OrganisationUnitService)4 Program (org.hisp.dhis.program.Program)4 ProgramService (org.hisp.dhis.program.ProgramService)4 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)4 TrackedEntityAttributeService (org.hisp.dhis.trackedentity.TrackedEntityAttributeService)4 TrackedEntityInstanceQueryParams (org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams)4 TrackedEntityType (org.hisp.dhis.trackedentity.TrackedEntityType)4 TrackedEntityTypeService (org.hisp.dhis.trackedentity.TrackedEntityTypeService)4 CurrentUserService (org.hisp.dhis.user.CurrentUserService)4 User (org.hisp.dhis.user.User)4 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)3