Class ScaleChallengeAttemptRepository
- java.lang.Object
-
- edu.cnm.deepdive.scalescroller.service.ScaleChallengeAttemptRepository
-
public class ScaleChallengeAttemptRepository extends Object
ScaleChallengeAttemptRepository
contains 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 Completable
delete(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.Completable
save(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
Completable
indicating 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
Completable
indicating 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:
LiveData
of aScaleChallengeAttempt
.
-
getAllScaleChallengeAttempts
public LiveData<List<ScaleChallengeAttempt>> getAllScaleChallengeAttempts()
Returns LiveData of all scale-challenge attempts.- Returns:
LiveData
of aList
ofScaleChallengeAttempt
.
-
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:
LiveData
of aList
ofChallengeAttempt
.
-
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:
LiveData
of aList
ofChallengeAttempt
.
-
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:
LiveData
of aList
ofScale
.
-
-