コード例 #1
0
 /**
  * Provide clean documents and statistics table and remove temporary files.
  * Create document for counting.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUpWithEnv('production');
     $this->assertSecurityConfigured();
     $path = Zend_Registry::get('temp_dir') . '~localstat.xml';
     @unlink($path);
     $this->_document = $this->createTestDocument();
     $this->_document->setType("doctoral_thesis");
     $this->_document->store();
     //setting server globals
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $_SERVER['HTTP_USER_AGENT'] = 'bla';
     $_SERVER['REDIRECT_STATUS'] = 200;
     // create collection test document
     $this->_document_col = $this->createTestDocument();
     $this->_document_col->addCollection(new Opus_Collection(40));
     // invisible collection
     $this->_document_col->addCollection(new Opus_Collection(16214));
     // visible collection with invisible collection role
     $this->_document_col->addCollection(new Opus_Collection(1031));
     // visible collection with visible collection role
     // collection role ID = 10 (sichbar)
     $this->_document_col->addCollection(new Opus_Collection(16136));
     // versteckte Collection (Role = 10)
     $this->_document_col->addCollection(new Opus_Collection(15991));
     // sichbare Collection (Role = 10);
     $this->_document_col->setServerState('published');
     $this->_document_col->store();
 }
コード例 #2
0
    $template = '<i><script language="javascript" type="text/javascript">alert(\'alert STRING\');</script>';
    return str_replace('STRING', $counter, $template);
}
// error handler function
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
    echo "WARNING: myErrorHandler({$errno}, '{$errstr}', '{$errfile}', {$errline})\n";
    return true;
}
// set to the user defined error handler
$oldErrorHandler = set_error_handler("myErrorHandler");
//
// Creating document, filling static fields.
//
$doc = new Opus_Document();
$doc->setType(randString($counter++));
$doc->setServerState('published');
$doc->setServerDatePublished('01.01.1900');
$doc->setLanguage('deu' . randString($counter++));
$doc->setThesisDateAccepted('01.02.2003');
$doc->setPublishedYear('2010');
$doc->setPublishedDate('28.09.2010');
$doc->setCompletedYear('2010');
$doc->setCompletedDate('27.09.2010');
$doc->setPublisherName(randString($counter++));
$doc->setPublisherPlace(randString($counter++));
$doc->setPageNumber(randString($counter++));
$doc->setPageFirst(randString($counter++));
$doc->setPageLast(randString($counter++));
$doc->setVolume(randString($counter++));
$doc->setIssue(randString($counter++));
コード例 #3
0
 private function processRow($row)
 {
     $doc = new Opus_Document();
     $oldId = $row[self::OLD_ID];
     try {
         $doc->setLanguage(trim($row[self::LANGUAGE]));
         // Dokumenttyp muss kleingeschrieben werden (bei Fromm aber groß)
         $doc->setType(lcfirst(trim($row[self::TYPE])));
         $doc->setServerState(trim($row[self::SERVER_STATE]));
         $doc->setVolume(trim($row[self::VOL_ID]));
         // speichere die oldId als Identifier old ab, so dass später nach dieser gesucht werden kann
         // und die Verbindung zwischen Ausgangsdatensatz und importiertem Datensatz erhalten bleibt
         $this->addIdentifier($doc, 'old', $oldId);
         $this->processTitlesAndAbstract($row, $doc, $oldId);
         $this->processDate($row, $doc, $oldId);
         $this->processIdentifier($row, $doc, $oldId);
         $this->processNote($row, $doc, $oldId);
         $this->processCollections($row, $doc);
         $this->processLicence($row, $doc, $oldId);
         $this->processSeries($row, $doc);
         $this->processEnrichmentKindofpublication($row, $doc, $oldId);
         // TODO Fromm verwendet aktuell sieben Enrichments (muss noch generalisiert werden)
         $enrichementkeys = array(self::ENRICHMENT_AVAILABILITY, self::ENRICHMENT_FORMAT, self::ENRICHMENT_KINDOFPUBLICATION, self::ENRICHMENT_IDNO, self::ENRICHMENT_COPYRIGHTPRINT, self::ENRICHMENT_COPYRIGHTEBOOK, self::ENRICHMENT_RELEVANCE);
         foreach ($enrichementkeys as $enrichmentkey) {
             $this->processEnrichment($enrichmentkey, $row, $doc);
         }
         $file = $this->processFile($row, $doc, $oldId);
         $doc->store();
         if (!is_null($file) && $file instanceof Opus_File && !is_null($this->_guestRole)) {
             $this->_guestRole->appendAccessFile($file->getId());
             $this->_guestRole->store();
         }
     } catch (Exception $e) {
         echo "import of document " . $oldId . " was not successful: " . $e->getMessage() . "\n";
     }
     try {
         $this->processPersons($row, $doc, $oldId);
         $doc->store();
         return true;
     } catch (Exception $e) {
         echo "import of person(s) for document " . $oldId . " was not successful: " . $e->getMessage() . "\n";
     }
     return false;
 }
コード例 #4
0
 * Foundation; either version 2 of the Licence, or any later version.
 * OPUS is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * 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      Pascal-Nicolas Becker <*****@*****.**>
 * @copyright   Copyright (c) 2008-2010, OPUS 4 development team
 * @license     http://www.gnu.org/licenses/gpl.html General Public License
 * @version     $Id$
 */
