123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <?php
- class local__source_data extends ChadoField {
-
-
-
-
-
-
-
-
- public static $default_label = 'Source of Data';
-
- public static $description = 'The source data used for this analysis.';
-
-
-
-
-
-
-
- public static $default_instance_settings = array(
-
- 'term_vocabulary' => 'local',
-
- 'term_name' => 'source_data',
-
- 'term_accession' => 'source_data',
-
-
-
- 'term_fixed' => FALSE,
- );
-
- public static $default_widget = 'local__source_data_widget';
-
- public static $default_formatter = 'local__source_data_formatter';
-
-
-
-
-
- protected $field;
-
-
-
- protected $instance;
-
- public function elementInfo() {
- $field_term = $this->getFieldTermID();
- $sourcename_term = chado_get_semweb_term('analysis', 'sourcename');
- $sourceversion_term = chado_get_semweb_term('analysis', 'sourceversion');
- $sourceuri_term = chado_get_semweb_term('analysis', 'sourceuri');
- return array(
- $field_term => array(
- 'operations' => array(),
- 'sortable' => FALSE,
- 'searchable' => FALSE,
- 'type' => 'xs:complexType',
- 'readonly' => TRUE,
- 'elements' => array(
- $sourcename_term => array(
- 'searchable' => TRUE,
- 'label' => 'Data Source Name',
- 'help' => 'The name of the data source used for the analysis.',
- 'sortable' => TRUE,
- 'type' => 'xs:string',
- 'readonly' => TRUE,
- 'required' => FALSE,
- ),
- $sourceversion_term => array(
- 'searchable' => TRUE,
- 'label' => 'Data Source Version',
- 'help' => 'If applicable, the version number of the source data used for the analysis.',
- 'sortable' => TRUE,
- 'type' => 'xs:string',
- 'readonly' => TRUE,
- 'required' => FALSE,
- ),
- $sourceuri_term => array(
- 'searchable' => FALSE,
- 'label' => 'Data Source URI',
- 'help' => 'If applicable, the universal resource indicator (e.g. URL) of the source data used for the analysis.',
- 'sortable' => FALSE,
- 'type' => 'xs:string',
- 'readonly' => TRUE,
- 'required' => FALSE,
- ),
- ),
- ),
- );
- }
-
- public function query($query, $condition) {
- $operator = $condition['operator'];
- $field_term_id = $this->getFieldTermID();
- $sourcename_term = $field_term_id . ',' . chado_get_semweb_term('analysis', 'sourcename');
- $sourceversion_term = $field_term_id . ',' . chado_get_semweb_term('analysis', 'sourceversion');
- $sourceuri_term = $field_term_id . ',' . chado_get_semweb_term('analysis', 'sourceuri');
- if ($condition['column'] == $sourcename_term) {
- $query->condition("base.sourcename", $condition['value'], $operator);
- }
- if ($condition['column'] == $sourceversion_term) {
- $query->condition("base.sourceversion", $condition['value'], $operator);
- }
- }
-
- public function queryOrder($query, $order) {
- $field_term_id = $this->getFieldTermID();
- $sourcename_term = $field_term_id . ',' . chado_get_semweb_term('analysis', 'sourcename');
- $sourceversion_term = $field_term_id . ',' . chado_get_semweb_term('analysis', 'sourceversion');
- $sourceuri_term = $field_term_id . ',' . chado_get_semweb_term('analysis', 'sourceuri');
- if ($order['column'] == $sourcename_term) {
- $query->orderBy("base.sourcename", $order['direction']);
- }
- if ($order['column'] == $sourceversion_term) {
- $query->orderBy("base.sourceversion", $order['direction']);
- }
- }
-
- public function load($entity) {
- $analysis = $entity->chado_record;
- $field_name = $this->field['field_name'];
- $field_type = $this->field['type'];
- $field_table = $this->instance['settings']['chado_table'];
- $field_column = $this->instance['settings']['chado_column'];
- $sourcename_term = chado_get_semweb_term('analysis', 'sourcename');
- $sourceversion_term = chado_get_semweb_term('analysis', 'sourceversion');
- $sourceuri_term = chado_get_semweb_term('analysis', 'sourceuri');
- $entity->{$field_name}['und'][0] = array(
- 'value' => array(
- $sourcename_term => $analysis->sourcename,
- $sourceversion_term => $analysis->sourceversion,
- $sourceuri_term => $analysis->sourceuri,
- ),
- 'chado-analysis__sourcename' => $analysis->sourcename,
- 'chado-analysis__sourceversion' => $analysis->sourceversion,
- 'chado-analysis__sourceuri' => $analysis->sourceuri,
- );
- }
- }
|