Esempio n. 1
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraView = cgiEnv.m_entity_id_dict["View"]
    oraSchema = cgiEnv.m_entity_id_dict["Schema"]
    oraDatabase = cgiEnv.m_entity_id_dict["Db"]

    grph = cgiEnv.GetGraph()

    node_oraView = oracle_view.MakeUri(oraDatabase, oraSchema, oraView)

    node_oraSchema = oracle_schema.MakeUri(oraDatabase, oraSchema)
    grph.add((node_oraSchema, pc.property_oracle_view, node_oraView))

    # TYPE = "VIEW", "TABLE", "PACKAGE BODY"
    sql_query = "select owner,name,type from all_dependencies where REFERENCED_TYPE = 'VIEW' AND REFERENCED_NAME = '" + oraView + "' and referenced_owner='" + oraSchema + "'"
    sys.stderr.write("sql_query=%s\n" % sql_query)
    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        lib_oracle.AddDependency(grph, row, node_oraView, oraDatabase, True)

    sql_query_inv = "select referenced_owner,referenced_name,referenced_type from all_dependencies where type='VIEW' and NAME = '" + oraView + "' and OWNER='" + oraSchema + "'"
    sys.stderr.write("sql_query_inv=%s\n" % sql_query_inv)
    result_inv = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query_inv)

    for row in result_inv:
        lib_oracle.AddDependency(grph, row, node_oraView, oraDatabase, False)

    cgiEnv.OutCgiRdf("LAYOUT_RECT")
Esempio n. 2
0
def Main():
	cgiEnv = lib_oracle.OracleEnv()

	oraPackageBody = cgiEnv.m_entity_id_dict["PackageBody"]
	oraSchema = cgiEnv.m_entity_id_dict["Schema"]

	grph = cgiEnv.GetGraph()

	node_oraPackageBody = oracle_package_body.MakeUri( cgiEnv.m_oraDatabase, oraSchema, oraPackageBody )

	node_oraSchema = oracle_schema.MakeUri( cgiEnv.m_oraDatabase, oraSchema )
	grph.add( ( node_oraSchema, pc.property_oracle_package_body, node_oraPackageBody ) )

	# TYPE = "VIEW", "TABLE", "PACKAGE BODY"
	sql_query = "select owner,name,type from all_dependencies where REFERENCED_TYPE = 'PACKAGE BODY' AND REFERENCED_NAME = '"\
				+ oraPackageBody + "' 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_oraPackageBody, cgiEnv.m_oraDatabase, True )

	sql_query_inv = "select referenced_owner,referenced_name,referenced_type from all_dependencies where type='PACKAGE BODY' and NAME = '"\
					+ oraPackageBody + "' 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_oraPackageBody, cgiEnv.m_oraDatabase, False )

	cgiEnv.OutCgiRdf("LAYOUT_SPLINE")
Esempio n. 3
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraSchema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'PACKAGE BODY' AND OWNER = '" + oraSchema + "'"
    DEBUG("sql_query=%s", sql_query)

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

    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)
    num_package_bodies = len(result)
    DEBUG("num_package_bodies=%d", num_package_bodies)

    for row in result:
        packageBodyName = str(row[0])
        # sys.stderr.write("tableName=%s\n" % tableName )
        nodePackageBody = oracle_package_body.MakeUri(cgiEnv.m_oraDatabase,
                                                      oraSchema,
                                                      packageBodyName)
        grph.add(
            (node_oraschema, pc.property_oracle_package_body, nodePackageBody))

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

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

    ora_table = cgiEnv.m_entity_id_dict["Table"]
    ora_schema = cgiEnv.m_entity_id_dict["Schema"]
    ora_database = cgiEnv.m_entity_id_dict["Db"]

    grph = cgiEnv.GetGraph()

    # TYPE = "VIEW", "TABLE", "PACKAGE BODY" etc...
    sql_query = "select owner,name,type from all_dependencies where REFERENCED_TYPE = 'TABLE' AND REFERENCED_NAME = '" \
                + ora_table + "' and referenced_owner='" + ora_schema + "'"

    logging.debug("sql_query=%s", sql_query)

    node_ora_table = oracle_table.MakeUri(ora_database, ora_schema, ora_table)

    node_ora_schema = oracle_schema.MakeUri(ora_database, ora_schema)
    grph.add((node_ora_schema, pc.property_oracle_table, node_ora_table))

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

    for row in result:
        lib_oracle.AddDependency(grph, row, node_ora_table, ora_database, True)

    cgiEnv.OutCgiRdf("LAYOUT_RECT")
Esempio n. 5
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraSchema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'VIEW' AND OWNER = '" + oraSchema + "'"
    DEBUG("sql_query=%s", sql_query)

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

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

    for row in result:
        viewName = str(row[0])
        nodeView = oracle_view.MakeUri(cgiEnv.m_oraDatabase, oraSchema,
                                       viewName)
        grph.add((node_oraschema, pc.property_oracle_view, nodeView))

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

    # It cannot work if there are too many views.
    # cgiEnv.OutCgiRdf("LAYOUT_RECT")
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_view])
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    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 BODY' 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)
    num_package_bodies = len(result)
    logging.debug("num_package_bodies=%d", num_package_bodies)

    for row in result:
        package_body_name = str(row[0])
        node_package_body = oracle_package_body.MakeUri(
            cgiEnv.m_oraDatabase, ora_schema, package_body_name)
        grph.add((node_oraschema, pc.property_oracle_package_body,
                  node_package_body))

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

    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_package_body])
