1 /*
2 * Copyright (c) 2024 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_old.h"
17
18 namespace OHOS {
19 namespace Notification {
20 // Reminder Table Basic Columns.
21 const std::string ReminderTable::TABLE_NAME = "reminder";
22 const std::string ReminderTable::REMINDER_ID = "reminder_id";
23 const std::string ReminderTable::PKG_NAME = "package_name";
24 const std::string ReminderTable::USER_ID = "user_id";
25 const std::string ReminderTable::UID = "uid";
26 const std::string ReminderTable::SYS_APP = "system_app";
27 const std::string ReminderTable::APP_LABEL = "app_label";
28 const std::string ReminderTable::REMINDER_TYPE = "reminder_type";
29 const std::string ReminderTable::REMINDER_TIME = "reminder_time";
30 const std::string ReminderTable::TRIGGER_TIME = "trigger_time";
31 const std::string ReminderTable::RTC_TRIGGER_TIME = "rtc_trigger_time";
32 const std::string ReminderTable::TIME_INTERVAL = "time_interval";
33 const std::string ReminderTable::SNOOZE_TIMES = "snooze_times";
34 const std::string ReminderTable::DYNAMIC_SNOOZE_TIMES = "dynamic_snooze_times";
35 const std::string ReminderTable::RING_DURATION = "ring_duration";
36 const std::string ReminderTable::IS_EXPIRED = "is_expired";
37 const std::string ReminderTable::IS_ACTIVE = "is_active";
38 const std::string ReminderTable::STATE = "state";
39 const std::string ReminderTable::ZONE_ID = "zone_id";
40 const std::string ReminderTable::HAS_SCHEDULED_TIMEOUT = "has_ScheduledTimeout";
41 const std::string ReminderTable::ACTION_BUTTON_INFO = "button_info";
42 const std::string ReminderTable::CUSTOM_BUTTON_URI = "custom_button_uri";
43 const std::string ReminderTable::SLOT_ID = "slot_id";
44 const std::string ReminderTable::SNOOZE_SLOT_ID = "snooze_slot_id";
45 const std::string ReminderTable::NOTIFICATION_ID = "notification_id";
46 const std::string ReminderTable::TITLE = "title";
47 const std::string ReminderTable::CONTENT = "content";
48 const std::string ReminderTable::SNOOZE_CONTENT = "snooze_content";
49 const std::string ReminderTable::EXPIRED_CONTENT = "expired_content";
50 const std::string ReminderTable::AGENT = "agent";
51 const std::string ReminderTable::MAX_SCREEN_AGENT = "maxScreen_agent";
52 const std::string ReminderTable::TAP_DISMISSED = "tapDismissed";
53 const std::string ReminderTable::AUTO_DELETED_TIME = "autoDeletedTime";
54 const std::string ReminderTable::REPEAT_DAYS_OF_WEEK = "repeat_days_of_week";
55 const std::string ReminderTable::GROUP_ID = "groupId";
56 const std::string ReminderTable::CUSTOM_RING_URI = "custom_ring_uri";
57 const std::string ReminderTable::CREATOR_BUNDLE_NAME = "creator_bundle_name";
58
59 // Reminder Table Calendar Columns.
60 const std::string ReminderTable::REPEAT_DAYS = "repeat_days";
61 const std::string ReminderTable::REPEAT_MONTHS = "repeat_months";
62 const std::string ReminderTable::FIRST_DESIGNATE_YEAR = "first_designate_year";
63 const std::string ReminderTable::FIRST_DESIGNATE_MONTH = "first_designate_month";
64 const std::string ReminderTable::FIRST_DESIGNATE_DAY = "first_designate_day";
65 const std::string ReminderTable::CALENDAR_YEAR = "calendar_year";
66 const std::string ReminderTable::CALENDAR_MONTH = "calendar_month";
67 const std::string ReminderTable::CALENDAR_DAY = "calendar_day";
68 const std::string ReminderTable::CALENDAR_HOUR = "calendar_hour";
69 const std::string ReminderTable::CALENDAR_MINUTE = "calendar_minute";
70
71 // Reminder Table Alarm Columns.
72 const std::string ReminderTable::ALARM_HOUR = "alarm_hour";
73 const std::string ReminderTable::ALARM_MINUTE = "alarm_minute";
74
75 std::string ReminderTable::ADD_COLUMNS = "";
76 std::string ReminderTable::SELECT_COLUMNS = "";
77
InitDbColumns()78 void ReminderTable::InitDbColumns()
79 {
80 InitBasicColumns();
81 InitCalendarColumns();
82 InitAlarmColumns();
83 }
84
InitBasicColumns()85 void ReminderTable::InitBasicColumns()
86 {
87 AddColumn(REMINDER_ID, "INTEGER PRIMARY KEY");
88 AddColumn(PKG_NAME, "TEXT NOT NULL");
89 AddColumn(USER_ID, "INT NOT NULL");
90 AddColumn(UID, "INT NOT NULL");
91 AddColumn(SYS_APP, "TEXT NOT NULL");
92 AddColumn(APP_LABEL, "TEXT");
93 AddColumn(REMINDER_TYPE, "INT NOT NULL");
94 AddColumn(REMINDER_TIME, "BIGINT NOT NULL");
95 AddColumn(TRIGGER_TIME, "BIGINT NOT NULL");
96 AddColumn(RTC_TRIGGER_TIME, "BIGINT NOT NULL");
97 AddColumn(TIME_INTERVAL, "BIGINT NOT NULL");
98 AddColumn(SNOOZE_TIMES, "INT NOT NULL");
99 AddColumn(DYNAMIC_SNOOZE_TIMES, "INT NOT NULL");
100 AddColumn(RING_DURATION, "BIGINT NOT NULL");
101 AddColumn(IS_EXPIRED, "TEXT NOT NULL");
102 AddColumn(IS_ACTIVE, "TEXT NOT NULL");
103 AddColumn(STATE, "INT NOT NULL");
104 AddColumn(ZONE_ID, "TEXT");
105 AddColumn(HAS_SCHEDULED_TIMEOUT, "TEXT");
106 AddColumn(ACTION_BUTTON_INFO, "TEXT");
107 AddColumn(CUSTOM_BUTTON_URI, "TEXT");
108 AddColumn(SLOT_ID, "INT");
109 AddColumn(SNOOZE_SLOT_ID, "INT");
110 AddColumn(NOTIFICATION_ID, "INT NOT NULL");
111 AddColumn(TITLE, "TEXT");
112 AddColumn(CONTENT, "TEXT");
113 AddColumn(SNOOZE_CONTENT, "TEXT");
114 AddColumn(EXPIRED_CONTENT, "TEXT");
115 AddColumn(AGENT, "TEXT");
116 AddColumn(MAX_SCREEN_AGENT, "TEXT");
117 AddColumn(TAP_DISMISSED, "TEXT");
118 AddColumn(AUTO_DELETED_TIME, "BIGINT");
119 AddColumn(REPEAT_DAYS_OF_WEEK, "INT");
120 AddColumn(GROUP_ID, "TEXT");
121 AddColumn(CUSTOM_RING_URI, "TEXT");
122 AddColumn(CREATOR_BUNDLE_NAME, "TEXT", false);
123 }
124
InitCalendarColumns()125 void ReminderTable::InitCalendarColumns()
126 {
127 AddColumn(REPEAT_DAYS, "INT");
128 AddColumn(REPEAT_MONTHS, "INT");
129 AddColumn(FIRST_DESIGNATE_YEAR, "INT");
130 AddColumn(FIRST_DESIGNATE_MONTH, "INT");
131 AddColumn(FIRST_DESIGNATE_DAY, "INT");
132 AddColumn(CALENDAR_YEAR, "INT");
133 AddColumn(CALENDAR_MONTH, "INT");
134 AddColumn(CALENDAR_DAY, "INT");
135 AddColumn(CALENDAR_HOUR, "INT");
136 AddColumn(CALENDAR_MINUTE, "INT");
137 }
138
InitAlarmColumns()139 void ReminderTable::InitAlarmColumns()
140 {
141 AddColumn(ALARM_HOUR, "INT");
142 AddColumn(ALARM_MINUTE, "INT", true);
143 }
144
AddColumn(const std::string & name,const std::string & type,bool isEnd)145 void ReminderTable ::AddColumn(
146 const std::string& name, const std::string& type, bool isEnd)
147 {
148 if (!isEnd) {
149 SELECT_COLUMNS.append(name).append(",");
150 ADD_COLUMNS += name + " " + type + ", ";
151 } else {
152 SELECT_COLUMNS.append(name);
153 ADD_COLUMNS += name + " " + type;
154 }
155 }
156 }
157 }
158