tripal_pub.chado_node.inc 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  1. <?php
  2. /**
  3. * @file
  4. * Implements the pub node content type
  5. */
  6. /**
  7. * Implements hook_node_info().
  8. *
  9. * @ingroup tripal_pub
  10. */
  11. function tripal_pub_node_info() {
  12. return array(
  13. 'chado_pub' => array(
  14. 'name' => t('Publication'),
  15. 'base' => 'chado_pub',
  16. 'description' => t('A publication from the Chado database'),
  17. 'has_title' => TRUE,
  18. 'locked' => TRUE,
  19. 'chado_node_api' => array(
  20. 'base_table' => 'pub',
  21. 'hook_prefix' => 'chado_pub',
  22. 'record_type_title' => array(
  23. 'singular' => t('Publication'),
  24. 'plural' => t('Publications')
  25. ),
  26. 'sync_filters' => array(
  27. 'type_id' => FALSE,
  28. 'organism_id' => FALSE
  29. ),
  30. ),
  31. ),
  32. );
  33. }
  34. /**
  35. * Implements hook_form().
  36. *
  37. * @ingroup tripal_pub
  38. */
  39. function chado_pub_form($node, $form_state) {
  40. $form = array();
  41. // Default values can come in the following ways:
  42. //
  43. // 1) as elements of the $node object. This occurs when editing an existing pub
  44. // 2) in the $form_state['values'] array which occurs on a failed validation or
  45. // ajax callbacks from non submit form elements
  46. // 3) in the $form_state['input'] array which occurs on ajax callbacks from submit
  47. // form elements and the form is being rebuilt
  48. //
  49. // set form field defaults
  50. $pub_id = null;
  51. $title = '';
  52. $pyear = '';
  53. $uniquename = '';
  54. $type_id = '';
  55. $is_obsolete = '';
  56. // some of the fields in the pub table should show up in the properties
  57. // form elements to make the form more seemless. We will add them
  58. // to this array.
  59. $more_props = array();
  60. // if we are editing an existing node then the pub is already part of the node
  61. if (property_exists($node, 'pub')) {
  62. $pub = $node->pub;
  63. $pub = chado_expand_var($pub, 'field', 'pub.title');
  64. $pub = chado_expand_var($pub, 'field', 'pub.volumetitle');
  65. $pub = chado_expand_var($pub, 'field', 'pub.uniquename');
  66. $pub_id = $pub->pub_id;
  67. $title = $pub->title;
  68. $pyear = $pub->pyear;
  69. $uniquename = $pub->uniquename;
  70. $type_id = $pub->type_id->cvterm_id;
  71. $is_obsolete = $pub->is_obsolete;
  72. // if the obsolete value is set by the database then it is in the form of
  73. // 't' or 'f', we need to convert to 1 or 0
  74. $is_obsolete = $is_obsolete == 't' ? 1 : $is_obsolete;
  75. $is_obsolete = $is_obsolete == 'f' ? 0 : $is_obsolete;
  76. // set the organism_id in the form
  77. $form['pub_id'] = array(
  78. '#type' => 'value',
  79. '#value' => $pub->pub_id,
  80. );
  81. // get fields from the pub table and convert them to properties. We will add these to the $more_props
  82. // array which gets passed in to the tripal_core_properties_form() API call further down
  83. if ($pub->volumetitle) {
  84. $cvterm = tripal_cv_get_cvterm_by_name('Volume Title', NULL, 'tripal_pub');
  85. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->volumetitle);
  86. }
  87. if ($pub->volume) {
  88. $cvterm = tripal_cv_get_cvterm_by_name('Volume', NULL, 'tripal_pub');
  89. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->volume);
  90. }
  91. if ($pub->series_name) {
  92. switch ($pub->type_id->name) {
  93. case 'Journal Article':
  94. $cvterm = tripal_cv_get_cvterm_by_name('Journal Name', NULL, 'tripal_pub');
  95. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->series_name);
  96. break;
  97. case 'Conference Proceedings':
  98. $cvterm = tripal_cv_get_cvterm_by_name('Conference Name', NULL, 'tripal_pub');
  99. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->series_name);
  100. break;
  101. default:
  102. $cvterm = tripal_cv_get_cvterm_by_name('Series Name', NULL, 'tripal_pub');
  103. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->series_name);
  104. }
  105. }
  106. if ($pub->issue) {
  107. $cvterm = tripal_cv_get_cvterm_by_name('Issue', NULL, 'tripal_pub');
  108. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->issue);
  109. }
  110. if ($pub->pages) {
  111. $cvterm = tripal_cv_get_cvterm_by_name('Pages', NULL, 'tripal_pub');
  112. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->pages);
  113. }
  114. if ($pub->miniref) {
  115. // not sure what to do with this one
  116. }
  117. if ($pub->publisher) {
  118. $cvterm = tripal_cv_get_cvterm_by_name('Publisher', NULL, 'tripal_pub');
  119. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->publisher);
  120. }
  121. if ($pub->pubplace) {
  122. $cvterm = tripal_cv_get_cvterm_by_name('Published Location', NULL, 'tripal_pub');
  123. $more_props[] = array('cvterm' => $cvterm, 'value' => $pub->pages);
  124. }
  125. }
  126. // if we are re constructing the form from a failed validation or ajax callback
  127. // then use the $form_state['values'] values
  128. if (array_key_exists('values', $form_state) and isset($form_state['values']['pubtitle'])) {
  129. $title = $form_state['values']['pubtitle'];
  130. $pyear = $form_state['values']['pyear'];
  131. $uniquename = $form_state['values']['uniquename'];
  132. $type_id = $form_state['values']['type_id'];
  133. $is_obsolete = $form_state['values']['is_obsolete'];
  134. }
  135. // if we are re building the form from after submission (from ajax call) then
  136. // the values are in the $form_state['input'] array
  137. if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
  138. $title = $form_state['input']['pubtitle'];
  139. $uniquename = $form_state['input']['uniquename'];
  140. $type_id = $form_state['input']['type_id'];
  141. $is_obsolete = $form_state['input']['is_obsolete'];
  142. }
  143. // a drupal title can only be 255 characters, but the Chado title can be much longer.
  144. // we use the publication title as the drupal title, but we'll need to truncate it.
  145. $form['title'] = array(
  146. '#type' => 'hidden',
  147. '#value' => substr($title, 0, 255),
  148. );
  149. $form['pubtitle'] = array(
  150. '#type' => 'textarea',
  151. '#title' => t('Publication Title'),
  152. '#default_value' => $title,
  153. '#required' => TRUE,
  154. );
  155. // get the list of publication types. In the Tripal publication
  156. // ontologies these are all grouped under the term 'Publication Type'
  157. // we want the default to be 'Journal Article'
  158. $sql = "
  159. SELECT
  160. CVTS.cvterm_id, CVTS.name
  161. FROM {cvtermpath} CVTP
  162. INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
  163. INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
  164. INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
  165. WHERE
  166. CV.name = 'tripal_pub' AND CVTO.name = 'Publication Type' AND
  167. NOT CVTS.is_obsolete = 1
  168. ORDER BY CVTS.name ASC
  169. ";
  170. $results = chado_query($sql);
  171. $pub_types = array();
  172. while ($pub_type = $results->fetchObject()) {
  173. $pub_types[$pub_type->cvterm_id] = $pub_type->name;
  174. // if we don't have a default type then set the default to be 'Journal Article'
  175. if (strcmp($pub_type->name,"Journal Article") == 0 and !$type_id) {
  176. $type_id = $pub_type->cvterm_id;
  177. }
  178. }
  179. $form['type_id'] = array(
  180. '#type' => 'select',
  181. '#title' => t('Publication Type'),
  182. '#options' => $pub_types,
  183. '#required' => TRUE,
  184. '#default_value' => $type_id,
  185. );
  186. $form['pyear'] = array(
  187. '#type' => 'textfield',
  188. '#title' => t('Publication Year'),
  189. '#default_value' => $pyear,
  190. '#required' => TRUE,
  191. '#size' => 5,
  192. '#description' => t('Enter the year of publication. Also, if available, please add a <b>Publication Date</b> property to specify the full date of publication.'),
  193. );
  194. $form['uniquename'] = array(
  195. '#type' => 'textarea',
  196. '#title' => t('Citation'),
  197. '#default_value' => $uniquename,
  198. '#description' => t('All publications must have a unique citation.
  199. <b>Please enter the full citation for this publication or leave blank and one will be generated
  200. automatically if possible</b>. For PubMed style citations list
  201. the last name of the author followed by initials. Each author should be separated by a comma. Next comes
  202. the title, followed by the series title (e.g. journal name), publication date (4 digit year, 3 character Month, day), volume, issue and page numbers. You may also use HTML to provide a link in the citation.
  203. Below is an example: <pre>Medeiros PM, Ladio AH, Santos AM, Albuquerque UP. <a href="http://www.ncbi.nlm.nih.gov/pubmed/23462414" target="_blank">Does the selection of medicinal plants by Brazilian local populations
  204. suffer taxonomic influence?</a> J Ethnopharmacol. 2013 Apr 19; 146(3):842-52.</pre>'),
  205. );
  206. $form['is_obsolete'] = array(
  207. '#type' => 'checkbox',
  208. '#title' => t('Is Obsolete? (Check for Yes)'),
  209. '#default_value' => $is_obsolete,
  210. );
  211. // Properties Form
  212. // ----------------------------------
  213. // Need to pass in our own select_options since we use cvtermpath to filter ours
  214. $select_options = array();
  215. $select_options[] = 'Select a Property';
  216. $sql = "
  217. SELECT
  218. DISTINCT CVTS.cvterm_id, CVTS.name, CVTS.definition
  219. FROM {cvtermpath} CVTP
  220. INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
  221. INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
  222. INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
  223. WHERE CV.name = 'tripal_pub' and
  224. (CVTO.name = 'Publication Details' OR CVTS.name = 'Publication Type') AND
  225. NOT CVTS.is_obsolete = 1
  226. ORDER BY CVTS.name ASC
  227. ";
  228. $prop_types = chado_query($sql);
  229. while ($prop = $prop_types->fetchObject()) {
  230. // add all properties except the Citation. That property is set via the uniquename field
  231. if ($prop->name != 'Citation') {
  232. $select_options[$prop->cvterm_id] = $prop->name;
  233. }
  234. }
  235. $details = array(
  236. 'property_table' => 'pubprop',
  237. 'chado_id' => $pub_id,
  238. 'cv_name' => 'tripal_pub',
  239. 'select_options' => $select_options,
  240. );
  241. chado_add_node_form_properties($form, $form_state, $details);
  242. // RELATIONSHIPS FORM
  243. //---------------------------------------------
  244. // We want to use the contact_relationship_types cv if there are any terms available
  245. // and if not, then default to the relationship ontology
  246. $cv_result = chado_select_record('cv',array('cv_id'),array('name' => 'pub_relationship_types'));
  247. if (count($cv_result) > 0) {
  248. $cv_id = $cv_result[0]->cv_id;
  249. $cv_name = 'pub_relationship_types';
  250. $select_options = tripal_cv_get_cvterm_options($cv_id);
  251. }
  252. // D7 @TODO: tell tripal admin's about this
  253. $details = array(
  254. 'relationship_table' => 'pub_relationship', // the name of the _relationship table
  255. 'base_table' => 'pub', // the name of your chado base table
  256. 'base_foreign_key' => 'pub_id', // the name of the key in your base chado table
  257. 'base_key_value' => $pub_id, // the value of example_id for this record
  258. 'nodetype' => 'pub', // the human-readable name of your node type
  259. 'cv_name' => $cv_name, // the cv.name of the cv containing the properties
  260. 'base_name_field' => 'uniquename', // the base table field you want to be used as the name
  261. 'select_options' => $select_options
  262. );
  263. // Adds the form elements to your current form
  264. chado_add_node_form_relationships($form, $form_state, $details);
  265. // ADDITIONAL DBXREFS FORM
  266. //---------------------------------------------
  267. $details = array(
  268. 'linking_table' => 'pub_dbxref', // the name of the _dbxref table
  269. 'base_foreign_key' => 'pub_id', // the name of the key in your base chado table
  270. 'base_key_value' => $pub_id // the value of pub_id for this record
  271. );
  272. // Adds the form elements to your current form
  273. chado_add_node_form_dbxrefs($form, $form_state, $details);
  274. return $form;
  275. }
  276. /**
  277. * Implements hook_validate().
  278. *
  279. * @ingroup tripal_pub
  280. */
  281. function chado_pub_validate($node, $form, &$form_state) {
  282. // get the submitted values
  283. $title = trim($node->pubtitle);
  284. $pyear = trim($node->pyear);
  285. $uniquename = trim($node->uniquename);
  286. $is_obsolete = $node->is_obsolete;
  287. $type_id = $node->type_id;
  288. // if this is a delete then don't validate
  289. if($node->op == 'Delete') {
  290. return;
  291. }
  292. // we are syncing if we do not have a node ID but we do have a pub_id. We don't
  293. // need to validate during syncing so just skip it.
  294. if (is_null($node->nid) and property_exists($node, 'pub_id') and $node->pub_id != 0) {
  295. return;
  296. }
  297. $pub = array();
  298. // make sure the year is four digits
  299. if(!preg_match('/^\d{4}$/', $pyear)){
  300. form_set_error('pyear', t('The publication year should be a 4 digit year.'));
  301. return;
  302. }
  303. // get the type of publication
  304. $values = array('cvterm_id' => $type_id);
  305. $options = array('statement_name' => 'sel_pub_ty');
  306. $cvterm = chado_select_record('cvterm', array('name'), $values, $options);
  307. if (count($cvterm) == 0) {
  308. $message = t('Invalid publication type.');
  309. form_set_error('type_id', $message);
  310. return;
  311. }
  312. // get the media name looking at the properties
  313. $series_name = '';
  314. foreach ($node as $element => $value) {
  315. // if this is an existing property (either previously in the database or
  316. // added via AHAH/AJAX callback)
  317. if (preg_match('/^prop_value-(\d+)-(\d+)$/', $element, $matches)) {
  318. $prop_type_id = $matches[1];
  319. $prop_type = tripal_cv_get_cvterm_by_id($prop_type_id);
  320. if($prop_type->name == 'Conference Name' or $prop_type->name == 'Journal Name') {
  321. $series_name = $value;
  322. }
  323. if($prop_type->name == 'Citation') {
  324. $uniquename = $value;
  325. }
  326. $pub[$prop_type->name] = $value;
  327. }
  328. // if this is a new property (added by this submit of the form)
  329. elseif ($element == 'new_id') {
  330. $prop_type = tripal_cv_get_cvterm_by_id($value);
  331. if($prop_type->name == 'Conference Name' or $prop_type->name == 'Journal Name') {
  332. $series_name = $node->new_value;
  333. }
  334. if($prop_type->name == 'Citation') {
  335. $uniquename = $node->new_value;
  336. }
  337. $pub[$prop_type->name] = $node->new_value;
  338. }
  339. }
  340. // if the citation is missing then try to generate one
  341. if (!$uniquename) {
  342. $pub['Title'] = $title;
  343. $pub['Publication Type'][0] = $cvterm[0]->name;
  344. $pub['Year'] = $pyear;
  345. $uniquename = tripal_pub_create_citation($pub);
  346. if (!$uniquename) {
  347. form_set_error('uniquename', "Cannot automatically generate a citation for this publication type. Please add one manually.");
  348. }
  349. }
  350. $skip_duplicate_check = 0;
  351. // if this publication is a Patent then skip the validation below. Patents can have the title
  352. // name and year but be different
  353. if (strcmp($cvterm[0]->name,'Patent') == 0) {
  354. $skip_duplicate_check = 1;
  355. }
  356. // Validating for an update
  357. if (!is_null($node->nid)) {
  358. $pub_id = $node->pub_id;
  359. // first get the original title, type and year before it was changed
  360. $values = array('pub_id' => $pub_id);
  361. $columns = array('title', 'pyear', 'type_id', 'series_name');
  362. $options = array('statement_name' => 'sel_pub_id');
  363. $pub = chado_select_record('pub', $columns, $values, $options);
  364. // if the title, type, year or series_name have changed then check the pub
  365. // to see if it is a duplicate of another
  366. if((strcmp(strtolower($pub[0]->title), strtolower($title)) == 0) and
  367. (strcmp(strtolower($pub[0]->series_name), strtolower($series_name)) == 0) and
  368. ($pub[0]->type_id == $type_id) and
  369. ($pub[0]->pyear == $pyear)) {
  370. $skip_duplicate_check = 1;
  371. }
  372. // check to see if a duplicate publication already exists
  373. if (!$skip_duplicate_check) {
  374. chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvterm, $pub_id);
  375. }
  376. chado_pub_validate_check_uniquename($uniquename, $pub_id);
  377. }
  378. // Validating for an insert
  379. else {
  380. chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvterm);
  381. chado_pub_validate_check_uniquename($uniquename);
  382. }
  383. }
  384. /**
  385. * Validate the publication uniquename. To be called from hook_validate().
  386. *
  387. * @param $uniquename
  388. * The uniquename of the publication
  389. *
  390. * @ingroup tripal_pub
  391. */
  392. function chado_pub_validate_check_uniquename($uniquename, $pub_id = NULL) {
  393. $results = tripal_pub_get_pub_by_uniquename($uniquename);
  394. // make sure we don't capture our pub_id in the list (remove it)
  395. foreach ($results as $index => $found_pub_id) {
  396. if($found_pub_id == $pub_id){
  397. unset($results[$index]);
  398. }
  399. }
  400. if (count($results) > 0) {
  401. $message = t('A publication with this unique citation already exists.');
  402. form_set_error('uniquename', $message);
  403. }
  404. }
  405. /**
  406. * Check for duplicate publications. To be called from hook_validate().
  407. *
  408. * @param $title
  409. * The title of the publication
  410. * @param $pyear
  411. * The year the publication was published
  412. * @param $series_name
  413. * The series name of the publication
  414. * @param $cvterm
  415. * The type of publication
  416. * @param $pub_id
  417. * the unique id of the publication
  418. *
  419. * @ingroup tripal_pub
  420. */
  421. function chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvterm, $pub_id = NULL) {
  422. // make sure the publication is unique using the prefereed import duplication check
  423. $import_dups_check = variable_get('tripal_pub_import_duplicate_check', 'title_year_media');
  424. switch ($import_dups_check) {
  425. case 'title_year':
  426. $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, NULL, $pyear, NULL);
  427. // make sure we don't capture our pub_id in the list (remove it)
  428. foreach ($results as $index => $found_pub_id) {
  429. if($found_pub_id == $pub_id){
  430. unset($results[$index]);
  431. }
  432. }
  433. if (count($results) > 0) {
  434. $message = t('A publication with this title and publication year, already exists.');
  435. form_set_error('pyear', $message);
  436. }
  437. break;
  438. case 'title_year_type':
  439. $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, $cvterm[0]->name, $pyear, NULL);
  440. // make sure we don't capture our pub_id in the list (remove it)
  441. foreach ($results as $index => $found_pub_id) {
  442. if($found_pub_id == $pub_id){
  443. unset($results[$index]);
  444. }
  445. }
  446. if (count($results) > 0) {
  447. $message = t('A publication with this title, type and publication year, already exists.');
  448. form_set_error('pyear', $message);
  449. }
  450. break;
  451. case 'title_year_media':
  452. $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, NULL, $pyear, $series_name);
  453. // make sure we don't capture our pub_id in the list (remove it)
  454. foreach ($results as $index => $found_pub_id) {
  455. if($found_pub_id == $pub_id){
  456. unset($results[$index]);
  457. }
  458. }
  459. if (count($results) > 0) {
  460. $message = t('A publication with this title, media name (e.g. Journal Name) and publication year, already exists.');
  461. form_set_error('pyear', $message);
  462. }
  463. break;
  464. }
  465. }
  466. /**
  467. * Implement hook_node_access().
  468. *
  469. * This hook allows node modules to limit access to the node types they define.
  470. *
  471. * @param $node
  472. * The node on which the operation is to be performed, or, if it does not yet exist, the
  473. * type of node to be created
  474. *
  475. * @param $op
  476. * The operation to be performed
  477. *
  478. * @param $account
  479. * A user object representing the user for whom the operation is to be performed
  480. *
  481. * @return
  482. * If the permission for the specified operation is not set then return FALSE. If the
  483. * permission is set then return NULL as this allows other modules to disable
  484. * access. The only exception is when the $op == 'create'. We will always
  485. * return TRUE if the permission is set.
  486. *
  487. * @ingroup tripal_pub
  488. */
  489. function chado_pub_node_access($node, $op, $account) {
  490. $node_type = $node;
  491. if (is_object($node)) {
  492. $node_type = $node->type;
  493. }
  494. if($node_type == 'chado_pub') {
  495. if ($op == 'create') {
  496. if (!user_access('create chado_pub', $account)) {
  497. return NODE_ACCESS_DENY;
  498. }
  499. return NODE_ACCESS_ALLOW;
  500. }
  501. if ($op == 'update') {
  502. if (!user_access('edit chado_pub', $account)) {
  503. return NODE_ACCESS_DENY;
  504. }
  505. }
  506. if ($op == 'delete') {
  507. if (!user_access('delete chado_pub', $account)) {
  508. return NODE_ACCESS_DENY;
  509. }
  510. }
  511. if ($op == 'view') {
  512. if (!user_access('access chado_pub', $account)) {
  513. return NODE_ACCESS_DENY;
  514. }
  515. }
  516. return NODE_ACCESS_IGNORE;
  517. }
  518. }
  519. /**
  520. * Implements hook_insert().
  521. *
  522. * @ingroup tripal_pub
  523. */
  524. function chado_pub_insert($node) {
  525. $title = trim($node->pubtitle);
  526. $pyear = trim($node->pyear);
  527. $uniquename = trim($node->uniquename);
  528. $is_obsolete = $node->is_obsolete;
  529. $type_id = $node->type_id;
  530. // we need an array suitable for the tripal_pub_create_citation() function
  531. // to automatically generate a citation if a uniquename doesn't already exist
  532. $pub_arr = array();
  533. // if there is an pub_id in the $node object then this must be a sync so
  534. // we can skip adding the pub as it is already there, although
  535. // we do need to proceed with the rest of the insert
  536. if (!property_exists($node, 'pub_id')) {
  537. $properties = array(); // stores all of the properties we need to add
  538. $cross_refs = array(); // stores any cross references for this publication
  539. // get the properties from the form
  540. $properties = chado_retrieve_node_form_properties($node);
  541. // get the list of properties for easy lookup (without doing lots of database queries
  542. $properties_list = array();
  543. $sql = "
  544. SELECT CVTS.cvterm_id, CVTS.name, CVTS.definition
  545. FROM {cvtermpath} CVTP
  546. INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
  547. INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
  548. INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
  549. WHERE CV.name = 'tripal_pub' and CVTO.name = 'Publication Details' and
  550. NOT CVTS.is_obsolete = 1
  551. ORDER BY CVTS.name ASC
  552. ";
  553. $prop_types = chado_query($sql);
  554. while ($prop = $prop_types->fetchObject()) {
  555. $properties_list[$prop->cvterm_id] = $prop->name;
  556. // The 'Citation' term is special because it serves
  557. // both as a property and as the uniquename for the
  558. // pub and we want it stored in both the pub table and the pubprop table
  559. if ($prop->name == 'Citation') {
  560. $citation_id = $prop->cvterm_id;
  561. if (!empty($node->uniquename)) {
  562. $properties[$citation_id] = $node->uniquename;
  563. }
  564. }
  565. }
  566. // iterate through all of the properties and remove those that really are
  567. // part of the pub table fields
  568. $volume = '';
  569. $volumetitle = '';
  570. $issue = '';
  571. $pages = '';
  572. $publisher = '';
  573. $series_name = '';
  574. $pubplace = '';
  575. $miniref = '';
  576. $cross_refs = array();
  577. foreach ($properties as $type_id => $element) {
  578. $value = trim($element[0]);
  579. $name = $properties_list[$type_id];
  580. // populate our $pub_array for building a citation
  581. $pub_arr[$name] = $value;
  582. // remove properties that are stored in the pub table
  583. if ($name == "Volume") {
  584. $volume = $value;
  585. unset($properties[$type_id]);
  586. }
  587. elseif ($name == "Volume Title") {
  588. $volumetitle = $value;
  589. unset($properties[$type_id]);
  590. }
  591. elseif ($name == "Issue") {
  592. $issue = $value;
  593. unset($properties[$type_id]);
  594. }
  595. elseif ($name == "Pages") {
  596. $pages = $value;
  597. unset($properties[$type_id]);
  598. }
  599. elseif ($name == "Publisher") {
  600. $publisher = $value;
  601. unset($properties[$type_id]);
  602. }
  603. elseif ($name == "Series Name" or $name == "Journal Name" or $name == "Conference Name") {
  604. $series_name = $value;
  605. unset($properties[$type_id]);
  606. }
  607. elseif ($name == "Journal Country" or $name == "Published Location") {
  608. $pubplace = $value;
  609. // allow this property to go into the pubprop table so we don't loose info
  610. // so don't unset it. But it will also go into the pub.pubplace field
  611. }
  612. elseif ($name == "Publication Dbxref") {
  613. // we will add the cross-references to the pub_dbxref table
  614. // but we also want to keep the property in the pubprop table so don't unset it
  615. $cross_refs[] = $value;
  616. }
  617. }
  618. // generate a citation for this pub if one doesn't already exist
  619. if (!$node->uniquename and !array_key_exists($citation_id, $properties)) {
  620. $pub_type = tripal_cv_get_cvterm_by_id($node->type_id);
  621. $pub_arr['Title'] = $node->pubtitle;
  622. $pub_arr['Publication Type'][0] = $pub_type->name;
  623. $pub_arr['Year'] = $node->pyear;
  624. $node->uniquename = tripal_pub_create_citation($pub_arr);
  625. $properties[$citation_id][0] = $node->uniquename;
  626. }
  627. // insert the pub record
  628. $values = array(
  629. 'title' => $node->pubtitle,
  630. 'series_name' => substr($series_name, 0, 255),
  631. 'type_id' => $node->type_id,
  632. 'pyear' => $node->pyear,
  633. 'is_obsolete' => $node->is_obsolete ? 'true' : 'false',
  634. 'uniquename' => $node->uniquename,
  635. 'volumetitle' => $volumetitle,
  636. 'volume' => $volume,
  637. 'issue' => $issue,
  638. 'pages' => $pages,
  639. 'miniref' => substr($miniref, 0, 255),
  640. 'publisher' => substr($publisher, 0, 255),
  641. 'pubplace' => substr($pubplace, 0, 255),
  642. );
  643. $pub = chado_insert_record('pub', $values);
  644. if (!$pub) {
  645. drupal_set_message("Error inserting publication", "error");
  646. watchdog('tripal_pub', "Error inserting publication", array(), WATCHDOG_ERROR);
  647. return;
  648. }
  649. $pub_id = $pub['pub_id'];
  650. // now add in the properties
  651. // Only adds in those not used in the pub record
  652. $details = array(
  653. 'property_table' => 'pubprop',
  654. 'base_table' => 'pub',
  655. 'foreignkey_name' => 'pub_id',
  656. 'foreignkey_value' => $pub_id
  657. );
  658. chado_update_node_form_properties($node, $details, $properties);
  659. // * Relationships Form *
  660. $details = array(
  661. 'relationship_table' => 'pub_relationship', // name of the _relationship table
  662. 'foreignkey_value' => $pub_id // value of the pub_id key
  663. );
  664. chado_update_node_form_relationships($node, $details);
  665. // add in any database cross-references
  666. foreach ($cross_refs as $index => $ref) {
  667. $pub_dbxref = tripal_pub_add_pub_dbxref($pub['pub_id'], trim($ref));
  668. if (!$pub_dbxref) {
  669. drupal_set_message("Error cannot add publication cross reference: $ref", "error");
  670. watchdog('tripal_pub', "Error cannot add publication cross reference: %ref",
  671. array('%ref' => $ref), WATCHDOG_ERROR);
  672. }
  673. }
  674. // * Additional DBxrefs Form *
  675. $details = array(
  676. 'linking_table' => 'pub_dbxref', // the name of your _dbxref table
  677. 'foreignkey_name' => 'pub_id', // the name of the key in your base table
  678. 'foreignkey_value' => $pub_id // the value of the pub_id key
  679. );
  680. chado_update_node_form_dbxrefs($node, $details);
  681. }
  682. else {
  683. $pub_id = $node->pub_id;
  684. }
  685. // Make sure the entry for this pub doesn't already exist in the
  686. // chado_pub table if it doesn't exist then we want to add it.
  687. $check_org_id = chado_get_id_from_nid('pub', $node->nid);
  688. if (!$check_org_id) {
  689. $record = new stdClass();
  690. $record->nid = $node->nid;
  691. $record->vid = $node->vid;
  692. $record->pub_id = $pub_id;
  693. drupal_write_record('chado_pub', $record);
  694. }
  695. }
  696. /**
  697. * Implements hook_update().
  698. *
  699. * The purpose of the function is to allow the module to take action when an edited node is being
  700. * updated. It updates any name changes to the database tables that werec reated upon registering a Publication.
  701. * As well, the database will be changed, so the user changed information will be saved to the database.
  702. *
  703. * @param $node
  704. * The node being updated
  705. *
  706. * @ingroup tripal_pub
  707. */
  708. function chado_pub_update($node) {
  709. $title = trim($node->pubtitle);
  710. $pyear = trim($node->pyear);
  711. $uniquename = trim($node->uniquename);
  712. $is_obsolete = $node->is_obsolete;
  713. $type_id = $node->type_id;
  714. // we need an array suitable for the tripal_pub_create_citation() function
  715. // to automatically generate a citation if a uniquename doesn't already exist
  716. $pub_arr = array();
  717. // get the publication ID for this publication
  718. $pub_id = chado_get_id_from_nid('pub', $node->nid) ;
  719. $properties = array(); // stores all of the properties we need to add
  720. $cross_refs = array(); // stores any cross references for this publication
  721. // get the properties from the form
  722. $properties = chado_retrieve_node_form_properties($node);
  723. // get the list of properties for easy lookup (without doing lots of database queries
  724. $properties_list = array();
  725. $sql = "
  726. SELECT DISTINCT CVTS.cvterm_id, CVTS.name, CVTS.definition
  727. FROM {cvtermpath} CVTP
  728. INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
  729. INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
  730. INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
  731. WHERE CV.name = 'tripal_pub' and
  732. (CVTO.name = 'Publication Details' or CVTS.name = 'Publication Type') and
  733. NOT CVTS.is_obsolete = 1
  734. ORDER BY CVTS.name ASC
  735. ";
  736. $prop_types = chado_query($sql);
  737. while ($prop = $prop_types->fetchObject()) {
  738. $properties_list[$prop->cvterm_id] = $prop->name;
  739. // The 'Citation' term is special because it serves
  740. // both as a property and as the uniquename for the
  741. // pub and we want it stored in both the pub table and the pubprop table
  742. if ($prop->name == 'Citation') {
  743. $citation_id = $prop->cvterm_id;
  744. if (!empty($node->uniquename)) {
  745. $properties[$citation_id][0] = $node->uniquename;
  746. }
  747. }
  748. }
  749. // iterate through all of the properties and remove those that really are
  750. // part of the pub table fields
  751. $volume = '';
  752. $volumetitle = '';
  753. $issue = '';
  754. $pages = '';
  755. $publisher = '';
  756. $series_name = '';
  757. $pubplace = '';
  758. $miniref = '';
  759. $cross_refs = array();
  760. foreach ($properties as $type_id => $element) {
  761. foreach ($element as $index => $value) {
  762. $name = $properties_list[$type_id];
  763. // populate our $pub_array for building a citation
  764. $pub_arr[$name] = $value;
  765. // remove properties that are stored in the pub table
  766. if ($name == "Volume") {
  767. $volume = $value;
  768. unset($properties[$type_id]);
  769. }
  770. elseif ($name == "Volume Title") {
  771. $volumetitle = $value;
  772. unset($properties[$type_id]);
  773. }
  774. elseif ($name == "Issue") {
  775. $issue = $value;
  776. unset($properties[$type_id]);
  777. }
  778. elseif ($name == "Pages") {
  779. $pages = $value;
  780. unset($properties[$type_id]);
  781. }
  782. elseif ($name == "Publisher") {
  783. $publisher = $value;
  784. unset($properties[$type_id]);
  785. }
  786. elseif ($name == "Journal Name" or $name == "Conference Name") {
  787. $series_name = $value;
  788. unset($properties[$type_id]);
  789. }
  790. elseif ($name == "Journal Country" or $name == "Published Location") {
  791. $pubplace = $value;
  792. // allow this property to go into the pubprop table so we don't loose info
  793. // so don't unset it. But it will also go into the pub.pubplace field
  794. }
  795. elseif ($name == "Publication Dbxref") {
  796. // we will add the cross-references to the pub_dbxref table
  797. // but we also want to keep the property in the pubprop table so don't unset it
  798. $cross_refs[] = $value;
  799. }
  800. }
  801. }
  802. // generate a citation for this pub if one doesn't already exist
  803. if (!$node->uniquename) {
  804. $pub_type = tripal_cv_get_cvterm_by_id($node->type_id);
  805. $pub_arr['Title'] = $node->pubtitle;
  806. $pub_arr['Publication Type'][0] = $pub_type->name;
  807. $pub_arr['Year'] = $node->pyear;
  808. $node->uniquename = tripal_pub_create_citation($pub_arr);
  809. $properties[$citation_id][0] = $node->uniquename;
  810. }
  811. // update the pub record
  812. $match = array(
  813. 'pub_id' => $pub_id,
  814. );
  815. $values = array(
  816. 'title' => $node->pubtitle,
  817. 'type_id' => $node->type_id,
  818. 'pyear' => $node->pyear,
  819. 'is_obsolete' => $node->is_obsolete ? 'true' : 'false',
  820. 'uniquename' => $node->uniquename,
  821. 'series_name' => substr($series_name, 0, 255),
  822. 'volumetitle' => $volumetitle,
  823. 'volume' => $volume,
  824. 'issue' => $issue,
  825. 'pages' => $pages,
  826. 'miniref' => substr($miniref, 0, 255),
  827. 'publisher' => substr($publisher, 0, 255),
  828. 'pubplace' => substr($pubplace, 0, 255),
  829. );
  830. $status = chado_update_record('pub', $match, $values);
  831. if (!$status) {
  832. drupal_set_message("Error updating publication", "error");
  833. watchdog('tripal_pub', "Error updating publication", array(), WATCHDOG_ERROR);
  834. return;
  835. }
  836. // now add in the properties by first removing any the publication
  837. // already has and adding the ones we have
  838. $details = array(
  839. 'property_table' => 'pubprop',
  840. 'base_table' => 'pub',
  841. 'foreignkey_name' => 'pub_id',
  842. 'foreignkey_value' => $pub_id
  843. );
  844. chado_update_node_form_properties($node, $details, $properties);
  845. // * Relationships Form *
  846. $details = array(
  847. 'relationship_table' => 'pub_relationship', // name of the _relationship table
  848. 'foreignkey_value' => $pub_id // value of the pub_id key
  849. );
  850. chado_update_node_form_relationships($node, $details);
  851. // add in any database cross-references after first removing
  852. chado_delete_record('pub_dbxref', array('pub_id' => $pub_id));
  853. foreach ($cross_refs as $index => $ref) {
  854. $pub_dbxref = tripal_pub_add_pub_dbxref($pub_id, trim($ref));
  855. if (!$pub_dbxref) {
  856. drupal_set_message("Error cannot add publication cross reference: $ref", "error");
  857. watchdog('tripal_pub', "Error cannot add publication cross reference: %ref",
  858. array('%ref' => $ref), WATCHDOG_ERROR);
  859. }
  860. }
  861. // * Additional DBxrefs Form *
  862. $details = array(
  863. 'linking_table' => 'pub_dbxref', // the name of your _dbxref table
  864. 'foreignkey_name' => 'pub_id', // the name of the key in your base table
  865. 'foreignkey_value' => $pub_id // the value of the pub_id key
  866. );
  867. chado_update_node_form_dbxrefs($node, $details);
  868. }
  869. /**
  870. * Implements hook_load().
  871. *
  872. * @param $node
  873. * The node that is to be loaded
  874. *
  875. * @return $node
  876. * The node with the information to be loaded into the database
  877. *
  878. * @ingroup tripal_pub
  879. */
  880. function chado_pub_load($nodes) {
  881. foreach ($nodes as $nid => $node) {
  882. // find the pub and add in the details
  883. $pub_id = chado_get_id_from_nid('pub', $nid);
  884. // get the pub
  885. $values = array('pub_id' => $pub_id);
  886. $pub = chado_generate_var('pub', $values);
  887. // expand the 'text' fields as those aren't included by default
  888. // and they really shouldn't be so large to cause problems
  889. $pub = chado_expand_var($pub, 'field', 'pub.title');
  890. $pub = chado_expand_var($pub, 'field', 'pub.volumetitle');
  891. $pub = chado_expand_var($pub, 'field', 'pub.uniquename');
  892. // set the URL path
  893. $nodes[$nid]->path = "pub/$pub_id";
  894. $nodes[$nid]->pub = $pub;
  895. }
  896. }
  897. /**
  898. * Implements hook_delete().
  899. *
  900. * This function takes a node and if the delete button has been chosen by the user, the publication
  901. * and it's details will be removed.Following,given the node-ID, the instance will be deleted from
  902. * the 'chado_pub' table.
  903. *
  904. * @parm $node
  905. * Then node to be deleted
  906. *
  907. * @ingroup tripal_pub
  908. */
  909. function chado_pub_delete(&$node) {
  910. $pub_id = chado_get_id_from_nid('pub', $node->nid);
  911. // if we don't have a pub id for this node then this isn't a node of
  912. // type chado_pub or the entry in the chado_pub table was lost.
  913. if (!$pub_id) {
  914. return;
  915. }
  916. // Remove data from {chado_pub}, {node} and {node_revision} tables of
  917. // drupal database
  918. $sql_del = "DELETE FROM {chado_pub} WHERE nid = :nid AND vid = :vid";
  919. db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  920. $sql_del = "DELETE FROM {node_revision} WHERE nid = :nid AND vid = :vid";
  921. db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  922. $sql_del = "DELETE FROM {node} WHERE nid = :nid AND vid = :vid";
  923. db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  924. // Remove data from pub and pubprop tables of chado database as well
  925. chado_query("DELETE FROM {pubprop} WHERE pub_id = :pub_id", array(':pub_id' => $pub_id));
  926. chado_query("DELETE FROM {pub} WHERE pub_id = :pub_id", array(':pub_id' => $pub_id));
  927. }
  928. /**
  929. * Implements hook_node_view(). Acts on all content types.
  930. *
  931. * @ingroup tripal_pub
  932. */
  933. function tripal_pub_node_view($node, $view_mode, $langcode) {
  934. switch ($node->type) {
  935. case 'chado_pub':
  936. // Show feature browser and counts
  937. if ($view_mode == 'full') {
  938. $node->content['tripal_pub_authors'] = array(
  939. '#markup' => theme('tripal_pub_authors', array('node' => $node)),
  940. '#tripal_toc_id' => 'authors',
  941. '#tripal_toc_title' => 'Author Details',
  942. );
  943. $node->content['tripal_pub_base'] = array(
  944. '#markup' => theme('tripal_pub_base', array('node' => $node)),
  945. '#tripal_toc_id' => 'base',
  946. '#tripal_toc_title' => 'Overview',
  947. '#weight' => -100,
  948. );
  949. $node->content['tripal_pub_featuremaps'] = array(
  950. '#markup' => theme('tripal_pub_featuremaps', array('node' => $node)),
  951. '#tripal_toc_id' => 'featuremaps',
  952. '#tripal_toc_title' => 'Maps',
  953. );
  954. $node->content['tripal_pub_features'] = array(
  955. '#markup' => theme('tripal_pub_features', array('node' => $node)),
  956. '#tripal_toc_id' => 'features',
  957. '#tripal_toc_title' => 'Features',
  958. );
  959. $node->content['tripal_pub_libraries'] = array(
  960. '#markup' => theme('tripal_pub_libraries', array('node' => $node)),
  961. '#tripal_toc_id' => 'libraries',
  962. '#tripal_toc_title' => 'Libraries',
  963. );
  964. $node->content['tripal_pub_projects'] = array(
  965. '#markup' => theme('tripal_pub_projects', array('node' => $node)),
  966. '#tripal_toc_id' => 'projects',
  967. '#tripal_toc_title' => 'Projects',
  968. );
  969. $node->content['tripal_pub_properties'] = array(
  970. '#markup' => theme('tripal_pub_properties', array('node' => $node)),
  971. '#tripal_toc_id' => 'properties',
  972. '#tripal_toc_title' => 'Properties',
  973. );
  974. $node->content['tripal_pub_references'] = array(
  975. '#markup' => theme('tripal_pub_references', array('node' => $node)),
  976. '#tripal_toc_id' => 'references',
  977. '#tripal_toc_title' => 'Cross References',
  978. );
  979. $node->content['tripal_pub_relationships'] = array(
  980. '#markup' => theme('tripal_pub_relationships', array('node' => $node)),
  981. '#tripal_toc_id' => 'relationships',
  982. '#tripal_toc_title' => 'Relationships',
  983. );
  984. $node->content['tripal_pub_stocks'] = array(
  985. '#markup' => theme('tripal_pub_stocks', array('node' => $node)),
  986. '#tripal_toc_id' => 'stocks',
  987. '#tripal_toc_title' => 'Stocks',
  988. );
  989. }
  990. if ($view_mode == 'teaser') {
  991. $node->content['tripal_pub_teaser'] = array(
  992. '#markup' => theme('tripal_pub_teaser', array('node' => $node)),
  993. );
  994. }
  995. break;
  996. }
  997. }
  998. /**
  999. * Implements hook_node_insert(). Acts on all content types.
  1000. *
  1001. * We want the publications to always have a URL of http://[base url]/pub/[pub id]
  1002. * where [pub id] is the Chado publication ID. This will allow for easy linking
  1003. * into the publication without needing to know the node. Of course if you know the
  1004. * node that will still work too (e.g. http://[base url]/node/[node id]
  1005. * so the nodeapi function ensures that the URL path is set after insert or update
  1006. * of the node and when the node is loaded if it hasn't yet been set.
  1007. *
  1008. * @ingroup tripal_pub
  1009. */
  1010. function tripal_pub_node_insert($node) {
  1011. if ($node->type == 'chado_pub') {
  1012. $pub_id = chado_get_id_from_nid('pub', $node->nid);
  1013. tripal_pub_set_pub_url($node, $pub_id);
  1014. }
  1015. }
  1016. /**
  1017. * Implements hook_node_load(). Acts on all content types.
  1018. *
  1019. * We want the publications to always have a URL of http://[base url]/pub/[pub id]
  1020. * where [pub id] is the Chado publication ID. This will allow for easy linking
  1021. * into the publication without needing to know the node. Of course if you know the
  1022. * node that will still work too (e.g. http://[base url]/node/[node id]
  1023. * so the nodeapi function ensures that the URL path is set after insert or update
  1024. * of the node and when the node is loaded if it hasn't yet been set.
  1025. *
  1026. * @ingroup tripal_pub
  1027. */
  1028. function tripal_pub_node_load($nodes, $types) {
  1029. if (count(array_intersect(array('chado_pub'), $types))) {
  1030. foreach ($nodes as $nid => $node) {
  1031. if ($node->type == 'chado_pub' and !property_exists($node, 'path')) {
  1032. $pub_id = chado_get_id_from_nid('pub', $node->nid);
  1033. $path = tripal_pub_set_pub_url($node, $pub_id);
  1034. }
  1035. }
  1036. }
  1037. }
  1038. /**
  1039. * Implements hook_node_update(). Acts on all content types.
  1040. *
  1041. * We want the publications to always have a URL of http://[base url]/pub/[pub id]
  1042. * where [pub id] is the Chado publication ID. This will allow for easy linking
  1043. * into the publication without needing to know the node. Of course if you know the
  1044. * node that will still work too (e.g. http://[base url]/node/[node id]
  1045. * so the nodeapi function ensures that the URL path is set after insert or update
  1046. * of the node and when the node is loaded if it hasn't yet been set.
  1047. *
  1048. * @ingroup tripal_pub
  1049. */
  1050. function tripal_pub_node_update($node) {
  1051. if ($node->type == 'chado_pub') {
  1052. $pub_id = chado_get_id_from_nid('pub', $node->nid);
  1053. tripal_pub_set_pub_url($node, $pub_id);
  1054. }
  1055. }