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 base table
21 const std::string ReminderBaseTable::TABLE_NAME = "reminder_base";
22 const std::string ReminderBaseTable::REMINDER_ID = "reminder_id";
23 const std::string ReminderBaseTable::PACKAGE_NAME = "package_name";
24 const std::string ReminderBaseTable::USER_ID = "user_id";
25 const std::string ReminderBaseTable::UID = "uid";
26 const std::string ReminderBaseTable::SYSTEM_APP = "system_app";
27 const std::string ReminderBaseTable::REMINDER_TYPE = "reminder_type";
28 const std::string ReminderBaseTable::REMINDER_TIME = "reminder_time";
29 const std::string ReminderBaseTable::TRIGGER_TIME = "trigger_time";
30 const std::string ReminderBaseTable::TIME_INTERVAL = "time_interval";
31 const std::string ReminderBaseTable::SNOOZE_TIMES = "snooze_times";
32 const std::string ReminderBaseTable::DYNAMIC_SNOOZE_TIMES = "dynamic_snooze_times";
33 const std::string ReminderBaseTable::RING_DURATION = "ring_duration";
34 const std::string ReminderBaseTable::IS_EXPIRED = "is_expired";
35 const std::string ReminderBaseTable::STATE = "state";
36 const std::string ReminderBaseTable::ACTION_BUTTON_INFO = "button_info";
37 const std::string ReminderBaseTable::CUSTOM_BUTTON_URI = "custom_button_uri";
38 const std::string ReminderBaseTable::SLOT_ID = "slot_id";
39 const std::string ReminderBaseTable::SNOOZE_SLOT_ID = "snooze_slot_id";
40 const std::string ReminderBaseTable::NOTIFICATION_ID = "notification_id";
41 const std::string ReminderBaseTable::TITLE = "title";
42 const std::string ReminderBaseTable::TITLE_RESOURCE_ID = "title_resource_id";
43 const std::string ReminderBaseTable::CONTENT = "content";
44 const std::string ReminderBaseTable::CONTENT_RESOURCE_ID = "content_resource_id";
45 const std::string ReminderBaseTable::SNOOZE_CONTENT = "snooze_content";
46 const std::string ReminderBaseTable::SNOOZE_CONTENT_RESOURCE_ID = "snooze_content_resource_id";
47 const std::string ReminderBaseTable::EXPIRED_CONTENT = "expired_content";
48 const std::string ReminderBaseTable::EXPIRED_CONTENT_RESOURCE_ID = "expired_content_resource_id";
49 const std::string ReminderBaseTable::WANT_AGENT = "want_agent";
50 const std::string ReminderBaseTable::MAX_SCREEN_WANT_AGENT = "max_screen_want_agent";
51 const std::string ReminderBaseTable::TAP_DISMISSED = "tap_dismissed";
52 const std::string ReminderBaseTable::AUTO_DELETED_TIME = "auto_deleted_time";
53 const std::string ReminderBaseTable::GROUP_ID = "group_id";
54 const std::string ReminderBaseTable::CUSTOM_RING_URI = "custom_ring_uri";
55 const std::string ReminderBaseTable::CREATOR_BUNDLE_NAME = "creator_bundle_name";
56 const std::string ReminderBaseTable::CREATOR_UID = "creator_uid";
57
58 // reminder alarm table
59 const std::string ReminderAlarmTable::TABLE_NAME = "reminder_alarm";
60 const std::string ReminderAlarmTable::REMINDER_ID = "reminder_id";
61 const std::string ReminderAlarmTable::ALARM_HOUR = "alarm_hour";
62 const std::string ReminderAlarmTable::ALARM_MINUTE = "alarm_minute";
63 const std::string ReminderAlarmTable::REPEAT_DAYS_OF_WEEK = "repeat_days_of_week";
64
65 // reminder calendar table
66 const std::string ReminderCalendarTable::TABLE_NAME = "reminder_calendar";
67 const std::string ReminderCalendarTable::REMINDER_ID = "reminder_id";
68 const std::string ReminderCalendarTable::FIRST_DESIGNATE_YEAR = "first_designate_year";
69 const std::string ReminderCalendarTable::FIRST_DESIGNATE_MONTH = "first_designate_month";
70 const std::string ReminderCalendarTable::FIRST_DESIGNATE_DAY = "first_designate_day";
71 const std::string ReminderCalendarTable::CALENDAR_DATE_TIME = "calendar_date_time";
72 const std::string ReminderCalendarTable::CALENDAR_END_DATE_TIME = "calendar_end_date_time";
73 const std::string ReminderCalendarTable::REPEAT_DAYS = "repeat_days";
74 const std::string ReminderCalendarTable::REPEAT_MONTHS = "repeat_months";
75 const std::string ReminderCalendarTable::REPEAT_DAYS_OF_WEEK = "repeat_days_of_week";
76 const std::string ReminderCalendarTable::RRULE_WANT_AGENT = "rrule_want_agent";
77 const std::string ReminderCalendarTable::EXCLUDE_DATES = "exclude_dates";
78 const std::string ReminderCalendarTable::CALENDAR_LAST_DATE_TIME = "calendar_last_date_time";
79
80 // reminder timer table
81 const std::string ReminderTimerTable::TABLE_NAME = "reminder_timer";
82 const std::string ReminderTimerTable::REMINDER_ID = "reminder_id";
83 const std::string ReminderTimerTable::TRIGGER_SECOND = "trigger_second";
84 const std::string ReminderTimerTable::START_DATE_TIME = "start_date_time";
85 const std::string ReminderTimerTable::END_DATE_TIME = "end_date_time";
86
87 std::string ReminderBaseTable::ADD_COLUMNS = "";
88 std::string ReminderBaseTable::SELECT_COLUMNS = "";
89
90 std::string ReminderAlarmTable::ADD_COLUMNS = "";
91 std::string ReminderAlarmTable::SELECT_COLUMNS = "";
92
93 std::string ReminderCalendarTable::ADD_COLUMNS = "";
94 std::string ReminderCalendarTable::SELECT_COLUMNS = "";
95
96 std::string ReminderTimerTable::ADD_COLUMNS = "";
97 std::string ReminderTimerTable::SELECT_COLUMNS = "";
98
AddColumn(const std::string & name,const std::string & type,std::string & sqlOfColumns,std::string & columns)99 static inline void AddColumn(const std::string& name, const std::string& type, std::string& sqlOfColumns,
100 std::string& columns)
101 {
102 columns.append(name).append(",");
103 sqlOfColumns.append(name).append(" ");
104 sqlOfColumns.append(type).append(", ");
105 }
106
AddColumnEnd(const std::string & name,const std::string & type,std::string & sqlOfColumns,std::string & columns)107 static inline void AddColumnEnd(const std::string& name, const std::string& type, std::string& sqlOfColumns,
108 std::string& columns)
109 {
110 columns.append(name);
111 sqlOfColumns.append(name).append(" ");
112 sqlOfColumns.append(type);
113 }
114
InitDbColumns()115 void ReminderBaseTable::InitDbColumns()
116 {
117 AddColumn(REMINDER_ID, "INTEGER PRIMARY KEY", ADD_COLUMNS, SELECT_COLUMNS);
118 AddColumn(PACKAGE_NAME, "TEXT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
119 AddColumn(USER_ID, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
120 AddColumn(UID, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
121 AddColumn(SYSTEM_APP, "TEXT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
122 AddColumn(REMINDER_TYPE, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
123 AddColumn(REMINDER_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
124 AddColumn(TRIGGER_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
125 AddColumn(TIME_INTERVAL, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
126 AddColumn(SNOOZE_TIMES, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
127 AddColumn(DYNAMIC_SNOOZE_TIMES, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
128 AddColumn(RING_DURATION, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
129 AddColumn(IS_EXPIRED, "TEXT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
130 AddColumn(STATE, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
131 AddColumn(ACTION_BUTTON_INFO, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
132 AddColumn(CUSTOM_BUTTON_URI, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
133 AddColumn(SLOT_ID, "INT", ADD_COLUMNS, SELECT_COLUMNS);
134 AddColumn(SNOOZE_SLOT_ID, "INT", ADD_COLUMNS, SELECT_COLUMNS);
135 AddColumn(NOTIFICATION_ID, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
136 AddColumn(TITLE, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
137 AddColumn(TITLE_RESOURCE_ID, "INT", ADD_COLUMNS, SELECT_COLUMNS);
138 AddColumn(CONTENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
139 AddColumn(CONTENT_RESOURCE_ID, "INT", ADD_COLUMNS, SELECT_COLUMNS);
140 AddColumn(SNOOZE_CONTENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
141 AddColumn(SNOOZE_CONTENT_RESOURCE_ID, "INT", ADD_COLUMNS, SELECT_COLUMNS);
142 AddColumn(EXPIRED_CONTENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
143 AddColumn(EXPIRED_CONTENT_RESOURCE_ID, "INT", ADD_COLUMNS, SELECT_COLUMNS);
144 AddColumn(WANT_AGENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
145 AddColumn(MAX_SCREEN_WANT_AGENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
146 AddColumn(TAP_DISMISSED, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
147 AddColumn(AUTO_DELETED_TIME, "BIGINT", ADD_COLUMNS, SELECT_COLUMNS);
148 AddColumn(GROUP_ID, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
149 AddColumn(CUSTOM_RING_URI, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
150 AddColumn(CREATOR_BUNDLE_NAME, "TEXT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
151 AddColumnEnd(CREATOR_UID, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
152 }
153
InitDbColumns()154 void ReminderAlarmTable::InitDbColumns()
155 {
156 AddColumn(REMINDER_ID, "INTEGER PRIMARY KEY", ADD_COLUMNS, SELECT_COLUMNS);
157 AddColumn(ALARM_HOUR, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
158 AddColumn(ALARM_MINUTE, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
159 AddColumnEnd(REPEAT_DAYS_OF_WEEK, "INT", ADD_COLUMNS, SELECT_COLUMNS);
160 }
161
InitDbColumns()162 void ReminderCalendarTable::InitDbColumns()
163 {
164 AddColumn(REMINDER_ID, "INTEGER PRIMARY KEY", ADD_COLUMNS, SELECT_COLUMNS);
165 AddColumn(FIRST_DESIGNATE_YEAR, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
166 AddColumn(FIRST_DESIGNATE_MONTH, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
167 AddColumn(FIRST_DESIGNATE_DAY, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
168 AddColumn(CALENDAR_DATE_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
169 AddColumn(CALENDAR_END_DATE_TIME, "BIGINT", ADD_COLUMNS, SELECT_COLUMNS);
170 AddColumn(REPEAT_DAYS, "INT", ADD_COLUMNS, SELECT_COLUMNS);
171 AddColumn(REPEAT_MONTHS, "INT", ADD_COLUMNS, SELECT_COLUMNS);
172 AddColumn(REPEAT_DAYS_OF_WEEK, "INT", ADD_COLUMNS, SELECT_COLUMNS);
173 AddColumn(RRULE_WANT_AGENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
174 AddColumn(EXCLUDE_DATES, "TEXT", ADD_COLUMNS, SELECT_COLUMNS);
175 AddColumnEnd(CALENDAR_LAST_DATE_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
176 }
177
InitDbColumns()178 void ReminderTimerTable::InitDbColumns()
179 {
180 AddColumn(REMINDER_ID, "INTEGER PRIMARY KEY", ADD_COLUMNS, SELECT_COLUMNS);
181 AddColumn(TRIGGER_SECOND, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
182 AddColumn(START_DATE_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
183 AddColumnEnd(END_DATE_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS);
184 }
185 }
186 }
187