Class FirebaseOrganizer
java.lang.Object
com.example.iconic_raffleevent.controller.FirebaseOrganizer
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Callback interface for deleting an event.static interface
Callback interface for deleting a facility.static interface
Callback interface for deleting an image.static interface
Callback interface for deleting a QR code.static interface
Callback interface for deleting a user.static interface
Callback interface for checking the existence of a facility.static interface
Callback interface for handling the result of facility creation.static interface
Callback interface for fetching a facility.static interface
Callback interface for handling the result of updating a facility.static interface
Callback interface for fetching events.static interface
Callback interface for fetching multiple facilities.static interface
Callback interface for fetching images.static interface
Callback interface for fetching QR codes.static interface
Callback interface for fetching users.static interface
Callback interface for updating user details. -
Constructor Summary
ConstructorsConstructorDescriptionInitializes the FirebaseFirestore instance for database operations. -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkUserFacility
(String userId, FirebaseOrganizer.FacilityCheckCallback callback) Checks if a user already has a facility.void
createFacility
(Facility facility, FirebaseOrganizer.FacilityCreationCallback callback) Creates a new facility in the Firestore database.void
deleteEvent
(String eventId, FirebaseOrganizer.DeleteEventCallback callback) Deletes an event by its ID from the Firestore database.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.void
deleteImage
(String imageId, FirebaseOrganizer.DeleteImageCallback callback) Deletes an image by its ID from the Firestore database.void
deleteQRCode
(String qrCodeId, FirebaseOrganizer.DeleteQRCodeCallback callback) Deletes a QR code by its ID from the Firestore database.void
deleteUser
(String userId, FirebaseOrganizer.DeleteUserCallback callback) Deletes a user by its ID from the Firestore database.void
Retrieves all events from the Firestore database.void
Retrieves all facilities from the Firestore database.void
Retrieves all images from the Firestore database.void
Retrieves all QR codes from the Firestore database.void
Retrieves all users from the Firestore database.void
getFacilityByUserId
(String userId, FirebaseOrganizer.FacilityFetchCallback callback) Fetches the facility associated with the given user ID.void
updateFacility
(String facilityId, Facility facility, FirebaseOrganizer.FacilityUpdateCallback callback) Updates an existing facility in the Firestore database.void
updateUserFacilityId
(String userId, String facilityId, FirebaseOrganizer.UserUpdateCallback callback) Updates the facility ID linked to a user
-
Constructor Details
-
FirebaseOrganizer
public FirebaseOrganizer()Initializes the FirebaseFirestore instance for database operations.
-
-
Method Details
-
createFacility
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
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
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
Retrieves all users from the Firestore database.- Parameters:
callback
- The callback interface for handling fetched users or errors.
-
getAllQRCodes
Retrieves all QR codes from the Firestore database.- Parameters:
callback
- The callback interface for handling fetched QR codes or errors.
-
getAllFacilities
Retrieves all facilities from the Firestore database.- Parameters:
callback
- The callback interface for handling fetched facilities or errors.
-
deleteFacility
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 userfacilityId
- ID of the related facilitycallback
- The callback interface for handling success or error responses.
-
getAllEvents
Retrieves all events from the Firestore database.- Parameters:
callback
- The callback interface for handling fetched events or errors.
-
deleteUser
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
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
Retrieves all images from the Firestore database.- Parameters:
callback
- The callback interface for handling fetched images or errors.
-
deleteImage
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
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.
-