1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "reminder_table.h"
17
18 namespace OHOS {
19 namespace Notification {
20 // Reminder Table Basic Columns.
21 const std::string ReminderTable::REMINDER_ID = "reminder_id";
22 const std::string ReminderTable::PKG_NAME = "package_name";
23 const std::string ReminderTable::USER_ID = "user_id";
24 const std::string ReminderTable::UID = "uid";
25 const std::string ReminderTable::SYS_APP = "system_app";
26 const std::string ReminderTable::APP_LABEL = "app_label";
27 const std::string ReminderTable::REMINDER_TYPE = "reminder_type";
28 const std::string ReminderTable::REMINDER_TIME = "reminder_time";
29 const std::string ReminderTable::TRIGGER_TIME = "trigger_time";
30 const std::string ReminderTable::RTC_TRIGGER_TIME = "rtc_trigger_time";
31 const std::string ReminderTable::TIME_INTERVAL = "time_interval";
32 const std::string ReminderTable::SNOOZE_TIMES = "snooze_times";
33 const std::string ReminderTable::DYNAMIC_SNOOZE_TIMES = "dynamic_snooze_times";
34 const std::string ReminderTable::RING_DURATION = "ring_duration";
35 const std::string ReminderTable::IS_EXPIRED = "is_expired";
36 const std::string ReminderTable::IS_ACTIVE = "is_active";
37 const std::string ReminderTable::STATE = "state";
38 const std::string ReminderTable::ZONE_ID = "zone_id";
39 const std::string ReminderTable::HAS_SCHEDULED_TIMEOUT = "has_ScheduledTimeout";
40 const std::string ReminderTable::ACTION_BUTTON_INFO = "button_info";
41 const std::string ReminderTable::CUSTOM_BUTTON_URI = "custom_button_uri";
42 const std::string ReminderTable::SLOT_ID = "slot_id";
43 const std::string ReminderTable::SNOOZE_SLOT_ID = "snooze_slot_id";
44 const std::string ReminderTable::NOTIFICATION_ID = "notification_id";
45 const std::string ReminderTable::TITLE = "title";
46 const std::string ReminderTable::CONTENT = "content";
47 const std::string ReminderTable::SNOOZE_CONTENT = "snooze_content";
48 const std::string ReminderTable::EXPIRED_CONTENT = "expired_content";
49 const std::string ReminderTable::AGENT = "agent";
50 const std::string ReminderTable::MAX_SCREEN_AGENT = "maxScreen_agent";
51 const std::string ReminderTable::TAP_DISMISSED = "tapDismissed";
52 const std::string ReminderTable::AUTO_DELETED_TIME = "autoDeletedTime";
53 const std::string ReminderTable::REPEAT_DAYS_OF_WEEK = "repeat_days_of_week";
54 const std::string ReminderTable::GROUP_ID = "groupId";
55 const std::string ReminderTable::CUSTOM_RING_URI = "custom_ring_uri";
56 const std::string ReminderTable::CREATOR_BUNDLE_NAME = "creator_bundle_name";
57
58 // Reminder Table Calendar Columns.
59 const std::string ReminderTable::REPEAT_DAYS = "repeat_days";
60 const std::string ReminderTable::REPEAT_MONTHS = "repeat_months";
61 const std::string ReminderTable::FIRST_DESIGNATE_YEAR = "first_designate_year";
62 const std::string ReminderTable::FIRST_DESIGNATE_MONTH = "first_designate_month";
63 const std::string ReminderTable::FIRST_DESIGNATE_DAY = "first_designate_day";
64 const std::string ReminderTable::CALENDAR_YEAR = "calendar_year";
65 const std::string ReminderTable::CALENDAR_MONTH = "calendar_month";
66 const std::string ReminderTable::CALENDAR_DAY = "calendar_day";
67 const std::string ReminderTable::CALENDAR_HOUR = "calendar_hour";
68 const std::string ReminderTable::CALENDAR_MINUTE = "calendar_minute";
69
70 // Reminder Table Alarm Columns.
71 const std::string ReminderTable::ALARM_HOUR = "alarm_hour";
72 const std::string ReminderTable::ALARM_MINUTE = "alarm_minute";
73
74 std::string ReminderTable::sqlOfAddColumns = "";
75 std::vector<std::string> ReminderTable::columns;
76
InitDbColumns()77 void ReminderTable::InitDbColumns()
78 {
79 InitBasicColumns();
80 InitCalendarColumns();
81 InitAlarmColumns();
82 }
83
InitBasicColumns()84 void ReminderTable::InitBasicColumns()
85 {
86 AddColumn(REMINDER_ID, "INTEGER PRIMARY KEY");
87 AddColumn(PKG_NAME, "TEXT NOT NULL");
88 AddColumn(USER_ID, "INT NOT NULL");
89 AddColumn(UID, "INT NOT NULL");
90 AddColumn(SYS_APP, "TEXT NOT NULL");
91 AddColumn(APP_LABEL, "TEXT");
92 AddColumn(REMINDER_TYPE, "INT NOT NULL");
93 AddColumn(REMINDER_TIME, "BIGINT NOT NULL");
94 AddColumn(TRIGGER_TIME, "BIGINT NOT NULL");
95 AddColumn(RTC_TRIGGER_TIME, "BIGINT NOT NULL");
96 AddColumn(TIME_INTERVAL, "BIGINT NOT NULL");
97 AddColumn(SNOOZE_TIMES, "INT NOT NULL");
98 AddColumn(DYNAMIC_SNOOZE_TIMES, "INT NOT NULL");
99 AddColumn(RING_DURATION, "BIGINT NOT NULL");
100 AddColumn(IS_EXPIRED, "TEXT NOT NULL");
101 AddColumn(IS_ACTIVE, "TEXT NOT NULL");
102 AddColumn(STATE, "INT NOT NULL");
103 AddColumn(ZONE_ID, "TEXT");
104 AddColumn(HAS_SCHEDULED_TIMEOUT, "TEXT");
105 AddColumn(ACTION_BUTTON_INFO, "TEXT");
106 AddColumn(CUSTOM_BUTTON_URI, "TEXT");
107 AddColumn(SLOT_ID, "INT");
108 AddColumn(SNOOZE_SLOT_ID, "INT");
109 AddColumn(NOTIFICATION_ID, "INT NOT NULL");
110 AddColumn(TITLE, "TEXT");
111 AddColumn(CONTENT, "TEXT");
112 AddColumn(SNOOZE_CONTENT, "TEXT");
113 AddColumn(EXPIRED_CONTENT, "TEXT");
114 AddColumn(AGENT, "TEXT");
115 AddColumn(MAX_SCREEN_AGENT, "TEXT");
116 AddColumn(TAP_DISMISSED, "TEXT");
117 AddColumn(AUTO_DELETED_TIME, "BIGINT");
118 AddColumn(REPEAT_DAYS_OF_WEEK, "INT");
119 AddColumn(GROUP_ID, "TEXT");
120 AddColumn(CUSTOM_RING_URI, "TEXT");
121 AddColumn(CREATOR_BUNDLE_NAME, "TEXT", false);
122 }
123
InitCalendarColumns()124 void ReminderTable::InitCalendarColumns()
125 {
126 AddColumn(REPEAT_DAYS, "INT");
127 AddColumn(REPEAT_MONTHS, "INT");
128 AddColumn(FIRST_DESIGNATE_YEAR, "INT");
129 AddColumn(FIRST_DESIGNATE_MONTH, "INT");
130 AddColumn(FIRST_DESIGNATE_DAY, "INT");
131 AddColumn(CALENDAR_YEAR, "INT");
132 AddColumn(CALENDAR_MONTH, "INT");
133 AddColumn(CALENDAR_DAY, "INT");
134 AddColumn(CALENDAR_HOUR, "INT");
135 AddColumn(CALENDAR_MINUTE, "INT");
136 }
137
InitAlarmColumns()138 void ReminderTable::InitAlarmColumns()
139 {
140 AddColumn(ALARM_HOUR, "INT");
141 AddColumn(ALARM_MINUTE, "INT", true);
142 }
143
AddColumn(const std::string & name,const std::string & type,bool isEnd)144 void ReminderTable ::AddColumn(
145 const std::string& name, const std::string& type, bool isEnd)
146 {
147 columns.push_back(name);
148 if (!isEnd) {
149 sqlOfAddColumns += name + " " + type + ", ";
150 } else {
151 sqlOfAddColumns += name + " " + type;
152 }
153 }
154
155 }
156 }
157