1/** 2 * @file Describe the file 3 * Copyright (c) 2023 Huawei Device Co., Ltd. 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 17import HashSet from '@ohos.util.HashSet'; 18 19import AlertsUpdateJudger from '../AlertsUpdateJudger'; 20 21import { Log } from '@ohos/common/src/main/ets/utils/Log'; 22 23import { CalendarsColumns } from '@ohos/datastructure/src/main/ets/calendars/CalendarsColumns'; 24import { EventColumns } from '@ohos/datastructure/src/main/ets/events/EventColumns'; 25import { InstancesColumns } from '@ohos/datastructure/src/main/ets/instances/InstancesColumns'; 26import { RemindersColumns } from '@ohos/datastructure/src/main/ets/reminders/RemindersColumns'; 27import relationalStore from '@ohos.data.relationalStore'; 28 29const TAG = "DeleteAlarmNeedUpdateJudgerImpl"; 30 31/** 32 * 在数据表 删除 场景下判断是否需要刷新 alerts 33 * 34 * @since 2022-09-09 35 */ 36export default class DeleteAlarmNeedUpdateJudgerImpl implements AlertsUpdateJudger { 37 // 删除数据的场景下,判断是否删除了四张表的内容 38 tableNameSet = new HashSet<string>(); 39 40 constructor() { 41 this.tableNameSet.add(CalendarsColumns.TABLE_NAME); 42 this.tableNameSet.add(EventColumns.TABLE_NAME); 43 this.tableNameSet.add(InstancesColumns.TABLE_NAME); 44 this.tableNameSet.add(RemindersColumns.TABLE_NAME); 45 } 46 47 isNeedToUpdateAlerts(tableName: string, values: relationalStore.ValuesBucket): boolean { 48 if (values == null && values == undefined) { 49 Log.error(TAG, "this is not a delete operation, please check your Code!"); 50 return false; 51 } 52 if (this.tableNameSet.has(tableName)) { 53 return true; 54 } 55 return false; 56 } 57}