1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package androidx.work.impl.model 17 18 import androidx.annotation.RestrictTo 19 import androidx.room.Dao 20 import androidx.room.Insert 21 import androidx.room.OnConflictStrategy 22 import androidx.room.Query 23 import androidx.work.Data 24 25 /** A DAO for [WorkProgress]. */ 26 @Dao 27 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) 28 interface WorkProgressDao { 29 /** 30 * Inserts a [WorkProgress] into the database. 31 * 32 * @param progress The [WorkProgress] 33 */ insertnull34 @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(progress: WorkProgress) 35 36 /** 37 * Deletes a [WorkProgress] from the database. 38 * 39 * @param workSpecId The [WorkSpec] id 40 */ 41 @Query("DELETE from WorkProgress where work_spec_id=:workSpecId") fun delete(workSpecId: String) 42 43 /** Removes all [WorkProgress] entries from the [WorkProgress] table. */ 44 @Query("DELETE FROM WorkProgress") fun deleteAll() 45 46 /** 47 * @param workSpecId The [String] workSpec id 48 * @return The progress [Data] associated with the given [String] workSpec id. 49 */ 50 @Query("SELECT progress FROM WorkProgress WHERE work_spec_id=:workSpecId") 51 fun getProgressForWorkSpecId(workSpecId: String): Data? 52 } 53