Commit 520f4749 authored by Bogdan's avatar Bogdan

progress on Car-sharing Mapping2

parent b4d3f717
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:
if os.path.exists(modules_path):
sys.path.insert(1, 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_user, add_car, add_hash
# 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,8 @@ if __name__ == "__main__": ...@@ -42,8 +48,8 @@ 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) #car.main(use_case)
offer.main(use_case) #offer.main(use_case)
travel.main(use_case) #travel.main(use_case)
add_hash.main(use_case) #add_hash.main(use_case)
\ No newline at end of file \ 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
...@@ -93,7 +93,7 @@ from security.token_manager import TokenManager ...@@ -93,7 +93,7 @@ from security.token_manager import TokenManager
import requests import requests
def add_table(use_case: str): def add_table(use_case: str, table_name:str):
''' '''
take the columns and add the mappings at the server take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_" replace all "/"'s in the internal representation with a "_"
...@@ -118,10 +118,11 @@ def add_table(use_case: str): ...@@ -118,10 +118,11 @@ def add_table(use_case: str):
columns = { c : c for c in columns } columns = { c : c for c in columns }
columns["UniqueID"] = "carLicensePlate" columns["UniqueID"] = "carLicensePlate"
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 = { table = {
"name": "car", "name": table_name,
"mappings": columns "mappings": columns
} }
...@@ -135,6 +136,130 @@ def add_table(use_case: str): ...@@ -135,6 +136,130 @@ def add_table(use_case: str):
print(url+": "+str(response.status_code)) print(url+": "+str(response.status_code))
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": [
#TODO discuss with others
"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": [
#TODO discuss with others
"year",
"state"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "Model_layer",
"properties": [
"UniqueId",
"brand",
"model",
"colour",
"seats",
"year",
"ownerId",
"deleted",
"state"
],
"cluster_properties": [
#TODO discuss with others
"brand",
"model",
"seats"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "CarState_layer",
"properties": [
"UniqueId",
"ownerId",
"deleted",
"state"
],
"cluster_properties": [
"deleted",
"state"
]
}
]
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): def main(use_case: str):
print("CAR") print("CAR")
add_table(use_case) table_name = "car"
\ No newline at end of file add_table(use_case,table_name)
add_layers(use_case, table_name)
\ 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, 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()
# TODO Manuel: check back with alex
use_case = "car-sharing"
columns = [
# "docType",
"documents",
"connection"
]
columns = { c : c for c in columns }
columns["UniqueID"] = "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"
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": "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",
"database",
"databaseType",
"host",
"port"
],
"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"
]
}
]
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("HASH")
table_name = "hash"
add_table(use_case,table_name)
add_layers(use_case,table_name)
\ 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, 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()
# 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//_id"
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["endLatitudeFirst"] = "endPlace[0]//latitude"
columns["endLongitudeFirst"] = "endPlace[0]//longitude"
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": "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",
"priceForKm",
"priceForTime",
"deposit"
],
"cluster_properties": [
"carOwner",
"priceForKm",
"priceForTime",
"deposit"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "OfferTime_layer",
"properties": [
"UniqueID",
"startDate",
"endDate"
],
"cluster_properties": [
"carOwner",
"startDate",
"endDate"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "OfferStatus_layer",
"properties": [
"UniqueID",
"available",
"deleted"
],
"cluster_properties": [
"carOwner",
"available",
"deleted"
]
}
]
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("OFFER")
table_name = "offer"
add_table(use_case,table_name)
add_layers(use_case,table_name)
\ 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, 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()
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?
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": "PublicationGeneral_layer",
"properties": [
"UniqueId",
"text",
"user",
"mediaUrlFirst",
"mediaTypeFirst",
"mediaLabelsFirst",
"latitude",
"longitude"
],
"cluster_properties": [
#TODO What to add?
]
},
{
"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",
"status",
"answerTo"
],
"cluster_properties": [
"status",
"answerTo"
]
}
]
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("PUBLICATION")
table_name = "publication"
add_table(use_case,table_name)
add_layers(use_case, table_name)
\ 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, 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()
# 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//Latitude"
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["endPlace1User"] = "endPlace[0]//user"
columns["endPlace1Moment"] = "endPlace[0]//moment"
columns["endPlace1Latitude"] = "endPlace[0]//coordinate//latitude"
columns["endPlace1Longitude"] = "endPlace[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?
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": "User_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',
'endPlace1Moment',
'startedBy1Moment'
],
"cluster_properties": [
'startedBy1Moment',
'startDate'
]
},{
"use_case": use_case,
"table": table_name,
"name": "Destination_Layer",
"properties": [
'user1Id',
'UniqueID',
'endPlace1Latitude',
'endPlace1Longitude',
'kmTraveled',
'startPlaceLatitude',
'startPlaceLongitude',
],
"cluster_properties": [
'endPlace1Latitude',
'endPlace1Longitude'
]
},{
"use_case": use_case,
"table": table_name,
"name": "FinishedTime_Layer",
"properties": [
'user1Id',
'UniqueID',
'startDate',
'endDate',
'endPlace1Moment',
'startedBy1Moment'
],
"cluster_properties": [
'endDate',
'endPlace1Moment'
]
},{
"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'
],
"cluster_properties": [
'status',
'score1Rating',
'rentForTime'
]
}
]
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("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",
"numberOfTrips",
"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",
"numberOfTrips",
"sumOfTripsScores"
],
"cluster_properties": [
"balance",
"numberOfTrips",
"sumOfTripsScores"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "UserBalance_layer",
"properties": [
"UniqueId",
"balance",
"payerId",
"numberOfTrips",
"sumOfTripsScores"
],
"cluster_properties": [
"balance",
"sumOfTripsScores"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "UserVeterancy_layer",
"properties": [
"UniqueId",
"balance",
"payerId",
"numberOfTrips",
"sumOfTripsScores"
],
"cluster_properties": [
"numberOfTrips",
"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() jwt = TokenManager.getInstance().getToken()
# TODO check back with alex url = f"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
use_case = "car-sharing" response = requests.post(
columns = [ url,
# "docType", verify=False,
"documents", proxies = { "http":None, "https":None },
"connection" headers = { "Authorization": f"Bearer {jwt}"},
] json = table
)
columns = { c : c for c in columns } print(url+": "+str(response.status_code)+" MSG:"+str(response.content))
columns["UniqueID"] = "id"
url = f"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
table = { def postLayersToSwagger(use_case:str, layers:dict):
"name": "hash",
"mappings": columns jwt = TokenManager.getInstance().getToken()
}
for layer in layers:
url = f"https://articonf1.itec.aau.at:30420/api/layers"
response = requests.post( response = requests.post(
url, url,
verify=False, verify=False,
proxies = { "http":None, "https":None }, proxies = { "http":None, "https":None },
headers = { "Authorization": f"Bearer {jwt}"}, headers = { "Authorization": f"Bearer {jwt}"},
json = table json = layer
) )
print(url+": "+str(response.status_code)) print(url+": "+str(response.status_code)+" MSG:"+str(response.content))
\ No newline at end of file
def main(use_case: str):
print("HASH")
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