• 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 { CalendarAlertsColumns } from '@ohos/datastructure/src/main/ets/calendaralerts/CalendarAlertsColumns';
18import { CalendarsColumns } from '@ohos/datastructure/src/main/ets/calendars/CalendarsColumns';
19import { InstancesColumns } from '@ohos/datastructure/src/main/ets/instances/InstancesColumns'
20import { EventColumns } from '@ohos/datastructure/src/main/ets/events/EventColumns'
21import { RemindersColumns } from '@ohos/datastructure/src/main/ets/reminders/RemindersColumns';
22
23import { AlertsProcessor } from './alerts/AlertsProcessor';
24import { CalendarsProcessor } from './calendars/CalendarsProcessor';
25import { DatabaseProcessor } from './DatabaseProcessor'
26import { DefaultProcessor } from './DefaultProcessor'
27import { InstancesProcessor } from './instances/InstancesProcessor'
28import { EventsProcessor } from './events/EventsProcessor'
29import { AlertsObserver } from './alerts/AlertsObserver'
30import { RemindersProcessor } from './reminders/RemindersProcessor';
31
32
33/**
34 * the Factory of database Processors
35 *
36 * @since 2022-06-21
37 */
38export default {
39  getDatabaseProcessor(tableName: string): DatabaseProcessor {
40    let processor: DatabaseProcessor;
41    switch (tableName) {
42      case CalendarsColumns.TABLE_NAME:
43        processor = new CalendarsProcessor();
44        break;
45      case EventColumns.TABLE_NAME:
46        processor = new EventsProcessor();
47        break;
48      case InstancesColumns.TABLE_NAME:
49        processor = new InstancesProcessor();
50        break;
51      case RemindersColumns.TABLE_NAME:
52        processor = new RemindersProcessor();
53        break;
54      case CalendarAlertsColumns.TABLE_NAME:
55        processor = new AlertsProcessor();
56        break;
57      default:
58        processor = new DefaultProcessor();
59        break;
60    }
61    if (processor instanceof DefaultProcessor) {
62      processor.addObserver(AlertsObserver.getInstance());
63    }
64    return processor;
65  }
66}