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
051f6946
Commit
051f6946
authored
Oct 15, 2020
by
Bogdan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added paper busineslogic
parent
56b9c64e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
208 additions
and
5 deletions
+208
-5
dummy_upload.py
...ata-hub/semantic-linking-microservice/app/dummy_upload.py
+7
-5
add_paper_schema.py
...rvice/app/_add_use_case_scripts/paper/add_paper_schema.py
+37
-0
add_smart_energy.py
...pp/_add_use_case_scripts/paper/tables/add_smart_energy.py
+164
-0
No files found.
src/data-hub/semantic-linking-microservice/app/dummy_upload.py
View file @
051f6946
...
...
@@ -42,7 +42,7 @@ if __name__ == '__main__':
##################
old_c
=
None
customer
s
Count
=
0
customerCount
=
0
rowCount
=
0
for
row
in
reader
:
...
...
@@ -56,14 +56,16 @@ if __name__ == '__main__':
customerCount
+=
1
rowCount
=
0
old_c
=
transaction
[
'Customer'
]
print
(
f
"uploading for {old_c}"
)
if
(
customerCount
>
maxCustomers
):
print
(
"
\n
MAX customers reached"
)
break
if
(
rowCount
<
maxRows
):
upload_transaction
(
transaction
)
print
(
f
"uploading for {old_c}"
)
rowCount
+=
1
if
(
customerCount
>
maxCustomers
-
1
):
print
(
"
\n
MAX customers reached"
)
break
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/paper/add_paper_schema.py
0 → 100644
View file @
051f6946
import
sys
import
os
from
pathlib
import
Path
from
typing
import
Dict
,
Any
import
requests
modules_path
=
'../../../modules/'
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
import
tables.add_smart_energy
as
smart_energy
def
add_use_case
(
use_case
:
str
):
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases"
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
{
"name"
:
use_case
}
)
print
(
url
+
": "
+
str
(
response
.
status_code
))
if
__name__
==
"__main__"
:
use_case
=
"paper"
# disable ssl warnings :)
requests
.
packages
.
urllib3
.
disable_warnings
()
add_use_case
(
use_case
)
smart_energy
.
main
(
use_case
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/paper/tables/add_smart_energy.py
0 → 100644
View file @
051f6946
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
import
requests
def
add_table
(
use_case
:
str
,
table_name
:
str
):
'''
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
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
[
"UniqueID"
]
=
"Customer+Postcode+Timestamp"
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
table
=
{
"name"
:
table_name
,
"mappings"
:
columns
}
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
table
)
print
(
url
+
": "
+
str
(
response
.
status_code
))
def
add_layers
(
use_case
:
str
,
table_name
:
str
):
layers
=
[
{
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Solar_Production_Layer"
,
"properties"
:
[
"UniqueID"
,
"Customer"
,
"Postcode"
,
"Timestamp"
,
"Solar_Production_kWh"
,
"Total_Demand_MWh"
],
"cluster_properties"
:
[
"Solar_Production_kWh"
,
]
},
{
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Energy_Consumption_Layer"
,
"properties"
:
[
"UniqueID"
,
"Customer"
,
"Postcode"
,
"Timestamp"
,
"Energy_Consumption_kWh"
,
"Total_Demand_MWh"
],
"cluster_properties"
:
[
"Energy_Consumption_kWh"
]
},{
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Heating_Consumption_Layer"
,
"properties"
:
[
"UniqueID"
,
"Customer"
,
"Postcode"
,
"Timestamp"
,
"Heating_Consumption_kWh"
,
"Total_Demand_MWh"
],
"cluster_properties"
:
[
"Heating_Consumption_kWh"
]
},{
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Price_Layer"
,
"properties"
:
[
"UniqueID"
,
"Customer"
,
"Postcode"
,
"Timestamp"
,
"Price_AUD_MWh"
,
"Total_Demand_MWh"
],
"cluster_properties"
:
[
"Price_AUD_MWh"
]
},{
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Demand_Layer"
,
"properties"
:
[
"UniqueID"
,
"Customer"
,
"Postcode"
,
"Timestamp"
,
"Total_Demand_MWh"
],
"cluster_properties"
:
[
"Total_Demand_MWh"
]
},{
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Position_Layer"
,
"properties"
:
[
"UniqueID"
,
"Customer"
,
"Postcode"
,
"Timestamp"
,
"Latitude"
,
"Longitude"
,
"Total_Demand_MWh"
],
"cluster_properties"
:
[
"Latitude"
,
"Longitude"
,
]
},
]
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
for
layer
in
layers
:
url
=
f
"https://articonf1.itec.aau.at:30420/api/layers"
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
layer
)
print
(
url
+
": "
+
str
(
response
.
status_code
))
def
main
(
use_case
:
str
):
print
(
"PAPER"
)
table_name
=
"paper"
add_table
(
use_case
,
table_name
)
add_layers
(
use_case
,
table_name
)
\ No newline at end of file
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