tripal_chado.migrate.api.inc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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
  17. * content type 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
  21. * data_table 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. *
  31. * @ingroup tripal_chado_migrate_api
  32. */
  33. function chado_migrate_tripal_content_type($type = []) {
  34. // Check if the term already exists.
  35. $term = tripal_load_term_entity($type);
  36. // If term doesn't exist, create a new bundle for this term.
  37. if (!$term) {
  38. print("Creating bundle for term '" . $type['term_name'] . "'...\n");
  39. $success = tripal_create_bundle($type);
  40. $term = tripal_load_term_entity($type);
  41. }
  42. // Create bundle name.
  43. $bundle_name = 'bio_data_' . $term->id;
  44. // Publish records for the bundle.
  45. $value = [
  46. 'sync_node' => 1,
  47. 'bundle_name' => $bundle_name,
  48. ];
  49. chado_publish_records($value);
  50. }