Class FirebaseOrganizer

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

public class FirebaseOrganizer extends Object
FirebaseOrganizer is a controller class responsible for handling operations related to the firebase database, such as creating, deleting, and fetching data related to users, facilities, events, images, and QR codes.
  • Constructor Details

    • FirebaseOrganizer

      public FirebaseOrganizer()
      Initializes the FirebaseFirestore instance for database operations.
  • Method Details

    • createFacility

      public void createFacility(Facility facility, FirebaseOrganizer.FacilityCreationCallback callback)
      Creates a new facility in the Firestore database.
      Parameters:
      facility - The Facility object containing the details of the facility to be created.
      callback - The callback interface for handling success or error responses.
    • updateFacility

      public void updateFacility(String facilityId, Facility facility, FirebaseOrganizer.FacilityUpdateCallback callback)
      Updates an existing facility in the Firestore database.
      Parameters:
      facilityId - The ID of the facility to update.
      facility - The Facility object containing the updated details.
      callback - The callback interface for handling success or error responses.
    • getFacilityByUserId

      public void getFacilityByUserId(String userId, FirebaseOrganizer.FacilityFetchCallback callback)
      Fetches the facility associated with the given user ID.
      Parameters:
      userId - The ID of the user whose facility is to be fetched.
      callback - The callback to handle the fetched facility or errors.
    • checkUserFacility

      public void checkUserFacility(String userId, FirebaseOrganizer.FacilityCheckCallback callback)
      Checks if a user already has a facility.
      Parameters:
      userId - The user ID to be checked.
      callback - The callback interface for handling success or error responses.
    • getAllUsers

      public void getAllUsers(FirebaseOrganizer.GetUsersCallback callback)
      Retrieves all users from the Firestore database.
      Parameters:
      callback - The callback interface for handling fetched users or errors.
    • getAllQRCodes

      public void getAllQRCodes(FirebaseOrganizer.GetQRCodesCallback callback)
      Retrieves all QR codes from the Firestore database.
      Parameters:
      callback - The callback interface for handling fetched QR codes or errors.
    • getAllFacilities

      public void getAllFacilities(FirebaseOrganizer.GetFacilitiesCallback callback)
      Retrieves all facilities from the Firestore database.
      Parameters:
      callback - The callback interface for handling fetched facilities or errors.
    • deleteFacility

      public void deleteFacility(String facilityId, FirebaseOrganizer.DeleteFacilityCallback callback)
      Deletes a facility from Firestore along with all associated events, their media (posters and QR codes) stored in Firebase Storage, and removes references from user documents. Updates the creator's facilityId in the User collection.
      Parameters:
      facilityId - The ID of the facility to be deleted.
      callback - The callback interface for handling success or error responses.
    • updateUserFacilityId

      public void updateUserFacilityId(String userId, String facilityId, FirebaseOrganizer.UserUpdateCallback callback)
      Updates the facility ID linked to a user
      Parameters:
      userId - ID of the related user
      facilityId - ID of the related facility
      callback - The callback interface for handling success or error responses.
    • getAllEvents

      public void getAllEvents(FirebaseOrganizer.GetEventsCallback callback)
      Retrieves all events from the Firestore database.
      Parameters:
      callback - The callback interface for handling fetched events or errors.
    • deleteUser

      public void deleteUser(String userId, FirebaseOrganizer.DeleteUserCallback callback)
      Deletes a user by its ID from the Firestore database.
      Parameters:
      userId - The ID of the user to be deleted.
      callback - The callback interface for handling success or error responses.
    • deleteEvent

      public void deleteEvent(String eventId, FirebaseOrganizer.DeleteEventCallback callback)
      Deletes an event by its ID from the Firestore database.
      Parameters:
      eventId - The ID of the event to be deleted.
      callback - The callback interface for handling success or error responses.
    • getAllImages

      public void getAllImages(FirebaseOrganizer.GetImagesCallback callback)
      Retrieves all images from the Firestore database.
      Parameters:
      callback - The callback interface for handling fetched images or errors.
    • deleteImage

      public void deleteImage(String imageId, FirebaseOrganizer.DeleteImageCallback callback)
      Deletes an image by its ID from the Firestore database.
      Parameters:
      imageId - The ID of the image to be deleted.
      callback - The callback interface for handling success or error responses.
    • deleteQRCode

      public void deleteQRCode(String qrCodeId, FirebaseOrganizer.DeleteQRCodeCallback callback)
      Deletes a QR code by its ID from the Firestore database.
      Parameters:
      qrCodeId - The ID of the QR code to be deleted.
      callback - The callback interface for handling success or error responses.