196279301Sopenharmony_ci/* 296279301Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 396279301Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 496279301Sopenharmony_ci * you may not use this file except in compliance with the License. 596279301Sopenharmony_ci * You may obtain a copy of the License at 696279301Sopenharmony_ci * 796279301Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 896279301Sopenharmony_ci * 996279301Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1096279301Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1196279301Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1296279301Sopenharmony_ci * See the License for the specific language governing permissions and 1396279301Sopenharmony_ci * limitations under the License. 1496279301Sopenharmony_ci */ 1596279301Sopenharmony_ci 1696279301Sopenharmony_ci#include "reminder_table.h" 1796279301Sopenharmony_ci 1896279301Sopenharmony_cinamespace OHOS { 1996279301Sopenharmony_cinamespace Notification { 2096279301Sopenharmony_ci// reminder base table 2196279301Sopenharmony_ciconst std::string ReminderBaseTable::TABLE_NAME = "reminder_base"; 2296279301Sopenharmony_ciconst std::string ReminderBaseTable::REMINDER_ID = "reminder_id"; 2396279301Sopenharmony_ciconst std::string ReminderBaseTable::PACKAGE_NAME = "package_name"; 2496279301Sopenharmony_ciconst std::string ReminderBaseTable::USER_ID = "user_id"; 2596279301Sopenharmony_ciconst std::string ReminderBaseTable::UID = "uid"; 2696279301Sopenharmony_ciconst std::string ReminderBaseTable::SYSTEM_APP = "system_app"; 2796279301Sopenharmony_ciconst std::string ReminderBaseTable::REMINDER_TYPE = "reminder_type"; 2896279301Sopenharmony_ciconst std::string ReminderBaseTable::REMINDER_TIME = "reminder_time"; 2996279301Sopenharmony_ciconst std::string ReminderBaseTable::TRIGGER_TIME = "trigger_time"; 3096279301Sopenharmony_ciconst std::string ReminderBaseTable::TIME_INTERVAL = "time_interval"; 3196279301Sopenharmony_ciconst std::string ReminderBaseTable::SNOOZE_TIMES = "snooze_times"; 3296279301Sopenharmony_ciconst std::string ReminderBaseTable::DYNAMIC_SNOOZE_TIMES = "dynamic_snooze_times"; 3396279301Sopenharmony_ciconst std::string ReminderBaseTable::RING_DURATION = "ring_duration"; 3496279301Sopenharmony_ciconst std::string ReminderBaseTable::IS_EXPIRED = "is_expired"; 3596279301Sopenharmony_ciconst std::string ReminderBaseTable::STATE = "state"; 3696279301Sopenharmony_ciconst std::string ReminderBaseTable::ACTION_BUTTON_INFO = "button_info"; 3796279301Sopenharmony_ciconst std::string ReminderBaseTable::CUSTOM_BUTTON_URI = "custom_button_uri"; 3896279301Sopenharmony_ciconst std::string ReminderBaseTable::SLOT_ID = "slot_id"; 3996279301Sopenharmony_ciconst std::string ReminderBaseTable::SNOOZE_SLOT_ID = "snooze_slot_id"; 4096279301Sopenharmony_ciconst std::string ReminderBaseTable::NOTIFICATION_ID = "notification_id"; 4196279301Sopenharmony_ciconst std::string ReminderBaseTable::TITLE = "title"; 4296279301Sopenharmony_ciconst std::string ReminderBaseTable::CONTENT = "content"; 4396279301Sopenharmony_ciconst std::string ReminderBaseTable::SNOOZE_CONTENT = "snooze_content"; 4496279301Sopenharmony_ciconst std::string ReminderBaseTable::EXPIRED_CONTENT = "expired_content"; 4596279301Sopenharmony_ciconst std::string ReminderBaseTable::WANT_AGENT = "want_agent"; 4696279301Sopenharmony_ciconst std::string ReminderBaseTable::MAX_SCREEN_WANT_AGENT = "max_screen_want_agent"; 4796279301Sopenharmony_ciconst std::string ReminderBaseTable::TAP_DISMISSED = "tap_dismissed"; 4896279301Sopenharmony_ciconst std::string ReminderBaseTable::AUTO_DELETED_TIME = "auto_deleted_time"; 4996279301Sopenharmony_ciconst std::string ReminderBaseTable::GROUP_ID = "group_id"; 5096279301Sopenharmony_ciconst std::string ReminderBaseTable::CUSTOM_RING_URI = "custom_ring_uri"; 5196279301Sopenharmony_ciconst std::string ReminderBaseTable::CREATOR_BUNDLE_NAME = "creator_bundle_name"; 5296279301Sopenharmony_ciconst std::string ReminderBaseTable::CREATOR_UID = "creator_uid"; 5396279301Sopenharmony_ci 5496279301Sopenharmony_ci// reminder alarm table 5596279301Sopenharmony_ciconst std::string ReminderAlarmTable::TABLE_NAME = "reminder_alarm"; 5696279301Sopenharmony_ciconst std::string ReminderAlarmTable::REMINDER_ID = "reminder_id"; 5796279301Sopenharmony_ciconst std::string ReminderAlarmTable::ALARM_HOUR = "alarm_hour"; 5896279301Sopenharmony_ciconst std::string ReminderAlarmTable::ALARM_MINUTE = "alarm_minute"; 5996279301Sopenharmony_ciconst std::string ReminderAlarmTable::REPEAT_DAYS_OF_WEEK = "repeat_days_of_week"; 6096279301Sopenharmony_ci 6196279301Sopenharmony_ci// reminder calendar table 6296279301Sopenharmony_ciconst std::string ReminderCalendarTable::TABLE_NAME = "reminder_calendar"; 6396279301Sopenharmony_ciconst std::string ReminderCalendarTable::REMINDER_ID = "reminder_id"; 6496279301Sopenharmony_ciconst std::string ReminderCalendarTable::FIRST_DESIGNATE_YEAR = "first_designate_year"; 6596279301Sopenharmony_ciconst std::string ReminderCalendarTable::FIRST_DESIGNATE_MONTH = "first_designate_month"; 6696279301Sopenharmony_ciconst std::string ReminderCalendarTable::FIRST_DESIGNATE_DAY = "first_designate_day"; 6796279301Sopenharmony_ciconst std::string ReminderCalendarTable::CALENDAR_DATE_TIME = "calendar_date_time"; 6896279301Sopenharmony_ciconst std::string ReminderCalendarTable::CALENDAR_END_DATE_TIME = "calendar_end_date_time"; 6996279301Sopenharmony_ciconst std::string ReminderCalendarTable::REPEAT_DAYS = "repeat_days"; 7096279301Sopenharmony_ciconst std::string ReminderCalendarTable::REPEAT_MONTHS = "repeat_months"; 7196279301Sopenharmony_ciconst std::string ReminderCalendarTable::REPEAT_DAYS_OF_WEEK = "repeat_days_of_week"; 7296279301Sopenharmony_ciconst std::string ReminderCalendarTable::RRULE_WANT_AGENT = "rrule_want_agent"; 7396279301Sopenharmony_ciconst std::string ReminderCalendarTable::EXCLUDE_DATES = "exclude_dates"; 7496279301Sopenharmony_ciconst std::string ReminderCalendarTable::CALENDAR_LAST_DATE_TIME = "calendar_last_date_time"; 7596279301Sopenharmony_ci 7696279301Sopenharmony_ci// reminder timer table 7796279301Sopenharmony_ciconst std::string ReminderTimerTable::TABLE_NAME = "reminder_timer"; 7896279301Sopenharmony_ciconst std::string ReminderTimerTable::REMINDER_ID = "reminder_id"; 7996279301Sopenharmony_ciconst std::string ReminderTimerTable::TRIGGER_SECOND = "trigger_second"; 8096279301Sopenharmony_ciconst std::string ReminderTimerTable::START_DATE_TIME = "start_date_time"; 8196279301Sopenharmony_ciconst std::string ReminderTimerTable::END_DATE_TIME = "end_date_time"; 8296279301Sopenharmony_ci 8396279301Sopenharmony_cistd::string ReminderBaseTable::ADD_COLUMNS = ""; 8496279301Sopenharmony_cistd::string ReminderBaseTable::SELECT_COLUMNS = ""; 8596279301Sopenharmony_ci 8696279301Sopenharmony_cistd::string ReminderAlarmTable::ADD_COLUMNS = ""; 8796279301Sopenharmony_cistd::string ReminderAlarmTable::SELECT_COLUMNS = ""; 8896279301Sopenharmony_ci 8996279301Sopenharmony_cistd::string ReminderCalendarTable::ADD_COLUMNS = ""; 9096279301Sopenharmony_cistd::string ReminderCalendarTable::SELECT_COLUMNS = ""; 9196279301Sopenharmony_ci 9296279301Sopenharmony_cistd::string ReminderTimerTable::ADD_COLUMNS = ""; 9396279301Sopenharmony_cistd::string ReminderTimerTable::SELECT_COLUMNS = ""; 9496279301Sopenharmony_ci 9596279301Sopenharmony_cistatic inline void AddColumn(const std::string& name, const std::string& type, std::string& sqlOfColumns, 9696279301Sopenharmony_ci std::string& columns) 9796279301Sopenharmony_ci{ 9896279301Sopenharmony_ci columns.append(name).append(","); 9996279301Sopenharmony_ci sqlOfColumns.append(name).append(" "); 10096279301Sopenharmony_ci sqlOfColumns.append(type).append(", "); 10196279301Sopenharmony_ci} 10296279301Sopenharmony_ci 10396279301Sopenharmony_cistatic inline void AddColumnEnd(const std::string& name, const std::string& type, std::string& sqlOfColumns, 10496279301Sopenharmony_ci std::string& columns) 10596279301Sopenharmony_ci{ 10696279301Sopenharmony_ci columns.append(name); 10796279301Sopenharmony_ci sqlOfColumns.append(name).append(" "); 10896279301Sopenharmony_ci sqlOfColumns.append(type); 10996279301Sopenharmony_ci} 11096279301Sopenharmony_ci 11196279301Sopenharmony_civoid ReminderBaseTable::InitDbColumns() 11296279301Sopenharmony_ci{ 11396279301Sopenharmony_ci AddColumn(REMINDER_ID, "INTEGER PRIMARY KEY", ADD_COLUMNS, SELECT_COLUMNS); 11496279301Sopenharmony_ci AddColumn(PACKAGE_NAME, "TEXT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 11596279301Sopenharmony_ci AddColumn(USER_ID, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 11696279301Sopenharmony_ci AddColumn(UID, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 11796279301Sopenharmony_ci AddColumn(SYSTEM_APP, "TEXT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 11896279301Sopenharmony_ci AddColumn(REMINDER_TYPE, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 11996279301Sopenharmony_ci AddColumn(REMINDER_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 12096279301Sopenharmony_ci AddColumn(TRIGGER_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 12196279301Sopenharmony_ci AddColumn(TIME_INTERVAL, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 12296279301Sopenharmony_ci AddColumn(SNOOZE_TIMES, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 12396279301Sopenharmony_ci AddColumn(DYNAMIC_SNOOZE_TIMES, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 12496279301Sopenharmony_ci AddColumn(RING_DURATION, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 12596279301Sopenharmony_ci AddColumn(IS_EXPIRED, "TEXT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 12696279301Sopenharmony_ci AddColumn(STATE, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 12796279301Sopenharmony_ci AddColumn(ACTION_BUTTON_INFO, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 12896279301Sopenharmony_ci AddColumn(CUSTOM_BUTTON_URI, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 12996279301Sopenharmony_ci AddColumn(SLOT_ID, "INT", ADD_COLUMNS, SELECT_COLUMNS); 13096279301Sopenharmony_ci AddColumn(SNOOZE_SLOT_ID, "INT", ADD_COLUMNS, SELECT_COLUMNS); 13196279301Sopenharmony_ci AddColumn(NOTIFICATION_ID, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 13296279301Sopenharmony_ci AddColumn(TITLE, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 13396279301Sopenharmony_ci AddColumn(CONTENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 13496279301Sopenharmony_ci AddColumn(SNOOZE_CONTENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 13596279301Sopenharmony_ci AddColumn(EXPIRED_CONTENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 13696279301Sopenharmony_ci AddColumn(WANT_AGENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 13796279301Sopenharmony_ci AddColumn(MAX_SCREEN_WANT_AGENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 13896279301Sopenharmony_ci AddColumn(TAP_DISMISSED, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 13996279301Sopenharmony_ci AddColumn(AUTO_DELETED_TIME, "BIGINT", ADD_COLUMNS, SELECT_COLUMNS); 14096279301Sopenharmony_ci AddColumn(GROUP_ID, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 14196279301Sopenharmony_ci AddColumn(CUSTOM_RING_URI, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 14296279301Sopenharmony_ci AddColumn(CREATOR_BUNDLE_NAME, "TEXT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 14396279301Sopenharmony_ci AddColumnEnd(CREATOR_UID, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 14496279301Sopenharmony_ci} 14596279301Sopenharmony_ci 14696279301Sopenharmony_civoid ReminderAlarmTable::InitDbColumns() 14796279301Sopenharmony_ci{ 14896279301Sopenharmony_ci AddColumn(REMINDER_ID, "INTEGER PRIMARY KEY", ADD_COLUMNS, SELECT_COLUMNS); 14996279301Sopenharmony_ci AddColumn(ALARM_HOUR, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 15096279301Sopenharmony_ci AddColumn(ALARM_MINUTE, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 15196279301Sopenharmony_ci AddColumnEnd(REPEAT_DAYS_OF_WEEK, "INT", ADD_COLUMNS, SELECT_COLUMNS); 15296279301Sopenharmony_ci} 15396279301Sopenharmony_ci 15496279301Sopenharmony_civoid ReminderCalendarTable::InitDbColumns() 15596279301Sopenharmony_ci{ 15696279301Sopenharmony_ci AddColumn(REMINDER_ID, "INTEGER PRIMARY KEY", ADD_COLUMNS, SELECT_COLUMNS); 15796279301Sopenharmony_ci AddColumn(FIRST_DESIGNATE_YEAR, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 15896279301Sopenharmony_ci AddColumn(FIRST_DESIGNATE_MONTH, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 15996279301Sopenharmony_ci AddColumn(FIRST_DESIGNATE_DAY, "INT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 16096279301Sopenharmony_ci AddColumn(CALENDAR_DATE_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 16196279301Sopenharmony_ci AddColumn(CALENDAR_END_DATE_TIME, "BIGINT", ADD_COLUMNS, SELECT_COLUMNS); 16296279301Sopenharmony_ci AddColumn(REPEAT_DAYS, "INT", ADD_COLUMNS, SELECT_COLUMNS); 16396279301Sopenharmony_ci AddColumn(REPEAT_MONTHS, "INT", ADD_COLUMNS, SELECT_COLUMNS); 16496279301Sopenharmony_ci AddColumn(REPEAT_DAYS_OF_WEEK, "INT", ADD_COLUMNS, SELECT_COLUMNS); 16596279301Sopenharmony_ci AddColumn(RRULE_WANT_AGENT, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 16696279301Sopenharmony_ci AddColumn(EXCLUDE_DATES, "TEXT", ADD_COLUMNS, SELECT_COLUMNS); 16796279301Sopenharmony_ci AddColumnEnd(CALENDAR_LAST_DATE_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 16896279301Sopenharmony_ci} 16996279301Sopenharmony_ci 17096279301Sopenharmony_civoid ReminderTimerTable::InitDbColumns() 17196279301Sopenharmony_ci{ 17296279301Sopenharmony_ci AddColumn(REMINDER_ID, "INTEGER PRIMARY KEY", ADD_COLUMNS, SELECT_COLUMNS); 17396279301Sopenharmony_ci AddColumn(TRIGGER_SECOND, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 17496279301Sopenharmony_ci AddColumn(START_DATE_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 17596279301Sopenharmony_ci AddColumnEnd(END_DATE_TIME, "BIGINT NOT NULL", ADD_COLUMNS, SELECT_COLUMNS); 17696279301Sopenharmony_ci} 17796279301Sopenharmony_ci} 17896279301Sopenharmony_ci} 179