local__child_properties.inc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. /**
  3. * @class
  4. * Purpose:
  5. *
  6. * Data:
  7. * Assumptions:
  8. */
  9. class local__child_properties extends ChadoField {
  10. // --------------------------------------------------------------------------
  11. // EDITABLE STATIC CONSTANTS
  12. //
  13. // The following constants SHOULD be set for each descendant class. They are
  14. // used by the static functions to provide information to Drupal about
  15. // the field and it's default widget and formatter.
  16. // --------------------------------------------------------------------------.
  17. /**
  18. * The default label for this field.
  19. */
  20. public static $default_label = 'Child Properties';
  21. /**
  22. * The default description for this field.
  23. */
  24. public static $default_description = 'All of the properties associated with child features.';
  25. /**
  26. * The default widget for this field.
  27. */
  28. public static $default_widget = 'local__child_properties_widget';
  29. /**
  30. * The default formatter for this field.
  31. */
  32. public static $default_formatter = 'local__child_properties_formatter';
  33. // The module that manages this field.
  34. // If no module manages the field (IE it's added via libraries)
  35. /**
  36. * Set this to 'tripal_chado'.
  37. */
  38. public static $module = 'tripal_manage_analyses';
  39. // A list of global settings. These can be accessed within the
  40. // globalSettingsForm. When the globalSettingsForm is submitted then
  41. // Drupal will automatically change these settings for all fields.
  42. // Once instances exist for a field type then these settings cannot be.
  43. /**
  44. * Changed.
  45. */
  46. public static $default_settings = [
  47. 'storage' => 'field_chado_storage',
  48. // It is expected that all fields set a 'value' in the load() function.
  49. // In many cases, the value may be an associative array of key/value pairs.
  50. // In order for Tripal to provide context for all data, the keys should
  51. // be a controlled vocabulary term (e.g. rdfs:type). Keys in the load()
  52. // function that are supported by the query() function should be
  53. // listed here.
  54. 'searchable_keys' => [],
  55. ];
  56. // Indicates the download formats for this field. The list must be the.
  57. /**
  58. * Name of a child class of the TripalFieldDownloader.
  59. */
  60. public static $download_formatters = [
  61. 'TripalTabDownloader',
  62. 'TripalCSVDownloader',
  63. ];
  64. // Provide a list of instance specific settings. These can be access within
  65. // the instanceSettingsForm. When the instanceSettingsForm is submitted
  66. // then Drupal with automatically change these settings for the instance.
  67. // It is recommended to put settings at the instance level whenever possible.
  68. // If you override this variable in a child class be sure to replicate the
  69. // term_name, term_vocab, term_accession and term_fixed keys as these are.
  70. /**
  71. * Required for all TripalFields.
  72. */
  73. public static $default_instance_settings = [
  74. // The DATABASE name, as it appears in chado.db. This also builds the link-out url. In most cases this will simply be the CV name. In some cases (EDAM) this will be the SUBONTOLOGY.
  75. 'term_vocabulary' => 'local',
  76. // The name of the term.
  77. 'term_name' => 'child_properties',
  78. // The unique ID (i.e. accession) of the term.
  79. 'term_accession' => 'child_properties',
  80. // Set to TRUE if the site admin is not allowed to change the term
  81. // type, otherwise the admin can change the term mapped to a field.
  82. 'term_fixed' => FALSE,
  83. // Indicates if this field should be automatically attached to display
  84. // or web services or if this field should be loaded separately. This
  85. // is convenient for speed. Fields that are slow should for loading
  86. // should have auto_attach set to FALSE so tha their values can be
  87. // attached asynchronously.
  88. 'auto_attach' => FALSE,
  89. // The table in Chado that the instance maps to.
  90. 'chado_table' => '',
  91. // The column of the table in Chado where the value of the field comes from.
  92. 'chado_column' => '',
  93. // The base table.
  94. 'base_table' => '',
  95. ];
  96. // A boolean specifying that users should not be allowed to create
  97. // fields and instances of this field type through the UI. Such
  98. // fields can only be created programmatically with field_create_field()
  99. /**
  100. * And field_create_instance().
  101. */
  102. public static $no_ui = FALSE;
  103. // A boolean specifying that the field will not contain any data. This
  104. // should exclude the field from web services or downloads. An example
  105. // could be a quick search field that appears on the page that redirects.
  106. /**
  107. * The user but otherwise provides no data.
  108. */
  109. public static $no_data = FALSE;
  110. /**
  111. * @see ChadoField::load()
  112. **/
  113. public function load($entity) {
  114. // ChadoFields automatically load the chado column specified in the
  115. // default settings above. If that is all you need then you don't even
  116. // need to implement this function. However, if you need to add any
  117. // additional data to be used in the display, you should add it here.
  118. parent::load($entity);
  119. $master = $entity->data__sequence_features['und'];
  120. //TODO: filter this to just hte properties. Right now we include everything because we are having this field do double duty for annotations.
  121. $entity->local__child_properties['und'] = $master;
  122. }
  123. /**
  124. * @see ChadoField::query()
  125. **/
  126. public function query($query, $condition) {
  127. }
  128. /**
  129. * @see ChadoField::queryOrder()
  130. **/
  131. public function queryOrder($query, $order) {
  132. }
  133. /**
  134. * @see ChadoField::elementInfo()
  135. **/
  136. public function elementInfo() {
  137. $field_term = $this->getFieldTermID();
  138. return [
  139. $field_term => [
  140. 'operations' => ['eq', 'ne', 'contains', 'starts'],
  141. 'sortable' => TRUE,
  142. 'searchable' => TRUE,
  143. ],
  144. ];
  145. }
  146. }