/** * @see {Opus_Model_Plugin_Interface::postDelete} */ public function postDelete($modelId) { $cache = new Opus_Model_Xml_Cache(); $omx = new Opus_Model_Xml(); // xml version 1 $omx->setStrategy(new Opus_Model_Xml_Version1()); $cache->remove($modelId, floor($omx->getStrategyVersion())); // xml version 2 $omx->setStrategy(new Opus_Model_Xml_Version2()); $cache->remove($modelId, floor($omx->getStrategyVersion())); }
/** * @param boolean $useCache * @return DOMNode Opus_Document node */ public function getNode($useCache = true) { $xmlModel = new Opus_Model_Xml(); $xmlModel->setModel($this->_document); $xmlModel->excludeEmptyFields(); // needed for preventing handling errors $xmlModel->setStrategy(new Opus_Model_Xml_Version1()); if ($useCache) { $xmlModel->setXmlCache(new Opus_Model_Xml_Cache()); } $result = $xmlModel->getDomDocument(); return $result->getElementsByTagName('Opus_Document')->item(0); }
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. You should have received a copy of the GNU General Public License * along with OPUS; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @category Application * @author Sascha Szott <*****@*****.**> * @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License * @version $Id$ */ /** * Returns the XML representation of the document with given id $id. */ if (isset($argv[2]) && !empty($argv[2]) && is_numeric($argv[2])) { $id = $argv[2]; } else { $id = 91; } try { $doc = new Opus_Document($id); } catch (Opus_Model_NotFoundException $e) { echo "document with id {$id} does not exist"; exit; } $xmlModel = new Opus_Model_Xml(); $xmlModel->setModel($doc); $xmlModel->setStrategy(new Opus_Model_Xml_Version1()); $xmlModel->excludeEmptyFields(); echo $xmlModel->getDomDocument()->saveXML(); exit;
* details. You should have received a copy of the GNU General Public License * along with OPUS; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @category Application * @author Edouard Simon <*****@*****.**> * @copyright Copyright (c) 2011-2013, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License * @version $Id: cron-update-document-cache.php 11732 2013-06-24 12:26:11Z esimon $ */ define('APPLICATION_ENV', 'development'); // Bootstrapping require_once dirname(__FILE__) . '/../common/bootstrap.php'; $opusDocCacheTable = new Opus_Db_DocumentXmlCache(); $db = Zend_Registry::get('db_adapter'); // $select = $db->select(); $select->from($opusDocCacheTable->info('name'), 'document_id'); $docFinder = new Opus_DocumentFinder(); $docFinder->setSubSelectNotExists($select); $docIds = $docFinder->ids(); echo "processing " . count($docIds) . " documents\n"; foreach ($docIds as $docId) { $model = new Opus_Document($docId); $cache = new Opus_Model_Xml_Cache(); // xml version 1 $omx = new Opus_Model_Xml(); $omx->setStrategy(new Opus_Model_Xml_Version1())->excludeEmptyFields()->setModel($model)->setXmlCache($cache); $dom = $omx->getDomDocument(); echo "Cache refreshed for document#{$docId}\n"; }
/** * * @param Opus_Document $document * @return DOMNode * @throws Exception */ private function getDocumentXmlDomNode($document) { if (!in_array($document->getServerState(), $this->_deliveringDocumentStates)) { $message = 'Trying to get a document in server state "' . $document->getServerState() . '"'; Zend_Registry::get('Zend_Log')->err($message); throw new Exception($message); } $xmlModel = new Opus_Model_Xml(); $xmlModel->setModel($document); $xmlModel->excludeEmptyFields(); $xmlModel->setStrategy(new Opus_Model_Xml_Version1()); $xmlModel->setXmlCache(new Opus_Model_Xml_Cache()); return $xmlModel->getDomDocument()->getElementsByTagName('Opus_Document')->item(0); }
/** * Returns an xml representation of the given document in the format that is * expected by Solr. * * @param Opus_Document $doc * @return DOMDocument */ private function getSolrXmlDocument(Opus_Document $doc) { // Set up caching xml-model and get XML representation of document. $caching_xml_model = new Opus_Model_Xml(); $caching_xml_model->setModel($doc); $caching_xml_model->excludeEmptyFields(); $caching_xml_model->setStrategy(new Opus_Model_Xml_Version1()); $cache = new Opus_Model_Xml_Cache($doc->hasPlugin('Opus_Document_Plugin_Index')); $caching_xml_model->setXmlCache($cache); $config = Zend_Registry::get('Zend_Config'); $modelXml = $caching_xml_model->getDomDocument(); // extract fulltext from file and append it to the generated xml. $this->attachFulltextToXml($modelXml, $doc->getFile(), $doc->getId()); // Set up XSLT stylesheet $xslt = new DomDocument(); if (isset($config->searchengine->solr->xsltfile)) { $xsltFilePath = $config->searchengine->solr->xsltfile; if (!file_exists($xsltFilePath)) { throw new Application_Exception('Solr XSLT file not found.'); } $xslt->load($xsltFilePath); } // Set up XSLT processor $proc = new XSLTProcessor(); $proc->importStyleSheet($xslt); $solrXmlDocument = new DOMDocument(); $solrXmlDocument->preserveWhiteSpace = false; $solrXmlDocument->loadXML($proc->transformToXML($modelXml)); if (isset($config->log->prepare->xml) && $config->log->prepare->xml) { $modelXml->formatOutput = true; $this->log->debug("input xml\n" . $modelXml->saveXML()); $solrXmlDocument->formatOutput = true; $this->log->debug("transformed solr xml\n" . $solrXmlDocument->saveXML()); } return $solrXmlDocument; }