Skip to content

Commit fc70cdd

Browse files
committed
chore(wip): collect some changes for analysis
1 parent 1835657 commit fc70cdd

29 files changed

Lines changed: 194 additions & 511 deletions

frost_sta_client/dao/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
__all__ = ['actuator', 'base', 'datastream', 'features_of_interest', 'historical_location', 'location',
2-
'multi_datastream', 'observation', 'observedproperty', 'sensor', 'task', 'tasking_capability', 'thing']
1+
__all__ = ['base']

frost_sta_client/dao/actuator.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

frost_sta_client/dao/base.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ def parent(self, value):
9999
def create(self, entity):
100100
url = furl(self.service.url)
101101
url.path.add(self.entitytype_plural)
102+
# Special handling: DataArrayDocument for Observations -> POST to CreateObservations
103+
is_data_array = (self.entitytype_plural == 'Observations' and hasattr(entity, 'get_observations'))
104+
if is_data_array:
105+
url.path.add('CreateObservations')
102106
logging.debug('Posting to ' + str(url.url))
103107
json_dict = frost_sta_client.utils.transform_entity_to_json_dict(entity)
104108
try:
@@ -108,6 +112,31 @@ def create(self, entity):
108112
entity.id = frost_sta_client.utils.extract_value(response.headers['location'])
109113
entity.service = self.service
110114
logging.debug('Received response: ' + str(response.status_code))
115+
if is_data_array:
116+
# Response is expected to be a JSON array of links
117+
try:
118+
links = json.loads(getattr(response, 'text', '[]'))
119+
except Exception:
120+
links = []
121+
result_list = []
122+
try:
123+
cl = frost_sta_client.utils.class_from_string(self.entity_class)
124+
except Exception:
125+
cl = None
126+
for href in links if isinstance(links, list) else []:
127+
try:
128+
obj = cl() if cl is not None else None
129+
except Exception:
130+
obj = None
131+
if obj is not None:
132+
try:
133+
obj.self_link = href
134+
obj.id = frost_sta_client.utils.extract_value(href)
135+
obj.service = self.service
136+
result_list.append(obj)
137+
except Exception:
138+
pass
139+
return result_list
111140

112141
def patch(self, entity, patches):
113142
"""

frost_sta_client/dao/datastream.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

frost_sta_client/dao/features_of_interest.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

frost_sta_client/dao/historical_location.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

frost_sta_client/dao/location.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

frost_sta_client/dao/multi_datastream.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

frost_sta_client/dao/observation.py

Lines changed: 0 additions & 52 deletions
This file was deleted.

frost_sta_client/dao/observedproperty.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)