Browse Source

Added checksum widget formatter classes

Stephen Ficklin 8 years ago
parent
commit
28221e5104

+ 0 - 1
tripal_chado/includes/TripalFields/data__accession.inc

@@ -32,7 +32,6 @@ class data__accession extends TripalField {
     'chado_table' => '',
     'chado_column' => '',
     'base_table' => '',
-    'semantic_web' => '',
   );
 
   // Provide a list of instance specific settings. These can be access within

+ 71 - 0
tripal_chado/includes/TripalFields/data__sequence_checksum.inc

@@ -0,0 +1,71 @@
+<?php
+
+class data__sequence_checksum extends TripalField {
+
+
+  // --------------------------------------------------------------------------
+  //                     EDITABLE STATIC CONSTANTS
+  //
+  // The following constants SHOULD be set for each descendent class.  They are
+  // used by the static functions to provide information to Drupal about
+  // the field and it's default widget and formatter.
+  // --------------------------------------------------------------------------
+
+  // The term that this field maps to.  The format for the term should be:
+  // [vocab]:[accession] where [vocab] is the short name of the vocabulary
+  // and [acession] is the unique accession number for the term.  This term
+  // must already exist in the vocabulary storage backend. This
+  // value should never be changed once fields exist for this type.
+  public static $term = 'data:2190';
+
+  // The default lable for this field.
+  public static $label = 'Sequence MD5 checksum';
+
+  // The default description for this field.
+  public static $description = 'A field for generating MD5 checksum for a sequence.';
+
+  // Provide a list of global settings. These can be accessed witihn the
+  // globalSettingsForm.  When the globalSettingsForm is submitted then
+  // Drupal will automatically change these settings for all fields.
+  public static $settings = array(
+    'chado_table' => '',
+    'chado_column' => '',
+    'base_table' => '',
+  );
+
+  // Provide a list of instance specific settings. These can be access within
+  // the instanceSettingsForm.  When the instanceSettingsForm is submitted
+  // then Drupal with automatically change these settings for the instnace.
+  // It is recommended to put settings at the instance level whenever possible.
+  public static $instance_settings  = array();
+
+  // Set this to the name of the storage backend that by default will support
+  // this field.
+  public static $storage = 'tripal_no_storage';
+
+  // The default widget for this field.
+  public static $default_widget = 'data__sequence_checksum_widget';
+
+  // The default formatter for this field.
+  public static $default_formatter = 'data__sequence_checksum_formatter';
+
+  // --------------------------------------------------------------------------
+  //              PROTECTED CLASS MEMBERS -- DO NOT OVERRIDE
+  // --------------------------------------------------------------------------
+  // An array containing details about the field. The format of this array
+  // is the same as that returned by field_info_fields()
+  protected $field;
+  // An array containing details about an instance of the field. A field does
+  // not have to have an instance.  But if dealing with an instance (such as
+  // when using the widgetForm, formatterSettingsForm, etc.) it should be set.
+  protected $instance;
+
+
+
+  /**
+   * @see TripalField::load()
+   */
+  public function load($entity, $details = array()) {
+
+  }
+}

+ 27 - 0
tripal_chado/includes/TripalFields/data__sequence_checksum_formatter.inc

@@ -0,0 +1,27 @@
+<?php
+
+class data__sequence_checksum_formatter extends TripalFieldFormatter {
+  // The default lable for this field.
+  public static $label = 'Sequence MD5 checksum';
+
+  // The list of field types for which this formatter is appropriate.
+  public static $field_types = array('data__sequence_checksum');
+
+  // The list of default settings for this formatter.
+  public static $settings = array();
+
+
+ /**
+  * @see TripalFieldFormatter::view()
+  */
+  public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
+    foreach ($items as $delta => $item) {
+      $content = key_exists('value', $item) ? $item['value'] : '';
+      $element[$delta] = array(
+        // We create a render array to produce the desired markup,
+        '#type' => 'markup',
+        '#markup' => $content,
+      );
+    }
+  }
+}

+ 1 - 0
tripal_chado/includes/TripalFields/data__sequence_checksum_widget.inc

@@ -0,0 +1 @@
+<?php

+ 1 - 1
tripal_chado/includes/tripal_chado.fields.inc

@@ -55,7 +55,7 @@ function tripal_chado_bundle_create_fields($entity_type, $bundle) {
 
   // Create custom fields.
   tripal_chado_bundle_create_fields_custom($info, $details, $entity_type, $bundle);
-dpm($info);
+
   // Create fields for linking tables.
   //tripal_chado_bundle_create_fields_linker($info, $details, $entity_type, $bundle);
 

+ 6 - 8
tripal_chado/includes/tripal_chado.semweb.inc

@@ -472,11 +472,11 @@ function tripal_chado_semweb_form($form, &$form_state, $chado_table = NULL) {
   if ($chado_table) {
     $schema = chado_get_schema($chado_table);
     $pk = $schema['primary key'][0];
-    $cv_default = db_select('tripal_cv_defaults', 'tc')
-      ->fields('tc', array('field_name'))
-      ->condition('table_name', $chado_table)
-      ->execute()
-      ->fetchField();
+//     $cv_default = db_select('tripal_cv_defaults', 'tc')
+//       ->fields('tc', array('field_name'))
+//       ->condition('table_name', $chado_table)
+//       ->execute()
+//       ->fetchField();
     $columns = $schema['fields'];
     $headers = array(
       'Field Name',
@@ -505,9 +505,7 @@ function tripal_chado_semweb_form($form, &$form_state, $chado_table = NULL) {
         $sw_desc = '';
         $sw_accession = '';
         if($cvterm_id) {
-          $term = tripal_get_cvterm(array(
-            'cvterm_id' => $cvterm_id
-          ));
+          $term = chado_generate_var('cvterm', array('cvterm_id' => $cvterm_id));
           $sw_voc = $term->cv_id->name;
           $sw_term = $term->name;
           $sw_accession = l($term->dbxref_id->db_id->name . ':' . $term->dbxref_id->accession,