Selaa lähdekoodia

Added chado_entity linker table. Moved chado-related columns from tripal_entity to chado_entity table.

Chun-Huai Cheng 9 vuotta sitten
vanhempi
commit
ef25e294b5

+ 2 - 5
tripal_entities/includes/TripalEntityController.inc

@@ -105,15 +105,12 @@ class TripalEntityController extends EntityAPIController {
     }
 
     // Write out the entity record.
-    $tablename = 'feature';
+    /* $tablename = 'feature';
     $schema = chado_get_schema($tablename);
-    $pkey_field = $schema['primary key'][0];
+    $pkey_field = $schema['primary key'][0]; */
     $record = array(
-      'cvterm_id' => $entity->cvterm_id,
       'type'      => $entity->entity_type,
       'bundle'    => $entity->bundle,
-      'tablename' => $tablename,
-      'record_id' => $entity->record_id,
       'title'     => 'title',
       'uid'       => $user->uid,
       'created'   => $entity->created,

+ 52 - 24
tripal_entities/tripal_entities.install

@@ -334,25 +334,6 @@ function tripal_entities_schema() {
         'not null' => TRUE,
         'default' => '',
       ),
-      'cvterm_id' => array(
-        'description' => 'The cvterm_id for the type of entity. This cvterm_id should match a record in the Chado cvterm table.',
-        'type' => 'varchar',
-        'length' => 32,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'tablename' => array(
-        'description' => 'The Chado table that contains the record that this entity is associated with.',
-        'type' => 'varchar',
-        'length' => 128,
-        'not null' => TRUE,
-        'default' => ''
-      ),
-      'record_id' => array(
-        'description' => 'The unique numerical identifier for the record that this entity is associated with (e.g. feature_id, stock_id, library_id, etc.).',
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
       'title' => array(
         'description' => 'The title of this node, always treated as non-markup plain text.',
         'type' => 'text',
@@ -387,15 +368,10 @@ function tripal_entities_schema() {
     'indexes' => array(
       'entity_changed' => array('changed'),
       'entity_created' => array('created'),
-      'tablename' => array('tablename'),
-      'record_id' => array('record_id'),
-      'tripal_record' => array('tablename', 'record_id'),
       'type' => array('type'),
-      'cvterm_id' => array('cvterm_id'),
       'uid' => array('uid'),
     ),
     'unique keys' => array(
-      'record' => array('tablename', 'record_id'),
     ),
     'primary key' => array('id'),
   );
@@ -450,6 +426,58 @@ function tripal_entities_schema() {
     ),
   );
   
+  $schema['chado_entity'] = array(
+    'description' => 'The linker table that associates an enitity from the public.tripal_entity table with a "base" record in Chado',
+    'fields' => array(
+      'chado_entity_id' => array(
+        'description' => 'The primary identifier for this table.',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'entity_id' => array(
+        'description' => 'The unique entity id.',
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'record_id' => array(
+        'description' => 'The unique numerical identifier for the record that this entity is associated with (e.g. feature_id, stock_id, library_id, etc.).',
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'data_table' => array(
+        'description' => 'Indicates the table in Chado that this term services (e.g. feature, stock, library, etc.)',
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'type_table' => array(
+        'description' => 'Sometimes the record in the data table doesn’t have a field that specifies  the record type.  For example, an analysis type is stored in the analysisprop table.  If the data_table does have a type field then this value will be the same as the data_table.',
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'field' => array(
+        'description' => 'The name of the field in the typetable that contains the cvterm record.',
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => FALSE,
+        'default' => ''
+      ),
+    ),
+    'indexes' => array(
+      'record_id' => array('record_id'),
+      'entity_id' => array('entity_id'),
+      'data_table' => array('data_table'),
+    ),
+    'unique keys' => array(
+      'record' => array('data_table', 'record_id'),
+      'entity_id' => array('entity_id'),
+    ),
+    'primary key' => array('chado_entity_id'),
+  );
   return $schema;
 }