Explorar o código

Nightly check-in

Stephen Ficklin %!s(int64=8) %!d(string=hai) anos
pai
achega
97801c5cd2

+ 3 - 179
tripal/api/tripal.entities.api.inc

@@ -245,7 +245,7 @@ function tripal_create_bundle($vocabulary, $accession, $term_name, &$error = '')
 
     // Get the list of fields created by Tripal modules and
     // create them if they don't already exist.
-    foreach (module_implements('create_tripalfields') as $module) {
+     foreach (module_implements('create_tripalfields') as $module) {
       $function = $module . '_create_tripalfields';
       if (function_exists($function)) {
         $fields = $function('TripalEntity', $bundle);
@@ -270,7 +270,7 @@ function tripal_create_bundle($vocabulary, $accession, $term_name, &$error = '')
       }
     }
 
-    // Now get the list of field instances to add to the bundle.
+/*     // Now get the list of field instances to add to the bundle.
     foreach (module_implements('create_tripalfield_instance') as $module) {
       $function = $module . '_create_tripalfield_instance';
       if (function_exists($function)) {
@@ -290,7 +290,7 @@ function tripal_create_bundle($vocabulary, $accession, $term_name, &$error = '')
           $instance = field_create_instance($info);
         }
       }
-    }
+    } */
   }
   catch (Exception $e) {
     $transaction->rollback();
@@ -853,180 +853,4 @@ function theme_token_list($tokens) {
   return theme('table', array('header' => $header, 'rows' => $rows));
 }
 
-/**
- * @section
- * Vocabulary Hooks.
- */
-
-/**
- * A hook for specifying information about the data store for vocabularies.
- *
- * The storage backend for controlled vocabularies has traditionally been
- * the Chado CV term tables. However, Tripal v3.0 introduces APIs for supporting
- * other backends.  Therefore, this function indicates to Tripal which
- * data stores are capable of providing support for terms.
- *
- * @return
- *   An array describing the storage backends implemented by the module. The
- *   keys are storage backend names. To avoid name clashes, storage
- *   backend names should be prefixed with the name of the module that
- *   exposes them. The values are arrays describing the storage backend,
- *   with the following key/value pairs:
- *
- *   label: The human-readable name of the storage backend.
- *   module:  The name of the module providing the support for this backend.
- *   description: A short description for the storage backend.
- *   settings: An array whose keys are the names of the settings available for
- *     the storage backend, and whose values are the default values for
- *     those settings.
- */
-function hook_vocab_storage_info() {
-  return array(
-    'term_chado_storage' => array(
-      'label' => t('Chado storage'),
-      'description' => t('Integrates terms stored in the local Chado database with Tripal entities.'),
-      'settings' => array(),
-    ),
-  );
-}
-
-
-/**
- * Creates a form for specifying a term for TripalEntity creation.
- *
- * This hook allows the module that implements a vocabulary storage backend
- * to provide the form necessary to select a term that will then be used for
- * creating a new TripalEntity type.  Tripal will expect that a 'vocabulary' and
- * 'accession' are in the $form_state['storage'] array. The 'vocabulary' and
- * must be the abbreviated uppercase vocabulary for the vocabulary (e.g. 'RO',
- * 'SO', 'PATO', etc.).  The 'accession' must be the unique term ID (or
- * accession) for the term in the vocabulary.
- *
- * @param $form
- * @param $form_state
- *
- * @return
- *   A form object.
- */
-function hook_vocab_select_term_form(&$form, &$form_state) {
-
-  return $form;
-}
-/**
- * Validates the hook_vocab_select_term_form().
- *
- * @param $name
- */
-function hook_vocab_select_term_form_validate($form, &$form_state) {
-
-}
-/**
- * Provides a form for importing vocabularies and their terms.
- *
- * Tripal allows for vocabularies to be stored separately from the biological
- * data. This hook allows the default term storage backend to provide an
- * approprite form for importing ontologies (either in OBO or OWL format).
- *
- * @param $form
- * @param $form_state
- *
- */
-function hook_vocab_import_form($form, &$form_state) {
-  return $form;
-}
-function hook_vocab_import_form_validate($form, &$form_state) {
-
-}
-function hook_vocab_import_form_submit($form, &$form_state) {
-
-}
-
-/**
- * Hook used by the default term storage backend to provide details for a term.
- *
- * This hook is called by the tripal_entity module to retrieve information
- * about the term from the storage backend.  It must return an array with
- * a set of keys.
- *
- * @param $vocabulary
- *   The vocabulary of the vocabulary in which the term is found.
- * @param $accession
- *   The unique identifier (accession) for this term.
- *
- * @return
- *   An array with at least the following keys:
- *     -vocabulary : An associative array with the following keys
- *       -name:  The short name for the vocabulary (e.g. SO, PATO, etc).
- *       -description: The description of this vocabulary.
- *       -url: The URL for the vocabulary.
- *     -accession : The name unique ID of the term.
- *     -url : The URL for the term.
- *     -name : The name of the term.
- *     -definition : The term's description.
- *   any other keys may be added as desired. Returns NULL if the term
- *   cannot be found.
- */
-function hook_vocab_get_term($vocabulary, $accession) {
-  // See the tripal_chado_vocab_get_term() function for an example.
-
-}
-
-/**
- * Hook used by the default term storage backend to add new terms.
- *
- * @param $values
- *   An associative array of key/value pairs used to add a new term.  The
- *   keys are:
- *     vocabulary : The vocabulary of the vocabulary.
- *     accession : The name unique ID of the term.
- *     url : The URL for the term.
- *     name : The name of the term.
- *     definition : The term's description.
- * @return
- *   TRUE if the term was added, FALSE otherwise.  If the term already exists
- *   it will be updated and the return value will be TRUE,
- */
-function hook_vocab_set_term($values) {
-  // See the tripal_chado_vocab_set_term() function for an example.
-}
-
-
-/**
- * Retrieves full information about a vocabulary term.
- *
- * Vocabularies are stored in a database backend.  Tripal has no requirements
- * for how terms are stored.  By default, the tripal_chado modules provides
- * storage for vocabularies and terms. This function will call the
- * hook_vocab_get_term() function for the database backend that is housing the
- * vocabularies and allow it to return the details about the term.
- *
- * @param $vocabulary
- *   The vocabulary of the vocabulary in which the term is found.
- * @param $accession
- *   The unique identifier (accession) for this term.
- *
- * @return
- *   An array with at least the following keys:
- *     vocabulary : The short name of the vocabulary (e.g. SO, PATO, foaf).
- *     accession : The name unique ID of the term.
- *     url : The URL for the term.
- *     name : The name of the term.
- *     definition : The term's description.
- *   any other keys may be added as desired. Returns NULL if the term
- *   cannot be found.
- */
-function tripal_get_term_details($vocabulary, $accession) {
-  // TODO: we need some sort of administrative interface that lets the user
-  // switch to the desired vocabulary type. For now, we'll just use the
-  // first one in the list.
-  $stores = module_invoke_all('vocab_storage_info');
-  if (is_array($stores) and count($stores) > 0) {
-    $keys = array_keys($stores);
-    $module = $stores[$keys[0]]['module'];
-    $function = $module . '_vocab_get_term';
-    if (function_exists($function)) {
-      return $function($vocabulary, $accession);
-    }
-  }
-}
 

+ 66 - 0
tripal/api/tripal.fields.api.inc

@@ -1,5 +1,71 @@
 <?php
 
+/**
+ * Adds a new field type to Tripal.
+ *
+ * Before a new field can be added to an entity, Drupal must know about the
+ * field types.  This function is used to add new Tripal field types.
+ *
+ * @param $term
+ *   The term that this field is associated with.  This should be an array as
+ *   returned by tripal_get_term_details()
+ * @param $options
+ */
+function tripal_add_field_type($term, $options) {
+  // TODO: add checks to make sure we have properly formatted options.
+
+  // Add the term in case it doesn't already exist
+  tripal_add_term($term);
+
+  $field_type = $term['vocab']['short_name'] . '__' . $term['accession'];
+
+  // Make sure that the field type doesn't already exist
+  $type_id = db_select('tripal_field_types', 'TFT')
+    ->fields('TFT', array('term'))
+    ->condition('term', $field_type)
+    ->execute()
+    ->fetchField();
+  if ($type_id) {
+    return FALSE;
+  }
+  $type_id = db_insert('tripal_field_types')
+    ->fields(array(
+      'term' => $field_type,
+      'label' => $options['label'],
+      'description' => $options['description'],
+      'settings' => serialize($options['settings']),
+      'instance_settings' => serialize($options['instance_settings']),
+      'default_widget' => $options['default_widget'],
+      'default_formatter' => $options['default_formatter'],
+      'storage' => serialize($options['storage']),
+    ))
+    ->execute();
+}
+/**
+ *
+ */
+function tripal_get_field_type_info() {
+  // Make sure that the field type doesn't already exist
+  $records = db_select('tripal_field_types', 'TFT')
+    ->fields('TFT')
+    ->execute();
+  $info = array();
+  while($record = $records->fetchObject()) {
+    $info[$record->term] = array(
+      'label' => $record->label,
+      'description' => $record->description,
+      'settings' => unserialize($record->settings),
+      'instance_settings' => unserialize($record->instance_settings),
+      'default_widget' => $record->default_widget,
+      'default_formatter' => $record->default_formatter,
+      'storage' => unserialize($record->storage),
+      // Tripal fields should only be added to entities programmatically
+      // and not through the UI.
+      'no_ui' => TRUE,
+    );
+  }
+  return $info;
+}
 
 /**
  * Executes a TripalFieldQuery using the provided conditions.

+ 3 - 0
tripal/includes/TripalTerm.inc

@@ -61,5 +61,8 @@ class TripalTerm extends Entity {
   public function getVocab() {
     return $this->vocab;
   }
+  public function getID() {
+    return $this->id;
+  }
 
 }

+ 40 - 37
tripal/includes/tripal.fields.inc

@@ -10,31 +10,9 @@
  * discovered and listed for Drupal by this function.
  */
 function tripal_field_info() {
-
-//   $info = array();
-//   $field_types = tripal_get_field_types();
-//   foreach ($field_types as $field_type) {
-//     $info[$field_type] = $field_type::globalInfo();
-//   }
-//   return $info;
-
-  return array(
-    'tripal_key_value' => array(
-      'label' => 'Tripal complex field',
-      'description' => 'A field specific to data managed by Tripal. ',
-      'settings' => array(
-        'tripal_term' => '',
-      ),
-      'instance_settings' => array(),
-      'default_widget' => 'tripal_generic_key_value_widget',
-      'default_formatter' => 'tripal_generic_key_value_formatter',
-      'storage' => array(
-        'type' => 'tripal_no_storage',
-        'module' => 'tripal',
-        'active' => TRUE
-      ),
-    ),
-  );
+   $info = tripal_get_field_type_info();
+   dpm($info);
+   return $info;
 }
 
 /**
@@ -98,20 +76,45 @@ function tripal_field_formatter_info() {
  *
  */
 function tripal_create_tripalfields($entity_type, $bundle) {
-  $field_name = 'content_type';
-  $info = array();
-  $info[$field_name] = array(
-    'field_name' => $field_name,
-    'type' => 'content_type',
-    'cardinality' => 1,
-    'locked' => FALSE,
-    'storage' => array(
-      'type' => 'tripal_no_storage'
-    ),
-    'settings' => array(
-      'semantic_web' => 'rdfs:type',
+
+  // Make sure the rdfs:type term exists.
+  $term = array(
+    'vocab' => array(
+      'name' => 'rdfs',
+      'short_name' => 'rdfs',
+      'description' => 'Resource Description Framework Schema',
+      'url' => 'https://www.w3.org/TR/rdf-schema/'
     ),
+    'name' => 'type',
+    'accession' => 'type',
+    'definition' => 'The type of resource.',
+    'url' => 'https://www.w3.org/TR/rdf-schema/#ch_type',
+  );
+  $options = array(
+    'label' => 'Content Type',
+    'description' => 'The Tripal content type.',
+    'settings' => array(),
+    'instance_settings' => array(),
+    'default_widget' => 'rdfs_type_widget',
+    'default_formatter' => 'rdfs_type_formatter',
+    'storage' => 'tripal_no_storage',
   );
+  tripal_add_field_type($term, $options);
+
+//   $field_name = 'content_type';
+//   $info = array();
+//   $info[$field_name] = array(
+//     'field_name' => $field_name,
+//     'type' => 'content_type',
+//     'cardinality' => 1,
+//     'locked' => FALSE,
+//     'storage' => array(
+//       'type' => 'tripal_no_storage'
+//     ),
+//     'settings' => array(
+//       'semantic_web' => 'rdfs:type',
+//     ),
+//   );
   return $info;
 }
 

+ 67 - 0
tripal/tripal.install

@@ -189,6 +189,9 @@ function tripal_schema() {
   $schema['tripal_entity'] = tripal_tripal_entity_schema();
   $schema['tripal_bundle'] = tripal_tripal_bundle_schema();
 
+  // Adds a table for managing fields created by the Tripal modules
+  $schema['tripal_field_types'] = tripal_tripal_field_types_schema();
+
   // Adds a table for additional information related to bundles.
   $schema['tripal_bundle_variables'] = tripal_tripal_bundle_variables_schema();
 
@@ -378,6 +381,7 @@ function tripal_tripal_variables_schema() {
  * Schema Definitions.
  */
 
+
 /**
  * The base table for Biological Data Entities.
  *
@@ -638,6 +642,69 @@ function tripal_tripal_bundle_schema() {
   return $schema;
 }
 
+/**
+ * The table for storing fields created by the Tripal module.
+ */
+function tripal_tripal_field_types_schema() {
+  $schema = array(
+    'description' => 'Stores field types created by Tripal. Field types are
+       vocabulary terms.',
+    'fields' => array (
+      'field_type_id' => array (
+        'type' => 'serial',
+        'not null' => TRUE,
+      ),
+      'term' => array(
+        'type' => 'varchar',
+        'not null' => TRUE,
+        'length' => 1024,
+      ),
+      'label' => array(
+        'type' => 'text',
+        'not null' => TRUE,
+      ),
+      'description' => array(
+        'type' => 'text',
+        'not null' => TRUE,
+      ),
+      'settings' => array(
+        'type' => 'text',
+        'not null' => TRUE,
+      ),
+      'instance_settings' => array(
+        'type' => 'text'
+      ),
+      'default_widget' => array(
+        'type' => 'varchar',
+        'length' => 1024,
+        'not null' => TRUE,
+      ),
+      'default_formatter' => array(
+        'type' => 'varchar',
+        'length' => 1024,
+        'not null' => TRUE,
+      ),
+      'storage' => array(
+        'type' => 'text',
+        'not null' => TRUE,
+      ),
+    ),
+    'primary key' => array (
+      0 => 'field_type_id',
+    ),
+    'unique keys' => array (
+      'tripal_field_types_c1' => array (
+        0 => 'term',
+      ),
+    ),
+    'indexes' => array (
+      'tripal_field_types_idx1' => array (
+        0 => 'term',
+      ),
+    ),
+  );
+  return $schema;
+}
 /**
  * Additional Tripal Bundle Information.
  *

+ 1 - 0
tripal/tripal.module

@@ -555,6 +555,7 @@ function tripal_menu_alter(&$items) {
 function tripal_import_api() {
   module_load_include('inc', 'tripal', 'api/tripal.d3js.api');
   module_load_include('inc', 'tripal', 'api/tripal.fields.api');
+  module_load_include('inc', 'tripal', 'api/tripal.terms.api');
   module_load_include('inc', 'tripal', 'api/tripal.entities.api');
   module_load_include('inc', 'tripal', 'api/tripal.files.api');
   module_load_include('inc', 'tripal', 'api/tripal.jobs.api');

+ 2 - 2
tripal_chado/includes/tripal_chado.fields.inc

@@ -51,7 +51,7 @@ function tripal_chado_field_widget_info() {
  * This is a Tripal defined hook that supports integration with the
  * TripalEntity field.
  */
-function tripal_chado_create_tripalfields($entity_type, $bundle) {
+function tripal_chado_create_tripalfields2($entity_type, $bundle) {
 
   // Get the table this bundle is mapped to.
   $term = tripal_load_term_entity(array('term_id' => $bundle->term_id));
@@ -663,7 +663,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
  * This is a Tripal defined hook that supports integration with the
  * TripalEntity field.
  */
-function tripal_chado_create_tripalfield_instance($entity_type, $bundle) {
+function tripal_chado_create_tripalfield_instance2($entity_type, $bundle) {
 
   $term = tripal_load_term_entity(array('term_id' => $bundle->term_id));
   $vocab = $term->vocab;

+ 25 - 25
tripal_chado/includes/tripal_chado.setup.inc

@@ -123,7 +123,7 @@ function tripal_chado_prepare_chado() {
       'A vocabulary for storing synonym types.'
     );
     // set the default vocabularies
-    tripal_set_default_cv('synonym', 'type_id', 'synonym_type');
+    //tripal_set_default_cv('synonym', 'type_id', 'synonym_type');
 
     // Add cvterms.
     tripal_insert_misc_cvterms();
@@ -138,7 +138,7 @@ function tripal_chado_prepare_chado() {
     );
 
     // Set the default vocabularies.
-    tripal_set_default_cv('organismprop', 'type_id', 'organism_property');
+    //tripal_set_default_cv('organismprop', 'type_id', 'organism_property');
 
     // Add taxonomic terms.
     $obo_id = tripal_insert_obo('Taxonomic Rank', 'http://purl.obolibrary.org/obo/taxrank.obo');
@@ -160,7 +160,7 @@ function tripal_chado_prepare_chado() {
     tripal_analysis_add_mview_analysis_organism();
 
     // set the default vocabularies
-    tripal_set_default_cv('analysisprop', 'type_id', 'analysis_property');
+    //tripal_set_default_cv('analysisprop', 'type_id', 'analysis_property');
 
     /////////////////////////////////////////////////////////////////////////////
     //                        Chado Contact Module
@@ -190,9 +190,9 @@ function tripal_chado_prepare_chado() {
     tripal_contact_add_cvs();
 
     // Set the default vocabularies.
-    tripal_set_default_cv('contact', 'type_id', 'tripal_contact');
-    tripal_set_default_cv('contactprop', 'type_id', 'tripal_contact');
-    tripal_set_default_cv('contact_relationship', 'type_id', 'contact_relationship');
+    //('contact', 'type_id', 'tripal_contact');
+    //tripal_set_default_cv('contactprop', 'type_id', 'tripal_contact');
+    //tripal_set_default_cv('contact_relationship', 'type_id', 'contact_relationship');
 
     /////////////////////////////////////////////////////////////////////////////
     //                        Chado Feature Module
@@ -226,9 +226,9 @@ function tripal_chado_prepare_chado() {
     }
 
     // Set the default vocabularies.
-    tripal_set_default_cv('feature', 'type_id', 'sequence');
-    tripal_set_default_cv('featureprop', 'type_id', 'feature_property');
-    tripal_set_default_cv('feature_relationship', 'type_id', 'feature_relationship');
+    //tripal_set_default_cv('feature', 'type_id', 'sequence');
+    //tripal_set_default_cv('featureprop', 'type_id', 'feature_property');
+    //tripal_set_default_cv('feature_relationship', 'type_id', 'feature_relationship');
 
     /////////////////////////////////////////////////////////////////////////////
     //                            Chado Map Module
@@ -241,9 +241,9 @@ function tripal_chado_prepare_chado() {
     tripal_featuremap_add_cvterms();
 
     // set the default vocabularies
-    tripal_set_default_cv('featuremapprop', 'type_id', 'featuremap_property');
-    tripal_set_default_cv('featureposprop', 'type_id', 'featurepos_property');
-    tripal_set_default_cv('featuremap', 'unittype_id', 'featuremap_units');
+    //tripal_set_default_cv('featuremapprop', 'type_id', 'featuremap_property');
+    //tripal_set_default_cv('featureposprop', 'type_id', 'featurepos_property');
+    //tripal_set_default_cv('featuremap', 'unittype_id', 'featuremap_units');
 
     /////////////////////////////////////////////////////////////////////////////
     //                          Chado Library Module
@@ -256,8 +256,8 @@ function tripal_chado_prepare_chado() {
     tripal_library_add_cvterms();
 
     // set the default vocabularies
-    tripal_set_default_cv('libraryprop', 'type_id', 'library_property');
-    tripal_set_default_cv('library', 'type_id', 'library_type');
+    //tripal_set_default_cv('libraryprop', 'type_id', 'library_property');
+    //tripal_set_default_cv('library', 'type_id', 'library_type');
 
     /////////////////////////////////////////////////////////////////////////////
     //                          Chado NatDiv Module
@@ -272,8 +272,8 @@ function tripal_chado_prepare_chado() {
     tripal_project_add_cvterms();
 
     // set the default vocabularies
-    tripal_set_default_cv('projectprop', 'type_id', 'project_property');
-    tripal_set_default_cv('project_relationship', 'type_id', 'project_relationship');
+    //tripal_set_default_cv('projectprop', 'type_id', 'project_property');
+    ///tripal_set_default_cv('project_relationship', 'type_id', 'project_relationship');
 
     /////////////////////////////////////////////////////////////////////////////
     //                          Chado Pub Module
@@ -295,9 +295,9 @@ function tripal_chado_prepare_chado() {
     tripal_pub_add_custom_tables();
 
     // set the default vocabularies
-    tripal_set_default_cv('pub', 'type_id', 'tripal_pub');
-    tripal_set_default_cv('pubprop', 'type_id', 'tripal_pub');
-    tripal_set_default_cv('pub_relationship', 'type_id', 'pub_relationship');
+    //tripal_set_default_cv('pub', 'type_id', 'tripal_pub');
+    //tripal_set_default_cv('pubprop', 'type_id', 'tripal_pub');
+    //tripal_set_default_cv('pub_relationship', 'type_id', 'pub_relationship');
 
     // Add the supported loaders
     variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));
@@ -309,9 +309,9 @@ function tripal_chado_prepare_chado() {
     tripal_stock_add_cvs();
 
     // set the default vocabularies
-    tripal_set_default_cv('stock', 'type_id', 'stock_type');
-    tripal_set_default_cv('stockprop', 'type_id', 'stock_property');
-    tripal_set_default_cv('stock_relationship', 'type_id', 'stock_relationship');
+    //tripal_set_default_cv('stock', 'type_id', 'stock_type');
+    //tripal_set_default_cv('stockprop', 'type_id', 'stock_property');
+    //tripal_set_default_cv('stock_relationship', 'type_id', 'stock_relationship');
 
     // add the materialized view
     tripal_stock_add_organism_count_mview();
@@ -366,11 +366,11 @@ function tripal_chado_prepare_chado() {
       'definition' => 'The way in which two things are connected.',
       'cv_name' => 'local',
     ));
-    
+
     tripal_insert_cvterm(array(
       'id' => 'local:biomaterial',
       'name' => 'biomaterial',
-      'definition' => 'A biomaterial represents the MAGE concept of BioSource, BioSample, ' . 
+      'definition' => 'A biomaterial represents the MAGE concept of BioSource, BioSample, ' .
         'and LabeledExtract. It is essentially some biological material (tissue, cells, serum) that ' .
         'may have been processed. Processed biomaterials should be traceable back to raw ' .
         'biomaterials via the biomaterialrelationship table.',
@@ -424,7 +424,7 @@ function tripal_chado_prepare_chado() {
     if (!tripal_create_bundle('local', 'project', 'project', $error)) {
       throw new Exception($error);
     }
-    
+
     // Initialize the population of the tripal_cvterm_mapping table.
     tripal_chado_map_cvterms();
 

+ 41 - 0
tripal_chado/includes/tripal_chado.vocab_storage.inc

@@ -58,6 +58,47 @@ function tripal_chado_vocab_get_term($vocabulary, $accession) {
   return $term;
 }
 
+/**
+ * Implements hook_vocab_add_term().
+ *
+ * This hook is created by the Tripal module and is not a Drupal hook.
+ */
+function tripal_chado_vocab_add_term($details) {
+  $vocabulary = $details['vocab']['name'];
+  $accession = $details['accession'];
+
+  // First check to make sure the term doesn't already exist
+  $term = tripal_chado_vocab_get_term($vocabulary, $accession);
+  if ($term) {
+    return TRUE;
+  }
+
+  // First make sure the vocabulary is added.
+  $values = array(
+    'name' => $vocabulary,
+    'description' => $details['vocab']['description'],
+    'url' => $details['vocab']['url'],
+    // TODO: deal with the URL prefix
+  );
+  $options = array('update_existing' => TRUE);
+  tripal_insert_db($values, $options);
+
+
+  // Second make sure the term is added.
+  $term = tripal_insert_cvterm(array(
+    'id' => $vocabulary . ':' . $accession,
+    'name' => $details['name'],
+    'definition' => $details['definition'],
+    'cv_name' => $details['vocab']['name'],
+  ));
+
+  // Return TRUE on success.
+  if (!$term) {
+    return FALSE;
+  }
+  return TRUE;
+}
+
 /**
  * Implements hook_vocab_import_form();
  */