2929class HistoricalLocation (entity .Entity ):
3030
3131 def __init__ (self ,
32- locations = None ,
32+ location = None ,
3333 time = None ,
3434 thing = None ,
3535 ** kwargs ):
3636 super ().__init__ (** kwargs )
37- self .locations = locations
37+ self .location = location
3838 self .time = time
3939 self .thing = thing
4040
4141 def __new__ (cls , * args , ** kwargs ):
4242 new_h_loc = super ().__new__ (cls )
43- attributes = {'_id' : None , '_locations ' : None , '_time' : None , '_thing' : None , '_self_link' : None ,
43+ attributes = {'_id' : None , '_location ' : None , '_time' : None , '_thing' : None , '_self_link' : None ,
4444 '_service' : None }
4545 for key , value in attributes .items ():
4646 new_h_loc .__dict__ [key ] = value
@@ -55,23 +55,15 @@ def time(self, value):
5555 self ._time = utils .check_datetime (value , 'time' )
5656
5757 @property
58- def locations (self ):
59- return self ._locations
58+ def location (self ):
59+ return self ._location
6060
61- @locations .setter
62- def locations (self , values ):
63- if values is None :
64- self ._locations = None
61+ @location .setter
62+ def location (self , value ):
63+ if value is None or isinstance ( value , location . Location ) :
64+ self ._location = value
6565 return
66- if isinstance (values , list ) and all (isinstance (loc , location .Location ) for loc in values ):
67- entity_class = entity_type .EntityTypes ['Location' ]['class' ]
68- self ._locations = entity_list .EntityList (entity_class = entity_class , entities = values )
69- return
70- if isinstance (values , entity_list .EntityList ) and \
71- all ((isinstance (loc , location .Location )) for loc in values .entities ):
72- self ._locations = values
73- return
74- raise ValueError ('locations should be a list of locations!' )
66+ raise ValueError ("location should be of type Location!" )
7567
7668 @property
7769 def thing (self ):
@@ -84,11 +76,6 @@ def thing(self, value):
8476 return
8577 raise ValueError ('thing should be of type Thing!' )
8678
87- def get_locations (self ):
88- result = self .service .locations ()
89- result .parent = self
90- return result
91-
9279 def ensure_service_on_children (self , service ):
9380 if self .locations is not None :
9481 self .locations .set_service (service )
@@ -127,11 +114,9 @@ def __setstate__(self, state):
127114 if state .get ("Thing" , None ) is not None :
128115 self .thing = frost_sta_client .model .thing .Thing ()
129116 self .thing .__setstate__ (state ["Thing" ])
130- if state .get ("Locations" , None ) is not None and isinstance (state ["Locations" ], list ):
131- entity_class = entity_type .EntityTypes ['Location' ]['class' ]
132- self .locations = utils .transform_json_to_entity_list (state ['Locations' ], entity_class )
133- self .locations .next_link = state .get ('Locations@iot.nextLink' , None )
134- self .locations .count = state .get ('Locations@iot.count' , None )
117+ if state .get ("Location" , None ) is not None :
118+ self .thing = frost_sta_client .model .location .Location ()
119+ self .thing .__setstate__ (state ["Location" ])
135120
136121 def get_dao (self , service ):
137122 return HistoricalLocationDao (service )
0 commit comments