Class ScaleChallengeAttemptRepository
- java.lang.Object
-
- edu.cnm.deepdive.scalescroller.service.ScaleChallengeAttemptRepository
-
public class ScaleChallengeAttemptRepository extends Object
ScaleChallengeAttemptRepositorycontains methods that provide a layer of abstraction above theScaleChallengeAttemptDao, and allows for creation, reading, updating, and deleting of attempts.
-
-
Constructor Summary
Constructors Constructor Description ScaleChallengeAttemptRepository(Context context)The constructor initializes the context, the database, and the dao.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Completabledelete(ScaleChallengeAttempt attempt)Deletes a attempt record in the database.LiveData<List<ScaleChallengeAttempt>>getAllScaleChallengeAttempts()Returns LiveData of all scale-challenge attempts.LiveData<List<ChallengeAttempt>>getChallengeAttemptsForScaleOrderByDate(long scaleId)Returns LiveData of all challenge attempts that use a particular scale, ordered by date.LiveData<List<ChallengeAttempt>>getChallengeAttemptsForScaleOrderByScore(long scaleId)Returns LiveData of all challenge attempts that use a particular scale, ordered by score.LiveData<ScaleChallengeAttempt>getScaleChallengeAttempt(long id)Returns LiveData of a scale-challenge attempt, given its id.LiveData<List<Scale>>getScalesForChallengeAttemptOrderByDate(long attemptId)Returns LiveData of all scales used in a particular attempt, ordered by date.LiveData<List<Scale>>getScalesForChallengeAttemptOrderByName(long attemptId)Returns LiveData of all scales used in a particular attempt, ordered by scale name.Completablesave(ScaleChallengeAttempt attempt)Creates or updates a attempt record in the database.
-
-
-
Constructor Detail
-
ScaleChallengeAttemptRepository
public ScaleChallengeAttemptRepository(Context context)
The constructor initializes the context, the database, and the dao.- Parameters:
context- The application context.
-
-
Method Detail
-
save
public Completable save(ScaleChallengeAttempt attempt)
Creates or updates a attempt record in the database.- Parameters:
attempt- TheScaleChallengeAttempt.- Returns:
- A
Completableindicating the success or failure of the creation/update.
-
delete
public Completable delete(ScaleChallengeAttempt attempt)
Deletes a attempt record in the database.- Parameters:
attempt- TheScaleChallengeAttempt.- Returns:
- A
Completableindicating the success or failure of the deletion.
-
getScaleChallengeAttempt
public LiveData<ScaleChallengeAttempt> getScaleChallengeAttempt(long id)
Returns LiveData of a scale-challenge attempt, given its id.- Parameters:
id- The id of the attempt.- Returns:
LiveDataof aScaleChallengeAttempt.
-
getAllScaleChallengeAttempts
public LiveData<List<ScaleChallengeAttempt>> getAllScaleChallengeAttempts()
Returns LiveData of all scale-challenge attempts.- Returns:
LiveDataof aListofScaleChallengeAttempt.
-
getChallengeAttemptsForScaleOrderByScore
public LiveData<List<ChallengeAttempt>> getChallengeAttemptsForScaleOrderByScore(long scaleId)
Returns LiveData of all challenge attempts that use a particular scale, ordered by score.- Parameters:
scaleId- The scale's id.- Returns:
LiveDataof aListofChallengeAttempt.
-
getChallengeAttemptsForScaleOrderByDate
public LiveData<List<ChallengeAttempt>> getChallengeAttemptsForScaleOrderByDate(long scaleId)
Returns LiveData of all challenge attempts that use a particular scale, ordered by date.- Parameters:
scaleId- The scale's id.- Returns:
LiveDataof aListofChallengeAttempt.
-
getScalesForChallengeAttemptOrderByName
public LiveData<List<Scale>> getScalesForChallengeAttemptOrderByName(long attemptId)
Returns LiveData of all scales used in a particular attempt, ordered by scale name.- Parameters:
attemptId- The attempt's id.- Returns:
LiveDataof aListofScale.
-
-