123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- <?php
- function tripal_pub_disable() {
-
- require_once("tripal_pub.views_default.inc");
- $views = tripal_pub_views_default_views();
- foreach (array_keys($views) as $view_name) {
- tripal_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
- }
- }
- function tripal_pub_requirements($phase) {
- $requirements = array();
- if ($phase == 'install') {
-
- if (!$GLOBALS["chado_is_installed"]) {
- $requirements ['tripal_pub'] = array(
- 'title' => "tripal_pub",
- 'value' => "ERROR: Chado must be installed before this module can be enabled",
- 'severity' => REQUIREMENT_ERROR,
- );
- }
- }
- return $requirements;
- }
- function tripal_pub_install() {
- global $base_path;
-
- $obo_path = '{tripal_pub}/files/tpub.obo';
- $obo_id = tripal_insert_obo('Tripal Publication', $obo_path);
- tripal_submit_obo_job(array('obo_id' => $obo_id));
- tripal_pub_add_cvs();
- tripal_pub_add_cvterms();
-
- tripal_pub_add_custom_tables();
-
- tripal_set_default_cv('pub', 'type_id', 'tripal_pub');
- tripal_set_default_cv('pubprop', 'type_id', 'tripal_pub');
- tripal_set_default_cv('pub_relationship', 'type_id', 'pub_relationship');
- }
- function tripal_pub_uninstall() {
- }
- function tripal_pub_enable() {
- }
- function tripal_pub_schema() {
- $schema['chado_pub'] = array(
- 'fields' => array(
- 'vid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE, 'default' => 0
- ),
- 'nid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0
- ),
- 'pub_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0
- ),
- 'sync_date' => array(
- 'type' => 'int',
- 'not null' => FALSE,
- 'description' => 'UNIX integer sync date/time'
- ),
- ),
- 'indexes' => array(
- 'pub_id' => array('pub_id')
- ),
- 'unique keys' => array(
- 'nid_vid' => array('nid', 'vid'),
- 'vid' => array('vid')
- ),
- 'primary key' => array('nid'),
- );
- $schema['tripal_pub_import'] = array(
- 'fields' => array(
- 'pub_import_id' => array(
- 'type' => 'serial',
- 'not null' => TRUE
- ),
- 'name' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE
- ),
- 'criteria' => array(
- 'type' => 'text',
- 'size' => 'normal',
- 'not null' => TRUE,
- 'description' => 'Contains a serialized PHP array containing the search criteria'
- ),
- 'disabled' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not NULL' => TRUE,
- 'default' => 0
- ),
- 'do_contact' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not NULL' => TRUE,
- 'default' => 0
- ),
- ),
- 'primary key' => array('pub_import_id'),
- 'indexes' => array(
- 'name' => array('name')
- ),
- );
- return $schema;
- }
- function tripal_pub_update_7200() {
-
- try {
- $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'tripal_pub'")->fetchField();
- if (!$cv_id) {
-
- $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();
- }
-
- db_insert('tripal_cv_defaults')
- ->fields(array(
- 'table_name' => 'pub',
- 'field_name' => 'type_id',
- 'cv_id' => $cv_id
- ))
- ->execute();
-
- 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);
- }
-
- try {
- $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'pub_property'")->fetchField();
- if (!$cv_id) {
-
- $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);
- }
-
- try {
- $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'pub_type'")->fetchField();
- if (!$cv_id) {
-
- $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);
- }
-
- try {
- $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'pub_relationship'")->fetchField();
- if (!$cv_id) {
-
- $cv_id = db_insert('chado.cv')
- ->fields(array(
- 'name' => 'pub_relationship',
- 'definition' => 'Contains types of relationships between publications.'
- ))
- ->execute();
- }
-
- 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);
- }
- }
- function tripal_pub_update_dependencies() {
- $dependencies = array();
-
- $dependencies['tripal_pub'][7200] = array(
- 'tripal_cv' => 7200
- );
- return $dependencies;
- }
- function tripal_pub_update_7201() {
-
-
-
-
- try {
- $fkey_exists = db_query('SELECT TRUE FROM pg_constraint WHERE conname = :constraint', array(':constraint' => 'pubauthor_contact_pubauthor_id_fkey'))->fetchField();
- if ($fkey_exists) {
- db_query('
- ALTER TABLE chado.pubauthor_contact
- DROP CONSTRAINT pubauthor_contact_pubauthor_id_fkey CASCADE
- ');
- db_query('
- ALTER TABLE chado.pubauthor_contact
- DROP CONSTRAINT pubauthor_contact_contact_id_fkey CASCADE
- ');
- }
- db_query('
- ALTER TABLE chado.pubauthor_contact
- ADD CONSTRAINT pubauthor_contact_pubauthor_id_fkey
- FOREIGN KEY (pubauthor_id) REFERENCES chado.pubauthor (pubauthor_id)
- ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
- ');
- db_query('
- ALTER TABLE chado.pubauthor_contact
- ADD CONSTRAINT pubauthor_contact_contact_id_fkey
- FOREIGN KEY (contact_id) REFERENCES chado.contact (contact_id)
- ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
- ');
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Failed to update foriegn key: '. $error);
- }
- }
- function tripal_pub_update_7202() {
- try {
-
- db_delete('tripal_cv_obo')
- ->condition('name', 'Tripal Publication')
- ->execute();
-
- $obo_path = '{tripal_pub}/files/tpub.obo';
- $obo_id = tripal_insert_obo('Tripal Publication', $obo_path);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Failed to update tripal_pub OBO path: '. $error);
- }
- }
|