Example #1
0
def bkpfGetDfg():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    db_type = parameters["db_type"] if "db_type" in parameters else "sqlite"
    db_con_args = parameters[
        "db_con_args"] if "db_con_args" in parameters else {
            "path": "sap.sqlite"
        }

    c = database_factory.apply(db_type, db_con_args)
    from sapextractor.algo.ap_ar import graph_retrieval_util
    dfg, act_count, sa, ea = graph_retrieval_util.extract_dfg_apar(c)
    dfg, sa, ea, act_count = dfg_filtering.filter_dfg_on_paths_percentage(
        dfg, sa, ea, act_count, 0.2, keep_all_activities=False)
    gviz = pm4py.visualization.dfg.visualizer.apply(dfg,
                                                    activities_count=act_count,
                                                    parameters={
                                                        "format": "svg",
                                                        "start_activities": sa,
                                                        "end_activities": ea
                                                    })
    ser = pm4py.visualization.dfg.visualizer.serialize(gviz).decode("utf-8")
    dfg = sorted([[x[0], x[1], y] for x, y in dfg.items()],
                 key=lambda x: x[1],
                 reverse=True)
    act_count = sorted([(x, y) for x, y in act_count.items()],
                       key=lambda x: x[1],
                       reverse=True)

    return jsonify({"dfg": dfg, "act_count": act_count, "ser": ser})
Example #2
0
def checkConnection():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    db_type = parameters["db_type"] if "db_type" in parameters else "sqlite"
    db_con_args = parameters[
        "db_con_args"] if "db_con_args" in parameters else {
            "path": "sap.sqlite"
        }

    c = database_factory.apply(db_type, db_con_args)
    return "yes"
Example #3
0
def p2pClientTable():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    db_type = parameters["db_type"] if "db_type" in parameters else "sqlite"
    db_con_args = parameters[
        "db_con_args"] if "db_con_args" in parameters else {
            "path": "sap.sqlite"
        }

    c = database_factory.apply(db_type, db_con_args)
    from sapextractor.algo.p2p import freq_doc_types
    return {"res": freq_doc_types.apply(c)}
Example #4
0
def getMainObjectClasses():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    db_type = parameters["db_type"] if "db_type" in parameters else "sqlite"
    db_con_args = parameters[
        "db_con_args"] if "db_con_args" in parameters else {
            "path": "sap.sqlite"
        }
    mandt = parameters["mandt"]

    c = database_factory.apply(db_type, db_con_args)
    from sapextractor.utils.objclass_to_tables import get
    return get.apply(c, mandt)
Example #5
0
def getTableCount():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    db_type = parameters["db_type"] if "db_type" in parameters else "sqlite"
    db_con_args = parameters[
        "db_con_args"] if "db_con_args" in parameters else {
            "path": "sap.sqlite"
        }
    table = parameters["table"]

    c = database_factory.apply(db_type, db_con_args)
    from sapextractor.utils.table_count import get
    return {"count": get.apply(c, table)}
Example #6
0
def expandTable():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    db_type = parameters["db_type"] if "db_type" in parameters else "sqlite"
    db_con_args = parameters[
        "db_con_args"] if "db_con_args" in parameters else {
            "path": "sap.sqlite"
        }
    table = parameters["table"]

    c = database_factory.apply(db_type, db_con_args)
    from sapextractor.utils.table_expansion import expand
    return {"expanded_tables": sorted(list(expand.expand(c, table)))}
Example #7
0
def getPrimaryKeys():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    db_type = parameters["db_type"] if "db_type" in parameters else "sqlite"
    db_con_args = parameters[
        "db_con_args"] if "db_con_args" in parameters else {
            "path": "sap.sqlite"
        }
    tabnames = parameters["tabnames"]

    c = database_factory.apply(db_type, db_con_args)
    from sapextractor.utils.preprocessing_fields import get_fields
    return {"primary_keys": get_fields.apply(c, tabnames)}
Example #8
0
def vbfaChangeActivityUtil():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    db_type = parameters["db_type"] if "db_type" in parameters else "sqlite"
    db_con_args = parameters[
        "db_con_args"] if "db_con_args" in parameters else {
            "path": "sap.sqlite"
        }

    c = database_factory.apply(db_type, db_con_args)
    from sapextractor.algo.o2c import change_activities_util
    changes_count = change_activities_util.extract(c)

    return jsonify({"changes_count": changes_count})
Example #9
0
def getMainTablesPerObjectClass():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    db_type = parameters["db_type"] if "db_type" in parameters else "sqlite"
    db_con_args = parameters[
        "db_con_args"] if "db_con_args" in parameters else {
            "path": "sap.sqlite"
        }
    mandt = parameters["mandt"]
    objectclass = parameters["objectclass"]

    c = database_factory.apply(db_type, db_con_args)
    from sapextractor.utils.objclass_to_tables import convert
    return {"obj_class_tables": list(convert.apply(c, objectclass, mandt))}
Example #10
0
def expandTables():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    db_type = parameters["db_type"] if "db_type" in parameters else "sqlite"
    db_con_args = parameters[
        "db_con_args"] if "db_con_args" in parameters else {
            "path": "sap.sqlite"
        }
    tabnames = parameters["tabnames"]

    c = database_factory.apply(db_type, db_con_args)
    from sapextractor.utils.table_expansion import expand
    from sapextractor.utils.table_fields import extract_fields
    from sapextractor.utils.dbstattora import extract_count
    dbstattora = extract_count.apply_static(c)
    tables = expand.expand_set(c, tabnames)
    tables_count = {}
    for x in tables:
        extract_fields.apply_static(c, x)
        tables_count[x] = dbstattora[x] if x in dbstattora else 1

    edges = expand.extract_expansion_graph(c, tables)

    for x in tables:
        extract_fields.apply_static(c, x)
        tables_count[x] = dbstattora[x] if x in dbstattora else 1

    ret = {
        "expanded_tables": sorted(list(tables)),
        "types":
        {x: extract_fields.classify_table(c, x, tables)
         for x in tables},
        "tables_count": tables_count,
        "initial_tabnames": tabnames,
        "edges": edges
    }
    print(ret)
    return ret
Example #11
0
def newExtractorPerformExtraction():
    parameters = request.args.get("parameters")
    parameters = __process_parameters(parameters)

    db_type = parameters["db_type"] if "db_type" in parameters else "sqlite"
    db_con_args = parameters[
        "db_con_args"] if "db_con_args" in parameters else {
            "path": "sap.sqlite"
        }
    tabnames = parameters["tabnames"]
    key_spec = parameters["key_spec"]
    mandt = parameters["mandt"]

    c = database_factory.apply(db_type, db_con_args)
    from sapextractor.utils.generic_extractors import extract_table
    file_name = str(uuid.uuid4()) + ".parquet"
    df = extract_table.apply_set_tables(c, tabnames, mandt=mandt)

    from pm4pymdl.objects.mdl.exporter import exporter
    exporter.apply(df, file_name)

    obj_types = [x for x in df.columns if not x.startswith("event_")]
    return {"file_name": file_name, "obj_types": obj_types}
Example #12
0
def apply(db_type, db_con_arg, process, ext_type, ext_arg):
    con = conn_factory.apply(db_type, db_con_arg)
    return algo_factory.apply(con, process, ext_type, ext_arg)