Esempio n. 7
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraSchema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'TABLE' AND OWNER = '" + oraSchema + "'"
    sys.stderr.write("sql_query=%s\n" % sql_query)

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

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

    for row in result:
        tableName = str(row[0])
        # sys.stderr.write("tableName=%s\n" % tableName )
        nodeTable = oracle_table.MakeUri(cgiEnv.m_oraDatabase, oraSchema,
                                         tableName)
        grph.add((node_oraschema, pc.property_oracle_table, nodeTable))

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

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

    ora_schema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'TYPE' 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:
        type_name = str(row[0])
        node_type = oracle_type.MakeUri(cgiEnv.m_oraDatabase, ora_schema,
                                        type_name)
        grph.add((node_oraschema, pc.property_oracle_type, node_type))

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

    # Display in lines.
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_type])
Esempio n. 9
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])
Esempio n. 10
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    ora_schema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'SEQUENCE' 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:
        sequence_name = str(row[0])
        node_sequence = oracle_sequence.MakeUri(cgiEnv.m_oraDatabase,
                                                ora_schema, sequence_name)
        grph.add((node_oraschema, pc.property_oracle_sequence, node_sequence))

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

    # "Collapsing", clustering nodes is needed if there are many objects.
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_sequence])
Esempio n. 11
0
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])
Esempio n. 12
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()
    oraSession = cgiEnv.m_entity_id_dict["Session"]
    grph = cgiEnv.GetGraph()
    node_oraSession = oracle_session.MakeUri(cgiEnv.m_oraDatabase, oraSession)

    # TYPE = "VIEW", "TABLE", "PACKAGE BODY"
    sql_query = "select SID,STATUS,USERNAME,SERVER,SCHEMANAME,COMMAND,MACHINE,PORT,OSUSER,PROCESS,SERVICE_NAME,ACTION from V$SESSION where SID='%s'" % oraSession
    sys.stderr.write("sql_query=%s\n" % sql_query)
    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    # There should be only one.
    for row in result:
        sys.stderr.write("SID=%s\n" % row[0])

        grph.add((node_oraSession, lib_common.MakeProp("Status"),
                  lib_common.NodeLiteral(row[1])))
        grph.add((node_oraSession, lib_common.MakeProp("Username"),
                  lib_common.NodeLiteral(row[2])))
        grph.add((node_oraSession, lib_common.MakeProp("Server"),
                  lib_common.NodeLiteral(row[3])))

        # grph.add( ( node_oraSession, lib_common.MakeProp("Schema"), lib_common.NodeLiteral(row[4]) ) )
        nodeSchema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, str(row[4]))
        grph.add((node_oraSession, pc.property_oracle_schema, nodeSchema))

        grph.add((node_oraSession, lib_common.MakeProp("Command"),
                  lib_common.NodeLiteral(row[5])))

        # This returns an IP address from "WORKGROUP\RCHATEAU-HP"
        user_machine = lib_oracle.OraMachineToIp(row[6])
        nodeMachine = lib_common.gUriGen.HostnameUri(user_machine)
        grph.add((nodeMachine, pc.property_information,
                  lib_common.NodeLiteral(row[6])))

        grph.add((node_oraSession, lib_common.MakeProp("Port"),
                  lib_common.NodeLiteral(row[7])))
        grph.add((node_oraSession, lib_common.MakeProp("OsUser"),
                  lib_common.NodeLiteral(row[8])))
        # grph.add( ( node_oraSession, lib_common.MakeProp("Process"), lib_common.NodeLiteral(row[9]) ) )
        sessPidTid = row[9]  # 7120:4784
        sessPid = sessPidTid.split(":")[0]
        node_process = lib_common.RemoteBox(user_machine).PidUri(sessPid)
        grph.add((node_process, lib_common.MakeProp("Pid"),
                  lib_common.NodeLiteral(sessPid)))
        grph.add((node_oraSession, pc.property_oracle_session, node_process))

        grph.add(
            (node_oraSession, lib_common.MakeProp("Hostname"), nodeMachine))

        grph.add((node_oraSession, lib_common.MakeProp("ServiceName"),
                  lib_common.NodeLiteral(row[10])))
        grph.add((node_oraSession, lib_common.MakeProp("Action"),
                  lib_common.NodeLiteral(row[11])))

    cgiEnv.OutCgiRdf("LAYOUT_RECT")
Esempio n. 13
0
def Main():
	cgiEnv = lib_oracle.OracleEnv()

	oraSchema = cgiEnv.m_entity_id_dict["Schema"]

	grph = cgiEnv.GetGraph()

	sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'PROCEDURE' AND OWNER = '" + oraSchema + "'"
	DEBUG("sql_query=%s", sql_query )

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

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

	for row in result:
		procedureName = str(row[0])
		nodeProcedure = oracle_procedure.MakeUri( cgiEnv.m_oraDatabase , oraSchema, procedureName )
		grph.add( ( node_oraschema, pc.property_oracle_procedure, nodeProcedure ) )

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

	cgiEnv.OutCgiRdf("LAYOUT_RECT",[pc.property_oracle_procedure])
Esempio n. 14
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraSchema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'FUNCTION' AND OWNER = '" + oraSchema + "'"
    sys.stderr.write("sql_query=%s\n" % sql_query)

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

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

    for row in result:
        functionName = str(row[0])
        nodeFunction = oracle_function.MakeUri(cgiEnv.m_oraDatabase, oraSchema,
                                               functionName)
        grph.add((node_oraschema, pc.property_oracle_function, nodeFunction))

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

    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_function])