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.
16 from typing import List, Set
17 from o2ims.domain import alarm_obj as obj
20 class AlarmEventRecordRepository(abc.ABC):
22 self.seen = set() # type: Set[obj.AlarmEventRecord]
24 def add(self, alarm_event_record: obj.AlarmEventRecord):
25 self._add(alarm_event_record)
26 self.seen.add(alarm_event_record)
28 def get(self, alarm_event_record_id) -> obj.AlarmEventRecord:
29 alarm_event_record = self._get(alarm_event_record_id)
30 if alarm_event_record:
31 self.seen.add(alarm_event_record)
32 return alarm_event_record
34 def list(self) -> List[obj.AlarmEventRecord]:
37 def update(self, alarm_event_record: obj.AlarmEventRecord):
38 self._update(alarm_event_record)
40 def delete(self, alarm_event_record_id):
41 self._delete(alarm_event_record_id)
44 def _add(self, alarm_event_record: obj.AlarmEventRecord):
45 raise NotImplementedError
48 def _get(self, alarm_event_record_id) -> obj.AlarmEventRecord:
49 raise NotImplementedError
52 def _list(self) -> List[obj.AlarmEventRecord]:
53 raise NotImplementedError
56 def _update(self, alarm_event_record: obj.AlarmEventRecord):
57 raise NotImplementedError
60 def _delete(self, alarm_event_record_id):
61 raise NotImplementedError
64 class AlarmDefinitionRepository(abc.ABC):
66 self.seen = set() # type: Set[obj.AlarmDefinition]
68 def add(self, definition: obj.AlarmDefinition):
70 self.seen.add(definition)
72 def get(self, definition_id) -> obj.AlarmDefinition:
73 definition = self._get(definition_id)
75 self.seen.add(definition)
78 def list(self) -> List[obj.AlarmDefinition]:
81 def update(self, definition: obj.AlarmDefinition):
82 self._update(definition)
84 def delete(self, definition_id):
85 self._delete(definition_id)
88 def _add(self, definition: obj.AlarmDefinition):
89 raise NotImplementedError
92 def _get(self, definition_id) -> obj.AlarmDefinition:
93 raise NotImplementedError
96 def _update(self, definition: obj.AlarmDefinition):
97 raise NotImplementedError
100 def _delete(self, definition_id):
101 raise NotImplementedError
104 class AlarmDictionaryRepository(abc.ABC):
106 self.seen = set() # type: Set[obj.AlarmDictionary]
108 def add(self, dictionary: obj.AlarmDictionary):
109 self._add(dictionary)
110 self.seen.add(dictionary)
112 def get(self, dictionary_id) -> obj.AlarmDictionary:
113 dictionary = self._get(dictionary_id)
115 self.seen.add(dictionary)
118 def list(self) -> List[obj.AlarmDictionary]:
121 def update(self, dictionary: obj.AlarmDictionary):
122 self._update(dictionary)
124 def delete(self, dictionary_id):
125 self._delete(dictionary_id)
128 def _add(self, dictionary: obj.AlarmDictionary):
129 raise NotImplementedError
132 def _get(self, dictionary_id) -> obj.AlarmDictionary:
133 raise NotImplementedError
136 def _update(self, dictionary: obj.AlarmDictionary):
137 raise NotImplementedError
140 def _delete(self, dictionary_id):
141 raise NotImplementedError
144 class AlarmSubscriptionRepository(abc.ABC):
146 self.seen = set() # type: Set[obj.AlarmSubscription]
148 def add(self, subscription: obj.AlarmSubscription):
149 self._add(subscription)
150 self.seen.add(subscription)
152 def get(self, subscription_id) -> obj.AlarmSubscription:
153 subscription = self._get(subscription_id)
155 self.seen.add(subscription)
158 def list(self) -> List[obj.AlarmSubscription]:
161 def update(self, subscription: obj.AlarmSubscription):
162 self._update(subscription)
164 def delete(self, subscription_id):
165 self._delete(subscription_id)
168 def _add(self, subscription: obj.AlarmSubscription):
169 raise NotImplementedError
172 def _get(self, subscription_id) -> obj.AlarmSubscription:
173 raise NotImplementedError
176 def _update(self, subscription: obj.AlarmSubscription):
177 raise NotImplementedError
180 def _delete(self, subscription_id):
181 raise NotImplementedError
184 class AlarmProbableCauseRepository(abc.ABC):
186 self.seen = set() # type: Set[obj.ProbableCause]
188 def add(self, probable_cause: obj.ProbableCause):
189 self._add(probable_cause)
190 self.seen.add(probable_cause)
192 def get(self, probable_cause_id) -> obj.ProbableCause:
193 probable_cause = self._get(probable_cause_id)
195 self.seen.add(probable_cause)
196 return probable_cause
198 def list(self) -> List[obj.ProbableCause]:
201 def update(self, probable_cause: obj.ProbableCause):
202 self._update(probable_cause)
204 def delete(self, probable_cause_id):
205 self._delete(probable_cause_id)
208 def _add(self, probable_cause: obj.ProbableCause):
209 raise NotImplementedError
212 def _get(self, probable_cause_id) -> obj.ProbableCause:
213 raise NotImplementedError
216 def _update(self, probable_cause: obj.ProbableCause):
217 raise NotImplementedError
220 def _delete(self, probable_cause_id):
221 raise NotImplementedError