Class UserMutationServiceImpl
java.lang.Object
it.univr.passportease.service.user.impl.UserMutationServiceImpl
- All Implemented Interfaces:
UserMutationService
This class implements the
UserMutationService
interface.
It contains all the GraphQL mutation methods that a user can perform.-
Field Summary
Modifier and TypeFieldDescriptionprivate final AvailabilityRepository
The repository forAvailability
entity.private final MapNotification
The service that maps theNotificationInputDB
DTO to theNotification
entity.private final NotificationRepository
The repository forNotification
entity.private final OfficeRepository
The repository forOffice
entity.private final RequestTypeRepository
The repository forRequestType
entity.private final UserRepository
The repository forUser
entity. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateNotification
(NotificationInput notificationInput, User user) Creates a notification.createReservation
(UUID availabilityId, User user) Creates a reservation by id, setting the availability status toStatus.TAKEN
void
deleteNotification
(UUID notificationId) Deletes a notification by idvoid
deleteReservation
(UUID availabilityId) Deletes a reservation by id, setting the availability status toStatus.FREE
and setting the availability user to nullmodifyNotification
(NotificationInput notificationInput, UUID notificationId) Modifies a notification by idvoid
preserveAvailability
(UUID availabilityId) Preserves the availability by id, setting the availability status toStatus.PENDING
void
This method is scheduled to run every 10 minutes.
-
Field Details
-
notificationRepository
The repository forNotification
entity. -
officeRepository
The repository forOffice
entity. -
requestTypeRepository
The repository forRequestType
entity. -
availabilityRepository
The repository forAvailability
entity. -
userRepository
The repository forUser
entity. -
mapNotification
The service that maps theNotificationInputDB
DTO to theNotification
entity.
-
-
Constructor Details
-
UserMutationServiceImpl
public UserMutationServiceImpl()
-
-
Method Details
-
createNotification
@PreAuthorize("hasAuthority(\'USER\') && hasAuthority(\'VALIDATED\')") public Notification createNotification(NotificationInput notificationInput, User user) throws OfficeNotFoundException, InvalidRequestTypeException Creates a notification.- Specified by:
createNotification
in interfaceUserMutationService
- Parameters:
notificationInput
- contains the notification datauser
- contains the user data- Returns:
- the created notification
- Throws:
OfficeNotFoundException
- if the office is not foundInvalidRequestTypeException
- if the request type is not found
-
deleteNotification
@PreAuthorize("hasAuthority(\'USER\') && hasAuthority(\'VALIDATED\')") public void deleteNotification(UUID notificationId) Deletes a notification by id- Specified by:
deleteNotification
in interfaceUserMutationService
- Parameters:
notificationId
- contains the notification id
-
modifyNotification
@PreAuthorize("hasAuthority(\'USER\') && hasAuthority(\'VALIDATED\')") public Notification modifyNotification(NotificationInput notificationInput, UUID notificationId) throws NotificationNotFoundException, OfficeNotFoundException, RequestTypeNotFoundException Modifies a notification by id- Specified by:
modifyNotification
in interfaceUserMutationService
- Parameters:
notificationInput
- contains the notification datanotificationId
- contains the notification id- Returns:
- the modified notification
- Throws:
NotificationNotFoundException
- if the notification is not foundOfficeNotFoundException
- if the office is not foundRequestTypeNotFoundException
- if the request type is not found
-
createReservation
@PreAuthorize("hasAuthority(\'USER\') && hasAuthority(\'VALIDATED\')") public Availability createReservation(UUID availabilityId, User user) throws UserNotFoundException, AvailabilityNotFoundException, InvalidAvailabilityIDException Creates a reservation by id, setting the availability status toStatus.TAKEN
- Specified by:
createReservation
in interfaceUserMutationService
- Parameters:
availabilityId
- contains the availability iduser
- contains the user data- Returns:
- the created reservation
- Throws:
UserNotFoundException
- if the user is not foundAvailabilityNotFoundException
- if the availability is not foundInvalidAvailabilityIDException
- if the availability 'ritiro passaporto' date is not valid, or if the availability is already taken. It must be at least one month after the last rilascio passaporto
-
deleteReservation
@PreAuthorize("hasAuthority(\'USER\') && hasAuthority(\'VALIDATED\')") public void deleteReservation(UUID availabilityId) throws AvailabilityNotFoundException Deletes a reservation by id, setting the availability status toStatus.FREE
and setting the availability user to null- Specified by:
deleteReservation
in interfaceUserMutationService
- Parameters:
availabilityId
- contains the availability id- Throws:
AvailabilityNotFoundException
- if the availability is not found
-
preserveAvailability
@PreAuthorize("hasAuthority(\'USER\') && hasAuthority(\'VALIDATED\')") public void preserveAvailability(UUID availabilityId) throws AvailabilityNotFoundException Preserves the availability by id, setting the availability status toStatus.PENDING
- Specified by:
preserveAvailability
in interfaceUserMutationService
- Parameters:
availabilityId
- contains the availability id- Throws:
AvailabilityNotFoundException
- if the availability is not found
-
restoreAvailability
@Scheduled(cron="0 */20 * * * *") public void restoreAvailability()This method is scheduled to run every 10 minutes. It restores the availability status toStatus.FREE
and sets the availability user to null for all the availabilities with statusStatus.PENDING
-