/**
  * 	Constructor
  * 
  * 
  * @return object XMLMIMEPartImporter
  * @access public
  * @since 12/6/06
  */
 function XMLFilePartImporter($existingArray)
 {
     parent::XMLImporter($existingArray);
 }
Exemple #2
0
 /**
  * Save our results. Tearing down and unsetting the Wizard is handled by
  * in {@link runWizard()} and does not need to be implemented here.
  * 
  * @param string $cacheName
  * @return boolean TRUE if save was successful and tear-down/cleanup of the
  *		Wizard should ensue.
  * @access public
  * @since 7/27/05
  */
 function saveWizard($cacheName)
 {
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("Id");
     $repositoryManager = Services::getService("Repository");
     $wizard = $this->getWizard($cacheName);
     $properties = $wizard->getAllValues();
     $centerPane = $this->getActionRows();
     ob_start();
     $path = $properties['filename']['tmp_name'];
     $filename = $properties['filename']['name'];
     if ($properties['filename']['name'] == "") {
         print "Please choose a file to upload!";
         $centerPane->add(new Block(ob_get_contents(), 1));
         ob_end_clean();
         return FALSE;
     }
     $newName = $this->moveArchive($path, $filename);
     //===== THIS ARRAY DEFINES THINGS THAT SHOULD NOT BE IMPORTED =====//
     $array = array("REMOTE_FILE", "FILE_URL", "FILE", "FILE_DATA", "FILE_NAME", "MIME_TYPE", "THUMBNAIL_DATA", "THUMBNAIL_MIME_TYPE", "FILE_SIZE", "DIMENSIONS", "THUMBNAIL_DIMENSIONS", "edu.middlebury.harmoni.repository.asset_content", "edu.middlebury.harmoni.repository.asset_content.Content", "edu.middlebury.concerto.exhibition_repository", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.target_id", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.text_position", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.display_metadata");
     $hasErrors = false;
     if ($properties['file_type'] == "XML") {
         //	define an empty importer for decompression
         if ($properties['is_archived'] == TRUE) {
             $importer = new XMLImporter($array);
             $directory = $importer->decompress($newName);
             // something happened so tell the end user
             if ($importer->hasErrors()) {
                 $importer->printErrorMessages();
                 $hasErrors = true;
             }
             unset($importer);
             $dir = opendir($directory);
             while ($file = readdir($dir)) {
                 // each folder is a collection
                 if (is_dir($directory . "/" . $file) && $file != "." && $file != "..") {
                     $importer = XMLRepositoryImporter::withFile($array, $directory . "/" . $file . "/metadata.xml", $properties['import_type']);
                     $importer->parseAndImport("asset");
                     // something happened so tell the end user
                     if ($importer->hasErrors()) {
                         $importer->printErrorMessages();
                         $hasErrors = true;
                     }
                     unset($importer);
                 }
             }
             closedir($dir);
             // Unlink the directory
             $this->deleteRecursive($directory);
         } else {
             // not compressed, only one xml file
             $importer = XMLRepositoryImporter::withFile($array, $newName, $properties['import_type']);
             $importer->parseAndImport("asset");
             // something happened so tell the end user
             if ($importer->hasErrors()) {
                 $importer->printErrorMessages();
                 $hasErrors = true;
             }
         }
     }
     if (file_exists($newName)) {
         unlink($newName);
     }
     if ($hasErrors) {
         $centerPane->add(new Block(ob_get_contents(), 1));
         ob_end_clean();
         return FALSE;
     }
     // clean and clear
     $centerPane->add(new Block(ob_get_contents(), 1));
     ob_end_clean();
     return TRUE;
 }
Exemple #3
0
 /**
  * Save our results. Tearing down and unsetting the Wizard is handled by
  * in {@link runWizard()} and does not need to be implemented here.
  * 
  * @param string $cacheName
  * @return boolean TRUE if save was successful and tear-down/cleanup of the
  *		Wizard should ensue.
  * @access public
  * @since 7/27/05
  */
 function saveWizard($cacheName)
 {
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("Id");
     $repositoryManager = Services::getService("Repository");
     $wizard = $this->getWizard($cacheName);
     $properties = $wizard->getAllValues();
     $centerPane = $this->getActionRows();
     ob_start();
     $path = $properties['filename']['tmp_name'];
     $filename = $properties['filename']['name'];
     if ($properties['filename']['name'] == "") {
         print "Please choose a file to upload!";
         $centerPane->add(new Block(ob_get_contents(), 1));
         ob_end_clean();
         return FALSE;
     }
     $newName = $this->moveArchive($path, $filename);
     //===== THIS ARRAY DEFINES THINGS THAT SHOULD NOT BE IMPORTED =====//
     $this->_ignore = array("REMOTE_FILE", "FILE_URL", "FILE", "FILE_DATA", "FILE_NAME", "MIME_TYPE", "THUMBNAIL_DATA", "THUMBNAIL_MIME_TYPE", "FILE_SIZE", "DIMENSIONS", "THUMBNAIL_DIMENSIONS", "edu.middlebury.harmoni.repository.asset_content", "edu.middlebury.harmoni.repository.asset_content.Content");
     $repository = $repositoryManager->getRepository($idManager->getId($harmoni->request->get('collection_id')));
     $startTime = DateAndTime::now();
     $this->_hasErrors = false;
     //===== Exif and Tab-Delim Importers are special =====//
     if ($properties['file_type'] == "Tab-Delimited") {
         $importer = new TabRepositoryImporter($newName, $repository->getId(), false);
     } else {
         if ($properties['file_type'] == "Exif") {
             $importer = new ExifRepositoryImporter($newName, $repository->getId(), false);
         } else {
             if ($properties['file_type'] == "FilesOnly") {
                 $importer = new FilesOnlyRepositoryImporter($newName, $repository->getId(), false);
             }
         }
     }
     if (isset($importer)) {
         if ($properties['parent']) {
             $importer->setParent($repository->getAsset($idManager->getId($properties['parent'])));
         }
         $importer->import($properties['is_archived']);
         // something happened so tell the end user
         if ($importer->hasErrors()) {
             $importer->printErrorMessages();
             $this->_hasErrors = true;
         }
     }
     //===== Done with special "RepositoryImporters" =====//
     if ($properties['file_type'] == "XML") {
         if ($properties['is_archived'] == TRUE) {
             //	define an empty importer for decompression
             $importer = new XMLImporter($this->_ignore);
             $directory = $importer->decompress($newName);
             unset($importer);
             $this->_repository = $repository;
             $this->_importType = $properties['import_type'];
             if ($properties['parent']) {
                 $parent = $repository->getAsset($idManager->getId($properties['parent']));
             } else {
                 $parent = null;
             }
             $this->importDirectoriesDown($directory, $parent);
         } else {
             // not compressed, only one xml file
             $importer = XMLRepositoryImporter::withObject($this->_ignore, $repositoryManager->getRepository($idManager->getId($harmoni->request->get('collection_id'))), $newName, $properties['import_type']);
             if ($properties['parent']) {
                 $importer->setParent($repository->getAsset($idManager->getId($properties['parent'])));
             }
             $importer->parseAndImportBelow("asset", 100);
             // something happened so tell the end user
             if ($importer->hasErrors()) {
                 $importer->printErrorMessages();
                 $this->_hasErrors = true;
             }
             unset($importer);
         }
     }
     // Unlink the directory
     if (isset($directory) && $directory) {
         $this->deleteRecursive($directory);
     }
     if (file_exists($newName)) {
         unlink($newName);
     }
     if ($this->_hasErrors) {
         $centerPane->add(new Block(ob_get_contents(), 1));
         ob_end_clean();
         return FALSE;
     }
     // Update any newly modified assets' tags
     $searchProperties = new HarmoniProperties(new Type("repository", "harmoni", "order"));
     $searchProperties->addProperty("order", $order = "ModificationDate");
     $searchProperties->addProperty("direction", $direction = "DESC");
     $assets = $repository->getAssetsBySearch($criteria = '*', new Type("Repository", "edu.middlebury.harmoni", "DisplayName"), $searchProperties);
     $systemAgentId = $idManager->getId('system:concerto');
     $tagGenerator = StructuredMetaDataTagGenerator::instance();
     while ($assets->hasNext()) {
         $asset = $assets->next();
         if ($startTime->isGreaterThan($asset->getModificationDate())) {
             break;
         }
         $tagGenerator->regenerateTagsForAsset($asset, $systemAgentId, 'concerto', $repository->getId());
     }
     // clean and clear
     $centerPane->add(new Block(ob_get_contents(), 1));
     ob_end_clean();
     return TRUE;
 }
 /**
  * 	Constructor
  * 
  * 
  * @return object XMLThumbpathPartImporter
  * @access public
  * @since 10/6/05
  */
 function XMLThumbpathPartImporter($existingArray)
 {
     parent::XMLImporter($existingArray);
 }
 /**
  * Constructor with XMLFile and starting object
  * 
  * @param object mixed
  * @param string
  * @param string
  * @param string
  * @return object mixed
  * @access public
  * @since 10/11/05
  * @static
  */
 public static function withObject($existingArray, $object, $filepath, $type, $class = 'XMLAssetImporter')
 {
     return parent::withObject($existingArray, $object, $filepath, $type, $class);
 }
 /**
  * 	Constructor
  * 
  * 
  * @return object XMLThumbDimensionsPartImporter
  * @access public
  * @since 10/10/05
  */
 function XMLThumbDimensionsPartImporter($existingArray)
 {
     parent::XMLImporter($existingArray);
 }
 }
 $repositories = $repositoryManager->getRepositories();
 $dcOrVraExist = FALSE;
 while ($repositories->hasNext() && !$dcOrVraExist) {
     $repository = $repositories->next();
     $recordStructures = $repository->getRecordStructures();
     while ($recordStructures->hasNext() && !$dcOrVraExist) {
         $recordStructure = $recordStructures->next();
         if (preg_match('/(Dublin)|(VRA)/i', $recordStructure->getDisplayName())) {
             $dcOrVraExist = TRUE;
         }
     }
 }
 if (!$dcOrVraExist) {
     $array = array();
     $importer = XMLImporter::withFile($array, MYDIR . "/sampledata/SchemaInstallCollection.xml", "insert");
     $importer->parseAndImport("repository");
     if ($importer->hasErrors()) {
         $importer->printErrorMessages();
         exit;
     }
     $repositories = $repositoryManager->getRepositories();
     while ($repositories->hasNext()) {
         $repository = $repositories->next();
         if ($repository->getDisplayName() == "Schema Install Collection") {
             $repositoryId = $repository->getId();
             $repositoryManager->deleteRepository($repositoryId);
             break;
         }
     }
 }
 /**
  * 	Constructor; parses XML if passed file
  * 
  * 
  * @return object XMLRecordImporter
  * @access public
  * @since 10/6/05
  */
 function XMLRecordImporter($existingArray)
 {
     parent::XMLImporter($existingArray);
 }
