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
313cea69
Commit
313cea69
authored
Sep 24, 2020
by
Manuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BusinessLogic] changed scripts to add schema information
parent
69817e5a
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
491 additions
and
197 deletions
+491
-197
add_carsharing_schema.py
...add_use_case_scripts/car-sharing/add_carsharing_schema.py
+49
-0
add_car.py
...e/app/_add_use_case_scripts/car-sharing/tables/add_car.py
+140
-0
add_hash.py
.../app/_add_use_case_scripts/car-sharing/tables/add_hash.py
+44
-0
add_offer.py
...app/_add_use_case_scripts/car-sharing/tables/add_offer.py
+58
-0
add_travel.py
...pp/_add_use_case_scripts/car-sharing/tables/add_travel.py
+65
-0
add_user.py
.../app/_add_use_case_scripts/car-sharing/tables/add_user.py
+45
-0
add_smart_energy_schema.py
..._use_case_scripts/smart-energy/add_smart_energy_schema.py
+37
-0
add_smart_energy.py
..._use_case_scripts/smart-energy/tables/add_smart_energy.py
+53
-48
add_carsharing_schema.py
.../business-logic-microservice/app/add_carsharing_schema.py
+0
-149
No files found.
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/car-sharing/add_carsharing_schema.py
0 → 100644
View file @
313cea69
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_user
as
user
import
tables.add_car
as
car
import
tables.add_offer
as
offer
import
tables.add_travel
as
travel
import
tables.add_hash
as
add_hash
def
add_use_case
(
use_case
:
str
):
use_case
=
"car-sharing"
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
=
"car-sharing"
# disable ssl warnings :)
requests
.
packages
.
urllib3
.
disable_warnings
()
add_use_case
(
use_case
)
user
.
main
(
use_case
)
car
.
main
(
use_case
)
offer
.
main
(
use_case
)
travel
.
main
(
use_case
)
add_hash
.
main
(
use_case
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/car-sharing/tables/add_car.py
0 → 100644
View file @
313cea69
# def add_car_layers():
# use_case = "car-sharing"
# layers = [
# {
# "use_case": use_case,
# "name": "doctype_layer",
# "properties": [
# "UniqueID",
# "doctype",
# ],
# "cluster_properties": [
# "doctype",
# ]
# },
# {
# "use_case": use_case,
# "name": "brand_layer",
# "properties": [
# "UniqueID",
# "brand",
# ],
# "cluster_properties": [
# "brand",
# ]
# },
# {
# "use_case": use_case,
# "name": "model_layer",
# "properties": [
# "UniqueID",
# "model",
# ],
# "cluster_properties": [
# "model",
# ]
# },
# {
# "use_case": use_case,
# "name": "colour_layer",
# "properties": [
# "UniqueID",
# "colour",
# ],
# "cluster_properties": [
# "colour",
# ]
# },
# {
# "use_case": use_case,
# "name": "seats_layer",
# "properties": [
# "UniqueID",
# "seats",
# ],
# "cluster_properties": [
# "seats",
# ]
# },
# {
# "use_case": use_case,
# "name": "year_layer",
# "properties": [
# "UniqueID",
# "year",
# ],
# "cluster_properties": [
# "year",
# ]
# },
# ]
# 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
# )
# if response.status_code == 200:
# print(f"Response: {response.status_code}")
# else:
# print(f"Response: {response.status_code}: {response.text}")
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
import
requests
def
add_table
(
use_case
:
str
):
'''
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
use_case
=
"car-sharing"
columns
=
[
# "doctype",
"carLicensePlate"
,
"brand"
,
"model"
,
"colour"
,
"seats"
,
"year"
,
"ownerId"
,
"deleted"
,
"state"
,
"observations"
]
columns
=
{
c
:
c
for
c
in
columns
}
columns
[
"UniqueID"
]
=
"carLicensePlate"
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
table
=
{
"name"
:
"car"
,
"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
main
(
use_case
:
str
):
print
(
"CAR"
)
add_table
(
use_case
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/car-sharing/tables/add_hash.py
0 → 100644
View file @
313cea69
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
import
requests
def
add_table
(
use_case
:
str
):
'''
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
# TODO check back with alex
use_case
=
"car-sharing"
columns
=
[
# "docType",
"documents"
,
"connection"
]
columns
=
{
c
:
c
for
c
in
columns
}
columns
[
"UniqueID"
]
=
"id"
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
table
=
{
"name"
:
"hash"
,
"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
main
(
use_case
:
str
):
print
(
"HASH"
)
add_table
(
use_case
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/car-sharing/tables/add_offer.py
0 → 100644
View file @
313cea69
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
import
requests
def
add_table
(
use_case
:
str
):
'''
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
# TODO check back with alex
use_case
=
"car-sharing"
columns
=
[
# "docType",
"id"
,
# "car",
"priceForKm"
,
"priceForTime"
,
"startDate"
,
"endDate"
,
"deposit"
,
# "startPlace",
# "endPlaces",
"available"
,
"deleted"
,
# "cancelledBy",
"carOwner"
,
# "checkedBy",
# "finishedBy",
"offererId"
]
columns
=
{
c
:
c
for
c
in
columns
}
columns
[
"UniqueID"
]
=
"id"
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
table
=
{
"name"
:
"offer"
,
"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
main
(
use_case
:
str
):
print
(
"OFFER"
)
add_table
(
use_case
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/car-sharing/tables/add_travel.py
0 → 100644
View file @
313cea69
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
import
requests
def
add_table
(
use_case
:
str
):
'''
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
# TODO check back with alex
use_case
=
"car-sharing"
columns
=
[
# "doctype",
"id"
,
"carLicensePlate"
,
# "users",
"offerId"
,
# "startPlace",
# "endPlace",
"startDate"
,
"endDate"
,
# "suggestedEndPlaces",
"rentForTime"
,
"seats"
,
"totalPrice"
,
"observations"
,
# "finishedBy",
"kmTraveled"
,
"priceBalance"
,
"depositBalance"
,
"rewardBalance"
,
# "score",
# "startedBy",
# "checkedBy",
"status"
,
# "cancelledBy"
]
columns
=
{
c
:
c
for
c
in
columns
}
columns
[
"UniqueID"
]
=
"id"
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
table
=
{
"name"
:
"travel"
,
"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
main
(
use_case
:
str
):
print
(
"TRAVEL"
)
add_table
(
use_case
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/car-sharing/tables/add_user.py
0 → 100644
View file @
313cea69
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
import
requests
def
add_table
(
use_case
:
str
):
'''
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
use_case
=
"car-sharing"
columns
=
[
# "doctype",
"id"
,
# pk
"balance"
,
"payerId"
,
"numberOfTrips"
,
"sumOfTripsScores"
]
columns
=
{
c
:
c
for
c
in
columns
}
columns
[
"UniqueID"
]
=
"id"
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
table
=
{
"name"
:
"user"
,
"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
main
(
use_case
:
str
):
print
(
"USER"
)
add_table
(
use_case
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/smart-energy/add_smart_energy_schema.py
0 → 100644
View file @
313cea69
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
=
"smart-energy"
# 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_bityoga_schema
.py
→
src/participation-hub/business-logic-microservice/app/
_add_use_case_scripts/smart-energy/tables/add_smart_energy
.py
View file @
313cea69
import
sys
import
network_constants
as
nc
import
os
from
security.token_manager
import
TokenManager
from
pathlib
import
Path
from
typing
import
Dict
,
Any
import
requests
import
requests
modules_path
=
'../../../modules/'
def
add_table
(
use_case
:
str
,
table_name
:
str
):
if
os
.
path
.
exists
(
modules_path
):
'''
sys
.
path
.
insert
(
1
,
modules_path
)
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
import
network_constants
as
nc
columns
=
[
from
security.token_manager
import
TokenManager
"Customer"
,
"Postcode"
,
"Timestamp"
,
"Solar_Production_kWh"
,
"Energy_Consumption_kWh"
,
"Heating_Consumption_kWh"
,
"Price_AUD/MWh"
,
"Total_Demand_MWh"
,
"Latitude"
,
"Longitude"
]
def
add_by_layers
():
columns
=
{
c
.
replace
(
"/"
,
"_"
)
:
c
for
c
in
columns
}
use_case
=
"smart-energy
"
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
=
[
layers
=
[
{
{
"use_case"
:
use_case
,
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Solar_Production_Layer"
,
"name"
:
"Solar_Production_Layer"
,
"properties"
:
[
"properties"
:
[
"UniqueID"
,
"UniqueID"
,
...
@@ -31,6 +62,7 @@ def add_by_layers():
...
@@ -31,6 +62,7 @@ def add_by_layers():
},
},
{
{
"use_case"
:
use_case
,
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Energy_Consumption_Layer"
,
"name"
:
"Energy_Consumption_Layer"
,
"properties"
:
[
"properties"
:
[
"UniqueID"
,
"UniqueID"
,
...
@@ -44,6 +76,7 @@ def add_by_layers():
...
@@ -44,6 +76,7 @@ def add_by_layers():
]
]
},{
},{
"use_case"
:
use_case
,
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Heating_Consumption_Layer"
,
"name"
:
"Heating_Consumption_Layer"
,
"properties"
:
[
"properties"
:
[
"UniqueID"
,
"UniqueID"
,
...
@@ -57,6 +90,7 @@ def add_by_layers():
...
@@ -57,6 +90,7 @@ def add_by_layers():
]
]
},{
},{
"use_case"
:
use_case
,
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Price_Layer"
,
"name"
:
"Price_Layer"
,
"properties"
:
[
"properties"
:
[
"UniqueID"
,
"UniqueID"
,
...
@@ -70,6 +104,7 @@ def add_by_layers():
...
@@ -70,6 +104,7 @@ def add_by_layers():
]
]
},{
},{
"use_case"
:
use_case
,
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Demand_Layer"
,
"name"
:
"Demand_Layer"
,
"properties"
:
[
"properties"
:
[
"UniqueID"
,
"UniqueID"
,
...
@@ -83,6 +118,7 @@ def add_by_layers():
...
@@ -83,6 +118,7 @@ def add_by_layers():
]
]
},{
},{
"use_case"
:
use_case
,
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Position_Layer"
,
"name"
:
"Position_Layer"
,
"properties"
:
[
"properties"
:
[
"UniqueID"
,
"UniqueID"
,
...
@@ -112,43 +148,12 @@ def add_by_layers():
...
@@ -112,43 +148,12 @@ def add_by_layers():
json
=
layer
json
=
layer
)
)
if
response
.
status_code
==
200
:
print
(
url
+
": "
+
str
(
response
.
status_code
))
print
(
f
"Response: {response.status_code}"
)
else
:
print
(
f
"Response: {response.status_code}: {response.text}"
)
def
add_by_schema
():
'''
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
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
=
{
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
(
def
main
(
use_case
:
str
):
url
,
print
(
"SMART-ENERGY"
)
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
columns
)
if
response
.
status_code
==
200
:
table_name
=
"smart-energy"
print
(
f
"Response: {response.status_code}"
)
return
True
else
:
print
(
f
"Response: {response.status_code}: {response.text}"
)
return
False
if
__name__
==
"__main__"
:
add_table
(
use_case
,
table_name
)
if
add_by_schema
():
add_layers
(
use_case
,
table_name
)
add_by_layers
()
\ No newline at end of file
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/add_carsharing_schema.py
deleted
100644 → 0
View file @
69817e5a
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
def
add_car_layers
():
use_case
=
"car-sharing"
layers
=
[
{
"use_case"
:
use_case
,
"name"
:
"doctype_layer"
,
"properties"
:
[
"UniqueID"
,
"doctype"
,
],
"cluster_properties"
:
[
"doctype"
,
]
},
{
"use_case"
:
use_case
,
"name"
:
"brand_layer"
,
"properties"
:
[
"UniqueID"
,
"brand"
,
],
"cluster_properties"
:
[
"brand"
,
]
},
{
"use_case"
:
use_case
,
"name"
:
"model_layer"
,
"properties"
:
[
"UniqueID"
,
"model"
,
],
"cluster_properties"
:
[
"model"
,
]
},
{
"use_case"
:
use_case
,
"name"
:
"colour_layer"
,
"properties"
:
[
"UniqueID"
,
"colour"
,
],
"cluster_properties"
:
[
"colour"
,
]
},
{
"use_case"
:
use_case
,
"name"
:
"seats_layer"
,
"properties"
:
[
"UniqueID"
,
"seats"
,
],
"cluster_properties"
:
[
"seats"
,
]
},
{
"use_case"
:
use_case
,
"name"
:
"year_layer"
,
"properties"
:
[
"UniqueID"
,
"year"
,
],
"cluster_properties"
:
[
"year"
,
]
},
]
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
)
if
response
.
status_code
==
200
:
print
(
f
"Response: {response.status_code}"
)
else
:
print
(
f
"Response: {response.status_code}: {response.text}"
)
def
add_car_schema
():
'''
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
print
(
f
"jwt token: {jwt}"
)
use_case
=
"car-sharing"
columns
=
[
"doctype"
,
"carLicensePlate"
,
"brand"
,
"model"
,
"colour"
,
"seats"
,
"year"
,
"ownerId"
,
"deleted"
,
"state"
,
"observations"
]
columns
=
{
c
:
c
for
c
in
columns
}
columns
[
"UniqueID"
]
=
"carLicensePlate"
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/schema"
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
columns
)
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__"
:
if
add_car_schema
():
add_car_layers
()
\ 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