Class UserWorkerQueryServiceImpl
java.lang.Object
it.univr.passportease.service.userworker.impl.UserWorkerQueryServiceImpl
- All Implemented Interfaces:
UserWorkerQueryService
Implementation of
UserWorkerQueryService-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AvailabilityRepositoryRepository forAvailabilityentityprivate final OfficeRepositoryRepository forOfficeentityprivate final RequestTypeRepositoryRepository forRequestTypeentity -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanareNotDatesValid(Date startDate, Date endDate) private booleanareNotTimesValid(LocalTime startTime, LocalTime endTime) private voidfiltersValidation(AvailabilityFilters availabilityFilters) The filters are not valid if: start date is after end date start time is after end time one of the offices doesn't exist one of the request types doesn't existgetAvailabilities(AvailabilityFilters availabilityFilters, Integer page, Integer size) Get all the availabilities that match the filtersGet all the officesprivate voidvalidateOffices(AvailabilityFilters availabilityFilters) For each office, check if it existsprivate voidvalidateRequestTypes(AvailabilityFilters availabilityFilters) For each request type, check if it exists
-
Field Details
-
officeRepository
Repository forOfficeentity -
availabilityRepository
Repository forAvailabilityentity -
requestTypeRepository
Repository forRequestTypeentity
-
-
Constructor Details
-
UserWorkerQueryServiceImpl
public UserWorkerQueryServiceImpl()
-
-
Method Details
-
getOffices
@PreAuthorize("hasAnyAuthority(\'USER\', \'WORKER\') && hasAuthority(\'VALIDATED\')") public List<Office> getOffices()Get all the offices- Specified by:
getOfficesin interfaceUserWorkerQueryService- Returns:
- all the offices
-
getAvailabilities
@PreAuthorize("hasAnyAuthority(\'USER\', \'WORKER\') && hasAuthority(\'VALIDATED\')") public List<Availability> getAvailabilities(AvailabilityFilters availabilityFilters, Integer page, Integer size) throws InvalidDataFromRequestException Get all the availabilities that match the filters- Specified by:
getAvailabilitiesin interfaceUserWorkerQueryService- Parameters:
availabilityFilters- filters to apply to the query, can be nullpage- page number, can be nullsize- page size, can be null- Returns:
- all the availabilities that match the filters
- Throws:
InvalidDataFromRequestException- if the filters are not valid, seefiltersValidation(AvailabilityFilters)
-
filtersValidation
private void filtersValidation(AvailabilityFilters availabilityFilters) throws InvalidDataFromRequestException The filters are not valid if:- start date is after end date
- start time is after end time
- one of the offices doesn't exist
- one of the request types doesn't exist
- Parameters:
availabilityFilters- filters to apply to the query- Throws:
InvalidDataFromRequestException- if the filters are not valid, i.e.:
-
areNotDatesValid
- Parameters:
startDate- start dateendDate- end date- Returns:
- true if the start date is after the end date, false otherwise
-
areNotTimesValid
- Parameters:
startTime- start timeendTime- end time- Returns:
- true if the start time is after the end time, false otherwise
-
validateRequestTypes
private void validateRequestTypes(AvailabilityFilters availabilityFilters) throws InvalidDataFromRequestException For each request type, check if it exists- Parameters:
availabilityFilters- filters to apply to the query- Throws:
InvalidDataFromRequestException- if one of the request types doesn't exist
-
validateOffices
private void validateOffices(AvailabilityFilters availabilityFilters) throws InvalidDataFromRequestException For each office, check if it exists- Parameters:
availabilityFilters- filters to apply to the query- Throws:
InvalidDataFromRequestException- if one of the offices doesn't exist
-