tripal_chado.migrate.api.inc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Migrate Tripal content types
  4. *
  5. * Migrate specified Tripal content type and publish all its content. The content type
  6. * will be created if it does not already exist.
  7. *
  8. * @param $type
  9. * A type array specifying the vocabular, accession, term_name, and chado data_table
  10. * e.g.
  11. * $type = array(
  12. * 'vocabulary' => 'OBI',
  13. * 'accession' => '0100026',
  14. * 'term_name' => 'organism',
  15. * 'storage_args' => array (
  16. * 'data_table' => $table
  17. * )
  18. * )
  19. *
  20. */
  21. function tripal_chado_migrate_tripal_content_type($type = array()) {
  22. // Check if the term already exists
  23. $term = tripal_load_term_entity($type);
  24. // If term doesn't exist, create a new bundle for this term
  25. if (!$term) {
  26. print("Creating bundle for term '" . $type['term_name'] . "'...\n");
  27. $success = tripal_create_bundle($type);
  28. $term = tripal_load_term_entity($type);
  29. }
  30. // Create bundle name
  31. $bundle_name = 'bio_data_' . $term->id;
  32. // Publish records for the bundle
  33. $value = array(
  34. 'sync_node' => 1,
  35. 'bundle_name' => $bundle_name
  36. );
  37. tripal_chado_publish_records($value);
  38. }