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")
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 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))