/**
  * Regression test for OPUSVIER-1841.
  */
 public function testWarningDisplayingDateOfBirth()
 {
     $doc = $this->createTestDocument();
     $person = new Opus_Person();
     $person->setFirstName("Johnny");
     $person->setLastName("Test");
     $dateOfBirth = new Opus_Date(new Zend_Date('1.1.2010', 'dd/MM/yyyy'));
     $person->setDateOfBirth($dateOfBirth);
     $doc->addPersonAuthor($person);
     $doc->store();
     $docId = $doc->getId();
     $this->dispatch('/admin/document/index/id/' . $docId);
     $body = $this->getResponse()->getBody();
     $this->assertTrue(substr_count($body, 'exception \'PHPUnit_Framework_Error_Warning\' with message \'htmlspecialchars() expects parameter 1 to be string, array given\' in /home/jens/opus4dev/opus4/server/modules/admin/views/scripts/document/index.phtml:145') == 0);
     $this->assertTrue(substr_count($body, 'Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/jens/opus4dev/opus4/server/modules/admin/views/scripts/document/index.phtml on line 145') == 0);
 }
 public function setUp()
 {
     parent::setUp();
     $document = $this->createTestDocument();
     $document->setServerState('unpublished');
     $document->setPersonReferee(array());
     $document->setEnrichment(array());
     $this->documentId = $document->store();
     $document = new Opus_Document($this->documentId);
     $this->assertEquals(0, count($document->getPersonReferee()));
     $this->assertEquals(0, count($document->getEnrichment()));
     $person = new Opus_Person();
     $person->setFirstName('John');
     $person->setLastName('Doe');
     $this->person = $person;
 }
 /**
  * Create Opus_Person object for currently logged user.  If no account
  * has been found, return NULL.
  *
  * @return Opus_Person
  */
 public function createPerson()
 {
     if (is_null($this->_account)) {
         return;
     }
     $person = new Opus_Person();
     $person->setFirstName(trim($this->_account->getFirstName()));
     $person->setLastName(trim($this->_account->getLastName()));
     $person->setEmail(trim($this->_account->getEmail()));
     if (!$person->isValid()) {
         $this->_log->err("Created Opus_Person object for user '" . $this->_login . "' is NOT VALID. ");
     }
     return $person;
 }
