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():
"use_case": use_case,
"name": "Solar_Production_Layer",
"properties": [
"UniqueID",
"Customer",
"PostCode",
"Postcode",
"Timestamp",
"Solar_Production_kWh"
],
......@@ -32,8 +33,9 @@ def add_by_layers():
"use_case": use_case,
"name": "Energy_Consumption_Layer",
"properties": [
"UniqueID",
"Customer",
"PostCode",
"Postcode",
"Timestamp",
"Energy_Consumption_kWh"
],
......@@ -44,8 +46,9 @@ def add_by_layers():
"use_case": use_case,
"name": "Heating_Consumption_Layer",
"properties": [
"UniqueID",
"Customer",
"PostCode",
"Postcode",
"Timestamp",
"Heating_Consumption_kWh"
],
......@@ -56,8 +59,9 @@ def add_by_layers():
"use_case": use_case,
"name": "Price_Layer",
"properties": [
"UniqueID",
"Customer",
"PostCode",
"Postcode",
"Timestamp",
"Price_AUD_MWh"
],
......@@ -68,8 +72,9 @@ def add_by_layers():
"use_case": use_case,
"name": "Demand_Layer",
"properties": [
"UniqueID",
"Customer",
"PostCode",
"Postcode",
"Timestamp",
"Total_Demand_MWh"
],
......@@ -80,8 +85,9 @@ def add_by_layers():
"use_case": use_case,
"name": "Position_Layer",
"properties": [
"UniqueID",
"Customer",
"PostCode",
"Postcode",
"Timestamp",
"Latitude",
"Longitude"
......@@ -96,7 +102,7 @@ def add_by_layers():
jwt = TokenManager.getInstance().getToken()
for layer in layers:
url = f"https://localhost:5000/api/layers"
url = f"https://articonf1.itec.aau.at:30420/api/layers"
response = requests.post(
url,
......@@ -121,15 +127,14 @@ def add_by_schema():
print(f"jwt token: {jwt}")
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://localhost:5000/api/use-cases/{use_case}/schema/mapping"
for column in columns:
internal = column.replace("/", "_")
external = column
url = f"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/schema/mapping"
for internal, external in columns:
response = requests.put(
url,
verify=False,
......
......@@ -140,7 +140,7 @@ paths:
/trace:
post:
security:
- JwtAdmin: []
- JwtRegular: []
operationId: "routes.blockchain_trace.receive"
tags:
- "Blockchain Trace"
......
......@@ -13,7 +13,7 @@ def receive():
message_sender.send_message('inhub', 'trace-retrieval', json.dumps(message))
return Response(status=201)
return Response(status=400)
return Response('ApplicationType is missing', status=400)
def isBlockchainTraceValid(trace) -> bool:
# different for every use case, no global schema
......
......@@ -164,7 +164,12 @@ class MessageHandler:
return
mappings = data["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)
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