def delete_biana_database(dbname, dbhost, dbuser, dbpassword, dbport=None): """ Deletes the specified BIANA database. ALERT!!! This action is not reversible! All data in BIANA database will be deleted permanently! "dbname": BIANA database name "dbhost" is the machine with the mysql server that holds the biana database (required) "dbuser" is the mysql user (not required in most systems) "dbpassword" is the mysql password (not required in most systems) "dbport" is the mysql port (not required in most systems) """ import BianaDB try: dbaccess = BianaDB.BianaDBaccess(dbhost=dbhost, dbuser=dbuser, dbpassword=dbpassword, dbport=dbport) dbaccess.db.insert_db_content( sql_query="DROP DATABASE IF EXISTS %s" % dbname) dbaccess.close() OutBianaInterface.send_data( "<biana_database_deleted dbname=\"%s\" dbhost=\"%s\"/>" % (dbname, dbhost)) except: OutBianaInterface.send_error_notification( "Error while deleting database %s at %s" % (dbname, dbhost), "ERROR MESSAGE") # TO CHECK ERROR MESSAGE return
def delete_biana_database(dbname,dbhost,dbuser,dbpassword,dbport=None): """ Deletes the specified BIANA database. ALERT!!! This action is not reversible! All data in BIANA database will be deleted permanently! "dbname": BIANA database name "dbhost" is the machine with the mysql server that holds the biana database (required) "dbuser" is the mysql user (not required in most systems) "dbpassword" is the mysql password (not required in most systems) "dbport" is the mysql port (not required in most systems) """ import BianaDB try: dbaccess = BianaDB.BianaDBaccess( dbhost = dbhost,dbuser = dbuser, dbpassword = dbpassword, dbport = dbport ) dbaccess.db.insert_db_content( sql_query = "DROP DATABASE IF EXISTS %s" %dbname ) dbaccess.close() OutBianaInterface.send_data("<biana_database_deleted dbname=\"%s\" dbhost=\"%s\"/>" %(dbname,dbhost)) except: OutBianaInterface.send_error_notification("Error while deleting database %s at %s" %(dbname,dbhost),"ERROR MESSAGE") # TO CHECK ERROR MESSAGE return
def get_available_external_entity_attributes(): """ Returns all the possible external entity attributes """ import biana.biana_globals as BIANA_GLOBALS OutBianaInterface.send_data( "".join( ["<external_entity_attribute name=\"%s\" />" % current_attribute[0] for current_attribute in BIANA_GLOBALS.EXTERNAL_ENTITY_IDENTIFIER_ATTRIBUTES ] ) ) OutBianaInterface.send_data( "".join( ["<external_entity_attribute name=\"%s\" />" % current_attribute[0] for current_attribute in BIANA_GLOBALS.EXTERNAL_ENTITY_VERSIONABLE_IDENTIFIER_ATTRIBUTE_TYPES]))
def get_available_external_entity_relation_types(): """ Returns all the possible external entity relation types """ import biana.biana_globals as BIANA_GLOBALS valid_eEr_types_list = list(BIANA_GLOBALS.EXTERNAL_ENTITY_RELATION_TYPES) valid_eEr_types_list.sort() OutBianaInterface.send_data( "".join( ["<external_entity_relation_type name=\"%s\" />" %x for x in valid_eEr_types_list] ) )
def get_available_parsers(): """ Returns the description of available parsers """ import BianaParser xml_list = ["<available_parsers>"] xml_list.extend(["<parser name=\"%s\" description=\"%s\" external_entity_definition=\"%s\"/>" %(x[0],x[1],x[2]) for x in BianaParser.get_available_parsers_info()]) xml_list.append("</available_parsers>") OutBianaInterface.send_data("\n".join(xml_list))
def remove_session(sessionID): """ Removes a session from memory "sessionID" is the identifier of the session """ available_sessions[sessionID].close() del available_sessions[sessionID] if( sessionID is not None ): OutBianaInterface.send_data("<close_session sessionID=\"%s\"/>" %sessionID) return
def get_available_external_entity_types(): """ Returns all the possible external entity types """ #from biana.BianaObjects.ExternalEntity import ExternalEntity #valid_eE_types_list = ExternalEntity.get_valid_external_entity_types() import biana.biana_globals as BIANA_GLOBALS valid_eE_types_list = list(BIANA_GLOBALS.EXTERNAL_ENTITY_TYPES) valid_eE_types_list.sort() OutBianaInterface.send_data( "".join( ["<external_entity_type name=\"%s\" />" %x for x in valid_eE_types_list] ) )
def check_database(dbname,dbhost,dbuser,dbpassword,dbport=None): """ Examines the current database and gets its basic information (external databases, unification protocols...) """ print "Checking BIANA database %s at %s..." %(dbname, dbhost) OutBianaInterface.send_process_message("Checking BIANA database %s at %s..." %(dbname, dbhost) ) import BianaDB try: dbaccess = BianaDB.BianaDBaccess( dbname = dbname, dbhost = dbhost, dbuser = dbuser, dbpassword = dbpassword, dbport = dbport ) if( OutBianaInterface.outmethod is not None ): tstr = [ "<unification_protocol description=\"%s\"/>" %x for x in dbaccess.get_available_unification_protocols_list() ] source_databases = dbaccess.get_external_database_list() eDstr = [] for current_eD in source_databases: attrStrList = [ "<eDB_external_entity_attribute name=\"%s\"/>" %x for x in current_eD.get_valid_external_entity_attribute_type() ] attrStrList.extend( ["<eDB_external_entity_relation_attribute name=\"%s\"/>" %x for x in current_eD.get_valid_external_entity_relation_attribute_type() ] ) attrStrList.extend( ["<eDB_external_entity_type name=\"%s\"/>" %x for x in current_eD.get_valid_external_entity_type() ] ) attrStrList.extend( ["<eDB_external_entity_relation_type name=\"%s\"/>" %x for x in current_eD.get_valid_external_entity_relation_type() ] ) eDstr.append("<external_database name=\"%s\" version=\"%s\" description=\"%s\" id=\"%s\">%s</external_database>" %(current_eD.get_name(), current_eD.get_version(), current_eD.get_description(), current_eD.get_id(), "".join(attrStrList))) ontologies = dbaccess.get_available_ontology_names() ontList = ["<ontology_attribute attribute=\"%s\" ontology_name=\"%s\"/>" %(ontologies[x],x) for x in ontologies ] OutBianaInterface.send_data("<db_info dbname=\"%s\" dbhost=\"%s\" dbuser=\"%s\" dbpass=\"%s\">%s%s%s</db_info>" %(dbname,dbhost,dbuser,dbpassword,"\n".join(tstr),"\n".join(eDstr),"\n".join(ontList))) dbaccess.close() except: traceback.print_exc() OutBianaInterface.send_data("<not_available_database dbname=\"%s\" dbhost=\"%s\"/>" %(dbname,dbhost)) OutBianaInterface.send_end_process_message()
def get_unification_protocol_atoms(unification_protocol_name, dbname,dbhost,dbuser,dbpassword,dbport=None): """ Returns unification protocol atom information of given unification protocol """ import BianaDB, BianaObjects.output_utilities try: dbaccess = BianaDB.BianaDBaccess( dbname = dbname, dbhost = dbhost, dbuser = dbuser, dbpassword = dbpassword, dbport = dbport ) unification_protocol_atoms = dbaccess.get_unification_protocol_atoms( unification_protocol_name = unification_protocol_name ) OutBianaInterface.send_data( BianaObjects.output_utilities.get_html_table(columns=["External DB 1", "External DB 2", "Crossed Attributes"], values = [(dbaccess.get_external_database(atom.get_externalDatabaseID_A()), dbaccess.get_external_database(atom.get_externalDatabaseID_B()), atom.get_external_attribute_list()) for atom in unification_protocol_atoms ], title="Unification Protocol Details" ) ) dbaccess.close() except: OutBianaInterface.send_error_notification("Error while fetching unification protocol information",traceback.format_exc())
def ping(): OutBianaInterface.send_data("<biana_ping_response />")
def ping(): OutBianaInterface.send_data("<biana_ping_response />")