sbo__relationship.inc 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  1. <?php
  2. class sbo__relationship 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 = 'Relationship';
  12. // The default description for this field.
  13. public static $description = 'Relationships between records.';
  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 = [
  22. // The short name for the vocabulary (e.g. shcema, SO, GO, PATO, etc.).
  23. 'term_vocabulary' => 'SBO',
  24. // The name of the term.
  25. 'term_name' => 'Relationship',
  26. // The unique ID (i.e. accession) of the term.
  27. 'term_accession' => '0000374',
  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. // Inidates if this field should be automatically attached to display
  33. // or web services or if this field should be loaded separately. This
  34. // is convenient for speed. Fields that are slow should for loading
  35. // should ahve auto_attach set to FALSE so tha their values can be
  36. // attached asyncronously.
  37. 'auto_attach' => FALSE,
  38. // Settings to help the site admin control how relationship types and
  39. // valid subject/objects can be selected by the user.
  40. 'relationships' => [
  41. 'option1_vocabs' => '',
  42. 'option2_vocab' => '',
  43. 'option2_parent' => '',
  44. 'relationship_types' => '',
  45. ],
  46. // The number of items to show on a page.
  47. 'items_per_page' => 10,
  48. ];
  49. // The default widget for this field.
  50. public static $default_widget = 'sbo__relationship_widget';
  51. // The default formatter for this field.
  52. public static $default_formatter = 'sbo__relationship_formatter';
  53. // --------------------------------------------------------------------------
  54. // PROTECTED CLASS MEMBERS -- DO NOT OVERRIDE
  55. // --------------------------------------------------------------------------
  56. // An array containing details about the field. The format of this array
  57. // is the same as that returned by field_info_fields()
  58. protected $field;
  59. // An array containing details about an instance of the field. A field does
  60. // not have to have an instance. But if dealing with an instance (such as
  61. // when using the widgetForm, formatterSettingsForm, etc.) it should be set.
  62. protected $instance;
  63. // An array of columns to use as the "name" of the subject and object.
  64. // For example, for the feature table, this will be the name,
  65. // whereas, for the organism table this will be the genus & species.
  66. protected $base_name_columns;
  67. // One of 'type_id', or 'table_name'. Not all base tables have a type_id so
  68. // this setting allows us to better handle these cases.
  69. protected $base_type_column;
  70. // This field depends heavily on the schema of the relationship and base
  71. // table. The following variables cache the schema to greatly speed up
  72. // this field.
  73. // Note: both are ChadoSchema objects.
  74. protected $schema;
  75. protected $base_schema;
  76. // The column which indicated the subject/object_id in the current
  77. // relationship table. This allows us to support exceptions in the common
  78. // chado naming conventions.
  79. protected $subject_id_column;
  80. protected $object_id_column;
  81. /**
  82. * @see TripalField::elements()
  83. */
  84. public function elementInfo() {
  85. $field_term = $this->getFieldTermID();
  86. return [
  87. $field_term => [
  88. 'operations' => ['eq', 'contains', 'starts'],
  89. 'sortable' => FALSE,
  90. 'searchable' => FALSE,
  91. 'type' => 'xs:complexType',
  92. 'readonly' => FALSE,
  93. 'elements' => [
  94. 'SIO:000493' => [
  95. 'searchable' => FALSE,
  96. 'name' => 'relationship_clause',
  97. 'label' => 'Relationship Clause',
  98. 'help' => 'An English phrase describing the relationships.',
  99. 'sortable' => FALSE,
  100. 'type' => 'xs:string',
  101. 'readonly' => TRUE,
  102. 'required' => FALSE,
  103. ],
  104. 'local:relationship_subject' => [
  105. 'searchable' => FALSE,
  106. 'name' => 'relationship_subject',
  107. 'operations' => ['eq', 'ne', 'contains', 'starts'],
  108. 'sortable' => FALSE,
  109. 'type' => 'xs:complexType',
  110. 'readonly' => FALSE,
  111. 'required' => TRUE,
  112. 'elements' => [
  113. 'rdfs:type' => [
  114. 'name' => 'type',
  115. 'searchable' => TRUE,
  116. 'label' => 'Relationship Subject Type',
  117. 'help' => 'The subject\'s data type in a relationship clause',
  118. 'operations' => ['eq', 'ne', 'contains', 'starts'],
  119. 'sortable' => TRUE,
  120. 'type' => 'xs:string',
  121. 'readonly' => FALSE,
  122. 'required' => TRUE,
  123. ],
  124. 'schema:name' => [
  125. 'name' => 'name',
  126. 'searchable' => TRUE,
  127. 'label' => 'Relationship Subject Name',
  128. 'help' => 'The subject\'s name in a relationship clause',
  129. 'operations' => ['eq', 'ne', 'contains', 'starts'],
  130. 'sortable' => TRUE,
  131. 'type' => 'xs:string',
  132. 'readonly' => FALSE,
  133. 'required' => TRUE,
  134. ],
  135. 'entity' => [
  136. 'searchable' => FALSE,
  137. 'sortable' => FALSE,
  138. ],
  139. ],
  140. ],
  141. 'local:relationship_type' => [
  142. 'searchable' => TRUE,
  143. 'name' => 'relationship_type',
  144. 'operations' => ['eq', 'ne', 'contains', 'starts'],
  145. 'sortable' => TRUE,
  146. 'type' => 'xs:string',
  147. 'readonly' => FALSE,
  148. 'required' => TRUE,
  149. ],
  150. 'local:relationship_object' => [
  151. 'searchable' => FALSE,
  152. 'name' => 'relationship_object',
  153. 'operations' => ['eq', 'ne', 'contains', 'starts'],
  154. 'sortable' => FALSE,
  155. 'type' => 'xs:complexType',
  156. 'readonly' => FALSE,
  157. 'required' => TRUE,
  158. 'elements' => [
  159. 'rdfs:type' => [
  160. 'searchable' => TRUE,
  161. 'name' => 'object_type',
  162. 'label' => 'Relationship Object Type',
  163. 'help' => 'The objects\'s data type in a relationship clause',
  164. 'operations' => ['eq', 'ne', 'contains', 'starts'],
  165. 'sortable' => TRUE,
  166. 'type' => 'xs:string',
  167. 'readonly' => FALSE,
  168. 'required' => TRUE,
  169. ],
  170. 'schema:name' => [
  171. 'searchable' => TRUE,
  172. 'name' => 'object_name',
  173. 'label' => 'Relationship Object Name',
  174. 'help' => 'The objects\'s name in a relationship clause',
  175. 'operations' => ['eq', 'ne', 'contains', 'starts'],
  176. 'sortable' => TRUE,
  177. 'type' => 'xs:string',
  178. 'readonly' => FALSE,
  179. 'required' => TRUE,
  180. ],
  181. 'entity' => [
  182. 'searchable' => FALSE,
  183. 'sortable' => FALSE,
  184. ],
  185. ],
  186. ],
  187. ],
  188. ],
  189. ];
  190. }
  191. /**
  192. * Extends TripalField::__construct().
  193. */
  194. public function __construct($field, $instance) {
  195. parent::__construct($field, $instance);
  196. $reltable = $instance['settings']['chado_table'];
  197. $base_table = $instance['settings']['base_table'];
  198. // First, initialize the schema's.
  199. $this->schema = new ChadoSchema();
  200. $this->schema = $this->schema->getTableSchema($reltable);
  201. $this->base_schema = new ChadoSchema();
  202. $this->base_schema = $this->base_schema->getTableSchema($base_table);
  203. // Determine the subject_id/object_id column names.
  204. foreach ($this->schema['foreign keys'][$base_table]['columns'] AS $lcolum => $rcolum) {
  205. if (preg_match('/^subject_.*id/', $lcolum)) {
  206. $this->subject_id_column = $lcolum;
  207. }
  208. else {
  209. if (preg_match('/^object_.*id/', $lcolum)) {
  210. $this->object_id_column = $lcolum;
  211. }
  212. }
  213. }
  214. // Determine the name and type columns.
  215. $this->base_name_columns = [];
  216. $this->base_type_column = 'table_name';
  217. switch ($instance['settings']['chado_table']) {
  218. case 'acquisition_relationship':
  219. case 'analysis_relationship':
  220. case 'biomaterial_relationship':
  221. case 'cell_line_relationship':
  222. case 'quantification_relationship':
  223. $this->base_type_column = 'table_name';
  224. break;
  225. case 'element_relationship':
  226. // RELATIONSHIP->subject_id_key->feature_id->name;
  227. $this->base_name_columns = ['name'];
  228. $this->base_type_column = 'table_name';
  229. break;
  230. case 'organism_relationship':
  231. $this->base_name_columns = ['genus', 'species'];
  232. $this->base_type_column = 'table_name';
  233. break;
  234. case 'project_relationship':
  235. $this->base_name_columns = ['name'];
  236. $this->base_type_column = 'table_name';
  237. break;
  238. case 'phylonode_relationship':
  239. $this->base_name_columns = ['label'];
  240. $this->base_type_column = 'table_name';
  241. break;
  242. case 'pub_relationship':
  243. $this->base_name_columns = ['name'];
  244. $this->base_type_column = 'table_name';
  245. break;
  246. case 'contact':
  247. $this->base_name_columns = ['name'];
  248. $this->base_type_column = 'type_id';
  249. break;
  250. default:
  251. // @todo update this to use the schema.
  252. $this->base_name_columns = ['name'];
  253. $this->base_type_column = 'type_id';
  254. }
  255. }
  256. /**
  257. * Retrive the subject from the current relationship.
  258. *
  259. * @param $relationship
  260. * A single expanded relationship from a variable generated by
  261. * chado_generate_var(). At a minimum, if will have a subject, object and
  262. * type which should be expanded to the appropriate type of record
  263. * depending on the content type this widget is attached to.
  264. *
  265. * @return
  266. * An array of information for the subject of the $relationship.
  267. */
  268. private function getRelationshipSubject($relationship) {
  269. $name = [];
  270. foreach ($this->base_name_columns as $column) {
  271. $name[] = $relationship->{$this->subject_id_column}->{$column};
  272. }
  273. // Retrieve the type.
  274. $type = $this->instance['settings']['base_table'];
  275. if (($this->base_type_column != 'table_name') AND isset($relationship->{$this->subject_id_column}->{$this->base_type_column})) {
  276. $type_object = $relationship->{$this->subject_id_column}->{$this->base_type_column};
  277. if (isset($type_object->name)) {
  278. $type = $type_object->name;
  279. }
  280. elseif (isset($type_object->uniquename)) {
  281. $type = $type_object->uniquename;
  282. }
  283. }
  284. $record = [
  285. 'rdfs:type' => $type,
  286. 'schema:name' => implode(' ', $name),
  287. ];
  288. // If the object has a uniquename then add that in for refernce.
  289. if (property_exists($relationship->{$this->subject_id_column}, 'uniquename')) {
  290. $record['data:0842'] = $relationship->{$this->subject_id_column}->uniquename;
  291. }
  292. // If the object has an organism then add that in for reference.
  293. if (property_exists($relationship->{$this->subject_id_column}, 'organism_id')
  294. AND is_object($relationship->{$this->subject_id_column}->organism_id)) {
  295. $record['OBI:0100026'] = $relationship->{$this->subject_id_column}->organism_id->genus . ' ' . $relationship->{$this->subject_id_column}->organism_id->species;
  296. }
  297. // Add in the TripalEntity ids if the object is published.
  298. if (property_exists($relationship->{$this->subject_id_column}, 'entity_id')) {
  299. $entity_id = $relationship->{$this->subject_id_column}->entity_id;
  300. $record['entity'] = 'TripalEntity:' . $entity_id;
  301. }
  302. return $record;
  303. }
  304. /**
  305. * Retrieve the object from the current relationship.
  306. *
  307. * @param $relationship
  308. * A single expanded relationship from a variable generated by
  309. * chado_generate_var(). At a minimum, if will have a subject, object and
  310. * type which should be expanded to the appropriate type of record
  311. * depending on the content type this widget is attached to.
  312. *
  313. * @return
  314. * An array of information for the object of the $relationship.
  315. */
  316. private function getRelationshipObject($relationship) {
  317. $name = [];
  318. // Retrieve the name (may be multiple parts).
  319. foreach ($this->base_name_columns as $column) {
  320. $name[] = $relationship->{$this->object_id_column}->{$column};
  321. }
  322. // Retrieve the Type.
  323. $type = $this->instance['settings']['base_table'];
  324. if (($this->base_type_column != 'table_name') AND isset($relationship->{$this->object_id_column}->{$this->base_type_column})) {
  325. $type_object = $relationship->{$this->object_id_column}->{$this->base_type_column};
  326. if (isset($type_object->name)) {
  327. $type = $type_object->name;
  328. }
  329. elseif (isset($type_object->uniquename)) {
  330. $type = $type_object->uniquename;
  331. }
  332. }
  333. $record = [
  334. 'rdfs:type' => $type,
  335. 'schema:name' => implode(' ', $name),
  336. ];
  337. // If the object has a unqiuename then add that in for reference.
  338. if (property_exists($relationship->{$this->object_id_column}, 'uniquename')) {
  339. $record['data:0842'] = $relationship->{$this->object_id_column}->uniquename;
  340. }
  341. // If the object has an organism then add that in for reference.
  342. if (property_exists($relationship->{$this->object_id_column}, 'organism_id')
  343. AND is_object($relationship->{$this->object_id_column}->organism_id)) {
  344. $record['OBI:0100026'] = $relationship->{$this->object_id_column}->organism_id->genus . ' ' . $relationship->{$this->object_id_column}->organism_id->species;
  345. }
  346. // Add in the TripalEntity ids if the object is published.
  347. if (property_exists($relationship->{$this->object_id_column}, 'entity_id')) {
  348. $entity_id = $relationship->{$this->object_id_column}->entity_id;
  349. $record['entity'] = 'TripalEntity:' . $entity_id;
  350. }
  351. return $record;
  352. }
  353. /**
  354. * Load a specific relationship as indicated by $delta.
  355. * This function is called by the load method below.
  356. *
  357. * Note: The relationship is loaded by adding it the the entitiy values.
  358. *
  359. * @param $relationship
  360. * A single expanded relationship from a variable generated by
  361. * chado_generate_var(). At a minimum, if will have a subject, object and
  362. * type which should be expanded to the appropriate type of record
  363. * depending on the content type this widget is attached to.
  364. * @param $entity
  365. * The entity the widget is attached to.
  366. * @param $delta
  367. * An integer indicating the specific relationship to load. This is usually
  368. * the rank from the relationship table (if there is one).
  369. */
  370. private function loadRelationship($relationship, &$entity, $delta) {
  371. $field_name = $this->field['field_name'];
  372. $field_table = $this->instance['settings']['chado_table'];
  373. $base_table = $this->instance['settings']['base_table'];
  374. $rel_acc = $relationship->type_id->dbxref_id->db_id->name . ':' . $relationship->type_id->dbxref_id->accession;
  375. $rel_type = $relationship->type_id->name;
  376. $verb = $this->get_rel_verb($rel_type);
  377. $pkey = $this->schema['primary key'][0];
  378. $subject_id_key = $this->subject_id_column;
  379. $object_id_key = $this->object_id_column;
  380. // @todo grab these separately like it was before.
  381. $subject_pkey = $object_pkey = $this->base_schema['primary key'][0];
  382. $entity->{$field_name}['und'][$delta]['value'] = [
  383. 'local:relationship_subject' => $this->getRelationshipSubject($relationship),
  384. 'local:relationship_type' => $relationship->type_id->name,
  385. 'local:relationship_object' => $this->getRelationshipObject($relationship),
  386. ];
  387. // Add the clause to the values array. The clause is a written version
  388. // of the relationships.
  389. $rel_type_clean = lcfirst(preg_replace('/_/', ' ', $rel_type));
  390. $subject_type = $entity->{$field_name}['und'][$delta]['value']['local:relationship_subject']['rdfs:type'];
  391. $subject_name = $entity->{$field_name}['und'][$delta]['value']['local:relationship_subject']['schema:name'];
  392. $object_type = $entity->{$field_name}['und'][$delta]['value']['local:relationship_object']['rdfs:type'];
  393. $object_name = $entity->{$field_name}['und'][$delta]['value']['local:relationship_object']['schema:name'];
  394. // Remember the current entity could be either the subject or object!
  395. // Example: The genetic_marker, MARKER1 , derives from the sequence_variant, VARIANT1.
  396. // The above relationship will be shown both on marker and variant pages
  397. // and as such both subject and object names need to be shown.
  398. $clause = 'The ' . $subject_type . ', ' .
  399. $subject_name . ', ' . $verb . ' ' . $rel_type_clean . ' ' .
  400. $object_type . ', ' . $object_name . '.';
  401. $entity->{$field_name}['und'][$delta]['value']['SIO:000493'] = $clause;
  402. // Adding a label allows us to provide a single text value for the
  403. // entire field. It is this text value that can be used in tab/csv
  404. // downloaders.
  405. $entity->{$field_name}['und'][$delta]['value']['rdfs:label'] = $clause;
  406. $entity->{$field_name}['und'][$delta]['chado-' . $field_table . '__' . $pkey] = $relationship->$pkey;
  407. $entity->{$field_name}['und'][$delta]['chado-' . $field_table . '__' . $subject_id_key] = $relationship->$subject_id_key->$subject_pkey;
  408. $entity->{$field_name}['und'][$delta]['chado-' . $field_table . '__type_id'] = $relationship->type_id->cvterm_id;
  409. $entity->{$field_name}['und'][$delta]['chado-' . $field_table . '__' . $object_id_key] = $relationship->$object_id_key->$object_pkey;
  410. // For the widget to work properly we will preform values.
  411. $entity->{$field_name}['und'][$delta]['type_name'] = $relationship->type_id->name;
  412. $entity->{$field_name}['und'][$delta]['subject_name'] = $subject_name . ' [id: ' . $relationship->$subject_id_key->$subject_pkey . ']';
  413. $entity->{$field_name}['und'][$delta]['object_name'] = $object_name . ' [id: ' . $relationship->$object_id_key->$object_pkey . ']';
  414. if (array_key_exists('value', $this->schema['fields'])) {
  415. $entity->{$field_name}['und'][$delta]['chado-' . $field_table . '__value'] = $relationship->value;
  416. }
  417. if (array_key_exists('rank', $this->schema['fields'])) {
  418. $entity->{$field_name}['und'][$delta]['chado-' . $field_table . '__rank'] = $relationship->rank;
  419. }
  420. }
  421. /**
  422. *
  423. * @see TripalField::load()
  424. */
  425. public function load($entity) {
  426. $settings = $this->field['settings'];
  427. $record = $entity->chado_record;
  428. $field_name = $this->field['field_name'];
  429. $field_type = $this->field['type'];
  430. $field_table = $this->instance['settings']['chado_table'];
  431. $field_column = $this->instance['settings']['chado_column'];
  432. $base_table = $this->instance['settings']['base_table'];
  433. $rel_table = $field_table;
  434. // Get the PKey for this table
  435. $pkey = $this->schema['primary key'][0];
  436. // Not all tables have the columns named 'subject_id' and 'object_id'.
  437. // some have variations on that name and we need to determine what they are.
  438. $subject_id_key = $this->subject_id_column;
  439. $object_id_key = $this->object_id_column;
  440. // If we don't have a chado record return before creating a stub for this field!
  441. if (!$record) {
  442. return;
  443. }
  444. // Set some defaults for the empty record.
  445. $entity->{$field_name}['und'][0] = [
  446. 'value' => '',
  447. 'chado-' . $field_table . '__' . $pkey => '',
  448. 'chado-' . $field_table . '__' . $subject_id_key => '',
  449. 'chado-' . $field_table . '__' . $object_id_key => '',
  450. 'chado-' . $field_table . '__type_id' => '',
  451. // These elements don't need to follow the naming scheme above
  452. // because we don't need the chado_field_storage to try and
  453. // save these values.
  454. 'object_name' => '',
  455. 'subject_name' => '',
  456. 'type_name' => '',
  457. ];
  458. // If the table has rank and value fields then add those to the default
  459. // value array.
  460. if (array_key_exists('value', $this->schema['fields'])) {
  461. $entity->{$field_name}['und'][0]['chado-' . $field_table . '__value'] = '';
  462. }
  463. if (array_key_exists('rank', $this->schema['fields'])) {
  464. $entity->{$field_name}['und'][0]['chado-' . $field_table . '__rank'] = '';
  465. }
  466. // Expand the object to include the relationships.
  467. $options = [
  468. 'return_array' => 1,
  469. // we don't want to fully recurse we only need information about the
  470. // relationship type and the object and subject
  471. 'include_fk' => [
  472. 'type_id' => 1,
  473. $object_id_key => [
  474. 'type_id' => 1,
  475. 'organism_id' => 1,
  476. ],
  477. $subject_id_key => [
  478. 'type_id' => 1,
  479. 'organism_id' => 1,
  480. ],
  481. ],
  482. ];
  483. if (array_key_exists('rank', $this->schema['fields'])) {
  484. $options['order_by'] = ['rank' => 'ASC'];
  485. }
  486. $record = chado_expand_var($record, 'table', $rel_table, $options);
  487. if (!$record->$rel_table) {
  488. return;
  489. }
  490. // Load the subject relationships
  491. $i = 0;
  492. if (isset($record->$rel_table->$subject_id_key)) {
  493. $srelationships = $record->$rel_table->$subject_id_key;
  494. foreach ($srelationships as $relationship) {
  495. $this->loadRelationship($relationship, $entity, $i);
  496. $i++;
  497. }
  498. }
  499. // Load the object relationships
  500. if (isset($record->$rel_table->$object_id_key)) {
  501. $orelationships = $record->$rel_table->$object_id_key;
  502. foreach ($orelationships as $relationship) {
  503. $this->loadRelationship($relationship, $entity, $i);
  504. $i++;
  505. }
  506. }
  507. }
  508. /**
  509. * @see ChadoField::query()
  510. */
  511. public function query($query, $condition) {
  512. $alias = $this->field['field_name'];
  513. $chado_table = $this->instance['settings']['chado_table'];
  514. $base_table = $this->instance['settings']['base_table'];
  515. $bschema = chado_get_schema($base_table);
  516. $bpkey = $bschema['primary key'][0];
  517. $operator = $condition['operator'];
  518. // Bulid the list of expected elements that will be provided.
  519. $field_term_id = $this->getFieldTermID();
  520. $rel_subject = $field_term_id . ',local:relationship_subject';
  521. $rel_subject_type = $rel_subject . ',' . 'rdfs:type';
  522. $rel_subject_name = $rel_subject . ',' . 'schema:name';
  523. $rel_subject_identifier = $rel_subject . ',' . 'data:0842';
  524. $rel_type = $field_term_id . ',local:relationship_type';
  525. $rel_object = $field_term_id . ',local:relationship_object';
  526. $rel_object_type = $rel_object . ',' . 'rdfs:type';
  527. $rel_object_name = $rel_object . ',' . 'schema:name';
  528. $rel_object_identifier = $rel_object . ',' . 'data:0842';
  529. // Filter by the name of the subject or object.
  530. if ($condition['column'] == $rel_subject_name) {
  531. $this->queryJoinOnce($query, $chado_table, $alias, "base.$bpkey = $alias.object_id");
  532. $this->queryJoinOnce($query, $base_table, 'base2', "base2.$bpkey = $alias.subject_id");
  533. $query->condition("base2.name", $condition['value'], $operator);
  534. }
  535. if ($condition['column'] == $rel_object_name) {
  536. $this->queryJoinOnce($query, $chado_table, $alias, "base.$bpkey = $alias.subject_id");
  537. $this->queryJoinOnce($query, $base_table, 'base2', "base2.$bpkey = $alias.object_id");
  538. $query->condition("base2.name", $condition['value'], $operator);
  539. }
  540. // Filter by unique name of the subject or object.
  541. // If this table has a uniquename!
  542. if (isset($this->schema['fields']['uniquename'])) {
  543. if ($condition['column'] == $rel_subject_identifier) {
  544. $this->queryJoinOnce($query, $chado_table, $alias, "base.$bpkey = $alias.object_id");
  545. $this->queryJoinOnce($query, $base_table, 'base2', "base2.$bpkey = $alias.subject_id");
  546. $query->condition("base2.uniquename", $condition['value'], $operator);
  547. }
  548. if ($condition['column'] == $rel_object_identifier) {
  549. $this->queryJoinOnce($query, $chado_table, $alias, "base.$bpkey = $alias.subject_id");
  550. $this->queryJoinOnce($query, $base_table, 'base2', "base2.$bpkey = $alias.object_id");
  551. $query->condition("base2.uniquename", $condition['value'], $operator);
  552. }
  553. }
  554. // Filter by the type of the subject or object
  555. if ($condition['column'] == $rel_subject_type) {
  556. $this->queryJoinOnce($query, $chado_table, $alias, "base.$bpkey = $alias.object_id");
  557. $this->queryJoinOnce($query, $base_table, 'base2', "base2.$bpkey = $alias.subject_id");
  558. $this->queryJoinOnce($query, 'cvterm', 'SubjectCVT', "SubjectCVT.cvterm_id = base2.type_id");
  559. $this->queryJoinOnce($query, "SubjectCVT.name", $condition['value'], $operator);
  560. }
  561. if ($condition['column'] == $rel_object_type) {
  562. $this->queryJoinOnce($query, $chado_table, $alias, "base.$bpkey = $alias.subject_id");
  563. $this->queryJoinOnce($query, $base_table, 'base2', "base2.$bpkey = $alias.object_id");
  564. $this->queryJoinOnce($query, 'cvterm', 'ObjectCVT', "ObjectCVT.cvterm_id = base2.type_id");
  565. $query->condition("ObjectCVT.name", $condition['value'], $operator);
  566. }
  567. // Filter by relationship type
  568. if ($condition['column'] == 'relationship.relationship_type') {
  569. // This filter commented out because it's way to slow...
  570. // $this->queryJoinOnce($query, $chado_table, $alias, "base.$bpkey = $alias.subject_id OR base.$bpkey = $alias.object_id");
  571. // $this->queryJoinOnce($query, 'cvterm', 'RelTypeCVT', "RelTypeCVT.cvterm_id = $alias.type_id");
  572. // $query->condition("RelTypeCVT.name", $condition['value'], $operator);
  573. }
  574. }
  575. /**
  576. * A helper function to define English verbs for relationship types.
  577. *
  578. * @param $rel_type
  579. * The vocabulary term name for the relationship.
  580. *
  581. * @return
  582. * The verb to use when creating a sentence of the relationship.
  583. */
  584. private function get_rel_verb($rel_type) {
  585. $rel_type_clean = lcfirst(preg_replace('/_/', ' ', $rel_type));
  586. $verb = '';
  587. switch ($rel_type_clean) {
  588. case 'integral part of':
  589. case 'instance of':
  590. $verb = 'is an';
  591. break;
  592. case 'proper part of':
  593. case 'transformation of':
  594. case 'genome of':
  595. case 'part of':
  596. $verb = 'is a';
  597. case 'position of':
  598. case 'sequence of':
  599. case 'variant of':
  600. $verb = 'is a';
  601. break;
  602. case 'derives from':
  603. case 'connects on':
  604. case 'contains':
  605. case 'finishes':
  606. case 'guides':
  607. case 'has origin':
  608. case 'has part':
  609. case 'has quality':
  610. case 'is a':
  611. case 'is a maternal parent of':
  612. case 'is a paternal parent of':
  613. case 'is consecutive sequence of':
  614. case 'maximally overlaps':
  615. case 'overlaps':
  616. case 'starts':
  617. break;
  618. default:
  619. $verb = 'is';
  620. }
  621. return $verb;
  622. }
  623. /**
  624. *
  625. * @see TripalField::settingsForm()
  626. */
  627. public function instanceSettingsForm() {
  628. $element = parent::instanceSettingsForm();
  629. $element['items_per_page'] = [
  630. '#type' => 'textfield',
  631. '#title' => 'Items per Page',
  632. '#description' => t('The number of items that should appear on each page. A pager is provided if more than this number of items exist.'),
  633. '#default_value' => $this->instance['settings']['items_per_page'],
  634. ];
  635. //$element = parent::instanceSettingsForm();
  636. $element['relationships'] = [
  637. '#type' => 'fieldset',
  638. '#title' => 'Allowed Relationship Types',
  639. '#description' => t('There are three ways that relationship types
  640. can be limited for users who have permission to add new relationships.
  641. Please select the most appropriate for you use case. By default
  642. all vocabularies are provided to the user which allows use of any
  643. term for the relationship type.'),
  644. '#collapsed' => TRUE,
  645. '#collapsible' => TRUE,
  646. ];
  647. // $element['instructions'] = array(
  648. // '#type' => 'item',
  649. // '#markup' => 'You may provide a list of terms that will be available in a select box
  650. // as the relationship types. This select box will replace the vocabulary select box if the
  651. // following value is set.'
  652. // );
  653. $vocs = chado_get_cv_select_options();
  654. $element['relationships']['option1'] = [
  655. '#type' => 'item',
  656. '#title' => 'Option #1',
  657. '#description' => t('Use this option to limit the vocabularies that a user .
  658. could use to specify relationship types. With this option any term in .
  659. the vocabulary can be used for the relationship type. You may select
  660. more than one vocabulary.'),
  661. ];
  662. $element['relationships']['option1_vocabs'] = [
  663. '#type' => 'select',
  664. '#multiple' => TRUE,
  665. '#options' => $vocs,
  666. '#size' => 6,
  667. '#default_value' => $this->instance['settings']['relationships']['option1_vocabs'],
  668. // TODO add ajax here so that the relationship autocomplete below works
  669. ];
  670. $element['relationships']['option2'] = [
  671. '#type' => 'item',
  672. '#title' => '<b>Option #2</b>',
  673. '#description' => 'Some vocabularies are heirarchichal (an ontology). Within this
  674. heirarchy groups of related terms typically fall under a common parent. If you
  675. wish to limit the list of terms that a user can use for the relationship type,
  676. you can provide the parent term here. Then, only that term\'s children will
  677. be avilable for use as a relationship type.',
  678. ];
  679. $element['relationships']['option2_vocab'] = [
  680. '#type' => 'select',
  681. '#description' => 'Specify Default Vocabulary',
  682. '#multiple' => FALSE,
  683. '#options' => $vocs,
  684. '#default_value' => $this->instance['settings']['relationships']['option2_vocab'],
  685. '#ajax' => [
  686. 'callback' => "sbo__relationship_instance_settings_form_ajax_callback",
  687. 'wrapper' => 'relationships-option2-parent',
  688. 'effect' => 'fade',
  689. 'method' => 'replace',
  690. ],
  691. ];
  692. $element['relationships']['option2_parent'] = [
  693. '#type' => 'textfield',
  694. '#description' => 'Specify a Heirarchical Parent Term',
  695. '#default_value' => $this->instance['settings']['relationships']['option2_parent'],
  696. '#autocomplete_path' => "admin/tripal/storage/chado/auto_name/cvterm/",
  697. '#prefix' => '<div id=relationships-option2-parent>',
  698. '#suffix' => '</div>',
  699. ];
  700. $element['relationships']['option3'] = [
  701. '#type' => 'item',
  702. '#title' => 'Option #3',
  703. '#description' => 'Provide terms separated by a new line. The term provided should be
  704. unique and distinguishable by the name. You can use a bar | to separate a vocabulary
  705. and a term to allow more specific assignment.',
  706. ];
  707. $element['relationships']['relationship_types'] = [
  708. '#type' => 'textarea',
  709. '#default_value' => $this->instance['settings']['relationships']['relationship_types'],
  710. ];
  711. return $element;
  712. }
  713. /**
  714. *
  715. * @param unknown $form
  716. * @param unknown $form_state
  717. */
  718. public function instanceSettingsFormValidate($form, &$form_state) {
  719. // Get relationships settings
  720. $settings = $form_state['values']['instance']['settings']['relationships'];
  721. $form_state['values']['instance']['settings']['relationships']['relationship_types'] = trim($settings['relationship_types']);
  722. // Make sure only one option is selected
  723. $option1test = $settings['option1_vocabs'];
  724. $option1 = isset($settings['option1_vocabs']) && array_pop($option1test);
  725. $option2 = (isset($settings['option2_vocab']) && $settings['option2_vocab']) || $settings['option2_parent'];
  726. $option3 = isset($settings['relationship_types']) && trim($settings['relationship_types']);
  727. if ($option1 && ($option2 || $option3) == 1 ||
  728. $option2 && ($option1 || $option3) == 1 ||
  729. $option3 && ($option1 || $option2) == 1) {
  730. form_set_error("instance][settings][relationships", t("Only one option is allowed to limit the relationship types."));
  731. return;
  732. }
  733. // For option3, make sure the supplied types are valid cvterms
  734. if ($option3) {
  735. $rel_types = explode(PHP_EOL, $settings['relationship_types']);
  736. foreach ($rel_types AS $type) {
  737. $type = trim($type);
  738. // Ignore empty lines
  739. if ($type == '') {
  740. continue;
  741. }
  742. // Find the matching cvterm
  743. $sql = "SELECT cvterm_id FROM {cvterm} WHERE name = :name";
  744. $results = chado_query($sql, [':name' => $type]);
  745. $terms = [];
  746. while ($obj = $results->fetchObject()) {
  747. $terms[] = $obj;
  748. }
  749. // Don't save the form if a term can not be found or it matches more than one cvterm
  750. $cv = '';
  751. if (count($terms) == 0) {
  752. // If a term can not be found, maybe the type contains '|', parse it as 'vocabulary|cvterm'
  753. if (strpos($type, '|')) {
  754. $tmp = explode('|', $type, 2);
  755. $type = trim($tmp[1]);
  756. $cv = chado_get_cv(['name' => trim($tmp[0])]);
  757. if ($cv) {
  758. $sql = "SELECT cvterm_id FROM {cvterm} WHERE name = :name AND cv_id = :cv_id";
  759. $results = chado_query($sql, [
  760. ':name' => $type,
  761. ':cv_id' => $cv->cv_id,
  762. ]);
  763. while ($obj = $results->fetchObject()) {
  764. $terms[] = $obj;
  765. }
  766. }
  767. else {
  768. $cv = $tmp[0];
  769. }
  770. }
  771. if (count($terms) != 1) {
  772. $message = "The term '@type' can not be found.";
  773. $token = ['@type' => $type];
  774. if ($cv) {
  775. $message = "The term '@type' can not be found within the vocabulary '@vocab'.";
  776. $token['@vocab'] = $cv;
  777. }
  778. form_set_error("instance][settings][relationships][relationship_types",
  779. t($message, $token));
  780. }
  781. }
  782. else {
  783. if (count($terms) > 1) {
  784. // If a type matches more than one term, parse it as 'vocabulary|cvterm' and try again
  785. if (strpos($type, '|')) {
  786. $tmp = explode('|', $type, 2);
  787. $type = trim($tmp[1]);
  788. $cv = chado_get_cv(['name' => trim($tmp[0])]);
  789. if ($cv) {
  790. $sql = "SELECT cvterm_id FROM {cvterm} WHERE name = :name AND cv_id = :cv_id";
  791. $results = chado_query($sql, [
  792. ':name' => $type,
  793. ':cv_id' => $cv->cv_id,
  794. ]);
  795. while ($obj = $results->fetchObject()) {
  796. $terms[] = $obj;
  797. }
  798. }
  799. }
  800. if (count($terms) != 1) {
  801. form_set_error("instance][settings][relationships][relationship_types",
  802. t("The term '@type' matches more than one term. Please specify its vocabulary in the format of 'vocabulary|@type'.", ['@type' => $type]));
  803. }
  804. }
  805. }
  806. }
  807. }
  808. // For option2: Make sure the parent term is a valid cvterm
  809. if ($option2) {
  810. $cv_id = $settings['option2_vocab'];
  811. $supertype = $settings['option2_parent'];
  812. $term = chado_get_cvterm([
  813. 'name' => trim($supertype),
  814. 'cv_id' => $cv_id,
  815. ]);
  816. // Tripal cv autocomplete also allow cvterm synonyms, if the parent term doesn't match
  817. // a cvterm, try cvtermsynonym
  818. if (!$term) {
  819. $synonym = chado_get_cvterm(
  820. [
  821. 'synonym' => [
  822. 'name' => trim($supertype),
  823. ],
  824. ]
  825. );
  826. if ($synonym && $synonym->cv_id->cv_id == $cv_id) {
  827. $term = $synonym;
  828. }
  829. }
  830. if (!isset($term->cvterm_id)) {
  831. form_set_error("instance][settings][relationships][option2_parent",
  832. t("The term '@type' is not a valid term for the vocabulary selected.", ['@type' => $supertype]));
  833. }
  834. }
  835. }
  836. /**
  837. * @see TripalField::validate()
  838. */
  839. public function validate($entity_type, $entity, $langcode, $items, &$errors) {
  840. // If we don't have an entity then we don't want to validate. The case
  841. // where this could happen is when a user is editing the field settings
  842. // and trying to set a default value. In that case there's no entity and
  843. // we don't want to validate. There will always be an entity for creation
  844. // and update operations of a content type.
  845. if (!$entity) {
  846. return;
  847. }
  848. $field_name = $this->field['field_name'];
  849. $field_type = $this->field['type'];
  850. $field_table = $this->instance['settings']['chado_table'];
  851. $field_column = $this->instance['settings']['chado_column'];
  852. $base_table = $this->instance['settings']['base_table'];
  853. // Grab the chado record_id for this entity.
  854. $chado_record_id = NULL;
  855. if ($entity AND isset($entity->chado_record_id)) {
  856. $chado_record_id = $entity->chado_record_id;
  857. }
  858. // Validate each releationship.
  859. foreach ($items as $delta => $item) {
  860. $item_errors = $this->validateItem($item, $chado_record_id);
  861. if (!empty($item_errors)) {
  862. $errors[$field_name][$delta][$langcode] = $item_errors;
  863. }
  864. }
  865. }
  866. /**
  867. * Validate a Single relationship.
  868. *
  869. * @param $item
  870. * A single item from the $items array passed to TripalField::validate().
  871. *
  872. * @return
  873. * An array of errors where each has a:
  874. * - error: this is an error code which is the name of the field.
  875. * - message: A message to show the user describing the problem.
  876. */
  877. public function validateItem($item, $chado_record_id = NULL) {
  878. $errors = [];
  879. $field_name = $this->field['field_name'];
  880. $field_type = $this->field['type'];
  881. $field_table = $this->instance['settings']['chado_table'];
  882. $field_column = $this->instance['settings']['chado_column'];
  883. $base_table = $this->instance['settings']['base_table'];
  884. // 'nd_reagent_relationship' and 'project_relationship' have different column names from
  885. // subject_id/object_id. Do a pattern matching to get the column names.
  886. $subject_id_key = $this->subject_id_column;
  887. $object_id_key = $this->object_id_column;
  888. $subject_id = $item['chado-' . $field_table . '__' . $subject_id_key];
  889. $object_id = $item['chado-' . $field_table . '__' . $object_id_key];
  890. $type_id = $item['chado-' . $field_table . '__type_id'];
  891. $type_id = isset($item['type_id']) ? $item['chado-' . $field_table . '__type_id'] : $type_id;
  892. $type_name = isset($item['type_name']) ? $item['type_name'] : '';
  893. $voc_id = isset($item['vocabulary']) ? $item['vocabulary'] : '';
  894. $subject_name = isset($item['subject_name']) ? $item['subject_name'] : '';
  895. $object_name = isset($item['object_name']) ? $item['object_name'] : '';
  896. // If the row is empty then just continue, there's nothing to validate.
  897. if (!$type_id and !$type_name and !$subject_name and !$object_name) {
  898. return;
  899. }
  900. // Check: Make sure we have values for all of the fields.
  901. if (!$type_name && !$type_id) {
  902. $errors[] = [
  903. 'error' => 'sbo__relationship',
  904. 'message' => t("Please provide the type of relationship."),
  905. 'element' => 'type',
  906. ];
  907. }
  908. if (!$subject_name) {
  909. $errors[] = [
  910. 'error' => 'sbo__relationship',
  911. 'message' => t("Please provide the subject of the relationship."),
  912. 'element' => 'subject',
  913. ];
  914. }
  915. if (!$object_name) {
  916. $errors[] = [
  917. 'error' => 'sbo__relationship',
  918. 'message' => t("Please provide the object of the relationship."),
  919. 'element' => 'object',
  920. ];
  921. }
  922. // Check: Cvterm exists.
  923. if (!$type_id AND !$type_name) {
  924. $errors[] = [
  925. 'error' => 'sbo__relationship',
  926. 'message' => t("We were unable to find the type you specified. Please check spelling and that the term already exists."),
  927. 'element' => 'type',
  928. ];
  929. }
  930. elseif ($type_name AND $voc_id) {
  931. $val = [
  932. 'cv_id' => $voc_id,
  933. 'name' => $type_name,
  934. ];
  935. $cvterm = chado_generate_var('cvterm', $val);
  936. if (!isset($cvterm->cvterm_id)) {
  937. $errors[] = [
  938. 'error' => 'sbo__relationship',
  939. 'message' => t("We were unable to find the type you specified. Please check spelling and that the term already exists."),
  940. 'element' => 'type',
  941. ];
  942. }
  943. }
  944. // Before submitting this form we need to make sure that our subject_id and
  945. // object_ids are real records. There are two ways to get the record, either
  946. // just with the text value or with an [id: \d+] string embedded. If the
  947. // later we will pull it out.
  948. $subject_id = '';
  949. $fkey_rcolumn = $this->schema['foreign keys'][$base_table]['columns'][$subject_id_key];
  950. $matches = [];
  951. if (preg_match('/\[id: (\d+)\]/', $subject_name, $matches)) {
  952. $subject_id = $matches[1];
  953. $values = [$fkey_rcolumn => $subject_id];
  954. $subject = chado_select_record($base_table, [$fkey_rcolumn], $values);
  955. if (count($subject) == 0) {
  956. $errors[] = [
  957. 'error' => 'sbo__relationship',
  958. 'message' => t("The subject record cannot be found using the specified id (e.g. [id: xx])."),
  959. 'element' => 'subject',
  960. ];
  961. }
  962. }
  963. else {
  964. // Otherwise we need to look it up using the name field determined in the
  965. // constructor for the current field. There may be more then one name field
  966. // (e.g. organism: genus + species) so we want to check both.
  967. $sql = 'SELECT ' . $fkey_rcolumn . ' FROM {' . $base_table . '} WHERE ' . implode('||', $this->base_name_columns) . '=:keyword';
  968. $subject = chado_query($sql, [':keyword' => $subject_name])->fetchAll();
  969. if (count($subject) == 0 AND $chado_record_id) {
  970. $errors[] = [
  971. 'error' => 'sbo__relationship',
  972. 'message' => t("The subject record cannot be found. Please check spelling."),
  973. 'element' => 'subject',
  974. ];
  975. }
  976. elseif (count($subject) > 1) {
  977. $errors[] = [
  978. 'error' => 'sbo__relationship',
  979. 'message' => t("The subject is not unique and therefore the relationship cannot be made."),
  980. 'element' => 'subject',
  981. ];
  982. }
  983. }
  984. // Now check for a matching object.
  985. $object_id = '';
  986. $fkey_rcolumn = $this->schema['foreign keys'][$base_table]['columns'][$object_id_key];
  987. $matches = [];
  988. if (preg_match('/\[id: (\d+)\]/', $object_name, $matches)) {
  989. $object_id = $matches[1];
  990. $values = [$fkey_rcolumn => $object_id];
  991. $object = chado_select_record($base_table, [$fkey_rcolumn], $values);
  992. if (count($subject) == 0 AND $chado_record_id) {
  993. $errors[] = [
  994. 'error' => 'sbo__relationship',
  995. 'message' => t("The object record cannot be found using the specified id (e.g. [id: xx])."),
  996. 'element' => 'object',
  997. ];
  998. }
  999. }
  1000. else {
  1001. // Otherwise we need to look it up using the name field determined in the
  1002. // constructor for the current field. There may be more then one name field
  1003. // (e.g. organism: genus + species) so we want to check both.
  1004. $sql = 'SELECT ' . $fkey_rcolumn . ' FROM {' . $base_table . '} WHERE ' . implode('||', $this->base_name_columns) . '=:keyword';
  1005. $object = chado_query($sql, [':keyword' => $object_name]);
  1006. if (count($object) == 0) {
  1007. $errors[] = [
  1008. 'error' => 'sbo__relationship',
  1009. 'message' => t("The object record cannot be found. Please check spelling."),
  1010. 'element' => 'object',
  1011. ];
  1012. }
  1013. elseif (count($object) > 1) {
  1014. $errors[] = [
  1015. 'error' => 'sbo__relationship',
  1016. 'message' => t("The object is not unique and therefore the relationship cannot be made."),
  1017. 'element' => 'object',
  1018. ];
  1019. }
  1020. }
  1021. // Make sure that either our object or our subject refers to the base record.
  1022. if ($object_id AND $subject_id) {
  1023. if ($object_id != $chado_record_id and $subject_id != $chado_record_id) {
  1024. $errors[] = [
  1025. 'error' => 'sbo__relationship',
  1026. 'message' => t("Either the subject or the object in the relationship must refer to this record."),
  1027. 'element' => 'row',
  1028. ];
  1029. }
  1030. }
  1031. // Make sure that the object and subject are not both the same thing.
  1032. if ($object_id AND $subject_id) {
  1033. if ($object_id == $subject_id) {
  1034. $errors[] = [
  1035. 'error' => 'sbo__relationship',
  1036. 'message' => t("The subject and the object in the relationship cannot both refer to the same record."),
  1037. 'element' => 'row',
  1038. ];
  1039. }
  1040. }
  1041. return $errors;
  1042. }
  1043. /**
  1044. * @see ChadoField::queryOrder()
  1045. */
  1046. public function queryOrder($query, $order) {
  1047. }
  1048. /**
  1049. * Retrieve the schema's
  1050. */
  1051. public function getRelTableSchema() {
  1052. return $this->schema;
  1053. }
  1054. public function getBaseTableSchema() {
  1055. return $this->base_schema;
  1056. }
  1057. /**
  1058. * Retrieve the subject/object key columns.
  1059. */
  1060. public function getSubjectIdColumn() {
  1061. return $this->subject_id_column;
  1062. }
  1063. public function getObjectIdColumn() {
  1064. return $this->object_id_column;
  1065. }
  1066. /**
  1067. * Retrieve the base name columns.
  1068. */
  1069. public function getBaseNameColumns() {
  1070. return $this->base_name_columns;
  1071. }
  1072. /**
  1073. * Retrieve the base type column.
  1074. */
  1075. public function getBaseTypeColumn() {
  1076. return $this->base_type_column;
  1077. }
  1078. }