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
FieldsModifier and TypeFieldDescriptionprivate final AvailabilityRepositoryThe repository forAvailabilityentity.private final MapNotificationThe service that maps theNotificationInputDBDTO to theNotificationentity.private final NotificationRepositoryThe repository forNotificationentity.private final OfficeRepositoryThe repository forOfficeentity.private final RequestTypeRepositoryThe repository forRequestTypeentity.private final UserRepositoryThe repository forUserentity. -
Constructor Summary
Constructors -
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.TAKENvoiddeleteNotification(UUID notificationId) Deletes a notification by idvoiddeleteReservation(UUID availabilityId) Deletes a reservation by id, setting the availability status toStatus.FREEand setting the availability user to nullmodifyNotification(NotificationInput notificationInput, UUID notificationId) Modifies a notification by idvoidpreserveAvailability(UUID availabilityId) Preserves the availability by id, setting the availability status toStatus.PENDINGvoidThis method is scheduled to run every 10 minutes.
-
Field Details
-
notificationRepository
The repository forNotificationentity. -
officeRepository
The repository forOfficeentity. -
requestTypeRepository
The repository forRequestTypeentity. -
availabilityRepository
The repository forAvailabilityentity. -
userRepository
The repository forUserentity. -
mapNotification
The service that maps theNotificationInputDBDTO to theNotificationentity.
-
-
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:
createNotificationin 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:
deleteNotificationin 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:
modifyNotificationin 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:
createReservationin 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.FREEand setting the availability user to null- Specified by:
deleteReservationin 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:
preserveAvailabilityin 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.FREEand sets the availability user to null for all the availabilities with statusStatus.PENDING
-