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.net.Uri;
20 
21 import androidx.annotation.NonNull;
22 import androidx.room.ColumnInfo;
23 import androidx.room.Entity;
24 import androidx.room.Index;
25 import androidx.room.TypeConverters;
26 
27 import com.android.adservices.data.common.FledgeRoomConverters;
28 
29 import com.google.auto.value.AutoValue;
30 import com.google.auto.value.AutoValue.CopyAnnotations;
31 
32 import java.util.Objects;
33 
34 /**
35  * Table to look up reporting URIs.
36  *
37  * @deprecated Columns moved to DBAuctionServerAdSelection table
38  */
39 @Deprecated(since = "Columns moved to DBAuctionServerAdSelection table")
40 @AutoValue
41 @CopyAnnotations
42 @Entity(
43         tableName = "reporting_uris",
44         indices = {@Index(value = {"ad_selection_id"})},
45         primaryKeys = {"ad_selection_id"})
46 @TypeConverters({FledgeRoomConverters.class})
47 public abstract class DBReportingUris {
48     /** The id associated with this auction. */
49     @AutoValue.CopyAnnotations
50     @ColumnInfo(name = "ad_selection_id")
getAdSelectionId()51     public abstract long getAdSelectionId();
52 
53     /** The reporting uri associated with seller. */
54     @AutoValue.CopyAnnotations
55     @NonNull
56     @ColumnInfo(name = "seller_reporting_uri")
getSellerReportingUri()57     public abstract Uri getSellerReportingUri();
58 
59     /** The reporting uri associated with auction winner/buyer. */
60     @AutoValue.CopyAnnotations
61     @NonNull
62     @ColumnInfo(name = "buyer_reporting_uri")
getBuyerReportingUri()63     public abstract Uri getBuyerReportingUri();
64 
65     /** Returns an AutoValue builder for a {@link DBReportingUris} entity. */
66     @NonNull
builder()67     public static DBReportingUris.Builder builder() {
68         return new AutoValue_DBReportingUris.Builder();
69     }
70 
71     /**
72      * Creates a {@link DBReportingUris} object using the builder.
73      *
74      * <p>Required for Room SQLite integration.
75      */
76     @NonNull
create( long adSelectionId, @NonNull Uri sellerReportingUri, @NonNull Uri buyerReportingUri)77     public static DBReportingUris create(
78             long adSelectionId, @NonNull Uri sellerReportingUri, @NonNull Uri buyerReportingUri) {
79         Objects.requireNonNull(sellerReportingUri);
80         Objects.requireNonNull(buyerReportingUri);
81 
82         return builder()
83                 .setAdSelectionId(adSelectionId)
84                 .setSellerReportingUri(sellerReportingUri)
85                 .setBuyerReportingUri(buyerReportingUri)
86                 .build();
87     }
88 
89     /** Builder class for a {@link DBReportingUris}. */
90     @AutoValue.Builder
91     public abstract static class Builder {
92         /** Sets ad selection id. */
setAdSelectionId(long adSelectionId)93         public abstract DBReportingUris.Builder setAdSelectionId(long adSelectionId);
94 
95         /** Sets seller reporting uri. */
setSellerReportingUri( @onNull Uri sellerReportingUri)96         public abstract DBReportingUris.Builder setSellerReportingUri(
97                 @NonNull Uri sellerReportingUri);
98 
99         /** Sets buyer reporting uri. */
setBuyerReportingUri( @onNull Uri buyerReportingUri)100         public abstract DBReportingUris.Builder setBuyerReportingUri(
101                 @NonNull Uri buyerReportingUri);
102 
103         /** Builds the {@link DBReportingUris}. */
build()104         public abstract DBReportingUris build();
105     }
106 }
107