Commit a797866f authored by Alexander Lercher's avatar Alexander Lercher

Fixed bityoga schema and flattening

parent 92010bd6
...@@ -19,8 +19,9 @@ def add_by_layers(): ...@@ -19,8 +19,9 @@ def add_by_layers():
"use_case": use_case, "use_case": use_case,
"name": "Solar_Production_Layer", "name": "Solar_Production_Layer",
"properties": [ "properties": [
"UniqueID",
"Customer", "Customer",
"PostCode", "Postcode",
"Timestamp", "Timestamp",
"Solar_Production_kWh" "Solar_Production_kWh"
], ],
...@@ -32,8 +33,9 @@ def add_by_layers(): ...@@ -32,8 +33,9 @@ def add_by_layers():
"use_case": use_case, "use_case": use_case,
"name": "Energy_Consumption_Layer", "name": "Energy_Consumption_Layer",
"properties": [ "properties": [
"UniqueID",
"Customer", "Customer",
"PostCode", "Postcode",
"Timestamp", "Timestamp",
"Energy_Consumption_kWh" "Energy_Consumption_kWh"
], ],
...@@ -44,8 +46,9 @@ def add_by_layers(): ...@@ -44,8 +46,9 @@ def add_by_layers():
"use_case": use_case, "use_case": use_case,
"name": "Heating_Consumption_Layer", "name": "Heating_Consumption_Layer",
"properties": [ "properties": [
"UniqueID",
"Customer", "Customer",
"PostCode", "Postcode",
"Timestamp", "Timestamp",
"Heating_Consumption_kWh" "Heating_Consumption_kWh"
], ],
...@@ -56,8 +59,9 @@ def add_by_layers(): ...@@ -56,8 +59,9 @@ def add_by_layers():
"use_case": use_case, "use_case": use_case,
"name": "Price_Layer", "name": "Price_Layer",
"properties": [ "properties": [
"UniqueID",
"Customer", "Customer",
"PostCode", "Postcode",
"Timestamp", "Timestamp",
"Price_AUD_MWh" "Price_AUD_MWh"
], ],
...@@ -68,8 +72,9 @@ def add_by_layers(): ...@@ -68,8 +72,9 @@ def add_by_layers():
"use_case": use_case, "use_case": use_case,
"name": "Demand_Layer", "name": "Demand_Layer",
"properties": [ "properties": [
"UniqueID",
"Customer", "Customer",
"PostCode", "Postcode",
"Timestamp", "Timestamp",
"Total_Demand_MWh" "Total_Demand_MWh"
], ],
...@@ -80,8 +85,9 @@ def add_by_layers(): ...@@ -80,8 +85,9 @@ def add_by_layers():
"use_case": use_case, "use_case": use_case,
"name": "Position_Layer", "name": "Position_Layer",
"properties": [ "properties": [
"UniqueID",
"Customer", "Customer",
"PostCode", "Postcode",
"Timestamp", "Timestamp",
"Latitude", "Latitude",
"Longitude" "Longitude"
...@@ -96,7 +102,7 @@ def add_by_layers(): ...@@ -96,7 +102,7 @@ def add_by_layers():
jwt = TokenManager.getInstance().getToken() jwt = TokenManager.getInstance().getToken()
for layer in layers: for layer in layers:
url = f"https://localhost:5000/api/layers" url = f"https://articonf1.itec.aau.at:30420/api/layers"
response = requests.post( response = requests.post(
url, url,
...@@ -121,15 +127,14 @@ def add_by_schema(): ...@@ -121,15 +127,14 @@ def add_by_schema():
print(f"jwt token: {jwt}") print(f"jwt token: {jwt}")
use_case = "smart-energy" use_case = "smart-energy"
columns = ["Customer", "PostCode", "Timestamp", "Solar_Production_kWh", "Energy_Consumption_kWh", "Heating_Consumption_kWh", "Price_AUD/MWh", "Total_Demand_MWh", "Latitude", "Longitude"] columns = ["Customer", "Postcode", "Timestamp", "Solar_Production_kWh", "Energy_Consumption_kWh", "Heating_Consumption_kWh", "Price_AUD/MWh", "Total_Demand_MWh", "Latitude", "Longitude"]
columns = [(c.replace("/", "_"), c) for c in columns]
columns.append(("UniqueID", "Customer+Postcode+Timestamp"))
# url = f"https://{nc.BUSINESS_LOGIC_HOSTNAME}:{nc.BUSINESS_LOGIC_REST_PORT}/api/use-cases/{use_case}/schema/mapping" # url = f"https://{nc.BUSINESS_LOGIC_HOSTNAME}:{nc.BUSINESS_LOGIC_REST_PORT}/api/use-cases/{use_case}/schema/mapping"
url = f"https://localhost:5000/api/use-cases/{use_case}/schema/mapping" url = f"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/schema/mapping"
for column in columns:
internal = column.replace("/", "_")
external = column
for internal, external in columns:
response = requests.put( response = requests.put(
url, url,
verify=False, verify=False,
......
...@@ -140,7 +140,7 @@ paths: ...@@ -140,7 +140,7 @@ paths:
/trace: /trace:
post: post:
security: security:
- JwtAdmin: [] - JwtRegular: []
operationId: "routes.blockchain_trace.receive" operationId: "routes.blockchain_trace.receive"
tags: tags:
- "Blockchain Trace" - "Blockchain Trace"
......
...@@ -13,7 +13,7 @@ def receive(): ...@@ -13,7 +13,7 @@ def receive():
message_sender.send_message('inhub', 'trace-retrieval', json.dumps(message)) message_sender.send_message('inhub', 'trace-retrieval', json.dumps(message))
return Response(status=201) return Response(status=201)
return Response(status=400) return Response('ApplicationType is missing', status=400)
def isBlockchainTraceValid(trace) -> bool: def isBlockchainTraceValid(trace) -> bool:
# different for every use case, no global schema # different for every use case, no global schema
......
...@@ -164,7 +164,12 @@ class MessageHandler: ...@@ -164,7 +164,12 @@ class MessageHandler:
return return
mappings = data["mappings"] mappings = data["mappings"]
flattened = self._flatten_transaction(transaction_message, mappings) try:
flattened = self._flatten_transaction(transaction_message, mappings)
except KeyError as e:
LOGGER.error(f"Failed while flattening with KeyError: {str(e)}")
self._mongo_repo.add_failed_transaction(transaction_message)
return
transaction = Transaction(use_case, flattened) transaction = Transaction(use_case, flattened)
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment