modules/custom/pasta/submit_eml/submit_eml.module

Summary

Maintainability
Test Coverage
<?php

/**
  * Implement hook_help()
  */
function submit_eml_help($path, $arg) {
  switch ($path) {
    case 'admin/help#sumbit_eml':
   return '<h3>' . t('About') . '</h3>' . '<p>' . t("The Submit EML, part of the PASTA module suite, provides an automated mechanism to participate
   in the PASTA services to store data and metadata objects. Only relevant to the LTER, PASTA, or Provenance Aware System Tracking Architecture, is a
   service offered to LTER sites to store permanently data records.  Once this module is enabled, each time a dataset is published
   or updated, the PASTA module will try to send a copy to the PASTA-enabled repositories using the PASTA services, it does so
   by using the Drupal queue systems and the EML Web Service") . '<p>';
  }
}

// ----------------------------------------------------------------------------
// Actions
// ----------------------------------------------------------------------------

/**
 * Implements hook_action_info().
 */
function submit_eml_action_info() {
  $info['submit_eml_action_dataset'] = array(
    'type' => 'node',
    'label' => t('Send Dataset to PASTA'),
    'configurable' => FALSE,
    'triggers' => array(),
  );

  return $info;
}

/**
 * Implements callback_action_info().
 *
 * Action callback to send the selected dataset to PASTA
 */
function submit_eml_action_dataset($node) {
  if ($node->type != 'data_set') {
    return;
  }

  try {
    $dataSet = new EmlDataSet($node);
    $pasta = new PastaApi($dataSet);
    $pasta->submitEml();
    drupal_set_message('A dataset EML has been sent to PASTA');
  }
  catch (Exception $exception) {
    watchdog('submit_eml', $exception);
  }
}