Class FirebaseAttendee

java.lang.Object
com.example.iconic_raffleevent.controller.FirebaseAttendee

public class FirebaseAttendee extends Object
FirebaseAttendee class interacts with Firebase Firestore and Firebase Storage to manage user profiles, events, and notifications. This class provides methods for managing users, events, event registration, waiting lists, notifications, and event media.
  • Constructor Details

    • FirebaseAttendee

      public FirebaseAttendee()
      Constructs a FirebaseAttendee instance and initializes references to Firebase Firestore and Firebase Storage.
  • Method Details

    • updateUser

      public void updateUser(User user)
      Updates a user's profile in Firebase Firestore.
      Parameters:
      user - The user whose profile is to be updated.
    • getUser

      public void getUser(String userID, UserController.UserFetchCallback callback)
      Retrieves a user from Firebase Firestore.
      Parameters:
      userID - The ID of the user to retrieve.
      callback - The callback to handle the result of the operation.
    • getAllUsers

      public void getAllUsers(UserController.UserListCallback callback)
      Retrieves all users from the Firebase database. This method fetches the list of all users and passes it to the provided callback.
      Parameters:
      callback - The callback to handle the response with the list of users.
    • deleteUser

      public void deleteUser(String userId, FirebaseAttendee.DeleteUserCallback callback)
      Deletes a user profile from Firebase Firestore.
      Parameters:
      userId - The ID of the user to delete.
      callback - Callback to handle the result of the operation.
    • updateWaitingList

      public void updateWaitingList(User user)
      Updates the waiting list for a user in Firebase Firestore.
      Parameters:
      user - The user whose waiting list is to be updated.
    • updateRegisteredEvents

      public void updateRegisteredEvents(User user)
      Updates the registered events for a user in Firebase Firestore.
      Parameters:
      user - The user whose registered events are to be updated.
    • updateGeneralNotificationPreference

      public void updateGeneralNotificationPreference(User user)
      Updates the user's win notification preference in the Firebase database. The preference is stored in the user's document under the field "winNotificationPref".
      Parameters:
      user - The user whose win notification preference needs to be updated.
    • getEventDetails

      public void getEventDetails(String eventId, EventController.EventDetailsCallback callback)
      Retrieves the details of a specific event.
      Parameters:
      eventId - The ID of the event to retrieve.
      callback - The callback to handle the result of the operation.
    • getAllEvents

      public void getAllEvents(EventController.EventListCallback callback)
      Retrieves all events from Firebase Firestore.
      Parameters:
      callback - The callback to handle the result of the operation.
    • addEvent

      public void addEvent(Event event, User user)
      Adds a new event and generates a QR code for the event.
      Parameters:
      event - The event to add.
      user - The user organizing the event.
    • getEventMap

      public void getEventMap(String eventId, EventController.EventMapCallback callback)
      Retrieves the map of entrant locations for a specific event.
      Parameters:
      eventId - The ID of the event.
      callback - The callback to handle the result of the operation.
    • deleteEventWithMedia

      public void deleteEventWithMedia(String eventId, FirebaseAttendee.DeleteEventCallback callback)
      Deletes an event along with its associated media (poster and QR code), and cleans up user references.
      Parameters:
      eventId - The ID of the event to be deleted.
      callback - The callback interface to notify the success or failure of the operation.
    • deleteEvent

      public void deleteEvent(String eventId, FirebaseAttendee.DeleteEventCallback callback)
      Deletes an event with the specified event ID from Firestore.
      Parameters:
      eventId - The ID of the event to delete.
      callback - Callback interface to notify the success or failure of the deletion.
    • updateEventDetails

      public void updateEventDetails(Event event)
      Updates the event details in the Firebase database. This method updates the entire event document with the provided event object.
      Parameters:
      event - The event object containing the updated event details.
    • setWaitingListLimit

      public void setWaitingListLimit(String eventId, int waitingListLimit, EventController.UpdateEventCallback callback)
      Updates the waiting list limit for a specific event. Validates and sets the new limit, ensuring it is not less than the current waiting list size.
      Parameters:
      eventId - The ID of the event.
      waitingListLimit - The new waiting list limit.
      callback - Callback to notify success or failure.
    • joinWaitingListWithLocation

      public void joinWaitingListWithLocation(String eventId, User user, com.google.firebase.firestore.GeoPoint userLocation, EventController.JoinWaitingListCallback callback)
      Adds a user to the event's waiting list with their location. Ensures the waiting list limit has not been reached before adding the user.
      Parameters:
      eventId - The ID of the event.
      user - The user joining the event.
      userLocation - The location of the user.
      callback - The callback to notify success or failure.
    • joinWaitingListWithoutLocation

      public void joinWaitingListWithoutLocation(String eventId, String userId, EventController.JoinWaitingListCallback callback)
      Adds a user to the event's waiting list without including their location. Ensures the waiting list limit has not been reached before adding the user.
      Parameters:
      eventId - The ID of the event to which the user is joining the waiting list.
      userId - The ID of the user joining the waiting list.
      callback - The callback to notify the success or failure of the operation.
    • leaveWaitingList

      public void leaveWaitingList(Event event, User user, EventController.LeaveWaitingListCallback callback)
      Removes a user from the event's waiting list. This method updates the "waitingList" field of the event document by removing the user ID.
      Parameters:
      event - The event we are removing the user from
      user - The user leaving the waiting list.
      callback - The callback to notify the success or failure of the operation.
    • leaveLocationsList

      public void leaveLocationsList(Event event, String userId, EventController.LeaveLocationsListCallback callback)
      Removes a user from the event's locations map. This method updates the "locations" field of the event document by removing the user's location.
      Parameters:
      event - The event we are removing the user from
      userId - The id of the user we are removing from the waiting list.
      callback - The callback to notify the success or failure of the operation.
    • acceptEventInvitation

      public void acceptEventInvitation(String eventId, String userId, EventController.AcceptInvitationCallback callback)
      Accepts an event invitation for a user by adding them to the registered attendees list and removing them from the invited list. Validates the event capacity to ensure the maxAttendees limit is not exceeded.
      Parameters:
      eventId - The ID of the event to which the user is accepting the invitation.
      userId - The ID of the user accepting the invitation.
      callback - The callback to notify the success or failure of the operation.
    • declineEventInvitation

      public void declineEventInvitation(String eventId, String userId, EventController.DeclineInvitationCallback callback)
      Declines an event invitation for a user, removing them from the invited list. This method updates the "invitedList" field of the event document by removing the user ID.
      Parameters:
      eventId - The ID of the event to which the user is declining the invitation.
      userId - The ID of the user declining the invitation.
      callback - The callback to notify the success or failure of the operation.
    • scanQRCode

      public void scanQRCode(String qrCodeData, EventController.ScanQRCodeCallback callback)
      Scans a QR code to find an event and attempts to add the user to the waiting list. This method retrieves the event associated with the QR code and joins the waiting list.
      Parameters:
      qrCodeData - The data encoded in the QR code (event identifier).
      callback - The callback interface to notify the success or failure of the operation.
    • getNotifications

      public void getNotifications(String userId, NotificationController.GetNotificationsCallback callback)
      Retrieves the notifications for a specific user. Queries Firestore for notifications associated with the user.
      Parameters:
      userId - The ID of the user whose notifications are to be retrieved.
      callback - The callback interface to notify the success or failure of the operation.
    • markNotificationAsRead

      public void markNotificationAsRead(String notificationId, NotificationController.MarkNotificationAsReadCallback callback)
      Marks a specific notification as read for a user. Updates the "read" field of the notification document in Firestore.
      Parameters:
      notificationId - The ID of the notification to mark as read.
      callback - The callback interface to notify the success or failure of the operation.
    • getUserWaitingListEvents

      public void getUserWaitingListEvents(String userId, EventController.EventListCallback callback)
      Retrieves the list of events for a user's waiting list. The method queries Firestore for all events where the user is present in the waiting list.
      Parameters:
      userId - The ID of the user whose waiting list events are to be retrieved.
      callback - The callback interface to notify the success or failure of the operation.
    • getAllUserEvents

      public void getAllUserEvents(String userId, EventController.EventListCallback callback)
      Retrieves the list of events a user is in a waiting list for or owns The method queries Firestore for all events where the user is present in the waiting list or owns.
      Parameters:
      userId - The ID of the user whose waiting list events/owned events are to be retrieved.
      callback - The callback interface to notify the success or failure of the operation.
    • updateEventLists

      public void updateEventLists(String eventId, List<String> invitedList, List<String> waitingList, List<String> registeredAttendees, List<String> cancelledList, FirebaseAttendee.UpdateCallback callback)
      Updates the event's invited and declined lists in the Firebase database. This method updates the event document with the provided lists of invited and declined users.
      Parameters:
      eventId - The ID of the event whose lists are being updated.
      invitedList - The list of users invited to the event.
      waitingList - The list of users who have declined the invitation.
      callback - The callback to notify the success or failure of the operation.
    • addEventPoster

      public void addEventPoster(android.net.Uri eventUri, Event eventObj, EventController.UploadEventPosterCallback callback)
      Uploads the event poster to Firebase Storage and retrieves the download URL. The image is uploaded under the "event_posters" directory in Firebase Storage.
      Parameters:
      eventUri - URI of the event poster image.
      eventObj - The event object associated with the poster.
      callback - The callback interface to notify the success or failure of the upload.
    • addEventQRCode

      public void addEventQRCode(Event eventObj, EventController.UploadEventQRCodeCallback callback)
      Adds the QR code for an event to Firebase Storage and retrieves the download URL. The QR code is generated based on the event's `qrCode` field and uploaded as a JPEG image.
      Parameters:
      eventObj - The event object containing the QR code data.
      callback - The callback interface to notify the success or failure of the upload.
    • sendDrawNotification

      public void sendDrawNotification(Notification notification, EventController.SendDrawNotificationCallback callback)
      Uploads a notification to firebase telling the user if they have been drawn
      Parameters:
      notification - Notification to be uploaded
      callback - The callback interface to notify the success or failure of the upload.
    • sendGeneralNotification

      public void sendGeneralNotification(Notification notification, NotificationController.SendNotificationCallback callback)
      Uploads a notification to firebase which is a general notification sent by an organizer
      Parameters:
      notification - Notification to be uploaded
      callback - The callback interface to notify the success or failure of the upload.