Ejemplo n.º 1
0
 /**
  * Imports Institutes from Opus3 to Opus4 directly (without XML)
  *
  * @param DOMDocument $data XML-Document to be imported
  * @return array List of documents that have been imported
  */
 protected function importInstitutes($data, $pColls)
 {
     $mf = $this->_config->migration->mapping->institutes;
     $fp = null;
     try {
         $fp = @fopen($mf, 'w');
         if (!$fp) {
             throw new Exception("ERROR Opus3InstituteImport: Could not create '" . $mf . "' for Institutes.\n");
         }
     } catch (Exception $e) {
         $this->_logger->log($e->getMessage(), Zend_Log::ERR);
         return;
     }
     $classification = $this->transferOpusClassification($data);
     foreach ($classification as $class) {
         if (array_key_exists('fakultaet', $class) === false || array_key_exists('name', $class) === false || array_key_exists('nr', $class) === false) {
             $invalidInstitute = '';
             foreach ($class as $key => $val) {
                 $invalidInstitute .= "[{$key}:'{$val}'] ";
             }
             $this->_logger->log("Invalid entry for Institute will be ignored: '" . $invalidInstitute, Zend_Log::ERR);
             continue;
         }
         if (array_key_exists($class['fakultaet'], $pColls) === false) {
             $this->_logger->log("No Faculty with ID '" . $class['fakultaet'] . "' for Institute with ID '" . $class['nr'] . "'", Zend_Log::ERR);
             continue;
         }
         /*  Create a Collection for Institute */
         $root = new Opus_Collection($pColls[$class['fakultaet']]);
         $coll = $root->addLastChild();
         $coll->setName($class['name']);
         $coll->setVisible(1);
         $root->store();
         $this->_logger->log("Institute imported: " . $class['name'], Zend_Log::DEBUG);
         fputs($fp, $class['nr'] . ' ' . $coll->getId() . "\n");
     }
     fclose($fp);
 }