1 /*
2  * Copyright (C) 2023 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 
17 package com.android.adservices.data.adselection;
18 
19 import android.database.sqlite.SQLiteConstraintException;
20 
21 import androidx.room.Dao;
22 import androidx.room.Insert;
23 import androidx.room.Query;
24 import androidx.room.Update;
25 
26 /** DAO to manage access to entities in Auction Server Ad Selection Table */
27 @Dao
28 public abstract class AuctionServerAdSelectionDao {
29     /**
30      * Inserts the given {@link DBAuctionServerAdSelection} in table.
31      *
32      * @throws SQLiteConstraintException if the ad selection id already exists
33      */
34     @Insert
insertAuctionServerAdSelection( DBAuctionServerAdSelection serverAdSelection)35     public abstract void insertAuctionServerAdSelection(
36             DBAuctionServerAdSelection serverAdSelection);
37 
38     /**
39      * Updates the given {@link DBAuctionServerAdSelection} in table.
40      *
41      * @return number of rows updated
42      */
43     @Update
updateAuctionServerAdSelection( DBAuctionServerAdSelection serverAdSelection)44     public abstract int updateAuctionServerAdSelection(
45             DBAuctionServerAdSelection serverAdSelection);
46 
47     /** Returns the {@link DBAuctionServerAdSelection} of given ad selection id if it exists. */
48     @Query("SELECT * FROM auction_server_ad_selection WHERE ad_selection_id = :adSelectionId")
getAuctionServerAdSelection(long adSelectionId)49     public abstract DBAuctionServerAdSelection getAuctionServerAdSelection(long adSelectionId);
50 
51     /** Delets the {@link DBAuctionServerAdSelection} of the givein ad selection id */
52     @Query("DELETE FROM auction_server_ad_selection WHERE ad_selection_id = :adSelectionId")
removeAdSelectionById(long adSelectionId)53     public abstract void removeAdSelectionById(long adSelectionId);
54 }
55