/* ******************************************************************* * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The Original Code is the BioWarehouse. * * The Initial Developer of the Original Code is SRI International. * Portions created by SRI International are Copyright (C) 2004. * All Rights Reserved. ******************************************************************* */ /* * PGDB TRANSUNIT loader for the BioSpice Data Warehouse * Thomas J Lee, SRI International, August 2002 */ #include "main.h" #include "transunit-parse.h" #ifdef ORACLE #include #define COMMON_NAME_MAXLEN 4000 #elif DEF_MYSQL #define COMMON_NAME_MAXLEN 65535 #endif #define DEBUG 0 extern int dataset_wid; extern int organism_wid; short ind; void transunit_load_entry(struct transunit_entry *entry) { int transunit_wid; short error = 0; /* numeric conversion error */ struct stringlist *sptr; /* to iterate over synonyms */ /* Set indicator variables for optional columns, and check string lengths, numeric formats etc. */ char * common_name = string_column(entry->common_name, COMMON_NAME_MAXLEN, &entry->common_name_ind); if (!entry) advise_error("Null entry passed to transunit_load_entry\n"); if (entry->common_name != common_name) { printf("*** Warning: COMMON-NAME of %s truncated to length %d - %s\n", entry->unique_id, COMMON_NAME_MAXLEN, common_name); error = 1; free(entry->common_name); entry->common_name = common_name; } if (error) transunit_parse_error(); if (DEBUG) printf("Loading transunit %s\n", entry->unique_id); #ifdef ORACLE /* Try a WHENEVER to assist in debugging silent Oracle errors */ EXEC SQL WHENEVER SQLERROR DO sql_error("Oracle error in transunit-load"); #endif // Remember this transunit WID so components can be associated with transunit_wid = wh_get_new_wid(); if (DEBUG) printf("Inserting transunitWID %d\n", transunit_wid); widtable_insert(transunit_wids, transunit_wid, entry->unique_id); /* remember wid-unique_id association */ if (!common_name) common_name = entry->unique_id; wh_insert_transcription_unit(transunit_wid, common_name); /* Add synonyms to SynonymTable */ for (sptr=entry->synonyms; sptr; sptr=sptr->next) wh_insert_synonymtable(transunit_wid, sptr->string); /* Add citations to CitationWIDOtherWID */ for (sptr=entry->citations; sptr; sptr=sptr->next) insert_citation(transunit_wid, sptr->string); /* Add comments to CommentTable */ for (sptr=entry->comments; sptr; sptr=sptr->next) wh_insert_comment(transunit_wid, sptr->string); /* Add DBID */ if (!entry->unique_id) entry->load_error = 1; else wh_insert_dbid(transunit_wid, entry->unique_id); /* Insert all DBLINKS as crossreferences */ insert_dblinks(transunit_wid, entry->dblinks_dbs, entry->dblinks_ids); /* Finally add Entry */ wh_insert_entry(transunit_wid, entry->load_error, 0, NULL); }