1 # Copyright (C) 2022 Wind River Systems, Inc.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 from typing import List
17 from o2ims.domain import alarm_obj
18 from o2ims.domain.alarm_repo import AlarmDictionaryRepository
19 from o2common.helper import o2logging
20 logger = o2logging.get_logger(__name__)
23 class AlarmDictionaryConfigFileRepository(AlarmDictionaryRepository):
28 def _add(self, alarm_dict: alarm_obj.AlarmDictionary):
29 self.dictionary[alarm_dict.entityType] = alarm_dict
31 def _get(self, alarm_entity_type) -> alarm_obj.AlarmDictionary:
32 return self.dictionary[alarm_entity_type] \
33 if alarm_entity_type in self.dictionary else None
35 def _list(self) -> List[alarm_obj.AlarmDictionary]:
36 return [alarm_dict for alarm_dict in self.dictionary.items()]
38 def _update(self, alarm_dict: alarm_obj.AlarmDictionary):
39 self.dictionary[alarm_dict.entityType] = alarm_dict
41 def _delete(self, alarm_entity_type):
42 if alarm_entity_type in self.dictionary.keys():
43 del self.dictionary[alarm_entity_type]