from _add_use_case_scripts.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 "_"
    '''

    columns = [
        # "docType",
        "objecttype",
        "userid",
        "videoid",
        "informative",
        "impact",
        "trustiness",
        "lastupdate"
    ]
    
    columns = { c : c for c in columns }
    columns["UniqueID"] = "userid+videoid"

    table = {
        "name": table_name,
        "mappings": columns
    }

    postTableToSwagger(use_case,table)

def add_layers(use_case:str, table_name: str):
    layers = [
        {   #Useless as all objects aree Classification?
            "use_case": use_case,
            "table": table_name,
            "name": "Object_Type_Layer",
            "properties": [
                "UniqueID",
                "objecttype",
                "userid",
                "videoid",
                "informative",
                "impact",
                "trustiness",
                "lastupdate"
            ],
            "cluster_properties": [
                "objecttype"
            ]
        },
        {
            "use_case": use_case,
            "table": table_name,
            "name": "Informative_Layer",
            "properties": [
                "UniqueID",
                "objecttype",
                "userid",
                "videoid",
                "informative",
                "impact",
                "trustiness",
                "lastupdate"
            ],
            "cluster_properties": [
                "informative"
            ]
        },
        {
            "use_case": use_case,
            "table": table_name,
            "name": "Impact_Layer",
            "properties": [
                "UniqueID",
                "objecttype",
                "userid",
                "videoid",
                "informative",
                "impact",
                "trustiness",
                "lastupdate"
            ],
            "cluster_properties": [
                "impact"
            ]
        },
        {
            "use_case": use_case,
            "table": table_name,
            "name": "Trust_Layer",
            "properties": [
                "UniqueID",
                "objecttype",
                "userid",
                "videoid",
                "informative",
                "impact",
                "trustiness",
                "lastupdate"
            ],
            "cluster_properties": [
                "trustiness"
            ]
        }
    ]

    postLayersToSwagger(use_case,layers)    

def main(use_case: str):
    print("Classification")
    table_name = "classification"
    add_table(use_case,table_name)
    add_layers(use_case,table_name)