public function setUp()
 {
     parent::setUp();
     $document = $this->createTestDocument();
     $document->setServerState('published');
     $document->setType('baz');
     $title = new Opus_Title();
     $title->setValue('foobartitle');
     $document->setTitleMain($title);
     $this->documentId = $document->store();
     $this->assertNotNull($this->documentId);
     $document = $this->createTestDocument();
     $document->setServerState('published');
     $document->setType('baz');
     $title = new Opus_Title();
     $title->setValue('foobartitle');
     $document->setTitleMain($title);
     $author = new Opus_Person();
     $author->setFirstName('John');
     $author->setLastName('Doe');
     $author->setEmail('*****@*****.**');
     $this->authorId = $author->store();
     $this->assertNotNull($this->authorId);
     $link_person = $document->addPersonAuthor($author);
     $link_person->setAllowEmailContact('1');
     $this->authorDocumentId = $document->store();
     $this->assertNotNull($this->authorDocumentId);
 }
Пример #2
0
 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');
 }
Пример #3
0
 public function setUp()
 {
     parent::setUp();
     $document = $this->createTestDocument();
     $document->setServerState('published');
     $document->setType('testtype');
     $title = new Opus_Title();
     $title->setValue('testtitle');
     $document->setTitleMain($title);
     $author1 = new Opus_Person();
     $author1->setFirstName('John');
     $author1->setLastName('Doe');
     $author1->setEmail('*****@*****.**');
     $this->author1Id = $author1->store();
     $link_person1 = $document->addPersonAuthor($author1);
     $link_person1->setAllowEmailContact('1');
     $author2 = new Opus_Person();
     $author2->setFirstName('Jane');
     $author2->setLastName('Doe');
     $this->author2Id = $author2->store();
     $link_person2 = $document->addPersonAuthor($author2);
     $link_person2->setAllowEmailContact('0');
     $author3 = new Opus_Person();
     $author3->setFirstName('Jimmy');
     $author3->setLastName('Doe');
     $this->author3Id = $author3->store();
     $link_person3 = $document->addPersonAuthor($author3);
     $link_person3->setAllowEmailContact('1');
     $author4 = new Opus_Person();
     $author4->setFirstName('Foo');
     $author4->setLastName('Bar');
     $author4->setEmail('*****@*****.**');
     $this->author4Id = $author4->store();
     $link_person4 = $document->addPersonAuthor($author4);
     $link_person4->setAllowEmailContact('1');
     $this->documentId = $document->store();
     $this->assertNotNull($this->documentId);
     $this->assertNotNull($this->author1Id);
     $this->assertNotEquals('', $this->author1Id);
     $this->assertNotNull($this->author2Id);
     $this->assertNotEquals('', $this->author2Id);
     $this->assertNotNull($this->author3Id);
     $this->assertNotEquals('', $this->author3Id);
     $this->assertNotNull($this->author4Id);
     $this->assertNotEquals('', $this->author4Id);
     $document = $this->createTestDocument();
     $document->setServerState('unpublished');
     $this->unpublishedDocumentId = $document->store();
     $this->assertNotNull($this->unpublishedDocumentId);
 }
Пример #4
0
 /**
  * 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;
 }
 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;
 }
 /**
  * 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);
 }
Пример #7
0
 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"]);
 }
 /**
  * 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);
 }
$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();
$noteTwo->setVisibility('private')->setMessage('und noch eine Bemerkung zum Bearbeitungsstand.');
$licences = Opus_Licence::getAll();
Пример #10
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;
 /**
  * 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']);
 }
Пример #16
0
 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);
 }
$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
//
$institutesRole = new Opus_CollectionRole();
$institutesRole->setName('institutes' . randString($counter++) . rand())->setOaiName('institutes' . randString($counter++) . rand())->setPosition(1)->setVisible(1)->setVisibleBrowsingStart(1)->setDisplayBrowsing('Name')->setVisibleFrontdoor(1)->setDisplayFrontdoor('Name')->setVisibleOai('Name')->setDisplayOai('Name')->store();
Пример #18
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);
             }
         }
     }
 }