id) { // For Tripal created entities add in the chado_entity details. $dbs = tripal_entities_get_db_names_for_published_vocabularies(); if (in_array($this->type, $dbs)) { $details = db_select('chado_entity', 'ce') ->fields('ce') ->condition('entity_id', $this->id) ->execute() ->fetchObject(); // Add the chado entity details to the entity in case it's needed // downstream (e.g. in field widget construction). $this->chado_entity_id = $details->chado_entity_id; $this->chado_table = $details->data_table; $this->chado_field = $details->field; // Add in the record. $schema = chado_get_schema($this->chado_table); $pkey = $schema['primary key'][0]; $this->chado_record_id = $details->record_id; $this->chado_record = chado_generate_var($this->chado_table, array($pkey =>+ $details->record_id)); } } // If we do not have an ID then we need to do a few queries to get // information about the chado table this entity maps to. else { // Use the cvterm_id to look up the base table for this term. We find // the base table by looking in the term_usage table for the mapping. $sel_values = array( 'term_id' => array( 'cvterm_id' => $this->cvterm_id, ), ); $term_usage = chado_generate_var('tripal_term_usage', $sel_values, array('return_array' => 1)); // For each table that uses this term, insert the field recursively foreach ($term_usage as $usage) { $this->chado_table = $usage->data_table; $this->chado_field = $usage->field; } } } protected function defaultLabel() { return $this->title; } protected function defaultUri() { return array('path' => 'data/' . $this->id); } }