コード例 #1
0
 function updateMODSStream($pid, $version = NULL, $usage = NULL, $xmlString = NULL)
 {
     module_load_include('inc', 'fedora_repository', 'fedora_item');
     $object = new Fedora_Item($pid);
     if (!isset($xmlString)) {
         $mods = $object->get_datastream_dissemination('MODS');
     } else {
         $mods = $xmlString;
     }
     $doc = new DOMDocument('1.0', 'UTF-8');
     $doc->substituteEntities = FALSE;
     try {
         $doc->loadXML($mods);
     } catch (exception $e) {
         drupal_set_message(t('Error loading MODS record! ') . $e->getMessage());
         return ' ';
     }
     if (isset($usage)) {
         $usageNode = $doc->createElement('accessCondition', $usage);
         $usageNode->setAttribute('type', 'use and reproduction');
         $nodeList = $doc->getElementsByTagName('mods');
         foreach ($nodeList as $reference) {
             $reference->appendChild($usageNode);
         }
     }
     if (isset($version)) {
         //check if the physicalDescription element exists
         if ($doc->getElementsByTagName('physicalDescription')->length != 0) {
             //drupal_set_message(t('physicalDescription element already exists!'));
             $statusNode = $doc->getElementsByTagName('physicalDescription');
             $form_node = $doc->createElement('form', $version);
             $form_node->setAttribute('authority', 'local');
             foreach ($statusNode as $node) {
                 $node->appendChild($form_node);
             }
             //add it to the reference node
             $reference_node_list = $doc->getElementsByTagName('mods');
         } else {
             //create the useage element as it does not exist
             //drupal_set_message(t('physicalDescription element does not exist, creating...'));
             $statusNode = $doc->createElement('physicalDescription');
             $form_node = $doc->createElement('form', $version);
             $form_node->setAttribute('authority', 'local');
             $statusNode->appendChild($form_node);
             //add it to the reference node
             $reference_node_list = $doc->getElementsByTagName('mods');
             foreach ($reference_node_list as $reference) {
                 $reference->appendChild($statusNode);
             }
         }
     }
     $result = $object->modify_datastream_by_value($doc->saveXML(), 'MODS', 'MODS record', 'text/xml', TRUE, 'MODS datastream modified');
 }