$editor = new Opus_Person();
$editor->setFirstName('Bob');
$editor->setLastName('Foster');
$editor->store();
$doc->addPersonEditor($editor);
$advisor = new Opus_Person();
$advisor->setFirstName('Fred');
$advisor->setLastName('Clever');
$advisor->store();
$doc->addPersonAdvisor($advisor);
$translator = new Opus_Person();
$translator->setFirstName('Erika');
$translator->setLastName('Fuchs');
$translator->store();
$doc->addPersonTranslator($translator);
$contributor = new Opus_Person();
$contributor->setFirstName('Jeff');
$contributor->setLastName('Smart');
$contributor->store();
$doc->addPersonContributor($contributor);
$doc->setCreatingCorporation('Walt Disney Creation Laboratories');
$doc->setContributingCorporation('Pixar Animation Studio');
$swd = $doc->addSubject()->setType('swd');
$swd->setValue('Test');
$freeSubjectDeu = $doc->addSubject()->setType('uncontrolled');
$freeSubjectDeu->setLanguage('deu')->setValue('Maustest');
$freeSubjectEng = $doc->addSubject()->setType('uncontrolled');
$freeSubjectEng->setLanguage('eng')->setValue('mouse test');
$note = $doc->addNote();
$note->setVisibility('public')->setMessage('ein Dokument, dass noch eine Bemerkung braucht, weil im Abstract nicht alles gesagt wurde...');
$noteTwo = $doc->addNote();
Exemple #5
0
 /**
  * Setzt die Felder einer Opus_Person Instanz entsprechend dem Formularinhalt.
  * @param Opus_Person $model
  */
 public function updateModel($model)
 {
     if ($model instanceof Opus_Person) {
         $model->setAcademicTitle($this->getElementValue(self::ELEMENT_ACADEMIC_TITLE));
         $model->setLastName($this->getElementValue(self::ELEMENT_LAST_NAME));
         $model->setFirstName($this->getElementValue(self::ELEMENT_FIRST_NAME));
         $model->setEmail($this->getElementValue(self::ELEMENT_EMAIL));
         $model->setPlaceOfBirth($this->getElementValue(self::ELEMENT_PLACE_OF_BIRTH));
         $model->setIdentifierGnd($this->getElementValue(self::ELEMENT_IDENTIFIER_GND));
         $model->setIdentifierOrcid($this->getElementValue(self::ELEMENT_IDENTIFIER_ORCID));
         $model->setIdentifierMisc($this->getElementValue(self::ELEMENT_IDENTIFIER_MISC));
         $datesHelper = $this->getDatesHelper();
         $model->setDateOfBirth($datesHelper->getOpusDate($this->getElementValue(self::ELEMENT_DATE_OF_BIRTH)));
     } else {
         $this->getLog()->err(__METHOD__ . ' called with object that is not instance of Opus_Person');
     }
 }
 * @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');
    $s->setValue($i % 97);
    $docId = $d->store();
    echo "docId: {$docId}\n";
}
exit;
Exemple #7
0
 /**
  *
  * @param DOMNode $node
  * @param Opus_Document $doc
  */
 private function handlePersons($node, $doc)
 {
     foreach ($node->childNodes as $childNode) {
         if ($childNode instanceof DOMElement) {
             $p = new Opus_Person();
             // mandatory fields
             $p->setFirstName(trim($childNode->getAttribute('firstName')));
             $p->setLastName(trim($childNode->getAttribute('lastName')));
             // optional fields
             $optionalFields = array('academicTitle', 'email', 'placeOfBirth', 'dateOfBirth');
             foreach ($optionalFields as $optionalField) {
                 if ($childNode->hasAttribute($optionalField)) {
                     $method = 'set' . ucfirst($optionalField);
                     $p->{$method}(trim($childNode->getAttribute($optionalField)));
                 }
             }
             $method = 'addPerson' . ucfirst($childNode->getAttribute('role'));
             $link = $doc->{$method}($p);
             if ($childNode->hasAttribute('allowEmailContact') && ($childNode->getAttribute('allowEmailContact') === 'true' || $childNode->getAttribute('allowEmailContact') === '1')) {
                 $link->setAllowEmailContact(true);
             }
         }
     }
 }
 private function addPerson($doc, $type, $firstname, $lastname, $oldId)
 {
     $p = new Opus_Person();
     if (trim($firstname) == '') {
         echo "Datensatz {$oldId} ohne Wert für {$type}.firstname\n";
     } else {
         $p->setFirstName(trim($firstname));
     }
     $p->setLastName(trim($lastname));
     $method = 'addPerson' . ucfirst(trim($type));
     $doc->{$method}($p);
 }
 /**
  * test for OPUSVIER-2484 and regression test for OPUSVIER-2539
  */
 public function testCatchAllSearchConsidersAllPersons()
 {
     $this->requireSolrConfig();
     // create a test doc with all available person types
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $doc->setLanguage('eng');
     $title = new Opus_Title();
     $title->setValue('test document for OPUSVIER-2484');
     $title->setLanguage('eng');
     $doc->setTitleMain($title);
     $person = new Opus_Person();
     $person->setLastName('personauthor-opusvier-2484');
     $doc->addPersonAuthor($person);
     $person = new Opus_Person();
     $person->setLastName('personadvisor-opusvier-2484');
     $doc->addPersonAdvisor($person);
     $person = new Opus_Person();
     $person->setLastName('personcontributor-opusvier-2484');
     $doc->addPersonContributor($person);
     $person = new Opus_Person();
     $person->setLastName('personeditor-opusvier-2484');
     $doc->addPersonEditor($person);
     $person = new Opus_Person();
     $person->setLastName('personreferee-opusvier-2484');
     $doc->addPersonReferee($person);
     $person = new Opus_Person();
     $person->setLastName('personother-opusvier-2484');
     $doc->addPersonOther($person);
     $person = new Opus_Person();
     $person->setLastName('persontranslator-opusvier-2484');
     $doc->addPersonTranslator($person);
     // nach Submitter kann nicht gesucht werden
     $person = new Opus_Person();
     $person->setLastName('personsubmitter-opusvier-2484');
     $doc->addPersonSubmitter($person);
     $doc->store();
     // search for document based on persons
     $persons = array('personauthor-opusvier-2484', 'personadvisor-opusvier-2484', 'personcontributor-opusvier-2484', 'personeditor-opusvier-2484', 'personreferee-opusvier-2484', 'personother-opusvier-2484', 'persontranslator-opusvier-2484');
     foreach ($persons as $person) {
         $this->dispatch('/solrsearch/index/search/searchtype/simple/query/' . $person);
         $this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
         $this->assertContains('test document for OPUSVIER-2484', $this->getResponse()->getBody());
         $this->assertContains($person, $this->getResponse()->getBody());
         $this->getResponse()->clearAllHeaders();
         $this->getResponse()->clearBody();
     }
     $this->dispatch('/solrsearch/index/search/searchtype/simple/query/personsubmitter-opusvier-2484');
     $this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
     // search should not return the test document
     $this->assertNotContains('test document for OPUSVIER-2484', $this->getResponse()->getBody());
 }
 public function testEditlinkedActionSave()
 {
     $document = $this->createTestDocument();
     $person = new Opus_Person();
     $person->setLastName('Testy-EditlinkedAction');
     $person = $document->addPersonTranslator($person);
     $this->documentId = $document->store();
     $personId = $person->getModel()->getId();
     $this->getRequest()->setMethod('POST')->setPost(array('PersonId' => $personId, 'LastName' => 'Testy', 'FirstName' => 'Simone', 'Document' => array('Role' => 'translator'), 'Save' => 'Speichern'));
     $this->dispatch('/admin/person/editlinked/personId/' . $personId . '/role/translator/document/' . $this->documentId);
     $this->assertRedirectTo('/admin/document/edit/id/' . $this->documentId . '/continue/updateperson/person/' . $personId);
     $person = new Opus_Person($personId);
     $this->assertEquals('Testy', $person->getLastName());
     $this->assertEquals('Simone', $person->getFirstName());
 }
 public function testAuthorNotificationForMultipleAuthors()
 {
     $this->enablePublishNotification();
     $doc = $this->createDocWithSubmitterAndAuthor('*****@*****.**', '*****@*****.**');
     $author = new Opus_Person();
     $author->setFirstName("AFN");
     $author->setLastName("ALN");
     $author->setEmail("*****@*****.**");
     $doc->addPersonAuthor($author);
     $author = new Opus_Person();
     $author->setFirstName("BFN");
     $author->setLastName("BLN");
     $doc->addPersonAuthor($author);
     $author = new Opus_Person();
     $author->setFirstName("CFN");
     $author->setLastName("CLN");
     $author->setEmail("*****@*****.**");
     $doc->addPersonAuthor($author);
     $doc->store();
     $this->dispatch('/admin/workflow/changestate/docId/' . $doc->getId() . '/targetState/published');
     $this->assertContains('*****@*****.**', $this->getResponse()->getBody());
     $this->assertContains('*****@*****.**', $this->getResponse()->getBody());
     $this->assertContains('*****@*****.**', $this->getResponse()->getBody());
     $this->assertContains('*****@*****.**', $this->getResponse()->getBody());
     $this->assertContains('<input type="checkbox" name="submitter" id="submitter" value="1" checked="checked"', $this->getResponse()->getBody());
     $this->assertContains('<input type="checkbox" name="author_1" id="author_1" value="1" checked="checked"', $this->getResponse()->getBody());
     $this->assertContains('<input type="checkbox" name="author_2" id="author_2" value="1" checked="checked"', $this->getResponse()->getBody());
     $this->assertContains('<input type="checkbox" name="author_3" id="author_3" value="1" disabled="1"', $this->getResponse()->getBody());
     $this->assertContains('<input type="checkbox" name="author_4" id="author_4" value="1" checked="checked"', $this->getResponse()->getBody());
 }
 public function testGetAuthors()
 {
     $doc = $this->createTestDocument();
     $person = new Opus_Person();
     $person->setLastName("Doe");
     $doc->addPersonAuthor($person);
     $person = new Opus_Person();
     $person->setLastName("Smith");
     $person->setFirstName("Jane");
     $doc->addPersonAuthor($person);
     $docAdapter = new Application_Util_DocumentAdapter(null, $doc);
     $authors = $docAdapter->getAuthors();
     $this->assertEquals('Doe', $authors[0]['name']);
     $this->assertEquals('Smith, Jane', $authors[1]['name']);
 }
 protected function tearDown()
 {
     $person = new Opus_Person($this->authorId);
     $person->delete();
     parent::tearDown();
 }
 /**
  * Regression test for OPUSVIER-2607
  */
 public function testXMetaDissPlusOmitPersonSurnameIfEmpty()
 {
     $document = $this->createTestDocument();
     $document->setServerState('published');
     $author = new Opus_Person();
     $author->setLastName('Foo');
     $author->setDateOfBirth('1900-01-01');
     $author->setPlaceOfBirth('Berlin');
     //      $authorId = $author->store();
     $document->addPersonAuthor($author);
     $advisor = new Opus_Person();
     $advisor->setLastName('Bar');
     $advisor->setDateOfBirth('1900-01-01');
     $advisor->setPlaceOfBirth('Berlin');
     //      $advisorId = $advisor->store();
     $document->addPersonAdvisor($advisor);
     $referee = new Opus_Person();
     $referee->setLastName('Baz');
     $referee->setDateOfBirth('1900-01-01');
     $referee->setPlaceOfBirth('Berlin');
     //      $refereeId = $referee->store();
     $document->addPersonReferee($referee);
     $this->docIds[] = $document->store();
     $this->dispatch('/oai?verb=GetRecord&metadataPrefix=xMetaDissPlus&identifier=oai::' . $document->getId());
     $author->delete();
     $advisor->delete();
     $referee->delete();
     $this->assertResponseCode(200);
     $response = $this->getResponse();
     $xpath = $this->prepareXpathFromResultString($response->getBody());
     $authorName = $xpath->query('//xMetaDiss:xMetaDiss/dc:creator/pc:person/pc:name');
     $this->assertEquals(1, $authorName->length);
     $authorFirstName = $xpath->query('//xMetaDiss:xMetaDiss/dc:creator/pc:person/pc:name/pc:foreName');
     $this->assertEquals(0, $authorFirstName->length);
     $authorLastName = $xpath->query('//xMetaDiss:xMetaDiss/dc:creator/pc:person/pc:name/pc:surName');
     $this->assertEquals(1, $authorLastName->length);
     $advisorName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="advisor"]/pc:person/pc:name');
     $this->assertEquals(1, $advisorName->length);
     $advisorFirstName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="advisor"]/pc:person/pc:name/pc:foreName');
     $this->assertEquals(0, $advisorFirstName->length);
     $advisorLastName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="advisor"]/pc:person/pc:name/pc:surName');
     $this->assertEquals(1, $advisorLastName->length);
     $refereeName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="referee"]/pc:person/pc:name');
     $this->assertEquals(1, $refereeName->length);
     $refereeFirstName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="referee"]/pc:person/pc:name/pc:foreName');
     $this->assertEquals(0, $refereeFirstName->length);
     $refereeLastName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="referee"]/pc:person/pc:name/pc:surName');
     $this->assertEquals(1, $refereeLastName->length);
 }
 public function testPopulateFromModel()
 {
     $this->useEnglish();
     $form = new Admin_Form_Person();
     $person = new Opus_Person();
     $person->setFirstName('John');
     $person->setLastName('Doe');
     $person->setAcademicTitle('PhD');
     $person->setPlaceOfBirth('Berlin');
     $datesHelper = $form->getDatesHelper();
     $person->setDateOfBirth($datesHelper->getOpusDate('1990/01/01'));
     $person->setEmail('*****@*****.**');
     $person->setIdentifierGnd('1234');
     $person->setIdentifierOrcid('3456');
     $person->setIdentifierMisc('5678');
     $person->store();
     $form->populateFromModel($person);
     $personId = $person->getId();
     $person->delete();
     $this->assertEquals($personId, $form->getElement('PersonId')->getValue());
     $this->assertEquals($person->getLastName(), $form->getElement('LastName')->getValue());
     $this->assertEquals($person->getFirstName(), $form->getElement('FirstName')->getValue());
     $this->assertEquals($person->getAcademicTitle(), $form->getElement('AcademicTitle')->getValue());
     $this->assertEquals($person->getEmail(), $form->getElement('Email')->getValue());
     $this->assertEquals($person->getPlaceOfBirth(), $form->getElement('PlaceOfBirth')->getValue());
     $this->assertEquals('1990/01/01', $form->getElement('DateOfBirth')->getValue());
     $this->assertEquals($form->getElement('IdentifierGnd')->getValue(), '1234');
     $this->assertEquals($form->getElement('IdentifierOrcid')->getValue(), '3456');
     $this->assertEquals($form->getElement('IdentifierMisc')->getValue(), '5678');
 }
 public function testGetRecipientsForPublicationContextWithoutSubmitter()
 {
     $doc = $this->createTestDocument();
     $doc->setLanguage("eng");
     $title = new Opus_Title();
     $title->setValue("Test Document");
     $title->setLanguage("eng");
     $doc->addTitleMain($title);
     $submitter = new Opus_Person();
     $submitter->setFirstName("John");
     $submitter->setLastName("Submitter");
     $submitter->setEmail("*****@*****.**");
     $doc->addPersonSubmitter($submitter);
     $doc->store();
     $method = $this->getMethod('getRecipients');
     $recipients = $method->invokeArgs($this->notification, array(Application_Util_Notification::PUBLICATION, array(array("name" => "foo", "address" => "foo@localhost")), $doc, false));
     $this->assertEquals(2, count($recipients));
     $this->assertEquals("published@localhost", $recipients[0]["name"]);
     $this->assertEquals("published@localhost", $recipients[0]["address"]);
     $this->assertEquals("foo", $recipients[1]["name"]);
     $this->assertEquals("foo@localhost", $recipients[1]["address"]);
 }
 public function tearDown()
 {
     $person = new Opus_Person($this->author1Id);
     $person->delete();
     $person = new Opus_Person($this->author2Id);
     $person->delete();
     $person = new Opus_Person($this->author3Id);
     $person->delete();
     $person = new Opus_Person($this->author4Id);
     $person->delete();
     parent::tearDown();
 }
