local__source_data.inc 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. class local__source_data extends ChadoField {
  3. // --------------------------------------------------------------------------
  4. // EDITABLE STATIC CONSTANTS
  5. //
  6. // The following constants SHOULD be set for each descendent class. They are
  7. // used by the static functions to provide information to Drupal about
  8. // the field and it's default widget and formatter.
  9. // --------------------------------------------------------------------------
  10. // The default lable for this field.
  11. public static $default_label = 'Source of Data';
  12. // The default description for this field.
  13. public static $description = 'The source data used for this analysis.';
  14. // Provide a list of instance specific settings. These can be access within
  15. // the instanceSettingsForm. When the instanceSettingsForm is submitted
  16. // then Drupal with automatically change these settings for the instnace.
  17. // It is recommended to put settings at the instance level whenever possible.
  18. // If you override this variable in a child class be sure to replicate the
  19. // term_name, term_vocab, term_accession and term_fixed keys as these are
  20. // required for all TripalFields.
  21. public static $default_instance_settings = array(
  22. // The short name for the vocabulary (e.g. shcema, SO, GO, PATO, etc.).
  23. 'term_vocabulary' => 'local',
  24. // The name of the term.
  25. 'term_name' => 'source_data',
  26. // The unique ID (i.e. accession) of the term.
  27. 'term_accession' => 'source_data',
  28. // Set to TRUE if the site admin is allowed to change the term
  29. // type. This will create form elements when editing the field instance
  30. // to allow the site admin to change the term settings above.
  31. 'term_fixed' => FALSE,
  32. );
  33. // The default widget for this field.
  34. public static $default_widget = 'local__source_data_widget';
  35. // The default formatter for this field.
  36. public static $default_formatter = 'local__source_data_formatter';
  37. // --------------------------------------------------------------------------
  38. // PROTECTED CLASS MEMBERS -- DO NOT OVERRIDE
  39. // --------------------------------------------------------------------------
  40. // An array containing details about the field. The format of this array
  41. // is the same as that returned by field_info_fields()
  42. protected $field;
  43. // An array containing details about an instance of the field. A field does
  44. // not have to have an instance. But if dealing with an instance (such as
  45. // when using the widgetForm, formatterSettingsForm, etc.) it should be set.
  46. protected $instance;
  47. /**
  48. *
  49. * @see TripalField::load()
  50. */
  51. public function load($entity) {
  52. $analysis = $entity->chado_record;
  53. $field_name = $this->field['field_name'];
  54. $field_type = $this->field['type'];
  55. $field_table = $this->instance['settings']['chado_table'];
  56. $field_column = $this->instance['settings']['chado_column'];
  57. $entity->{$field_name}['und'][0] = array(
  58. 'value' => array(
  59. // The name of the data source.
  60. 'schema:name' => $analysis->sourcename,
  61. // The version of the data source.
  62. 'IAO:0000129' => $analysis->sourceversion,
  63. // The URI of the data source.
  64. 'data:1047' => $analysis->sourceuri,
  65. ),
  66. 'chado-analysis__sourcename' => $analysis->sourcename,
  67. 'chado-analysis__sourceversion' => $analysis->sourceversion,
  68. 'chado-analysis__sourceuri' => $analysis->sourceuri,
  69. );
  70. }
  71. }