def convert_aliases(new_session, old_cv_terms): ''' Convert Aliases ''' from model_new_schema.chemical import Chemical as NewChemical, ChemicalAlias as NewChemicalAlias #Cache aliases key_to_alias = cache_by_key(NewChemicalAlias, new_session) key_to_chemical = cache_by_key(NewChemical, new_session) #Create new aliases if they don't exist, or update the database if they do. new_aliases = [] for old_cv_term in old_cv_terms: new_aliases.extend(create_alias(old_cv_term, key_to_chemical)) values_to_check = ['used_for_search', 'date_created', 'created_by'] success = create_or_update_and_remove(new_aliases, key_to_alias, values_to_check, new_session) return success
def convert_chemicalrels(new_session, old_cv_terms): ''' Convert ChemicalRelations ''' from model_new_schema.chemical import Chemical as NewChemical, ChemicalRelation as NewChemicalRelation #Cache altids key_to_chemrels = cache_by_key(NewChemicalRelation, new_session) key_to_chemical = cache_by_key(NewChemical, new_session) #Create new chemrels if they don't exist, or update the database if they do. new_chemrels = [] for old_cv_term in old_cv_terms: new_chemrels.extend(create_chemrels(old_cv_term, key_to_chemical)) values_to_check = ['date_created', 'created_by'] success = create_or_update_and_remove(new_chemrels, key_to_chemrels, values_to_check, new_session) return success
def convert_altids(new_session, old_cv_terms): ''' Convert Altids ''' from model_new_schema.chemical import Chemical as NewChemical, ChemicalAltid as NewChemicalAltid #Cache altids key_to_altid = cache_by_key(NewChemicalAltid, new_session) key_to_chemical = cache_by_key(NewChemical, new_session) #Create new altids if they don't exist, or update the database if they do. new_altids = [] for old_cv_term in old_cv_terms: new_altids.extend(create_altids(old_cv_term, key_to_chemical)) values_to_check = ['chemical_id', 'source', 'altid_name', 'date_created', 'created_by'] success = create_or_update_and_remove(new_altids, key_to_altid, values_to_check, new_session) return success
def convert_chemicals(new_session, old_cv_terms): ''' Convert Chemicals ''' from model_new_schema.chemical import Chemical as NewChemical #Cache chemicals key_to_chemical = cache_by_key(NewChemical, new_session) #Create new chemicals if they don't exist, or update the database if they do. new_chemicals = [create_chemical(x) for x in old_cv_terms] values_to_check = ['display_name', 'source', 'date_created', 'created_by'] success = create_or_update_and_remove(new_chemicals, key_to_chemical, values_to_check, new_session) return success