Class UserWorkerQueryServiceImpl
java.lang.Object
it.univr.passportease.service.userworker.impl.UserWorkerQueryServiceImpl
- All Implemented Interfaces:
UserWorkerQueryService
Implementation of
UserWorkerQueryService
-
Field Summary
Modifier and TypeFieldDescriptionprivate final AvailabilityRepository
Repository forAvailability
entityprivate final OfficeRepository
Repository forOffice
entityprivate final RequestTypeRepository
Repository forRequestType
entity -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
areNotDatesValid
(Date startDate, Date endDate) private boolean
areNotTimesValid
(LocalTime startTime, LocalTime endTime) private void
filtersValidation
(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 void
validateOffices
(AvailabilityFilters availabilityFilters) For each office, check if it existsprivate void
validateRequestTypes
(AvailabilityFilters availabilityFilters) For each request type, check if it exists
-
Field Details
-
officeRepository
Repository forOffice
entity -
availabilityRepository
Repository forAvailability
entity -
requestTypeRepository
Repository forRequestType
entity
-
-
Constructor Details
-
UserWorkerQueryServiceImpl
public UserWorkerQueryServiceImpl()
-
-
Method Details
-
getOffices
@PreAuthorize("hasAnyAuthority(\'USER\', \'WORKER\') && hasAuthority(\'VALIDATED\')") public List<Office> getOffices()Get all the offices- Specified by:
getOffices
in 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:
getAvailabilities
in 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
-