Explorar el Código

Added more documentation and fixed a bug for chado-compliance.

Lacey Sanderson hace 6 años
padre
commit
9a5df7986d

+ 1 - 1
tests/tripal_chado/api/ChadoComplianceTest.php

@@ -117,7 +117,7 @@ class ChadoComplianceTest extends TripalTestCase {
 
         // Check #4: The constraint exists.
         $this->assertTrue(
-          $chado_schema->checkFKConstraintExists($table_name, $base_column, 'FOREIGN KEY'),
+          $chado_schema->checkFKConstraintExists($table_name, $base_column),
           t('The foreign key constraint "!name" for "!table.!column" must exist for chado v!version.',
             array('!name' => $constraint_name, '!table' => $table_name,
               '!column' => $column_name, '!version' => $version))

+ 27 - 0
tripal_chado/api/ChadoSchema.inc

@@ -14,6 +14,30 @@
  * retireve.  The getTableSchema method determines the appropriate version of
  * Chado and uses the Drupal hook infrastructure to call the appropriate
  * hook function to retrieve the table schema.
+ *
+ * Additionally, here are some other examples of how to use this class:
+ * @code
+
+    // Retrieve the schema array for the organism table in chado 1.2
+    $chado_schema = new \ChadoSchema('1.2');
+    $table_schema = $chado_schema->getTableSchema('organism');
+
+    // Retrieve all chado tables.
+    $chado_schema = new \ChadoSchema();
+    $tables = $chado_schema->getTableNames();
+    $base_tables = $chado_schema->getbaseTables();
+
+    // Check the feature.type_id foreign key constraint
+    $chado_schema = new \ChadoSchema();
+    $exists = $chado_schema ->checkFKConstraintExists('feature','type_id');
+
+    // Check Sequence exists
+    $chado_schema = new \ChadoSchema();
+    $exists = $chado_schema->checkSequenceExists('organism','organism_id');
+    // Or just check the primary key directly
+    $compliant = $chado_schema->checkPrimaryKey('organism');
+
+ * @endcode
  */
 class ChadoSchema {
 
@@ -448,6 +472,9 @@ class ChadoSchema {
     elseif ($type == 'smallint' AND $expected_type == 'integer') {
       return TRUE;
     }
+    elseif ($type == 'bigint' AND $expected_type == 'integer') {
+      return TRUE;
+    }
     else {
       print "$table.$column... Expected: $expected_type, Actual: $type.\n";
       return FALSE;