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 interfaceCallback interface for deleting an event.static interfaceCallback interface for deleting a facility.static interfaceCallback interface for deleting an image.static interfaceCallback interface for deleting a QR code.static interfaceCallback interface for deleting a user.static interfaceCallback interface for checking the existence of a facility.static interfaceCallback interface for handling the result of facility creation.static interfaceCallback interface for fetching a facility.static interfaceCallback interface for handling the result of updating a facility.static interfaceCallback interface for fetching events.static interfaceCallback interface for fetching multiple facilities.static interfaceCallback interface for fetching images.static interfaceCallback interface for fetching QR codes.static interfaceCallback interface for fetching users.static interfaceCallback interface for updating user details. -
Constructor Summary
ConstructorsConstructorDescriptionInitializes the FirebaseFirestore instance for database operations. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckUserFacility(String userId, FirebaseOrganizer.FacilityCheckCallback callback) Checks if a user already has a facility.voidcreateFacility(Facility facility, FirebaseOrganizer.FacilityCreationCallback callback) Creates a new facility in the Firestore database.voiddeleteEvent(String eventId, FirebaseOrganizer.DeleteEventCallback callback) Deletes an event by its ID from the Firestore database.voiddeleteFacility(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.voiddeleteImage(String imageId, FirebaseOrganizer.DeleteImageCallback callback) Deletes an image by its ID from the Firestore database.voiddeleteQRCode(String qrCodeId, FirebaseOrganizer.DeleteQRCodeCallback callback) Deletes a QR code by its ID from the Firestore database.voiddeleteUser(String userId, FirebaseOrganizer.DeleteUserCallback callback) Deletes a user by its ID from the Firestore database.voidRetrieves all events from the Firestore database.voidRetrieves all facilities from the Firestore database.voidRetrieves all images from the Firestore database.voidRetrieves all QR codes from the Firestore database.voidRetrieves all users from the Firestore database.voidgetFacilityByUserId(String userId, FirebaseOrganizer.FacilityFetchCallback callback) Fetches the facility associated with the given user ID.voidupdateFacility(String facilityId, Facility facility, FirebaseOrganizer.FacilityUpdateCallback callback) Updates an existing facility in the Firestore database.voidupdateUserFacilityId(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.
-