Commit 383b7388 authored by Alexander Lercher's avatar Alexander Lercher

Merge branch 'feature/mapping-car-sharing-use-case' into 'feature/community-detection-pipeline'

Feature/mapping car sharing use case

See merge request !16
parents c2545270 8b38c505
# 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",a
# "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
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
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
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
...@@ -4,20 +4,26 @@ from pathlib import Path ...@@ -4,20 +4,26 @@ from pathlib import Path
from typing import Dict, Any from typing import Dict, Any
import requests import requests
modules_path = '../../../modules/' modules_paths = ['.', '../../../modules/']
if os.path.exists(modules_path): for modules_path in modules_paths:
sys.path.insert(1, modules_path) if os.path.exists(modules_path):
sys.path.insert(1, modules_path)
# import _add_use_case_scripts.car_sharing.tables.add_user as user
from _add_use_case_scripts.car_sharing.tables import add_car, add_hash, add_offer, add_publication, add_travel, add_user
# import _add_use_case_scripts.car_sharing.tables.add_user as user
# from _add_use_case_scripts.car_sharing.tables import add_car
# from _add_use_case_scripts.car_sharing.tables import add_hash
# from _add_use_case_scripts.car_sharing.tables import add_publication
# from _add_use_case_scripts.car_sharing.tables import add_offer
# from _add_use_case_scripts.car_sharing.tables import add_travel
import network_constants as nc import network_constants as nc
from security.token_manager import TokenManager 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): def add_use_case(use_case: str):
use_case = "car-sharing" use_case = "car-sharing"
...@@ -32,7 +38,7 @@ def add_use_case(use_case: str): ...@@ -32,7 +38,7 @@ def add_use_case(use_case: str):
json = {"name": use_case} json = {"name": use_case}
) )
print(url+": "+str(response.status_code)) print(url+": "+str(response.content))
if __name__ == "__main__": if __name__ == "__main__":
...@@ -42,8 +48,10 @@ if __name__ == "__main__": ...@@ -42,8 +48,10 @@ if __name__ == "__main__":
requests.packages.urllib3.disable_warnings() requests.packages.urllib3.disable_warnings()
add_use_case(use_case) add_use_case(use_case)
user.main(use_case) add_user.main(use_case)
car.main(use_case) add_car.main(use_case)
offer.main(use_case) add_hash.main(use_case)
travel.main(use_case) add_offer.main(use_case)
add_hash.main(use_case) add_publication.main(use_case)
\ No newline at end of file add_travel.main(use_case)
\ No newline at end of file
from _add_use_case_scripts.car_sharing.tables import add_car
from _add_use_case_scripts.car_sharing.tables import add_hash
from _add_use_case_scripts.car_sharing.tables import add_offer
from _add_use_case_scripts.car_sharing.tables import add_publication
from _add_use_case_scripts.car_sharing.tables import add_travel
from _add_use_case_scripts.car_sharing.tables import add_user
from _add_use_case_scripts.car_sharing.tables import requestPost
\ No newline at end of file
from _add_use_case_scripts.car_sharing.tables.requestPost import postLayersToSwagger, postTableToSwagger
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 "_"
'''
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"
table = {
"name": table_name,
"mappings": columns
}
postTableToSwagger(use_case,table)
def add_layers(use_case:str, table_name: str):
layers = [
{
"use_case": use_case,
"table": table_name,
"name": "GeneralCar_layer",
"properties": [
"UniqueID",
"brand",
"model",
"colour",
"seats",
"year",
"ownerId",
"deleted",
"state"
],
"cluster_properties": [
"brand",
"model",
"seats",
"year",
"ownerId",
"state"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "Owner_layer",
"properties": [
"UniqueID",
"brand",
"model",
"colour",
"seats",
"year",
"ownerId",
"deleted",
"state"
],
"cluster_properties": [
"OwnerID",
"UniqueID"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "CarAge_layer",
"properties": [
"UniqueID",
"brand",
"model",
"colour",
"seats",
"year",
"ownerId",
"deleted",
"state"
],
"cluster_properties": [
"year",
"state"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "Model_layer",
"properties": [
"UniqueID",
"brand",
"model",
"colour",
"seats",
"year",
"ownerId",
"deleted",
"state"
],
"cluster_properties": [
"brand",
"model",
"seats"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "CarState_layer",
"properties": [
"UniqueID",
"ownerId",
"deleted",
"state"
],
"cluster_properties": [
"deleted",
"state"
]
}
]
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("CAR")
table_name = "car"
add_table(use_case,table_name)
add_layers(use_case, table_name)
\ No newline at end of file
from _add_use_case_scripts.car_sharing.tables.requestPost import postLayersToSwagger, postTableToSwagger
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 "_"
'''
# TODO Manuel: check back with alex
use_case = "car-sharing"
columns = [
# "docType",
"documents",
"connection"
]
columns = { c : c for c in columns }
columns["UniqueID"] = "documents[0]//id"
columns["document1id"] = "documents[0]//id"
columns["document1collection"] = "documents[0]//collection"
columns["document1hash"] = "documents[0]//hash"
columns["databaseType"] = "connection//databaseType"
columns["database"] = "connection//database"
columns["host"] = "connection//host"
columns["port"] = "connection//port"
columns["username"] = "connection//username"
columns["password"] = "connection//password"
table = {
"name": table_name,
"mappings": columns
}
postTableToSwagger(use_case,table)
def add_layers(use_case:str, table_name: str):
layers = [
{
"use_case": use_case,
"table": table_name,
"name": "document_layer",
"properties": [
"UniqueID",
"document1id",
"document1collection",
"document1hash"
],
"cluster_properties": [
##TODO discuss with other to see if we keep them?
"document1id",
"document1collection"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "connection_layer",
"properties": [
"UniqueID",
"username",
"password"
],
"cluster_properties": [
##TODO discuss with other to see if we keep them?
"username"
]
}
]
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("HASH")
table_name = "hash"
add_table(use_case,table_name)
add_layers(use_case,table_name)
\ No newline at end of file
from _add_use_case_scripts.car_sharing.tables.requestPost import postLayersToSwagger, postTableToSwagger
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 "_"
'''
# TODO check back with alex
use_case = "car-sharing"
columns = [
# "docType",
"id",
"priceForKm",
"priceForTime",
"startDate",
"endDate",
"deposit",
# "startPlace",
# "endPlaces",
"available",
"deleted",
# "cancelledBy",
"carOwner"
# "checkedBy",
# "finishedBy"
]
columns = { c : c for c in columns }
columns["UniqueID"] = "id"
columns["carID"] = "car//carLicensePlate"
columns["carOwner"] = "car//ownerId"
##TODO Question: should i get all the data from the car field? or just the car id/owner?
columns["startLatitude"] = "startPlace//latitude"
columns["startLongitude"] = "startPlace//longitude"
#TODO what if there are more end places? how can i define them? i can only get the first index of the array
columns["endFirstLatitude"] = "endPlaces[0]//latitude"
columns["endFirstLongitude"] = "endPlaces[0]//longitude"
table = {
"name": table_name,
"mappings": columns
}
postTableToSwagger(use_case,table)
def add_layers(use_case:str, table_name: str):
layers = [
{
"use_case": use_case,
"table": table_name,
"name": "OfferStartLocation_layer",
"properties": [
"UniqueID",
"carID",
"carOwner",
"startLatitude",
"startLongitude",
"startDate",
"endFirstLatitude",
"endFirstLongitude",
],
"cluster_properties": [
"carOwner",
"startLatitude",
"startLongitude"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "OfferEndLocation_layer",
"properties": [
"UniqueID",
"carID",
"carOwner",
"startLatitude",
"startLongitude",
"endDate",
"endFirstLatitude",
"endFirstLongitude",
],
"cluster_properties": [
"carOwner",
"endFirstLatitude",
"endFirstLongitude"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "OfferedCar_layer",
"properties": [
"UniqueID",
"carID",
"carOwner"
],
"cluster_properties": [
"carID",
"carOwner"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "OfferPrice_layer",
"properties": [
"UniqueID",
"carOwner",
"priceForKm",
"priceForTime",
"deposit"
],
"cluster_properties": [
"carOwner",
"priceForKm",
"priceForTime",
"deposit"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "OfferTime_layer",
"properties": [
"UniqueID",
"carOwner",
"startDate",
"endDate"
],
"cluster_properties": [
"carOwner",
"startDate",
"endDate"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "OfferStatus_layer",
"properties": [
"UniqueID",
"carOwner",
"available",
"deleted"
],
"cluster_properties": [
"carOwner",
"available",
"deleted"
]
}
]
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("OFFER")
table_name = "offer"
add_table(use_case,table_name)
add_layers(use_case,table_name)
\ No newline at end of file
from _add_use_case_scripts.car_sharing.tables.requestPost import postLayersToSwagger, postTableToSwagger
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 "_"
'''
use_case = "car-sharing"
columns = [
# "doctype",
"id",
"text",
#"media"
#"location"
"user",
"date",
#"likesUsers"
#"reportedBy"
"deleted",
"answerTo"
]
columns = { c : c for c in columns }
columns["UniqueID"] = "id"
#TODO what if it doesn't have media? i.e the list is empty
columns["mediaUrlFirst"] = "media[0]//mediaUrl"
columns["mediaTypeFirst"]= "media[0]//mediaType"
columns["mediaLabelsFirst"]= "media[0]//mediaLabels"
columns["latitude"] = "location//latitude"
columns["longitude"] = "location//longitude"
#TODO get Likes/reportedBy?
table = {
"name": table_name,
"mappings": columns
}
postTableToSwagger(use_case,table)
def add_layers(use_case:str, table_name: str):
layers = [
{
"use_case": use_case,
"table": table_name,
"name": "PublicationLocation_layer",
"properties": [
"UniqueID",
"user",
"latitude",
"longitude"
],
"cluster_properties": [
"latitude",
"longitude"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "PublicationTime_layer",
"properties": [
"UniqueID",
"user",
"latitude",
"longitude"
],
"cluster_properties": [
"date"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "PublicationUser_layer",
"properties": [
"UniqueID",
"text",
"user",
"mediaUrlFirst",
"mediaTypeFirst",
"mediaLabelsFirst"
],
"cluster_properties": [
"user"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "PublicationStatus_layer",
"properties": [
"UniqueID",
"text",
"user",
"deleted",
"answerTo"
],
"cluster_properties": [
"deleted",
"answerTo"
]
}
]
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("PUBLICATION")
table_name = "publication"
add_table(use_case,table_name)
add_layers(use_case, table_name)
\ No newline at end of file
from _add_use_case_scripts.car_sharing.tables.requestPost import postLayersToSwagger, postTableToSwagger
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 "_"
'''
# TODO disscuss with others if it looks ok
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"
columns["user1ID"] = "users[0]//userId"
columns["user1PassengersNr"] = "users[0]//passengers"
columns["isDriver"] = "users[0]//isDriver"
columns["startPlaceLatitude"] = "startPlace//latitude"
columns["startPlaceLongitude"] = "startPlace//longitude"
columns["endPlaceLatitude"] = "endPlace//latitude"
columns["endPlaceLongitude"] = "endPlace//longitude"
#TODO consider only the first sugested place? how to consider multiple
#columns["suggestedEndPlace1Latitude"] = "suggestedEndPlaces[0]//endplace//latitude"
#columns["suggestedEndPlace1Longitude"] = "suggestedEndPlaces[0]//endplace//longitude"
#columns["finishedBy1User"] = "finishedBy[0]//user"
#columns["finishedBy1Moment"] = "finishedBy[0]//moment"
#columns["finishedBy1Latitude"] = "finishedBy[0]//coordinate//latitude"
#columns["finishedBy1Longitude"] = "finishedBy[0]//coordinate//longitude"
#columns["score1User"] = "score[0]//user"
#columns["score1Rating"] = "score[0]//value"
columns["startedBy1StartPlaceLatitude"] = "startedBy[0]//startPlace//latitude"
columns["startedBy1StartPlaceLongitude"] = "startedBy[0]//startPlace//longitude"
columns["startedBy1Moment"] = "startedBy[0]//moment"
columns["startedBy1User"] = "startedBy[0]//user"
#TODO CheckedBy,CanceledBy usefull?
table = {
"name": table_name,
"mappings": columns
}
postTableToSwagger(use_case,table)
def add_layers(use_case:str, table_name: str):
layers = [
{
"use_case": use_case,
"table": table_name,
"name": "TravelUser_Layer",
"properties": [
'UniqueID',
'user1ID',
'isDriver',
#'score1User',
#'score1Rating',
'startedBy1User'
],
"cluster_properties": [
'user1ID'
]
},
{
"use_case": use_case,
"table": table_name,
"name": "StartingPoint_Layer",
"properties": [
'user1ID',
'UniqueID',
'startPlaceLatitude',
'startPlaceLongitude',
'startDate',
'endDate'
],
"cluster_properties": [
'startPlaceLatitude',
'startPlaceLatitude'
]
},{
"use_case": use_case,
"table": table_name,
"name": "StartingTime_Layer",
"properties": [
'user1ID',
'UniqueID',
'startDate',
'endDate',
#'finishedBy1Moment',
'startedBy1Moment'
],
"cluster_properties": [
'startedBy1Moment',
'startDate'
]
},{
"use_case": use_case,
"table": table_name,
"name": "Destination_Layer",
"properties": [
'user1ID',
'UniqueID',
#'finishedBy1Latitude',
#'finishedBy1Longitude',
'kmTraveled',
'startPlaceLatitude',
'startPlaceLongitude',
],
"cluster_properties": [
#'finishedBy1Latitude',
#'finishedBy1Longitude'
]
},{
"use_case": use_case,
"table": table_name,
"name": "FinishedTime_Layer",
"properties": [
'user1ID',
'UniqueID',
'startDate',
'endDate',
#'finishedBy1Moment',
'startedBy1Moment'
],
"cluster_properties": [
'endDate' #,
#'finishedBy1Moment'
]
},{
"use_case": use_case,
"table": table_name,
"name": "Price_Layer",
"properties": [
'user1ID',
'UniqueID',
'totalPrice',
'kmTraveled',
'priceBalance',
'depositBalance',
'rewardBalance'
],
"cluster_properties": [
'totalPrice',
'kmTraveled',
'priceBalance',
'depositBalance',
'rewardBalance'
]
},
{
"use_case": use_case,
"table": table_name,
"name": "Status_Layer",
"properties": [
'UniqueID',
'user1ID',
'status',
#'score1User',
#'score1Rating',
'rentForTime'
],
"cluster_properties": [
'status',
#'score1Rating',
'rentForTime'
]
}
]
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("TRAVEL")
table_name = "travel"
add_table(use_case,table_name)
add_layers(use_case, table_name)
from _add_use_case_scripts.car_sharing.tables.requestPost import postLayersToSwagger, postTableToSwagger
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 "_"
'''
use_case = "car-sharing"
columns = [
# "doctype",
"id", # pk
"balance",
"payerId",
"numberOfTripsDone",
"sumOfTripsScores"
]
columns = { c : c for c in columns }
columns["UniqueID"] = "id"
table = {
"name": table_name,
"mappings": columns
}
postTableToSwagger(use_case,table)
def add_layers(use_case:str, table_name: str):
layers = [
{
"use_case": use_case,
"table": table_name,
"name": "User_layer",
"properties": [
"UniqueID",
"balance",
"payerId",
"numberOfTripsDone",
"sumOfTripsScores"
],
"cluster_properties": [
"balance",
"numberOfTripsDone",
"sumOfTripsScores"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "UserBalance_layer",
"properties": [
"UniqueID",
"balance",
"payerId",
"numberOfTripsDone",
"sumOfTripsScores"
],
"cluster_properties": [
"balance",
"sumOfTripsScores"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "UserVeterancy_layer",
"properties": [
"UniqueID",
"balance",
"payerId",
"numberOfTripsDone",
"sumOfTripsScores"
],
"cluster_properties": [
"numberOfTripsDone",
"sumOfTripsScores"
]
}
]
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("USER")
table_name = "user"
add_table(use_case,table_name)
add_layers(use_case, table_name)
\ No newline at end of file
import network_constants as nc import network_constants as nc
from security.token_manager import TokenManager from security.token_manager import TokenManager
import requests import requests
def add_table(use_case: str): def postTableToSwagger(use_case:str, table:dict ):
'''
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 jwt = TokenManager.getInstance().getToken()
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" url = f"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
table = {
"name": "hash",
"mappings": columns
}
response = requests.post( response = requests.post(
url, url,
verify=False, verify=False,
...@@ -37,8 +17,22 @@ def add_table(use_case: str): ...@@ -37,8 +17,22 @@ def add_table(use_case: str):
json = table json = table
) )
print(url+": "+str(response.status_code)) print(url+": "+str(response.status_code)+" MSG:"+str(response.content))
def postLayersToSwagger(use_case:str, layers:dict):
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
)
def main(use_case: str): print(url+": "+str(response.status_code)+" MSG:"+str(response.content))
print("HASH") \ No newline at end of file
add_table(use_case)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment