|
@@ -115,6 +115,11 @@ function tripal_chado_bundle_fields_info_base(&$info, $details, $entity_type, $b
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ // Skip the type ID as it will be handled by a custom field.
|
|
|
+ if ($column_name == 'type_id') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
// Set some defaults for the field.
|
|
|
$base_info = array(
|
|
|
'field_name' => $field_name,
|
|
@@ -191,7 +196,6 @@ function tripal_chado_bundle_fields_info_base(&$info, $details, $entity_type, $b
|
|
|
$base_info['type'] = 'text';
|
|
|
$base_info['settings']['text_processing'] = 0;
|
|
|
}
|
|
|
-
|
|
|
$info[$field_name] = $base_info;
|
|
|
}
|
|
|
}
|
|
@@ -209,8 +213,8 @@ function tripal_chado_bundle_fields_info_custom(&$info, $details, $entity_type,
|
|
|
|
|
|
$schema = chado_get_schema($table_name);
|
|
|
|
|
|
- // An additional type for the publication
|
|
|
- if ($table_name == 'pub') {
|
|
|
+ // Handle type_id fields that are not the type_column.
|
|
|
+ if (array_key_exists('type_id', $schema['fields']) and 'type_id' != $type_column) {
|
|
|
$field_name = 'schema__additional_type';
|
|
|
$field_type = 'schema__additional_type';
|
|
|
$info[$field_name] = array(
|
|
@@ -448,11 +452,27 @@ function tripal_chado_bundle_fields_info_custom(&$info, $details, $entity_type,
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ //protocol
|
|
|
+ if ($table_name == 'protocol' and array_key_exists('protocol_id', $schema['fields'])) {
|
|
|
+ $field_name = 'sep__protocol';
|
|
|
+ $field_type = 'sep__protocol';
|
|
|
+ $info[$field_name] = array(
|
|
|
+ 'field_name' => $field_name,
|
|
|
+ 'type' => $field_type,
|
|
|
+ 'cardinality' => 1,
|
|
|
+ 'locked' => FALSE,
|
|
|
+ 'storage' => array(
|
|
|
+ 'type' => 'field_chado_storage',
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
- * @param unknown $details
|
|
|
+ * @param $details
|
|
|
*/
|
|
|
function tripal_chado_bundle_fields_info_linker(&$info, $details, $entity_type, $bundle) {
|
|
|
|
|
@@ -776,14 +796,19 @@ function tripal_chado_bundle_instances_info_base(&$info, $entity_type, $bundle,
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- // Don't create base fields for the primary key and the type_id field.
|
|
|
- if ($column_name == $pkey or $column_name == $type_column) {
|
|
|
+ // Skip the cvterm.is_relationshptype.
|
|
|
+ if ($table_name == 'cvterm' and $column_name == 'is_relationshiptype') {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- // Skip the type field that will always be custom
|
|
|
- if (($table_name == $type_table and $column_name == $type_column) or
|
|
|
- $column_name == 'type_id') {
|
|
|
+ // The biosourceprovider_id and taxon_id are handled by custom fields.
|
|
|
+ if ($table_name == 'biomaterial' and (
|
|
|
+ $column_name == 'biosourceprovider_id' or $column_name == 'taxon_id')) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Don't create base fields for the primary key and the type_id field.
|
|
|
+ if ($column_name == $pkey or $column_name == $type_column) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -793,12 +818,6 @@ function tripal_chado_bundle_instances_info_base(&$info, $entity_type, $bundle,
|
|
|
// don't create another one here.
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
- if ($table_name == 'biomaterial' and (
|
|
|
- $column_name == 'biosourceprovider_id' or $column_name == 'taxon_id')) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
$field_name = strtolower($cvterm->dbxref_id->db_id->name . '__' . preg_replace('/[^\w]/', '_', $cvterm->name));
|
|
|
$field_name = substr($field_name, 0, 32);
|
|
|
|
|
@@ -813,6 +832,11 @@ function tripal_chado_bundle_instances_info_base(&$info, $entity_type, $bundle,
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ // Skip the type ID as it will be handled by a custom field.
|
|
|
+ if ($column_name == 'type_id') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
$base_info = array(
|
|
|
'field_name' => $field_name,
|
|
|
'entity_type' => 'TripalEntity',
|
|
@@ -1017,6 +1041,14 @@ function tripal_chado_bundle_instances_info_base(&$info, $entity_type, $bundle,
|
|
|
$base_info['label'] = 'Short Description';
|
|
|
}
|
|
|
|
|
|
+ //
|
|
|
+ // CONTACT TABLE
|
|
|
+ //
|
|
|
+ if ($table_name == 'contact' and $column_name == 'description') {
|
|
|
+ $base_info['label'] = 'Short Description';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$info[$field_name] = $base_info;
|
|
|
}
|
|
|
}
|
|
@@ -1040,27 +1072,47 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
|
|
|
$schema = chado_get_schema($table_name);
|
|
|
|
|
|
// An additional type for publications
|
|
|
- if ($table_name == 'pub') {
|
|
|
+ if (array_key_exists('type_id', $schema['fields']) and 'type_id' != $type_column) {
|
|
|
$field_name = 'schema__additional_type';
|
|
|
$is_required = FALSE;
|
|
|
if (array_key_exists('not null', $schema['fields']['type_id']) and
|
|
|
$schema['fields']['type_id']['not null']) {
|
|
|
$is_required = TRUE;
|
|
|
}
|
|
|
+ $label = ucwords(preg_replace('/_/', ' ', $table_name)) . ' Type';
|
|
|
+ $default_vocab = '';
|
|
|
+ $parent_term = '';
|
|
|
+ switch($table_name) {
|
|
|
+ case 'pub':
|
|
|
+ $default_vocab = 'tripal_pub';
|
|
|
+ $label = 'Publication Type';
|
|
|
+ $parent_term = 'TPUB:0000015';
|
|
|
+ $description = 'Select the type.';
|
|
|
+ break;
|
|
|
+ case 'contact':
|
|
|
+ $default_vocab = 'tripal_contact';
|
|
|
+ $parent_term = 'TContact:0000001';
|
|
|
+ $description = 'Select the type.';
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $description = t('Enter the name of the term that specifies the type. ' .
|
|
|
+ 'The type must be the name of a term in a controlled vocabulary and ' .
|
|
|
+ 'the controlled vocabulary should already be loaded into this site.');
|
|
|
+ }
|
|
|
$info[$field_name] = array(
|
|
|
'field_name' => $field_name,
|
|
|
'entity_type' => $entity_type,
|
|
|
'bundle' => $bundle->name,
|
|
|
- 'label' => 'Publication Type',
|
|
|
- 'description' => 'Select the publication type.',
|
|
|
+ 'label' => $label,
|
|
|
+ 'description' => $description,
|
|
|
'required' => $is_required,
|
|
|
'settings' => array(
|
|
|
'auto_attach' => TRUE,
|
|
|
'chado_table' => $table_name,
|
|
|
'chado_column' => 'type_id',
|
|
|
'base_table' => $table_name,
|
|
|
- 'vocabulary' => 'tripal_pub',
|
|
|
- 'parent_term' => 'TPUB:0000015',
|
|
|
+ 'vocabulary' => $default_vocab,
|
|
|
+ 'parent_term' => $parent_term,
|
|
|
),
|
|
|
'widget' => array(
|
|
|
'type' => 'schema__additional_type_widget',
|
|
@@ -1575,6 +1627,51 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ // PROTOCOL FIELD
|
|
|
+ if ($table_name != 'protocol' and
|
|
|
+ (array_key_exists('protocol_id', $schema['fields']))) {
|
|
|
+
|
|
|
+ $field_name = 'sep__protocol';
|
|
|
+ $is_required = FALSE;
|
|
|
+ $table_column = 'protocol_id';
|
|
|
+ if (array_key_exists('not null', $schema['fields']['protocol_id']) and
|
|
|
+ $schema['fields']['protocol_id']['not null']) {
|
|
|
+ $is_required = TRUE;
|
|
|
+ }
|
|
|
+ $info[$field_name] = array(
|
|
|
+ 'field_name' => $field_name,
|
|
|
+ 'entity_type' => $entity_type,
|
|
|
+ 'bundle' => $bundle->name,
|
|
|
+ 'label' => 'Protocol',
|
|
|
+ 'description' => 'The parameterizable description of a process',
|
|
|
+ 'required' => $is_required,
|
|
|
+ 'settings' => array(
|
|
|
+ 'auto_attach' => TRUE,
|
|
|
+ 'chado_table' => $table_name,
|
|
|
+ 'chado_column' => $table_column,
|
|
|
+ 'base_table' => $table_name,
|
|
|
+ ),
|
|
|
+ 'widget' => array(
|
|
|
+ 'type' => 'sep__protocol_widget',
|
|
|
+ 'settings' => array(
|
|
|
+ 'display_label' => 1,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ 'display' => array(
|
|
|
+ 'default' => array(
|
|
|
+ 'label' => 'inline',
|
|
|
+ 'type' => 'sep__protocol_formatter',
|
|
|
+ 'settings' => array(),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|