コード例 #2
0
ファイル: Refworks.php プロジェクト: ratzeni/islandora
 function handleForm(&$form_values)
 {
     $errorMessage = NULL;
     module_load_include('php', 'Fedora_Repository', 'CollectionClass');
     module_load_include('php', 'Fedora_Repository', 'ContentModel');
     module_load_include('php', 'fedora_repository', 'api/fedora_item');
     $content_model_pid = ContentModel::getPidFromIdentifier($form_values['models']);
     $content_model_dsid = ContentModel::getDSIDFromIdentifier($form_values['models']);
     $collectionHelper = new CollectionClass();
     $startTime = time();
     $collection_pid = $form_values['collection_pid'];
     $this->parse_refworks_item($form_values);
     $this->security_helper = new SecurityClass();
     $collection_item = new Fedora_Item($collection_pid);
     $this->collection_policy_stream = $collection_item->get_datastream_dissemination('CHILD_SECURITY');
     if (empty($this->collection_policy_stream)) {
         $this->collection_policy_stream = file_get_contents(drupal_get_path('module', 'fedora_repository') . '/policies/noObjectEditPolicy.xml');
     }
     $success = 0;
     $errors = 0;
     foreach ($this->referencelist as $reference) {
         $dom = new DomDocument("1.0", "UTF-8");
         $dom->substituteEntities = FALSE;
         $dom->formatOutput = true;
         $pid = $collectionHelper->getNextPid($collection_pid, $content_model_dsid);
         $rootElement = $dom->createElement("foxml:digitalObject");
         $rootElement->setAttribute('VERSION', '1.1');
         $rootElement->setAttribute('PID', "{$pid}");
         $rootElement->setAttribute('xmlns:foxml', "info:fedora/fedora-system:def/foxml#");
         $rootElement->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
         $rootElement->setAttribute('xsi:schemaLocation', "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd");
         $dom->appendChild($rootElement);
         //create standard fedora stuff
         $qdc_element = $this->createQDCStream($dom, $rootElement, $reference);
         if (!$qdc_element) {
             drupal_set_message(t('Error Create DC for Refworks'), 'error');
             continue;
         }
         $item_title = '';
         foreach ($reference->t1 as $value) {
             $item_title .= ' --- ' . $value;
         }
         $this->createStandardFedoraStuff($form_values, $dom, $rootElement, $reference);
         $rootElement->appendChild($qdc_element);
         //create relationships
         $this->createRelationShips($form_values, $dom, $rootElement, $pid);
         //create dublin core
         $this->createFedoraDataStreams($form_values, $dom, $rootElement, $reference);
         if (!empty($this->collection_policy_stream)) {
             $this->create_security_policies($dom, $rootElement, $reference);
         }
         $params = array('objectXML' => $dom->saveXML(), 'format' => 'info:fedora/fedora-system:FOXML-1.1', 'logMessage' => "Fedora Object Ingested");
         try {
             $soapHelper = new ConnectionHelper();
             $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
             if ($client == null) {
                 drupal_set_message(t('Error Getting Soap Client.'), 'error');
                 watchdog(t("FEDORA_REPOSITORY"), t("Error Getting SOAP client") . $e, null, WATCHDOG_ERROR);
                 return;
             }
             $object = $client->__soapCall('ingest', array($params));
             watchdog(t("FEDORA_REPOSITORY"), t("Successfully added repository item ") . $pid . ' - ' . $item_title, null, WATCHDOG_INFO);
             $deleteFiles = $form_values['delete_file'];
             //remove files from drupal file system
             if ($deleteFiles > 0) {
                 unlink($form_values['fullpath']);
             }
         } catch (exception $e) {
             $errors++;
             $errorMessage = 'yes';
             //drupal_set_message(t('Error Ingesting Object! Check Drupal watchdog logs for more info' . $e->getMessage()), 'error');
             watchdog(t("FEDORA_REPOSITORY"), t("Error during ingest") . $item_title . ' ' . $e, null, WATCHDOG_ERROR);
             //return ' ';
         }
         $success++;
     }
     if (isset($errorMessage)) {
         drupal_set_message(t('Error Ingesting one or more records! Check Drupal watchdog logs for more info'), 'error');
     }
     $endTime = time();
     drupal_set_message(t('Successfull ingest of %success records.  %errors records failed.  Ingest took %seconds seconds', array('%success' => $success - $errors, '%errors' => $errors, '%seconds' => $endTime - $startTime)), 'info');
     //drupal_set_message(t('ingest took %seconds ',array('%seconds'=>$endTime-$startTime)),'info');
 }
コード例 #3
0
ファイル: rels-ext.php プロジェクト: ratzeni/islandora
 /**
  * Constructor that builds itself by retrieving the RELS-EXT stream from
  * the repository for the given Fedora_Item.
  * @param Fedora_Item $item
  */
 function RelsExt($item)
 {
     $relsextxml = $item->get_datastream_dissemination('RELS-EXT');
 }
コード例 #4
0
ファイル: FormBuilder.php プロジェクト: ratzeni/epistemetec
 function updateTags($pid, $terms)
 {
     $object = new Fedora_Item($pid);
     $stream = $object->get_datastream_dissemination("TAGS");
     if (strcasecmp($stream, "")) {
         $object->purge_datastream("TAGS");
     }
     $toinject = "<tags>";
     foreach ($terms as $term) {
         $toinject .= "<tag>" . $term->name . "</tag>";
     }
     $toinject .= "</tags>";
     $object->add_datastream_from_string($toinject, "TAGS", "Tag Utenti");
 }