def Main():
    cgiEnv = lib_oracle.OracleEnv()

    # BEWARE: There is an implicit dependency on the structure of Oracle schema URI.
    ora_schema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'PACKAGE' AND OWNER = '" + ora_schema + "'"
    logging.debug("sql_query=%s", sql_query)

    node_oraschema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, ora_schema)

    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        package_name = str(row[0])
        node_package = oracle_package.MakeUri(cgiEnv.m_oraDatabase, ora_schema,
                                              package_name)
        grph.add((node_oraschema, pc.property_oracle_package, node_package))

        lib_oracle.AddLiteralNotNone(grph, node_package, "Status", row[1])
        lib_oracle.AddLiteralNotNone(grph, node_package, "Creation", row[2])

    # It cannot work if there are too many tables.
    # cgiEnv.OutCgiRdf("LAYOUT_RECT")
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_package])
Example #2
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraPackage = cgiEnv.m_entity_id_dict["Package"]
    oraSchema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    node_oraPackage = oracle_package.MakeUri(cgiEnv.m_oraDatabase, oraSchema,
                                             oraPackage)

    node_oraSchema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, oraSchema)
    grph.add((node_oraSchema, pc.property_oracle_package, node_oraPackage))

    # TODO: This is problematic as these could also be functions.
    # TODO: But when joining with ALL_OBJECTS, most rows are gone. So what to do ?
    sql_query = "select distinct procedure_name from all_procedures where object_type='PACKAGE' " \
       "and owner='" + oraSchema + "' and object_name='" + oraPackage + "'"
    DEBUG("sql_query=%s", sql_query)
    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    propProcToPackage = lib_common.MakeProp("Package")
    for row in result:
        procedureName = row[0]
        procedureNode = oracle_procedure.MakeUri(cgiEnv.m_oraDatabase,
                                                 oraSchema, procedureName)
        grph.add((node_oraPackage, propProcToPackage, procedureNode))

    cgiEnv.OutCgiRdf("LAYOUT_SPLINE", [propProcToPackage])
Example #3
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraPackage = cgiEnv.m_entity_id_dict["Package"]
    oraSchema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    node_oraPackage = oracle_package.MakeUri(cgiEnv.m_oraDatabase, oraSchema,
                                             oraPackage)

    node_oraSchema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, oraSchema)
    grph.add((node_oraSchema, pc.property_oracle_package, node_oraPackage))

    # TYPE = "VIEW", "TABLE", "PACKAGE BODY"
    sql_query = "select owner,name,type from dba_dependencies where REFERENCED_TYPE = 'PACKAGE' AND REFERENCED_NAME = '"\
       + oraPackage + "' and referenced_owner='" + oraSchema + "'"
    DEBUG("sql_query=%s", sql_query)
    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        lib_oracle.AddDependency(grph, row, node_oraPackage,
                                 cgiEnv.m_oraDatabase, True)

    sql_query_inv = "select referenced_owner,referenced_name,referenced_type from dba_dependencies where type='PACKAGE' and NAME = '"\
        + oraPackage + "' and OWNER='" + oraSchema + "'"
    DEBUG("sql_query_inv=%s", sql_query_inv)
    result_inv = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query_inv)

    for row in result_inv:
        lib_oracle.AddDependency(grph, row, node_oraPackage,
                                 cgiEnv.m_oraDatabase, False)

    cgiEnv.OutCgiRdf("LAYOUT_SPLINE")
Example #4
0
def AddInfo(grph, node, entity_ids_arr):
    arg_db = entity_ids_arr[0]
    arg_schema = entity_ids_arr[1]
    arg_package_body = entity_ids_arr[2]

    node_package = oracle_package.MakeUri(arg_db, arg_schema, arg_package_body)
    grph.add((node, lib_common.MakeProp("Associated package"), node_package))

    node_oraschema = oracle_schema.MakeUri(arg_db, arg_schema)
    grph.add((node_oraschema, pc.property_oracle_package, node))
Example #5
0
def AddDependency(grph, row, nodeRoot, oraDatabase, direction):
    depOwner = str(row[0])
    depName = str(row[1])
    depType = str(row[2])

    if depType == "TABLE":
        nodeObject = oracle_table.MakeUri(oraDatabase, depOwner, depName)
    elif depType == "VIEW":
        nodeObject = oracle_view.MakeUri(oraDatabase, depOwner, depName)
    elif depType == "PACKAGE":
        nodeObject = oracle_package.MakeUri(oraDatabase, depOwner, depName)
    elif depType == "PACKAGE BODY":
        nodeObject = oracle_package_body.MakeUri(oraDatabase, depOwner,
                                                 depName)
    elif depType == "SYNONYM":
        nodeObject = oracle_synonym.MakeUri(oraDatabase, depOwner, depName)
    elif depType == "TYPE":
        nodeObject = oracle_type.MakeUri(oraDatabase, depOwner, depName)
    elif depType == "SEQUENCE":
        nodeObject = oracle_sequence.MakeUri(oraDatabase, depOwner, depName)
    elif depType == "LIBRARY":
        nodeObject = oracle_library.MakeUri(oraDatabase, depOwner, depName)
    elif depType == "PROCEDURE":
        nodeObject = oracle_procedure.MakeUri(oraDatabase, depOwner, depName)
    elif depType == "FUNCTION":
        nodeObject = oracle_function.MakeUri(oraDatabase, depOwner, depName)
    elif depType == "TRIGGER":
        nodeObject = oracle_trigger.MakeUri(oraDatabase, depOwner, depName)
    else:
        lib_common.ErrorMessageHtml(
            "Unknown dependency depType=%s depName=%s" % (depType, depName))
        return

    if direction == True:
        grph.add((nodeRoot, pc.property_oracle_depends, nodeObject))
    else:
        grph.add((nodeObject, pc.property_oracle_depends, nodeRoot))