Package com.xffffff.wellfed.storage
Class StorageIngredientDB
- java.lang.Object
-
- com.xffffff.wellfed.storage.StorageIngredientDB
-
public class StorageIngredientDB extends java.lang.ObjectThe StorageIngredientDB class is a database for the storage ingredients.
-
-
Constructor Summary
Constructors Constructor Description StorageIngredientDB(DBConnection connection)Creates a reference to the Firebase DB.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddStorageIngredient(StorageIngredient storageIngredient, OnCompleteListener<StorageIngredient> listener)Adds an ingredient in storage to the Firebase DB.voiddeleteStorageIngredient(StorageIngredient storageIngredient, OnCompleteListener<StorageIngredient> listener)Removes an ingredient from storage, but keeps the Ingredient referencevoidgetAllStorageIngredients(OnCompleteListener<java.util.ArrayList<StorageIngredient>> listener)getAllStorageIngredients returns all StorageIngredients in FireStorecom.google.firebase.firestore.QuerygetSearchQuery(java.lang.String field)getSearchedQuery returns a query for StorageIngredients in FireStorecom.google.firebase.firestore.QuerygetSortedQuery(java.lang.String field)Gets a sorted query for StorageIngredients in FireStorevoidgetStorageIngredient(com.google.firebase.firestore.DocumentSnapshot snapshot, OnCompleteListener<StorageIngredient> listener)Gets an ingredient from the Firebase DBvoidgetStorageIngredient(java.lang.String id, OnCompleteListener<StorageIngredient> listener)Gets an ingredient from the Firebase DBvoidupdateStorageIngredient(StorageIngredient storageIngredient, OnCompleteListener<StorageIngredient> listener)Updates a stored ingredient in the Firebase DB.voidupdateStorageIngredient(StorageIngredient storageIngredient, StorageIngredient oldStorageIngredient, Ingredient ingredient, OnCompleteListener<StorageIngredient> listener)Updates a stored ingredient in the Firebase DB.
-
-
-
Constructor Detail
-
StorageIngredientDB
public StorageIngredientDB(DBConnection connection)
Creates a reference to the Firebase DB.- Parameters:
connection- the DBConnection object
-
-
Method Detail
-
addStorageIngredient
public void addStorageIngredient(@NonNull StorageIngredient storageIngredient, OnCompleteListener<StorageIngredient> listener)Adds an ingredient in storage to the Firebase DB.- Parameters:
storageIngredient- the ingredient to be addedlistener- the listener to be called when the operation is complete
-
updateStorageIngredient
public void updateStorageIngredient(StorageIngredient storageIngredient, OnCompleteListener<StorageIngredient> listener)
Updates a stored ingredient in the Firebase DB.- Parameters:
storageIngredient- the Ingredient containing the updated fieldslistener- the listener to handle the result
-
updateStorageIngredient
public void updateStorageIngredient(StorageIngredient storageIngredient, StorageIngredient oldStorageIngredient, Ingredient ingredient, OnCompleteListener<StorageIngredient> listener)
Updates a stored ingredient in the Firebase DB.- Parameters:
storageIngredient- the Ingredient containing the updated fieldsoldStorageIngredient- the old ingredientingredient- the ingredient to be addedlistener- the listener to handle the result
-
deleteStorageIngredient
public void deleteStorageIngredient(StorageIngredient storageIngredient, OnCompleteListener<StorageIngredient> listener)
Removes an ingredient from storage, but keeps the Ingredient reference- Parameters:
storageIngredient- the storageIngredient to removelistener- the listener to handle the result
-
getStorageIngredient
public void getStorageIngredient(java.lang.String id, OnCompleteListener<StorageIngredient> listener)Gets an ingredient from the Firebase DB- Parameters:
id- the ID of the ingredient to get a StorageIngredient with a null description. when the onComplete listener is interruptedlistener- the listener to handle the result
-
getStorageIngredient
public void getStorageIngredient(com.google.firebase.firestore.DocumentSnapshot snapshot, OnCompleteListener<StorageIngredient> listener)Gets an ingredient from the Firebase DB- Parameters:
snapshot- the snapshot of the StorageIngredient to getlistener- the listener to call when the ingredient is found
-
getSortedQuery
public com.google.firebase.firestore.Query getSortedQuery(java.lang.String field)
Gets a sorted query for StorageIngredients in FireStore- Parameters:
field- the field to sort by- Returns:
- the query
-
getSearchQuery
public com.google.firebase.firestore.Query getSearchQuery(java.lang.String field)
getSearchedQuery returns a query for StorageIngredients in FireStore- Parameters:
field- the field to search by- Returns:
- the query
-
getAllStorageIngredients
public void getAllStorageIngredients(OnCompleteListener<java.util.ArrayList<StorageIngredient>> listener)
getAllStorageIngredients returns all StorageIngredients in FireStore- Parameters:
listener- the listener to handle the result
-
-