$referee->setLastName('Gearloose' . randString($counter++));
$referee->setAcademicTitle('Prof. Dr.' . randString($counter++));
$doc->addPersonReferee($referee);
$editor = new Opus_Person();
$editor->setFirstName('Bob' . randString($counter++));
$editor->setLastName('Foster' . randString($counter++));
$doc->addPersonEditor($editor);
$advisor = new Opus_Person();
$advisor->setFirstName('Fred' . randString($counter++));
$advisor->setLastName('Clever' . randString($counter++));
$doc->addPersonAdvisor($advisor);
$translator = new Opus_Person();
$translator->setFirstName('Erika' . randString($counter++));
$translator->setLastName('Fuchs' . randString($counter++));
$doc->addPersonTranslator($translator);
$contributor = new Opus_Person();
$contributor->setFirstName('Jeff' . randString($counter++));
$contributor->setLastName('Smart' . randString($counter++));
$contributor->store();
$doc->addPersonContributor($contributor);
//
// Titles
//
foreach (array('addTitleMain', 'addTitleAbstract', 'addTitleParent', 'addTitleSub', 'addTitleAdditional') as $titleMethod) {
    $doc->{$titleMethod}()->setValue(randString($counter++))->setLanguage(randString($counter++));
    $doc->{$titleMethod}()->setValue(randString($counter++))->setLanguage('deu');
    $doc->{$titleMethod}()->setValue(randString($counter++))->setLanguage('eng');
}
//
// Collections
//
 * @copyright   Copyright (c) 2008-2012, OPUS 4 development team
 * @license     http://www.gnu.org/licenses/gpl.html General Public License
 * @version     $Id: split_firstname_academic_title.php 10652 2012-07-09 12:46:16Z sszott $
 */
