1 # Copyright (C) 2021 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 # pylint: disable=attribute-defined-outside-init
16 from __future__ import annotations
19 from o2ims.domain.ocloud_repo import OcloudRepository,\
20 ResourcePoolRepository, ResourceRepository, ResourceTypeRepository
21 from o2ims.domain.stx_repo import StxObjectRepository
24 class AbstractUnitOfWork(abc.ABC):
25 oclouds: OcloudRepository
26 resource_types: ResourceTypeRepository
27 resource_pools: ResourcePoolRepository
28 resources: ResourceRepository
29 stxobjects: StxObjectRepository
34 def __exit__(self, *args):
40 def collect_new_events(self):
41 for entry in self.oclouds.seen:
43 yield entry.events.pop(0)
44 for entry in self.resource_pools.seen:
46 yield entry.events.pop(0)
47 for entry in self.resources.seen:
49 yield entry.events.pop(0)
50 for entry in self.resource_types.seen:
52 yield entry.events.pop(0)
53 for entry in self.stxobjects.seen:
55 yield entry.events.pop(0)
59 raise NotImplementedError
63 raise NotImplementedError