Commit f6840670 authored by Bogdan's avatar Bogdan

Fixed Schema Mapping

parent 520f4749
......@@ -11,7 +11,7 @@ for modules_path in modules_paths:
# 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
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
......@@ -49,7 +49,9 @@ if __name__ == "__main__":
add_use_case(use_case)
add_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
# add_car.main(use_case)
# add_hash.main(use_case)
# add_offer.main(use_case)
# add_publication.main(use_case)
# add_travel.main(use_case)
\ No newline at end of file
# 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
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 "_"
'''
jwt = TokenManager.getInstance().getToken()
use_case = "car-sharing"
columns = [
......@@ -109,7 +15,7 @@ def add_table(use_case: str, table_name:str):
"colour",
"seats",
"year",
"ownerId",
"ownerID",
"deleted",
"state",
"observations"
......@@ -118,23 +24,13 @@ def add_table(use_case: str, table_name:str):
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": table_name,
"mappings": columns
}
response = requests.post(
url,
verify=False,
proxies = { "http":None, "https":None },
headers = { "Authorization": f"Bearer {jwt}"},
json = table
)
postTableToSwagger(use_case,table)
print(url+": "+str(response.status_code))
def add_layers(use_case:str, table_name: str):
layers = [
......@@ -143,13 +39,13 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "GeneralCar_layer",
"properties": [
"UniqueId",
"UniqueID",
"brand",
"model",
"colour",
"seats",
"year",
"ownerId",
"ownerID",
"deleted",
"state"
],
......@@ -159,7 +55,7 @@ def add_layers(use_case:str, table_name: str):
"model",
"seats",
"year",
"ownerId",
"ownerID",
"state"
]
},
......@@ -168,19 +64,19 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "Owner_layer",
"properties": [
"UniqueId",
"UniqueID",
"brand",
"model",
"colour",
"seats",
"year",
"ownerId",
"ownerID",
"deleted",
"state"
],
"cluster_properties": [
"OwnerId",
"UniqueId"
"OwnerID",
"UniqueID"
]
},
{
......@@ -188,13 +84,13 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "CarAge_layer",
"properties": [
"UniqueId",
"UniqueID",
"brand",
"model",
"colour",
"seats",
"year",
"ownerId",
"ownerID",
"deleted",
"state"
],
......@@ -209,13 +105,13 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "Model_layer",
"properties": [
"UniqueId",
"UniqueID",
"brand",
"model",
"colour",
"seats",
"year",
"ownerId",
"ownerID",
"deleted",
"state"
],
......@@ -231,8 +127,8 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "CarState_layer",
"properties": [
"UniqueId",
"ownerId",
"UniqueID",
"ownerID",
"deleted",
"state"
],
......@@ -243,20 +139,7 @@ def add_layers(use_case:str, table_name: str):
}
]
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))
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("CAR")
......
import network_constants as nc
from security.token_manager import TokenManager
import requests
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 "_"
'''
jwt = TokenManager.getInstance().getToken()
# TODO Manuel: check back with alex
......@@ -33,23 +29,12 @@ def add_table(use_case: str, table_name: str):
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))
postTableToSwagger(use_case,table)
def add_layers(use_case:str, table_name: str):
layers = [
......@@ -58,7 +43,7 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "document_layer",
"properties": [
"UniqueId",
"UniqueID",
"document1id",
"document1collection",
"document1hash"
......@@ -76,7 +61,7 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "connection_layer",
"properties": [
"UniqueId",
"UniqueID",
"database",
"databaseType",
"host",
......@@ -95,7 +80,7 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "connection_layer",
"properties": [
"UniqueId",
"UniqueID",
"username",
"password"
......@@ -108,20 +93,7 @@ def add_layers(use_case:str, table_name: str):
}
]
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))
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("HASH")
......
import network_constants as nc
from security.token_manager import TokenManager
import requests
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 "_"
'''
jwt = TokenManager.getInstance().getToken()
# TODO check back with alex
......@@ -33,31 +29,21 @@ def add_table(use_case: str, table_name: str):
columns = { c : c for c in columns }
columns["UniqueID"] = "id"
columns["carId"] = "car//_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"
columns["endFirstLatitude"] = "endPlace[0]//latitude"
columns["endFirstLongitude"] = "endPlace[0]//longitude"
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))
postTableToSwagger(use_case,table)
def add_layers(use_case:str, table_name: str):
layers = [
......@@ -67,7 +53,7 @@ def add_layers(use_case:str, table_name: str):
"name": "OfferStartLocation_layer",
"properties": [
"UniqueID",
"carId",
"carID",
"carOwner",
"startLatitude",
"startLongitude",
......@@ -88,7 +74,7 @@ def add_layers(use_case:str, table_name: str):
"name": "OfferEndLocation_layer",
"properties": [
"UniqueID",
"carId",
"carID",
"carOwner",
"startLatitude",
"startLongitude",
......@@ -109,12 +95,12 @@ def add_layers(use_case:str, table_name: str):
"name": "OfferedCar_layer",
"properties": [
"UniqueID",
"carId",
"carID",
"carOwner"
],
"cluster_properties": [
"carId",
"carID",
"carOwner"
]
},
......@@ -124,6 +110,7 @@ def add_layers(use_case:str, table_name: str):
"name": "OfferPrice_layer",
"properties": [
"UniqueID",
"carOwner",
"priceForKm",
"priceForTime",
"deposit"
......@@ -142,6 +129,7 @@ def add_layers(use_case:str, table_name: str):
"name": "OfferTime_layer",
"properties": [
"UniqueID",
"carOwner",
"startDate",
"endDate"
......@@ -158,6 +146,7 @@ def add_layers(use_case:str, table_name: str):
"name": "OfferStatus_layer",
"properties": [
"UniqueID",
"carOwner",
"available",
"deleted"
......@@ -170,20 +159,7 @@ def add_layers(use_case:str, table_name: str):
}
]
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))
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("OFFER")
......
import network_constants as nc
from security.token_manager import TokenManager
import requests
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 "_"
'''
jwt = TokenManager.getInstance().getToken()
use_case = "car-sharing"
columns = [
# "doctype",
"id"
"text"
"id",
"text",
#"media"
#"location"
"user"
"date"
"user",
"date",
#"likesUsers"
#"reportedBy"
"deleted"
"deleted",
"answerTo"
]
......@@ -35,50 +31,21 @@ def add_table(use_case: str, table_name: str):
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))
postTableToSwagger(use_case,table)
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",
"UniqueID",
"user",
"latitude",
"longitude"
......@@ -94,7 +61,7 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "PublicationTime_layer",
"properties": [
"UniqueId",
"UniqueID",
"user",
"latitude",
"longitude"
......@@ -109,7 +76,7 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "PublicationUser_layer",
"properties": [
"UniqueId",
"UniqueID",
"text",
"user",
"mediaUrlFirst",
......@@ -126,34 +93,21 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "PublicationStatus_layer",
"properties": [
"UniqueId",
"UniqueID",
"text",
"user",
"status",
"deleted",
"answerTo"
],
"cluster_properties": [
"status",
"deleted",
"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))
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("PUBLICATION")
......
import network_constants as nc
from security.token_manager import TokenManager
import requests
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 "_"
'''
jwt = TokenManager.getInstance().getToken()
# TODO disscuss with others if it looks ok
......@@ -42,7 +38,7 @@ def add_table(use_case: str, table_name: str):
columns = { c : c for c in columns }
columns["UniqueID"] = "id"
columns["user1Id"] = "users[0]//userId"
columns["user1ID"] = "users[0]//userId"
columns["user1PassengersNr"] = "users[0]//passengers"
columns["isDriver"] = "users[0]//isDriver"
columns["startPlaceLatitude"] = "startPlace//Latitude"
......@@ -64,39 +60,29 @@ def add_table(use_case: str, table_name: str):
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))
postTableToSwagger(use_case,table)
def add_layers(use_case:str, table_name: str):
layers = [
{
"use_case": use_case,
"table": table_name,
"name": "User_Layer",
"name": "TravelUser_Layer",
"properties": [
'UniqueID',
'user1Id',
'user1ID',
'isDriver',
'score1User',
'score1Rating',
'startedBy1User'
],
"cluster_properties": [
'user1Id'
'user1ID'
]
},
{
......@@ -104,7 +90,7 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "StartingPoint_Layer",
"properties": [
'user1Id',
'user1ID',
'UniqueID',
'startPlaceLatitude',
'startPlaceLongitude',
......@@ -120,7 +106,7 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "StartingTime_Layer",
"properties": [
'user1Id',
'user1ID',
'UniqueID',
'startDate',
'endDate',
......@@ -136,7 +122,7 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "Destination_Layer",
"properties": [
'user1Id',
'user1ID',
'UniqueID',
'endPlace1Latitude',
'endPlace1Longitude',
......@@ -153,7 +139,7 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "FinishedTime_Layer",
"properties": [
'user1Id',
'user1ID',
'UniqueID',
'startDate',
'endDate',
......@@ -169,7 +155,7 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "Price_Layer",
"properties": [
'user1Id',
'user1ID',
'UniqueID',
'totalPrice',
'kmTraveled',
......@@ -191,10 +177,11 @@ def add_layers(use_case:str, table_name: str):
"name": "Status_Layer",
"properties": [
'UniqueID',
'user1Id',
'user1ID',
'status',
'score1User',
'score1Rating'
'score1Rating',
'rentForTime'
],
"cluster_properties": [
'status',
......@@ -204,20 +191,7 @@ def add_layers(use_case:str, table_name: str):
}
]
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))
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("TRAVEL")
......
......@@ -15,12 +15,12 @@ def add_table(use_case: str, table_name: str):
"id", # pk
"balance",
"payerId",
"numberOfTrips",
"numberOfTripsDone",
"sumOfTripsScores"
]
columns = { c : c for c in columns }
columns["UniqueId"] = "id"
columns["UniqueID"] = "id"
table = {
"name": table_name,
......@@ -37,16 +37,16 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "User_layer",
"properties": [
"UniqueId",
"UniqueID",
"balance",
"payerId",
"numberOfTrips",
"numberOfTripsDone",
"sumOfTripsScores"
],
"cluster_properties": [
"balance",
"numberOfTrips",
"numberOfTripsDone",
"sumOfTripsScores"
]
},
......@@ -55,10 +55,10 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "UserBalance_layer",
"properties": [
"UniqueId",
"UniqueID",
"balance",
"payerId",
"numberOfTrips",
"numberOfTripsDone",
"sumOfTripsScores"
],
......@@ -72,15 +72,15 @@ def add_layers(use_case:str, table_name: str):
"table": table_name,
"name": "UserVeterancy_layer",
"properties": [
"UniqueId",
"UniqueID",
"balance",
"payerId",
"numberOfTrips",
"numberOfTripsDone",
"sumOfTripsScores"
],
"cluster_properties": [
"numberOfTrips",
"numberOfTripsDone",
"sumOfTripsScores"
]
}
......
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