Browse Source

Modified to include content model as a field cmodel_t in solr doc. Also does some basic checking and returns messages if the xsl fails to load/run

pull/105/head
root 14 years ago
parent
commit
9412cfff89
  1. 32
      workflow_client/plugins/solr_index.inc

32
workflow_client/plugins/solr_index.inc

@ -27,6 +27,8 @@ class solr_index extends Process {
}
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'ContentModel');
$xsltDom = NULL;
if (isset($parameters['xslt'])) {
list($template_pid, $template_dsid) = explode('/', $parameters['xslt']);
@ -44,6 +46,11 @@ class solr_index extends Process {
$xsltDom->load(drupal_get_path('module', 'islandora_workflow_client') .'/xsl/'. trim($parameters['xslt_file']));
}
if ($xsdlDom === FALSE) {
$this->setMessage(t('Unable to load xslt.'));
return FALSE;
}
$item = new fedora_item($pid);
$dslist = $item->get_datastreams_list_as_array();
if (!isset($dslist[$parameters['dsid']])) {
@ -59,9 +66,12 @@ class solr_index extends Process {
$proc = new XSLTProcessor();
$proc->importStylesheet($xsltDom);
$solrDoc = $proc->transformToXML($dom);
$solrDom = DOMDocument::loadXML($solrDoc);
$solrDom = $proc->transformToDOC($dom);
if ($solrDoc === FALSE) {
$this->setMessage(t('Document transform failed.'));
return FALSE;
}
$doc = $solrDom->getElementsByTagName('doc');
if ($doc->length > 0) {
$doc=$doc->item(0);
@ -72,13 +82,19 @@ class solr_index extends Process {
$field->setAttribute('name', 'workflow_process_t');
$doc->appendChild($field);
}
if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) {
$field=$solrDom->createElement('field', $cm->pid);
$field->setAttribute('name', 'cmodel_t');
$doc->appendChild($field);
}
if (isset($dslist['DC']))
{
$dc = $item->get_datastream('DC');
$field=$solrDom->createElement('field',$dc->createDate);
$field->setAttribute('name','created_d');
$doc->appendChild($field);
$dc = $item->get_datastream('DC');
$field=$solrDom->createElement('field',$dc->createDate);
$field->setAttribute('name','created_d');
$doc->appendChild($field);
}
}

Loading…
Cancel
Save