Exemple #9
0
 /**
  * Save our results. Tearing down and unsetting the Wizard is handled by
  * in {@link runWizard()} and does not need to be implemented here.
  * 
  * @param string $cacheName
  * @return boolean TRUE if save was successful and tear-down/cleanup of the
  *		Wizard should ensue.
  * @access public
  * @since 7/27/05
  */
 function saveWizard($cacheName)
 {
     $harmoni = Harmoni::instance();
     $wizard = $this->getWizard($cacheName);
     $properties = $wizard->getAllValues();
     $centerPane = $this->getActionRows();
     ob_start();
     $path = $properties['filename']['tmp_name'];
     $filename = $properties['filename']['name'];
     if ($properties['filename']['name'] == "") {
         print "Please choose a file to upload!";
         $centerPane->add(new Block(ob_get_contents(), 1));
         ob_end_clean();
         return FALSE;
     }
     $newName = $this->moveArchive($path, $filename);
     $array = array("FILE", "FILE_DATA", "FILE_NAME", "MIME_TYPE", "THUMBNAIL_DATA", "THUMBNAIL_MIME_TYPE", "FILE_SIZE", "DIMENSIONS", "THUMBNAIL_DIMENSIONS", "edu.middlebury.harmoni.repository.asset_content", "edu.middlebury.harmoni.repository.asset_content.Content", "edu.middlebury.concerto.exhibition_repository", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.target_id", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.text_position", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.display_metadata");
     if ($properties['file_type'] == "XML") {
         $importer = new XMLImporter($array);
         if ($properties['is_archived'] == TRUE) {
             $directory = $importer->decompress($newName);
             $importer = XMLImporter::withFile($array, $directory . "/metadata.xml", $properties['import_type']);
         } else {
             $importer = XMLImporter::withFile($array, $newName, $properties['import_type']);
         }
         $importer->parseAndImportBelow("asset", 75);
     }
     if ($importer->hasErrors()) {
         $importer->printErrorMessages();
         $centerPane->add(new Block(ob_get_contents(), 1));
         ob_end_clean();
         return FALSE;
     }
     $centerPane->add(new Block(ob_get_contents(), 1));
     ob_end_clean();
     return true;
 }
 /**
  * sets the node's info
  * 
  * @access public
  * @since 10/6/05
  */
 function getNodeInfo()
 {
     parent::getNodeInfo();
     if ($this->_node->hasAttribute("isMandatory")) {
         $this->_info['isMandatory'] = $this->_node->getAttribute("isMandatory");
     } else {
         $this->_info['isMandatory'] = FALSE;
     }
     if ($this->_node->hasAttribute("isRepeatable")) {
         $this->_info['isRepeatable'] = $this->_node->getAttribute("isRepeatable");
     } else {
         $this->_info['isRepeatable'] = FALSE;
     }
     if ($this->_node->hasAttribute("isPopulated")) {
         $this->_info['isPopulated'] = $this->_node->getAttribute("isPopulated");
     } else {
         $this->_info['isPopulated'] = FALSE;
     }
 }
 /**
  * 	Constructor
  * 
  * 
  * @return object XMLRepositoryImporter
  * @access public
  * @since 10/5/05
  */
 function XMLRepositoryFileImporter($existingArray)
 {
     parent::XMLImporter($existingArray);
 }