$doc = new Opus_Document();
$doc->setType('all');
$doc->setServerState('published');
$doc->setServerDatePublished('1900-01-01');
// damn API. $doc->addPersonSubmiter() doesn't work for link models!
// -> we should change this in 4.x
$submitter = new Opus_Person();
$submitter->setFirstName('Donald')->setLastName('Duck')->setEmail('*****@*****.**')->setDateOfBirth('1920-03-13')->setPlaceOfBirth('Entenhausen');
$doc->addPersonSubmitter($submitter);
$author = new Opus_Person();
$author->setFirstName('Daniel')->setLastName('Düsentrieb')->setAcademicTitle('Dr.-Ing.');
$doc->addPersonAuthor($author);
$doc->setLanguage('deu');
$titleMain = $doc->addTitleMain();
$titleMain->setValue('Dokument zur empirischen Unterschung der OAI-Schnittstelle');
$titleMain->setLanguage('deu');
$titleMainEng = $doc->addTitleMain();
コード例 #5
0
 * 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      Thoralf Klein <*****@*****.**>
 * @copyright   Copyright (c) 2008-2011, OPUS 4 development team
 * @license     http://www.gnu.org/licenses/gpl.html General Public License
 * @version     $Id$
 */
/**
 * script to create 10000 documents, e.g., for performance testing
 */
for ($i = 1; $i < 10000; $i++) {
    $d = new Opus_Document();
    $d->setServerState('published');
    $d->setType('preprint');
    $d->setLanguage('deu');
    $title = $d->addTitleMain();
    $title->setLanguage('deu');
    $title->setValue('title-' . rand());
    $date = new Opus_Date();
    $date->setNow();
    $date->setYear(1990 + $i % 23);
    $d->setPublishedDate($date);
    $p = new Opus_Person();
    $p->setFirstName("foo-" . $i % 7);
    $p->setLastName("bar-" . $i % 5);
    $p = $d->addPersonAuthor($p);
    $c = new Opus_Collection(15990 + $i % 103);
    $d->addCollection($c);
    $s = $d->addSubject()->setType('ddc');
コード例 #6
0
 private function setDocumentType($documenttype)
 {
     $doc = new Opus_Document($this->documentId);
     $doc->setType($documenttype);
     $doc->store();
 }
コード例 #7
0
ファイル: General.php プロジェクト: alexukua/opus4
 /**
  * Aktualisiert ein Dokument mit den Werten im Formular.
  * @param Opus_Document $document
  */
 public function updateModel($document)
 {
     // Language
     $value = $this->getElementValue(self::ELEMENT_LANGUAGE);
     $document->setLanguage($value);
     // Type
     $value = $this->getElementValue(self::ELEMENT_TYPE);
     $document->setType($value);
     $datesHelper = $this->getDatesHelper();
     // CompletedDate
     $value = $this->getElementValue(self::ELEMENT_COMPLETED_DATE);
     $date = $datesHelper->getOpusDate($value);
     $document->setCompletedDate($date);
     // CompletedYear
     $value = $this->getElementValue(self::ELEMENT_COMPLETED_YEAR);
     $document->setCompletedYear($value);
     // PublishedDate
     $value = $this->getElementValue(self::ELEMENT_PUBLISHED_DATE);
     $date = $datesHelper->getOpusDate($value);
     $document->setPublishedDate($date);
     // PublishedYear
     $value = $this->getElementValue(self::ELEMENT_PUBLISHED_YEAR);
     $document->setPublishedYear($value);
     $value = $this->getElementValue(self::ELEMENT_EMBARGO_DATE);
     $date = $datesHelper->getOpusDate($value);
     $document->setEmbargoDate($date);
 }
コード例 #8
0
 /**
  * @expectedException CitationExport_Model_Exception
  * @expectedExceptionMessage invalid_format
  */
 public function testGetTemplateForDocumentInvalidFormat()
 {
     $document = new Opus_Document($this->_documentId);
     $document->setType('masterthesis');
     $document->store();
     $this->assertEquals('bibtex_masterthesis.xslt', $this->_helper->getTemplateForDocument($document, 'plain'));
 }
コード例 #9
0
    echo "script must be executed directy (not via opus-console)\n";
    exit;
}
require_once dirname(__FILE__) . '/../common/bootstrap.php';
$options = getopt('', array('dryrun', 'from:', 'to:'));
$dryrun = isset($options['dryrun']);
if (!isset($options['from']) || empty($options['from']) || !isset($options['to']) || empty($options['to'])) {
    echo "Usage: {$argv[0]} --from <current doc type> --to <target doc type> (--dryrun)\n";
    echo "--from and --to must be provided.\n";
    exit;
}
$from = $options['from'];
$to = $options['to'];
if ($dryrun) {
    _log("TEST RUN: NO DATA WILL BE MODIFIED");
}
$docFinder = new Opus_DocumentFinder();
$docIds = $docFinder->setType($from)->ids();
_log(count($docIds) . " documents found");
foreach ($docIds as $docId) {
    $doc = new Opus_Document($docId);
    $doc->setType($to);
    if (!$dryrun) {
        $doc->store();
    }
    _log("Document #{$docId} changed from '{$from}' to '{$to}'");
}
function _log($message)
{
    echo "{$message}\n";
}