• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 InsertOrUpdateAlertsUpdateJudgerImpl from './judger/InsertOrUpdateAlertsJudgerImpl';
18import DeleteAlertsUpdateJudgerImpl from './judger/DeleteAlertsUpdateJudgerImpl';
19import AlertsUpdateJudger from './AlertsUpdateJudger';
20
21export const INSERT_OPERATION_NAME = 'insert';
22
23export const UPDATE_OPERATION_NAME = 'update';
24
25export const DELETE_OPERATION_NAME = 'delete';
26
27/**
28 * AlarmNeedUpdateJudger 的工厂方法类,提供AlarmNeedUpdateJudger的创建与初始化
29 * AlarmNeedUpdateJudger 被设计用来判断在不同场景中是否需要刷新alerts表
30 *
31 * @since 2022-09-09
32 */
33export default class AlertsUpdateJudgerFactory {
34  map: Map<string, AlertsUpdateJudger> = new Map();
35
36  constructor() {
37    this.map.set(INSERT_OPERATION_NAME, new InsertOrUpdateAlertsUpdateJudgerImpl());
38    this.map.set(UPDATE_OPERATION_NAME, new InsertOrUpdateAlertsUpdateJudgerImpl());
39    this.map.set(DELETE_OPERATION_NAME, new DeleteAlertsUpdateJudgerImpl());
40  }
41
42  getAlertsUpdateJudger(judgerType: string): AlertsUpdateJudger | undefined {
43    return this.map.has(judgerType) ? this.map.get(judgerType) : undefined;
44  }
45}