Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
718c4778
Commit
718c4778
authored
Sep 14, 2020
by
Manuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BusinessLogic] fixed upload script for smart-energy schema
parent
ab8cb3d4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
21 deletions
+23
-21
add_bityoga_schema.py
...hub/business-logic-microservice/app/add_bityoga_schema.py
+8
-4
routes.yml
...on-hub/business-logic-microservice/app/configs/routes.yml
+7
-11
schema.py
...tion-hub/business-logic-microservice/app/routes/schema.py
+8
-6
No files found.
src/participation-hub/business-logic-microservice/app/add_bityoga_schema.py
View file @
718c4778
...
...
@@ -127,9 +127,11 @@ def add_by_schema():
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
=
[(
c
.
replace
(
"/"
,
"_"
),
c
)
for
c
in
columns
]
columns
.
append
((
"UniqueID"
,
"Customer+Postcode+Timestamp"
))
columns
=
{
c
.
replace
(
"/"
,
"_"
)
:
c
for
c
in
columns
}
columns
[
"UniqueID"
]
=
"Customer+Postcode+Timestamp"
# url = f"https://localhost:5000/api/use-cases/{use_case}/schema"
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/schema"
response
=
requests
.
post
(
...
...
@@ -142,9 +144,11 @@ def add_by_schema():
if
response
.
status_code
==
200
:
print
(
f
"Response: {response.status_code}"
)
return
True
else
:
print
(
f
"Response: {response.status_code}: {response.text}"
)
return
False
if
__name__
==
"__main__"
:
add_by_schema
()
add_by_layers
()
\ No newline at end of file
if
add_by_schema
():
add_by_layers
()
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/configs/routes.yml
View file @
718c4778
...
...
@@ -53,17 +53,13 @@ paths:
in
:
"
body"
required
:
true
schema
:
type
:
"
object"
properties
:
mappings
:
type
:
array
items
:
type
:
object
additionalProperties
:
type
:
string
example
:
name
:
name
dough
:
dough//type
type
:
object
additionalProperties
:
type
:
string
example
:
name
:
name
dough
:
dough//type
responses
:
'
200'
:
description
:
"
Successful
Request"
...
...
src/participation-hub/business-logic-microservice/app/routes/schema.py
View file @
718c4778
...
...
@@ -15,18 +15,20 @@ def all():
return
[
schema
.
to_serializable_dict
()
for
schema
in
schema_repository
.
all
()]
def
add_complete
(
use_case
:
str
):
data
=
request
.
json
if
"mappings"
not
in
data
:
return
Response
(
status
=
400
,
response
=
"Missing fields. Required fields: (mappings)."
)
mappings
=
request
.
json
reference
=
schema_repository
.
get_for_use_case
(
use_case
)
if
reference
!=
None
and
len
(
reference
.
mappings
)
>
0
:
return
Response
(
status
=
400
,
response
=
"Schema already exists."
)
schema_repository
.
delete_for_use_case
(
use_case
)
data
[
"use_case"
]
=
use_case
schema_repository
.
add
(
Schema
.
from_serializable_dict
(
data
))
schema_dict
=
{
"use_case"
:
use_case
,
"mappings"
:
mappings
}
schema_repository
.
add
(
Schema
.
from_serializable_dict
(
schema_dict
))
return
Response
(
status
=
200
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment