Skip to content

Commit

Permalink
BREAKING: Updated ThingRepository implementation according to 6bd353a
Browse files Browse the repository at this point in the history
  • Loading branch information
s-kostyuk committed Feb 27, 2018
1 parent 6bd353a commit 2a3e1f7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions dpl/repo_impls/in_memory/thing_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ThingRepository(BaseRepository[Thing], AbsThingRepository):
An implementation of Things storage
"""

def select_by_placement(self, placement_id: Optional[TDomainId]) -> Sequence[TDomainId]:
def select_by_placement(self, placement_id: Optional[TDomainId]) -> Sequence[Thing]:
"""
Fetches a collection of identifiers of all Things
that are present in the specified placement
Expand All @@ -20,34 +20,34 @@ def select_by_placement(self, placement_id: Optional[TDomainId]) -> Sequence[TDo
used for filtering; None (null) can be used as
a value of parameter to fetch a list of Things
that don't belong to any Placement
:return: a collection of identifiers of all things that
belong to the specified placement
:return: a collection of all things that belong to
the specified placement
"""
# FIXME: Replace by native database filtering when DB
# of settings will be added
result = list() # type: MutableSequence[TDomainId]
result = list() # type: MutableSequence[Thing]

for thing in self._objects.values():
if thing.metadata.get('placement') == placement_id:
result.append(thing.domain_id)
result.append(thing)

return result

def select_by_connection(self, connection_id: TDomainId) -> Sequence[TDomainId]:
def select_by_connection(self, connection_id: TDomainId) -> Sequence[Thing]:
"""
Fetches a collection of identifiers of all Things that
use the specified Connection
:param connection_id: an ID of Connection of interest
:return: a collection of identifiers of all Things that
use the specified connection
:return: a collection of all Things that use the
specified connection
"""
# FIXME: Replace by native database filtering when DB
# of settings will be added
result = list() # type: MutableSequence[TDomainId]
result = list() # type: MutableSequence[Thing]

for thing in self._objects.values():
if thing.metadata.get('con_id') == connection_id:
result.append(thing.domain_id)
result.append(thing)

return result

0 comments on commit 2a3e1f7

Please sign in to comment.