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
15a9e683
Commit
15a9e683
authored
Oct 27, 2020
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added table and layers for bank-app schema
parent
25546930
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
0 deletions
+135
-0
add_bank_app_schema.py
...app/_add_use_case_scripts/bank-app/add_bank_app_schema.py
+40
-0
add_bank_app.py
...app/_add_use_case_scripts/bank-app/tables/add_bank_app.py
+95
-0
No files found.
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/bank-app/add_bank_app_schema.py
0 → 100644
View file @
15a9e683
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_bank_app
as
add_bank_app
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
}
)
if
response
.
status_code
>=
400
:
raise
Exception
(
f
"Error while uploading {use_case}: {str(response.content)}"
)
print
(
url
+
": "
+
str
(
response
.
status_code
))
if
__name__
==
"__main__"
:
# disable ssl warnings :)
requests
.
packages
.
urllib3
.
disable_warnings
()
use_case_name
=
'bank-app'
add_use_case
(
use_case_name
)
add_bank_app
.
main
(
use_case_name
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/bank-app/tables/add_bank_app.py
0 → 100644
View file @
15a9e683
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
=
[
"Transaction_ID"
,
"From_User_ID"
,
"To_User_ID"
,
"Timestamp"
,
"Amount"
,
"Transaction_Type"
,
]
columns
=
{
c
:
c
for
c
in
columns
}
columns
[
"UniqueID"
]
=
"Transaction_ID+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"
:
"Amount_Layer"
,
"properties"
:
[
"UniqueID"
,
"From_User_ID"
,
"To_User_ID"
,
"Timestamp"
,
"Amount"
],
"cluster_properties"
:
[
"Amount"
]
},
{
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Transaction_Type_Layer"
,
"properties"
:
[
"UniqueID"
,
"From_User_ID"
,
"To_User_ID"
,
"Timestamp"
,
"Transaction_Type"
],
"cluster_properties"
:
[
"Transaction_Type"
]
},
]
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_name
):
table_name
=
'bank-app'
add_table
(
use_case_name
,
table_name
)
add_layers
(
use_case_name
,
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