tripal_chado.migrate.api.inc

Provides an application programming interface (API) to migrate content.

File

tripal_chado/api/tripal_chado.migrate.api.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provides an application programming interface (API) to migrate content.
  5. */
  6. /**
  7. * @defgroup tripal_chado_migrate_api Chado Entity
  8. * @ingroup tripal_chado_api
  9. * @{
  10. * Provides an application programming interface (API) to migrate content.
  11. * @}
  12. */
  13. /**
  14. * Migrate Tripal content types
  15. *
  16. * Migrate specified Tripal content type and publish all its content. The content type
  17. * will be created if it does not already exist.
  18. *
  19. * @param $type
  20. * A type array specifying the vocabular, accession, term_name, and chado data_table
  21. * e.g.
  22. * $type = array(
  23. * 'vocabulary' => 'OBI',
  24. * 'accession' => '0100026',
  25. * 'term_name' => 'organism',
  26. * 'storage_args' => array (
  27. * 'data_table' => $table
  28. * )
  29. * )
  30. * @ingroup tripal_chado_migrate_api
  31. */
  32. function chado_migrate_tripal_content_type($type = array()) {
  33. // Check if the term already exists.
  34. $term = tripal_load_term_entity($type);
  35. // If term doesn't exist, create a new bundle for this term.
  36. if (!$term) {
  37. print("Creating bundle for term '" . $type['term_name'] . "'...\n");
  38. $success = tripal_create_bundle($type);
  39. $term = tripal_load_term_entity($type);
  40. }
  41. // Create bundle name.
  42. $bundle_name = 'bio_data_' . $term->id;
  43. // Publish records for the bundle.
  44. $value = array(
  45. 'sync_node' => 1,
  46. 'bundle_name' => $bundle_name
  47. );
  48. chado_publish_records($value);
  49. }