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
22ef8a54
Commit
22ef8a54
authored
Sep 15, 2020
by
Manuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added script to add car-sharing schema+layers
parent
bde0fa8b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
149 additions
and
0 deletions
+149
-0
add_carsharing_schema.py
.../business-logic-microservice/app/add_carsharing_schema.py
+149
-0
No files found.
src/participation-hub/business-logic-microservice/app/add_carsharing_schema.py
0 → 100644
View file @
22ef8a54
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