function tripal_pub_update_7200
2.x tripal_pub.install | tripal_pub_update_7200() |
3.x tripal_pub.install | tripal_pub_update_7200() |
This is the required update for tripal_pub when upgrading from Drupal core API 6.x.
File
- legacy/
tripal_pub/ tripal_pub.install, line 223 - Installation of the publication module
Code
function tripal_pub_update_7200() {
// add the tripal_pub CV and set it to be the default for pub types and pub properties
try {
$cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'tripal_pub'")->fetchField();
if (!$cv_id) {
// add the vocabulary
$cv_id = db_insert('chado.cv')
->fields(array(
'name' => 'tripal_pub',
'definition' => 'A heirarchical set of terms for describing a publication. It is intended to be used as the default vocabularies in Tripal for publication types and contact properties.'
))
->execute();
}
// use the new pub_property CV we just added
db_insert('tripal_cv_defaults')
->fields(array(
'table_name' => 'pub',
'field_name' => 'type_id',
'cv_id' => $cv_id
))
->execute();
// use the new pub_property CV we just added
db_insert('tripal_cv_defaults')
->fields(array(
'table_name' => 'pubprop',
'field_name' => 'type_id',
'cv_id' => $cv_id
))
->execute();
}
catch (\PDOException $e) {
$error = $e->getMessage();
throw new DrupalUpdateException('Failed to add pub_property vocabulary: ' . $error);
}
// add the pub_property CV
try {
$cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'pub_property'")->fetchField();
if (!$cv_id) {
// add the vocabulary
$cv_id = db_insert('chado.cv')
->fields(array(
'name' => 'pub_property',
'definition' => 'Contains properties for publications. This can be used if the tripal_pub vocabulary (which is default for publications in Tripal) is not desired.'
))
->execute();
}
}
catch (\PDOException $e) {
$error = $e->getMessage();
throw new DrupalUpdateException('Failed to add pub_property vocabulary: ' . $error);
}
// add the pub_type CV
try {
$cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'pub_type'")->fetchField();
if (!$cv_id) {
// add the vocabulary
$cv_id = db_insert('chado.cv')
->fields(array(
'name' => 'pub_type',
'definition' => 'Contains types of publications. This can be used if the tripal_pub vocabulary (which is default for publications in Tripal) is not desired.'
))
->execute();
}
}
catch (\PDOException $e) {
$error = $e->getMessage();
throw new DrupalUpdateException('Failed to add pub_type vocabulary: ' . $error);
}
// add the pub_relationship CV
try {
$cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'pub_relationship'")->fetchField();
if (!$cv_id) {
// add the vocabulary
$cv_id = db_insert('chado.cv')
->fields(array(
'name' => 'pub_relationship',
'definition' => 'Contains types of relationships between publications.'
))
->execute();
}
// use the new pub_property CV we just added
db_insert('tripal_cv_defaults')
->fields(array(
'table_name' => 'pub_relationship',
'field_name' => 'type_id',
'cv_id' => $cv_id
))
->execute();
}
catch (\PDOException $e) {
$error = $e->getMessage();
throw new DrupalUpdateException('Failed to add pub_relationship vocabulary: ' . $error);
}
}