/**
 * 
 * Durchsucht die Vornamen aller in der Datenbank abgespeicherten Personen.
 * Ist in einem Vornamen auch der akademische Titel angegebenen (in Klammern),
 * dann wird dieser entfernt und in dem dafür vorgesehenen OPUS4-Feld
 * abgespeichert.
 *
 * Dieses Problem tritt auf bei der Migration aus OPUS3, wo es noch kein
 * separates Feld für das Ablegen des akademischen Titels einer Person gab.
 * 
 */
foreach (Opus_Person::getAll() as $person) {
    $firstname = $person->getFirstName();
    $numOfOpeningParenthesis = substr_count($firstname, '(');
    $numOfClosingParenthesis = substr_count($firstname, ')');
    if ($numOfOpeningParenthesis != $numOfClosingParenthesis) {
        // conflict found
        echo '[WARN] Opus_Person #' . $person->getId() . " with conflict in firstname '{$firstname}' : mismatch between opening and closing parentheses -- skip person\n";
        continue;
    }
    if ($numOfOpeningParenthesis == 0) {
        // nothing to do
        echo '[INFO] Opus_Person #' . $person->getId() . " without parenthesis in firstname '{$firstname}' -- skip person\n";
        continue;
    }
    // check if firstname ends with '('
    if (preg_match('/^.*\\)\\s*$/', $firstname) == 0) {