Browse Source

Updated to also allow searching by process id instead of just process name and collection. Updated to process 500 JMS messages per cron run.

pull/2/head
mroy 14 years ago
parent
commit
2981b09949
  1. 112
      workflow_client/islandora_workflow_client.module

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<500;$i++) {
$msg = $con->readFrame(); $msg = $con->readFrame();
if ($msg != null) { if ($msg != null) {

Loading…
Cancel
Save