Browse Source

Merge remote branch 'upstream/master'

pull/105/head
Zachary Howarth 14 years ago
parent
commit
e78462154c
  1. 15
      ObjectHelper.inc
  2. 11
      fedora_repository.module
  3. 1
      form_elements/js/filechooser.js
  4. 30
      ilives/book.inc
  5. 2
      ilives/fedora_ilives.module
  6. 42
      plugins/Exiftool.inc
  7. 89
      plugins/ModsFormBuilder.inc
  8. 112
      workflow_client/islandora_workflow_client.module
  9. 72
      workflow_client/plugins/exif.inc
  10. 48
      workflow_client/plugins/mods_extend.inc

15
ObjectHelper.inc

@ -34,11 +34,12 @@ class ObjectHelper {
/** /**
* Grabs a stream from fedora sets the mimetype and returns it. $dsID is the * Grabs a stream from fedora sets the mimetype and returns it. $dsID is the
* datastream id. * datastream id. If $forceSoap is set, the function will always buffer the datastream from fedora. Otherwise, it will
* try and use a redirect if possible.
* @param $pid String * @param $pid String
* @param $dsID String * @param $dsID String
*/ */
function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL) { function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL, $forceSoap = FALSE) {
global $user; global $user;
module_load_include('inc','fedora_repository','ContentModel'); module_load_include('inc','fedora_repository','ContentModel');
if ($pid == NULL || $dsID == NULL) { if ($pid == NULL || $dsID == NULL) {
@ -163,7 +164,12 @@ class ObjectHelper {
header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"'); header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"');
} }
curl_exec($ch);
if ( (isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) {
curl_exec($ch);
} else {
header('Location: '.$url);
}
} }
curl_close($ch); curl_close($ch);
} else { } else {
@ -986,7 +992,8 @@ class ObjectHelper {
where (<info:fedora/' . $pid . '> <dc:title> $title where (<info:fedora/' . $pid . '> <dc:title> $title
and $parentObject <fedora-model:hasModel> $content and $parentObject <fedora-model:hasModel> $content
and (<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject and (<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject
or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject) or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject
or <info:fedora/' . $pid . '> <fedora-rels-ext:isPartOf> $parentObject)
and $parentObject <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $parentObject <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by $title'; order by $title';

11
fedora_repository.module

@ -91,6 +91,7 @@ function fedora_repository_collection_view($pid = NULL, $collection = NULL, $pag
function fedora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) { function fedora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
if (!user_access('ingest new fedora objects')) { if (!user_access('ingest new fedora objects')) {
drupal_set_message(t('You do not have permission to ingest.'), 'error'); drupal_set_message(t('You do not have permission to ingest.'), 'error');
return ''; return '';
@ -112,6 +113,11 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
} }
$output = drupal_get_form('fedora_repository_ingest_form', $collection_pid, $collection_label, $content_model); $output = drupal_get_form('fedora_repository_ingest_form', $collection_pid, $collection_label, $content_model);
$breadcrumbs = array();
$objectHelper = new ObjectHelper();
$objectHelper->getBreadcrumbs($collection_pid, $breadcrumbs);
drupal_set_breadcrumb(array_reverse($breadcrumbs));
return $output; return $output;
} }
@ -586,6 +592,11 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
// Check if there is a custom edit metadata function defined in the content model. // Check if there is a custom edit metadata function defined in the content model.
$breadcrumbs = array();
$objectHelper = new ObjectHelper();
$objectHelper->getBreadcrumbs($pid, $breadcrumbs);
drupal_set_breadcrumb(array_reverse($breadcrumbs));
$output = ''; $output = '';
if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) { if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) {

1
form_elements/js/filechooser.js

@ -63,7 +63,6 @@ $(document).ready(function () {
mouseWheel: true, mouseWheel: true,
circular: false, circular: false,
speed: 750, speed: 750,
easing: "bounceout",
visible: visibleFiles, visible: visibleFiles,
scroll: visibleFiles, scroll: visibleFiles,
initial: selectedIndex initial: selectedIndex

30
ilives/book.inc

@ -36,16 +36,17 @@ class IslandoraBook {
'#title' => 'Catalogue item URL', '#title' => 'Catalogue item URL',
); );
$form['unapi_url_submit'] = array( $form['unapi_url_submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Retrieve MODS record'), '#value' => t('Retrieve MODS record'),
'#submit' => array('fedora_ilives_retrieve_unapi_submit'), '#submit' => array('fedora_ilives_retrieve_unapi_submit'),
'#ahah' => array( '#ahah' => array(
'path' => 'fedora/ilives/retrieve_unapi/js', // path we defined in hook_menu 'path' => 'fedora/ilives/retrieve_unapi/js', // path we defined in hook_menu
'wrapper' => 'mods-wrapper', // the HTML that wraps the element that needs to be replaced 'wrapper' => 'mods-wrapper', // the HTML that wraps the element that needs to be replaced
'method' => 'replace', // the method we're going to use: a replace operation 'method' => 'replace', // the method we're going to use: a replace operation
'effect' => 'fade', // the effect used when replacing the element (try fade!) //'effect' => 'fade', // the effect used when replacing the element (try fade!)
) ),
); '#suffix' => '<br/>',
);
drupal_add_js('', 'inline'); drupal_add_js('', 'inline');
// We define a <div> wrapper. Everything in it will be replaced. // We define a <div> wrapper. Everything in it will be replaced.
$form['mods'] = array( $form['mods'] = array(
@ -56,6 +57,7 @@ class IslandoraBook {
$form['mods']['mods_record'] = array( $form['mods']['mods_record'] = array(
'#type' => 'textarea', '#type' => 'textarea',
'#title' => 'MODS Record to Import', '#title' => 'MODS Record to Import',
'#rows' => 20,
'#value' => (!empty($mods_save) ? $mods_save['mods']['mods_record'] : ''), '#value' => (!empty($mods_save) ? $mods_save['mods']['mods_record'] : ''),
); );
return $form; return $form;
@ -133,7 +135,13 @@ class IslandoraBook {
$dc = transform_mods_to_dc($form_values['mods']['mods_record']); $dc = transform_mods_to_dc($form_values['mods']['mods_record']);
if ($dc) { if ($dc) {
$new_item->modify_datastream_by_value($dc, 'DC', 'Dublin Core XML Metadata', 'text/xml'); // Add the PID to a dc:identifier field.
$dc_doc = simplexml_load_string($dc);
$dc_item = $dc_doc->xpath('/srw_dc:dcCollection/srw_dc:dc[1]');
foreach($dc_item as $node) {
$node->addChild('identifier', $new_item->pid, 'http://purl.org/dc/elements/1.1/');
}
$new_item->modify_datastream_by_value($dc_doc->saveXML(), 'DC', 'Dublin Core XML Metadata', 'text/xml');
} }
$new_item->add_relationship('hasModel', $form_values['content_model_pid'], FEDORA_MODEL_URI); $new_item->add_relationship('hasModel', $form_values['content_model_pid'], FEDORA_MODEL_URI);
$new_item->add_relationship(!empty($form_values['relationship']) ? $form_values['relationship'] : 'isMemberOfCollection', $form_values['collection_pid']); $new_item->add_relationship(!empty($form_values['relationship']) ? $form_values['relationship'] : 'isMemberOfCollection', $form_values['collection_pid']);

2
ilives/fedora_ilives.module

@ -430,7 +430,7 @@ function retrieve_unapi_MODS_record($url) {
$bib_response = drupal_http_request($url); $bib_response = drupal_http_request($url);
$bib_html = $bib_response->data; $bib_html = $bib_response->data;
$bib_doc = new DOMDocument; $bib_doc = new DOMDocument;
$bib_doc->loadHTML($bib_html); @$bib_doc->loadHTML($bib_html);
$links = $bib_doc->getElementsByTagName('link'); $links = $bib_doc->getElementsByTagName('link');
foreach ($links as $link) { foreach ($links as $link) {
if ($link->getAttribute('rel') == 'unapi-server') { if ($link->getAttribute('rel') == 'unapi-server') {

42
plugins/Exiftool.inc

@ -8,7 +8,15 @@
*/ */
class Exiftool { class Exiftool {
function Exiftool() {
private $pid = NULL;
private $item = NULL;
function __construct($pid) {
//drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$this->pid = $pid;
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$this->item = new Fedora_Item($this->pid);
} }
function extractMetadata($parameterArray, $dsid, $file, $file_ext) { function extractMetadata($parameterArray, $dsid, $file, $file_ext) {
@ -21,4 +29,36 @@ class Exiftool {
$_SESSION['fedora_ingest_files']["$dsid"] = $file . $file_suffix; $_SESSION['fedora_ingest_files']["$dsid"] = $file . $file_suffix;
return TRUE; return TRUE;
} }
function displayMetadata() {
$output='';
$exifDom = DOMDocument::loadXML($this->item->get_datastream_dissemination('EXIF'));
if ($exifDom != NULL) {
$description = $exifDom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#','Description');
if ($description->length > 0) {
$description=$description->item(0);
$output .= '<div class="fedora_technical_metadata"><ul>';
for ($i=0;$i<$description->childNodes->length;$i++){
$name=$description->childNodes->item($i)->nodeName;
$value=$description->childNodes->item($i)->nodeValue;
if ($name != '#text' && !preg_match('/^System\:.*$/',$name) && trim($value) != '') {
list($type,$name) = preg_split('/\:/',$name);
$name = trim(preg_replace('/(?<!^)([A-Z][a-z]|(?<=[a-z])[A-Z])/'," $1", $name));
$output .= '<li><b>'.$name. '</b>: '. $value .' </li>';
}
}
$output.='</ul></div>';
$fieldset = array(
'#title' => t("!text", array('!text' => 'Technical Metadata')),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#value' => $output
);
$output = theme('fieldset', $fieldset);
}
}
return $output;
}
} }

89
plugins/ModsFormBuilder.inc

@ -5,9 +5,9 @@
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder');
class ModsFormBuilder extends FormBuilder { class ModsFormBuilder extends FormBuilder {
static $MODS_NS = 'http://www.loc.gov/mods/v3'; static $MODS_NS = 'http://www.loc.gov/mods/v3';
private $cm; protected $cm;
private $item; protected $item;
private $pid; protected $pid;
function __construct($pid=null) function __construct($pid=null)
{ {
@ -43,7 +43,7 @@ class ModsFormBuilder extends FormBuilder {
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('Edit metadata'), '#title' => t('Edit metadata'),
); );
if ($this->cm !== FALSE && $this->item != NULL) { if ($this->cm !== FALSE && $this->item != NULL) {
$form['pid'] = array('#type'=>'hidden','#value'=>$this->pid); $form['pid'] = array('#type'=>'hidden','#value'=>$this->pid);
@ -85,9 +85,12 @@ class ModsFormBuilder extends FormBuilder {
$includeEl=FALSE; $includeEl=FALSE;
break; break;
case '#edit_metadata_xpath': case '#edit_metadata_xpath':
$nodeList = $xpath->evaluate($val); $nodeList = $xpath->evaluate($val);
// echo $val. ' '.$nodeList->length.' '. $nodeList. '<br/>'; // echo $val. ' '.$nodeList->length.' ';
// echo $nodeList->item(0)->nodeValue.' ';
// echo '<br/>';
if (is_string($nodeList)) if (is_string($nodeList))
{ {
@ -101,7 +104,15 @@ class ModsFormBuilder extends FormBuilder {
} }
} else if ($nodeList->length > 0) } else if ($nodeList->length > 0)
{ {
$el['#default_value'] = $nodeList->item(0)->nodeValue; if ($el['#type'] == 'list') {
$values=array();
for ($i=0;$i<$nodeList->length;$i++) {
$values[]=$nodeList->item($i)->nodeValue;
}
$el['#default_value']=join('; ',$values);
} else {
$el['#default_value'] = $nodeList->item(0)->nodeValue;
}
} }
break; break;
} }
@ -385,6 +396,25 @@ class ModsFormBuilder extends FormBuilder {
$mods->appendChild($titleinfo); $mods->appendChild($titleinfo);
} }
if (isset($form_values['mods_alternative_titles']) && trim($form_values['mods_alternative_titles']) != '') {
$titles=preg_split('/\s+\;\s+/',trim($form_values['mods_alternative_titles']));
foreach ($titles as $t) {
$titleinfo = $dom->createElement('mods:titleInfo');
$titleinfo->setAttribute('type','alternative') ;
$title = $dom->createElement('mods:title',$t);
$titleinfo->appendChild($title);
$mods->appendChild($titleinfo);
}
}
if (isset($form_values['mods_alternative_title']) && trim($form_values['mods_alternative_title']) != '') {
$titleinfo = $dom->createElement('mods:titleInfo');
$titleinfo->setAttribute('type','alternative') ;
$title = $dom->createElement('mods:title',trim($form_values['mods_alternative_title']));
$titleinfo->appendChild($title);
$mods->appendChild($titleinfo);
}
if (isset($form_values['mods_description']) && trim($form_values['mods_description']) != '') { if (isset($form_values['mods_description']) && trim($form_values['mods_description']) != '') {
$abstract = $dom->createElement('mods:abstract', htmlspecialchars(trim($form_values['mods_description']))); $abstract = $dom->createElement('mods:abstract', htmlspecialchars(trim($form_values['mods_description'])));
$mods->appendChild($abstract); $mods->appendChild($abstract);
@ -443,7 +473,8 @@ class ModsFormBuilder extends FormBuilder {
$originInfo->appendChild($edition); $originInfo->appendChild($edition);
$addOriginInfo = TRUE; $addOriginInfo = TRUE;
} }
if (isset($form_values['mods_pubinfo_date']) && trim($form_values['mods_pubinfo_date']) != '' && if (isset($form_values['mods_pubinfo_date']) && trim($form_values['mods_pubinfo_date']) != '' &&
isset($form_values['mods_pubinfo_dateType']) && trim($form_values['mods_pubinfo_dateType']) != '') { isset($form_values['mods_pubinfo_dateType']) && trim($form_values['mods_pubinfo_dateType']) != '') {
if (in_array($form_values['mods_pubinfo_dateType'], array('issued', 'created', 'copyright', 'captured'))) { if (in_array($form_values['mods_pubinfo_dateType'], array('issued', 'created', 'copyright', 'captured'))) {
@ -456,18 +487,45 @@ class ModsFormBuilder extends FormBuilder {
} }
$originInfo->appendChild($date); $originInfo->appendChild($date);
$addOriginInfo = TRUE; $addOriginInfo = TRUE;
} else {
if (isset($form_values['mods_createdDate'])) {
$date = $dom->createElement('mods:createdDate',htmlspecialchars(trim($form_values['mods_createdDate'])));
$originInfo->appendChild($date);
$addOriginInfo = TRUE;
}
if (isset($form_values['mods_issuedDate'])) {
$date = $dom->createElement('mods:issuedDate',htmlspecialchars(trim($form_values['mods_issuedDate'])));
$originInfo->appendChild($date);
$addOriginInfo = TRUE;
}
if (isset($form_values['mods_copyrightDate'])) {
$date = $dom->createElement('mods:copyrightDate',htmlspecialchars(trim($form_values['mods_copyrightDate'])));
$originInfo->appendChild($date);
$addOriginInfo = TRUE;
}
if (isset($form_values['mods_capturedDate'])) {
$date = $dom->createElement('mods:capturedDate',htmlspecialchars(trim($form_values['mods_capturedDate'])));
$originInfo->appendChild($date);
$addOriginInfo = TRUE;
}
} }
if (isset($form_values['mods_pubinfo_journalFreq']) && trim($form_values['mods_pubinfo_journalFreq']) != '') { if (isset($form_values['mods_pubinfo_journalFreq']) && trim($form_values['mods_pubinfo_journalFreq']) != '') {
$frequency = $dom->createElement('mods:frequency', htmlspecialchars(trim($form_values['mods_pubinfo_journalFreq']))); $frequency = $dom->createElement('mods:frequency', htmlspecialchars(trim($form_values['mods_pubinfo_journalFreq'])));
$originInfo->appendChild($frequency); $originInfo->appendChild($frequency);
$issuance= $dom->createElement('mods:issuance', 'journal'); $issuance= $dom->createElement('mods:issuance', 'journal');
$originInfo->appendChild($issuance);
$addOriginInfo = TRUE; $addOriginInfo = TRUE;
} }
else { elseif (isset($form_values['mods_pubinfo_journalFreq'])) {
$issuance= $dom->createElement('mods:issuance', 'monographic'); $issuance= $dom->createElement('mods:issuance', 'monographic');
$originInfo->appendChild($issuance);
} }
$originInfo->appendChild($issuance);
if ($addOriginInfo) { if ($addOriginInfo) {
$mods->appendChild($originInfo); $mods->appendChild($originInfo);
@ -477,6 +535,12 @@ class ModsFormBuilder extends FormBuilder {
$note = $dom->createElement('mods:note', htmlspecialchars(trim($form_values['mods_note']))); $note = $dom->createElement('mods:note', htmlspecialchars(trim($form_values['mods_note'])));
$mods->appendChild($note); $mods->appendChild($note);
} }
if (isset($form_values['mods_caption']) && trim($form_values['mods_caption']) != '') {
$note = $dom->createElement('mods:note', htmlspecialchars(trim($form_values['mods_caption'])));
$note->setAttribute('type','caption');
$mods->appendChild($note);
}
if (isset($form_values['mods_format']) && trim($form_values['mods_format']) != '') { if (isset($form_values['mods_format']) && trim($form_values['mods_format']) != '') {
$typeOfResource = $dom->createElement('mods:typeOfResource', htmlspecialchars($form_values['mods_format'])); $typeOfResource = $dom->createElement('mods:typeOfResource', htmlspecialchars($form_values['mods_format']));
@ -524,6 +588,13 @@ class ModsFormBuilder extends FormBuilder {
$city = $dom->createElement('mods:city', htmlspecialchars($form_values['mods_city'])); $city = $dom->createElement('mods:city', htmlspecialchars($form_values['mods_city']));
$geographic->appendChild($city); $geographic->appendChild($city);
} }
if (isset($form_values['mods_area']) && trim($form_values['mods_area']) != '') {
$state = $dom->createElement('mods:area', htmlspecialchars($form_values['mods_area']));
$geographic->appendChild($state);
}
$subject->appendChild($geographic); $subject->appendChild($geographic);
} }

112
workflow_client/islandora_workflow_client.module

@ -16,44 +16,66 @@ function islandora_workflow_client_menu()
function islandora_workflow_client_search_submit($form,&$form_state) function islandora_workflow_client_search_submit($form,&$form_state)
{ {
if (trim($form['collection_pid']['#value']) !== '') $url ='admin/settings/workflow_client/'.$form['process_name']['#value'];
{ if (trim($form['process_id']['#value']) !== '') {
drupal_goto('admin/settings/workflow_client/'.$form['process_name']['#value'].'/'.$form['collection_pid']['#value']); $url.='/'.$form['process_id']['#value'];
} else } else {
{ $url .= '/-/';
drupal_goto('admin/settings/workflow_client/'.$form['process_name']['#value']);
} }
if (trim($form['collection_pid']['#value']) !== '') {
$url.='/'.$form['collection_pid']['#value'];
} else {
$url .= '/-/';
}
drupal_goto($url);
} }
function islandora_workflow_client_search() function islandora_workflow_client_search(&$form_state,$terms=null,$process_id=null,$collection=null)
{ {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$form = array(); $form = array();
$form['process_name'] = array( $form['process_name'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#required'=> TRUE,
'#title' => t('Search by Process Name'), '#title' => t('Search by Process Name'),
'#default_value' => ($terms!=null?$terms:''),
'#description' => t('Returns a list of objects that match the process name(s) entered. Separate multiple names by spaces.'), '#description' => t('Returns a list of objects that match the process name(s) entered. Separate multiple names by spaces.'),
); );
$form['process_id'] = array(
'#type' => 'textfield',
'#title' => t('Search by Process ID'),
'#default_value' => ($process_id!=null?$process_id:''),
'#description' => t('Returns only objects that match the also match the process id entered. '),
);
$form['collection_pid'] = array( $form['collection_pid'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Search by Collection PID'), '#title' => t('Search by Collection PID'),
'#default_value' => ($collection!=null?$collection:''),
'#description' => t('Returns only objects that match the also match the collection pid(s) entered. Separate multiple PIDs by spaces.'), '#description' => t('Returns only objects that match the also match the collection pid(s) entered. Separate multiple PIDs by spaces.'),
); );
$form['submit'] = array('#type' => 'submit', '#value' => t('Search')); $form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
return $form; return $form;
} }
function islandora_workflow_client_manage($terms = null, $collection = null, $queue= null, $queueProcess = null) function islandora_workflow_client_manage($terms = null, $process_id= null, $collection = null, $queue= null, $queueProcess = null)
{ {
if ($collection == 'none') if ($collection == 'none' || $collection == '-') {
{
$collection = null; $collection = null;
} }
if ($process_id == 'none' || $process_id == '-') {
$process_id = null;
}
$output = ''; $output = '';
if (trim($terms) != '') if (trim($terms) != '')
@ -143,49 +165,57 @@ function islandora_workflow_client_manage($terms = null, $collection = null, $qu
$errCount = 0; $errCount = 0;
$waitCount =0; $waitCount =0;
$completeCount = 0; $completeCount = 0;
$display = false;
foreach ($pids as $pid) foreach ($pids as $pid)
{ {
if ( isset($workflows[$pid]) && $workflows[$pid] !== false ) if ( isset($workflows[$pid]) && $workflows[$pid] !== false )
{ {
$display = true;
$procs = $workflows[$pid]->getProcesses(); $procs = $workflows[$pid]->getProcesses();
$updated = FALSE; $updated = FALSE;
foreach ($procs as $id=>$n) foreach ($procs as $id=>$n)
{ {
if ($process_id == null || $id == $process_id)
if ($name == $n) {
{ if ($name == $n)
$proc=$workflows[$pid]->getProcess($id); {
if (($queue == 'queue'|| ($queue =='errorQueue' && $proc['state'] == 'error')) && $queueProcess == $n) $proc=$workflows[$pid]->getProcess($id);
{ if (($queue == 'queue'|| ($queue =='errorQueue' && $proc['state'] == 'error')) && $queueProcess == $n)
$workflows[$pid]->setState($id,'waiting'); {
$updated=TRUE; $workflows[$pid]->setState($id,'waiting');
} $updated=TRUE;
}
switch ($proc['state'])
{ switch ($proc['state'])
case 'completed': {
$completeCount++; case 'completed':
break; $completeCount++;
case 'waiting': break;
$waitCount++; case 'waiting':
break; $waitCount++;
case 'error': break;
$errCount++; case 'error':
$errors[]=$proc; $errCount++;
break; $errors[]=$proc;
break;
}
} }
} }
} if ($updated)
if ($updated) {
{ $workflows[$pid]->saveToFedora();
$workflows[$pid]->saveToFedora(); }
} }
} }
} }
$rows[]= array($name, $waitCount,$completeCount,$errCount,l('Add All to Queue','admin/settings/workflow_client/'.$terms.'/'.(trim($collection)==''?'none':$collection).'/queue/'.$name).'<br/>'.l('Add Errors to Queue','admin/settings/workflow_client/'.$terms.'/'.(trim($collection)==''?'none':$collection).'/errorQueue/'.$name)); if ($display) {
$rows[]= array($name, $waitCount,$completeCount,$errCount,
l('Add All to Queue','admin/settings/workflow_client/'.$terms.'/'.(trim($process_id)==''?'none':$process_id).'/'.(trim($collection)==''?'none':$collection).'/queue/'.$name).'<br/>'.
l('Add Errors to Queue','admin/settings/workflow_client/'.$terms.'/'.(trim($process_id)==''?'none':$process_id).'/'.(trim($collection)==''?'none':$collection).'/errorQueue/'.$name));
}
} }
if ($queue == 'queue' || $queue == 'errorQueue') if ($queue == 'queue' || $queue == 'errorQueue')
@ -193,7 +223,7 @@ function islandora_workflow_client_manage($terms = null, $collection = null, $qu
drupal_goto('admin/settings/workflow_client/'.$terms.(trim($collection)==''?'/'.$collection:'')); drupal_goto('admin/settings/workflow_client/'.$terms.(trim($collection)==''?'/'.$collection:''));
} }
$output.='<h3>Search for "'.$terms.'" '.(trim($collection)!=''?'in collection(s) "'.$collection.'" ':'').'returned Processes:</h3>'; $output.='<h3>Search for '.($process_id!=null?'process id '.$process_id.' with terms ':'').' "'.$terms.'" '.(trim($collection)!=''?'in collection(s) "'.$collection.'" ':'').'returned Processes:</h3>';
$output.=theme('table',$headers,$rows); $output.=theme('table',$headers,$rows);
if (count ($errors) > 0) if (count ($errors) > 0)
@ -223,7 +253,7 @@ function islandora_workflow_client_manage($terms = null, $collection = null, $qu
} }
} }
$output .= drupal_get_form('islandora_workflow_client_search'); $output .= drupal_get_form('islandora_workflow_client_search',$form,NULL, $terms, $process_id, $collection);
return $output; return $output;
} }
@ -239,7 +269,7 @@ function islandora_workflow_client_cron()
$queue='/queue/fedora.apim.update'; $queue='/queue/fedora.apim.update';
$con->subscribe($queue); $con->subscribe($queue);
$messagesToSend=array(); $messagesToSend=array();
for ($i=0;$i<50;$i++) { for ($i=0;$i<100;$i++) {
$msg = $con->readFrame(); $msg = $con->readFrame();
if ($msg != null) { if ($msg != null) {

72
workflow_client/plugins/exif.inc

@ -0,0 +1,72 @@
<?php
// $Id$
module_load_include('inc', 'islandora_workflow_client', 'process');
class exif extends Process {
protected function process($pid, $parameters) {
$required_params = array('dsid');
$missing_params = array();
foreach ($required_params as $param)
if (!isset($parameters[$param]))
$missing_params[]=$param;
if (count($missing_params) > 0) {
$this->setMessage(t('Missing parameter(s) "%params" for exif process on "%pid"', array('%params' => join(',', $missing_params), '%pid' => $pid)));
return FALSE;
}
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$item = new fedora_item($pid);
$dslist = $item->get_datastreams_list_as_array();
if (!isset($dslist[$parameters['dsid']])) {
$this->setMessage(t('Datastream "%dsid" could not be found for exif process on "%pid"', array('%dsid' => $parameters['dsid'], '%pid' => $pid)));
return FALSE;
}
$ds = $dslist[$parameters['dsid']];
$file = '/tmp/'. $ds['label'];
$dest_ds = isset($parameters['dest_ds']) ? $parameters['dest_ds'] : 'EXIF';
$objectHelper = new ObjectHelper();
$objectHelper->makeObject($pid, $parameters['dsid'], FALSE, NULL, $file);
if (!file_exists($file)) {
$this->setMessage('couldnt get datastream '. $parameters['dsid'] .' as '. $file);
return FALSE;
}
$system = getenv('System');
$returnValue=TRUE;
$output=array();
$command = '/usr/local/exif/exiftool -X '. $file;
exec($command, $output, $returnValue);
if (!file_exists($file . $file_suffix)) {
$this->setMessage('command failed: '. htmlentities($command ."\n" . join("\n", $output) ."\n return value: $returnValue"));
@unlink($file);
return FALSE;
}
if ($returnValue == '0') {
if (isset($dslist[$dest_ds])) {
$item->purge_datastream($dest_ds);
}
$ret = $item->add_datastream_from_string(join("\n",$output), $dest_ds, $ds['label'] . $file_suffix, 'text/xml', 'X','Added by workflow process EXIF.');
@unlink($file);
@unlink($file . $file_suffix);
if (!$ret) {
$this->setMessage(t('Unable to add datastream "%dsid" to "%pid".', array('%dsid' => $dest_ds, '%pid' => $pid)));
return FALSE;
}
return TRUE;
}
}
}

48
workflow_client/plugins/mods_extend.inc

@ -65,35 +65,39 @@ class mods_extend extends Process {
break; break;
} }
} }
$collections= $relsExtDom->getElementsByTagName('isMemberOfCollection'); $relationships = array('isMemberOfCollection','isMemberOf','isPartOf');
for ($i=0; $i < $collections->length; $i++) { foreach ($relationships as $relationship)
$collection = $collections->item($i); {
list(, $ident) = explode('/', $collection->getAttribute('rdf:resource')); $collections= $relsExtDom->getElementsByTagName($relationship);
for ($i=0; $i < $collections->length; $i++) {
$collection = $collections->item($i);
list(, $ident) = explode('/', $collection->getAttribute('rdf:resource'));
$collection = new fedora_item($ident); $collection = new fedora_item($ident);
$dc = new SimpleXMLElement($collection->get_datastream_dissemination('DC'), NULL, FALSE, 'http://purl.org/dc/elements/1.1/'); $dc = new SimpleXMLElement($collection->get_datastream_dissemination('DC'), NULL, FALSE, 'http://purl.org/dc/elements/1.1/');
$relatedItem = $modsDom->createElement('mods:relatedItem'); $relatedItem = $modsDom->createElement('mods:relatedItem');
$relatedItem->setAttribute('type', 'host'); $relatedItem->setAttribute('type', 'host');
$titleInfo = $modsDom->createElement('mods:titleInfo'); $titleInfo = $modsDom->createElement('mods:titleInfo');
$title = $modsDom->createElement('mods:title', $dc->title); $title = $modsDom->createElement('mods:title', $dc->title);
$titleInfo->appendChild($title); $titleInfo->appendChild($title);
$relatedItem->appendChild($titleInfo); $relatedItem->appendChild($titleInfo);
$identifier = $modsDom->createElement('mods:identifier', $ident); $identifier = $modsDom->createElement('mods:identifier', $ident);
$identifier->setAttribute('type', 'pid'); $identifier->setAttribute('type', 'pid');
$relatedItem->appendChild($identifier); $relatedItem->appendChild($identifier);
$ident = preg_replace('/^.*\:/', '10719/', $ident); $ident = preg_replace('/^.*\:/', '10719/', $ident);
$identifier = $modsDom->createElement('mods:identifier', $ident); $identifier = $modsDom->createElement('mods:identifier', $ident);
$identifier->setAttribute('type', 'hdl'); $identifier->setAttribute('type', 'hdl');
$relatedItem->appendChild($identifier); $relatedItem->appendChild($identifier);
$modsRoot->appendChild($relatedItem); $modsRoot->appendChild($relatedItem);
}
} }
$identifier = $modsDom->createElement('mods:identifier', $pid); $identifier = $modsDom->createElement('mods:identifier', $pid);
$identifier->setAttribute('type', 'pid'); $identifier->setAttribute('type', 'pid');
$modsRoot->appendChild($identifier); $modsRoot->appendChild($identifier);

Loading…
Cancel
Save