Package com.example.oblong
Class Database
java.lang.Object
com.example.oblong.Database
Database This class handles sending and fetching data from the Firebase-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCalled when data is successfully received. -
Constructor Summary
ConstructorsConstructorDescriptionDatabase()TheDatabasemethod assigns the variables to the Firebase collections -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntrant(String id, boolean locationEnabled, boolean notificationsEnabled, String user) TheaddEntrantmethod adds an entrant to FirebasevoidaddEvent(String id, String capacity, String dateAndTime, String description, com.google.firebase.firestore.GeoPoint location, String poster, String qrID) TheaddEventmethod adds an event to FirebasevoidTheaddFacilitymethod adds a facility to FirebasevoidaddNotification(String id, String event, String text, String title, String target, String[] targetList) TheaddNotificationmethod adds a notification to FirebasevoidaddOrganizer(String id, String facility, String user) TheaddOrganizermethod adds an organizer to FirebasevoidaddParticipant(String id, String entrant, String event, com.google.firebase.firestore.GeoPoint location, String status) TheaddParticipantmethod adds a participant to FirebasevoidTheaddUsermethod adds a user to FirebasevoiddeleteEvent(android.content.Context context, Event event) Completely removes an event and its associated data from the database.voidUpdates the QR code of an event by generating a new UUID.voiddeleteUser(android.content.Context context, User viewed_user) Deletes a user from the database along with associated data.static voidgetCurrentUser(Database.OnDataReceivedListener<String> listener) ThegetCurrentUsermethod retrieves the user ID from FirebasevoidgetEntrant(String id, Database.OnDataReceivedListener<HashMap<String, Object>> listener) ThegetEntrantmethod retrieves an entrant data from FirebasevoidThegetEventmethod retrieves an event data from FirebasevoidgetFacility(String id, Database.OnDataReceivedListener<HashMap<String, Object>> listener) ThegetFacilitymethod retrieves a facility data from FirebasevoidgetNotification(String id, Database.OnDataReceivedListener<HashMap<String, Object>> listener) getNotificationmethod retrieves a notification data from Firebase}voidgetOrganizer(String id, Database.OnDataReceivedListener<HashMap<String, Object>> listener) ThegetOrganizermethod retrieves an organizer data from FirebasevoidgetParticipants(String id, Database.OnDataReceivedListener<HashMap<String, Object>> listener) ThegetParticipantmethod retrieves a participant data from FirebasevoidThegetUsermethod retrieves user data from Firebasevoidquery(String collectionName, HashMap<String, Object> conditions, Database.OnDataReceivedListener<List<HashMap<String, Object>>> listener) Thequerymethod queries a collection in FirebasevoidupdateDocument(String collection, String document_id, HashMap<String, Object> updates, Database.OnDataReceivedListener<Boolean> listener) TheupdateDocumentmethod updates a document in Firebase
-
Constructor Details
-
Database
public Database()TheDatabasemethod assigns the variables to the Firebase collections
-
-
Method Details
-
getCurrentUser
ThegetCurrentUsermethod retrieves the user ID from Firebase- Parameters:
listener-
-
updateDocument
public void updateDocument(String collection, String document_id, HashMap<String, Object> updates, Database.OnDataReceivedListener<Boolean> listener) TheupdateDocumentmethod updates a document in Firebase- Parameters:
collection-document_id-updates-listener-
-
getParticipants
public void getParticipants(String id, Database.OnDataReceivedListener<HashMap<String, Object>> listener) ThegetParticipantmethod retrieves a participant data from Firebase- Parameters:
id-listener-
-
getOrganizer
public void getOrganizer(String id, Database.OnDataReceivedListener<HashMap<String, Object>> listener) ThegetOrganizermethod retrieves an organizer data from Firebase- Parameters:
id-listener-
-
getNotification
public void getNotification(String id, Database.OnDataReceivedListener<HashMap<String, Object>> listener) getNotificationmethod retrieves a notification data from Firebase}- Parameters:
id-listener-
-
getFacility
public void getFacility(String id, Database.OnDataReceivedListener<HashMap<String, Object>> listener) ThegetFacilitymethod retrieves a facility data from Firebase- Parameters:
id-listener-
-
getEntrant
ThegetEntrantmethod retrieves an entrant data from Firebase- Parameters:
id-listener-
-
getEvent
ThegetEventmethod retrieves an event data from Firebase- Parameters:
id-listener-
-
getUser
ThegetUsermethod retrieves user data from Firebase- Parameters:
id-listener-
-
query
public void query(String collectionName, HashMap<String, Object> conditions, Database.OnDataReceivedListener<List<HashMap<String, Object>>> listener) Thequerymethod queries a collection in Firebase- Parameters:
collectionName-conditions-listener-
-
addParticipant
public void addParticipant(String id, String entrant, String event, com.google.firebase.firestore.GeoPoint location, String status) TheaddParticipantmethod adds a participant to Firebase- Parameters:
id-entrant-event-location-status-
-
addOrganizer
TheaddOrganizermethod adds an organizer to Firebase- Parameters:
id-facility-user-
-
addNotification
public void addNotification(String id, String event, String text, String title, String target, String[] targetList) TheaddNotificationmethod adds a notification to Firebase- Parameters:
id-event-text-title-target-targetList-
-
addFacility
TheaddFacilitymethod adds a facility to Firebase- Parameters:
id-email-name-phone-photo-
-
addEntrant
public void addEntrant(String id, boolean locationEnabled, boolean notificationsEnabled, String user) TheaddEntrantmethod adds an entrant to Firebase- Parameters:
id-locationEnabled-notificationsEnabled-user-
-
addUser
public void addUser(String id, String name, String email, String type, String phone, String profilePhoto) TheaddUsermethod adds a user to Firebase- Parameters:
id-name-email-type-phone-profilePhoto-
-
addEvent
public void addEvent(String id, String capacity, String dateAndTime, String description, com.google.firebase.firestore.GeoPoint location, String poster, String qrID) TheaddEventmethod adds an event to Firebase- Parameters:
id-capacity-dateAndTime-description-location-poster-qrID-
-
deleteUser
Deletes a user from the database along with associated data.- Parameters:
context- The context from which this method is called.viewed_user- TheUserobject representing the user to delete.
-
deleteEvent
Completely removes an event and its associated data from the database.- Parameters:
context- The context from which this method is called.event- TheEventobject representing the event to delete.
-
deleteQR
Updates the QR code of an event by generating a new UUID.- Parameters:
context- The context from which this method is called.event- TheEventobject representing the event to update.
-