Skip to content

Commit

Permalink
Merge pull request #985 from OPUS4/4.7.1.2
Browse files Browse the repository at this point in the history
OPUS 4.7.1.2 Release
  • Loading branch information
j3nsch authored Dec 13, 2022
2 parents e3453ac + 4067e57 commit a669469
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# OPUS 4 Change Log

## Release 4.7.1.2 - 2022-12-13

* OPUS4/application#983 - Export von Suchtreffern ab 100 liefert leere Datei
* OPUS4/application#978 - Ausgabe von GND-ID und ORCID iD in XMetaDissPlus

## Release 4.7.1.1 - 2022-07-12

* OPUS4/application#598 - Werte für Konfigurationsparameter "supportedLanguages" trimmen
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ redevelopment that was created as part of a DFG ([Deutsche Forschungsgemeinschaf
Since then the development has been continued at KOBV ([Kooperativer Bibliotheksverbund Berlin-Brandenburg][KOBV])
mostly.

## OPUS 4.7.1 (current version)
## OPUS 4.7.1.2 (current version)

The current version of OPUS 4 is __4.7.1__. It is available on the [master][MASTER] branch.
The current version of OPUS 4 is __4.7.1.2__. It is available on the [master][MASTER] branch.

[Documentation][DOC]
: Information on setting up a repository, for users and administrators.
Expand Down
10 changes: 10 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# OPUS 4 Release Notes

## Patch Release 4.7.1.2 - 2022-12-13

ORCID und GND-ID werden jetzt in XMetaDissPlus für die Rollen `Author`,
`Advisor`, `Referee` and `Editor` ausgegeben.

Ein Bug, der beim seitenweisen Export von Suchergebnissen unter Umständen
für eine leere Export-Datei gesorgt hat, wurde beseitigt.

--

## Patch Release 4.7.1.1 - 2022-07-12

Die Sprachen im Konfigurationsparameter `supportedLanguages` werden nun
Expand Down
2 changes: 1 addition & 1 deletion application/configs/application.ini
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ name = 'OPUS 4'
logoLink = home
security = 1
workspacePath = APPLICATION_PATH "/workspace"
version = 4.7.1.1
version = 4.7.1.2
update.latestVersionCheckUrl = "https://api.github.com/repos/opus4/application/releases/latest"

; base URL of your OPUS instance (used for generating absolute URLs, e.g. in email messages)
Expand Down
7 changes: 7 additions & 0 deletions modules/export/models/XmlExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ public function prepareXml()
/**
* Returns maximum number of rows for export depending on autentication.
*
* IMPORTANT: maxRows must not exceed 2147483647 (java,lang.Integer.MAX_VALUE)
*
* @return int
*/
public function getMaxRows()
Expand All @@ -323,6 +325,11 @@ public function getMaxRows()
}
}

// Do not allows configured values to exceed java.lang.Integer.MAX_VALUE (Solr)
if ($maxRows > Opus\Search\Util\Query::MAX_ROWS) {
$maxRows = Opus\Search\Util\Query::MAX_ROWS;
}

return $maxRows;
}

Expand Down
46 changes: 43 additions & 3 deletions modules/oai/views/scripts/index/prefixes/XMetaDissPlus.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
xmlns="http://www.d-nb.de/standards/subject/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:php="http://php.net/xsl"
xsi:schemaLocation="http://www.d-nb.de/standards/xmetadissplus/ http://files.dnb.de/standards/xmetadissplus/xmetadissplus.xsd"
xsi:schemaLocation="http://www.d-nb.de/standards/xmetadissplus/ https://d-nb.info/standards/schema/xmetadissplus.xsd"
exclude-result-prefixes="php">

<xsl:output method="xml" indent="yes" />
Expand All @@ -68,7 +68,7 @@
<xMetaDiss:xMetaDiss
xmlns:xMetaDiss="http://www.d-nb.de/standards/xmetadissplus/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.d-nb.de/standards/xmetadissplus/ http://files.dnb.de/standards/xmetadissplus/xmetadissplus.xsd">
xsi:schemaLocation="http://www.d-nb.de/standards/xmetadissplus/ https://d-nb.info/standards/schema/xmetadissplus.xsd">

<!-- dc:title -->
<xsl:apply-templates select="TitleMain" mode="xmetadissplus" />
Expand Down Expand Up @@ -287,7 +287,17 @@

<xsl:template match="PersonAuthor" mode="xmetadissplus">
<dc:creator xsi:type="pc:MetaPers">
<pc:person>
<pc:person>
<xsl:if test="normalize-space(@IdentifierGnd)">
<xsl:attribute name="ddb:GND-Nr">
<xsl:value-of select="@IdentifierGnd"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="normalize-space(@IdentifierOrcid)">
<ddb:ORCID>
<xsl:value-of select="@IdentifierOrcid"/>
</ddb:ORCID>
</xsl:if>
<xsl:choose>
<xsl:when test="normalize-space(@FirstName) != '' and normalize-space(@LastName) != ''">
<pc:name type="nameUsedByThePerson">
Expand Down Expand Up @@ -370,6 +380,16 @@
<xsl:template match="PersonAdvisor" mode="xmetadissplus">
<dc:contributor xsi:type="pc:Contributor" type="dcterms:ISO3166" thesis:role="advisor">
<pc:person>
<xsl:if test="normalize-space(@IdentifierGnd)">
<xsl:attribute name="ddb:GND-Nr">
<xsl:value-of select="@IdentifierGnd"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="normalize-space(@IdentifierOrcid)">
<ddb:ORCID>
<xsl:value-of select="@IdentifierOrcid"/>
</ddb:ORCID>
</xsl:if>
<xsl:choose>
<xsl:when test="normalize-space(@FirstName) != '' and normalize-space(@LastName) != ''">
<pc:name type="nameUsedByThePerson">
Expand Down Expand Up @@ -401,6 +421,16 @@
<xsl:template match="PersonReferee" mode="xmetadissplus">
<dc:contributor xsi:type="pc:Contributor" type="dcterms:ISO3166" thesis:role="referee">
<pc:person>
<xsl:if test="normalize-space(@IdentifierGnd)">
<xsl:attribute name="ddb:GND-Nr">
<xsl:value-of select="@IdentifierGnd"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="normalize-space(@IdentifierOrcid)">
<ddb:ORCID>
<xsl:value-of select="@IdentifierOrcid"/>
</ddb:ORCID>
</xsl:if>
<xsl:choose>
<xsl:when test="normalize-space(@FirstName) != '' and normalize-space(@LastName) != ''">
<pc:name type="nameUsedByThePerson">
Expand Down Expand Up @@ -432,6 +462,16 @@
<xsl:template match="PersonEditor" mode="xmetadissplus">
<dc:contributor xsi:type="pc:Contributor" type="dcterms:ISO3166" thesis:role="editor">
<pc:person>
<xsl:if test="normalize-space(@IdentifierGnd)">
<xsl:attribute name="ddb:GND-Nr">
<xsl:value-of select="@IdentifierGnd"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="normalize-space(@IdentifierOrcid)">
<ddb:ORCID>
<xsl:value-of select="@IdentifierOrcid"/>
</ddb:ORCID>
</xsl:if>
<xsl:choose>
<xsl:when test="normalize-space(@FirstName) != '' and normalize-space(@LastName) != ''">
<pc:name type="nameUsedByThePerson">
Expand Down
34 changes: 27 additions & 7 deletions modules/solrsearch/models/Search/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

use Opus\Search\Util\Query;

/**
* Abstract base class for search type implementations.
*
Expand Down Expand Up @@ -121,18 +123,36 @@ public function createQueryBuilderInputFromRequest($request)
$startParam = $request->getParam('start', 0);
$rowsParam = $request->getParam('rows', $maxNumber);
$start = intval($startParam);
$rows = intval($rowsParam);

$input['start'] = $start > 0 ? $start : 0;
if (is_string($rowsParam)) {
// for invalid values $maxNumber should be used
if (ctype_digit($rowsParam)) {
$rows = intval($rowsParam);
} else {
$rows = $maxNumber;
}
} else {
$rows = $rowsParam;
}

$input['rows'] = $rows > 0 || ($rows == 0 && $rowsParam == '0') ? $rows : $maxNumber;
// rows = 0 should be support to allow just getting the number of possible results (TODO Is it used?)
$rows = $rows > $maxNumber || $rows < 0 ? $maxNumber : $rows;

if ($input['start'] > $maxNumber) {
$input['start'] = $maxNumber;
// IMPORTANT: 'start' + 'row' must not exceed 2147483647 (java,lang.Integer.MAX_VALUE)
if ($start > Query::MAX_ROWS) {
$start = Query::MAX_ROWS;
$rows = 0;
// TODO throwing exception would be better because this query does not make sense
// need to change tests for changed behaviour
}
if ($input['rows'] + $input['start'] > $maxNumber) {
$input['rows'] = $maxNumber - $input['start'];
$start = $start > 0 ? $start : 0;

if ($start + $rows > Query::MAX_ROWS) {
$rows = Query::MAX_ROWS - $start;
}

$input['rows'] = $rows;
$input['start'] = $start;
}

foreach ($this->_searchFields as $searchField) {
Expand Down
21 changes: 21 additions & 0 deletions tests/modules/export/controllers/IndexControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
*/
class Export_IndexControllerTest extends ControllerTestCase
{
protected $configModifiable = true;

protected $additionalResources = 'all';

Expand Down Expand Up @@ -442,6 +443,24 @@ public function testPaginationIsSupportedInExportWithExtremeValues5()
$this->helperForOPUSVIER2488('/export/index/index/searchtype/simple/query/opusvier-2488/export/xml/start/2147483646/rows/1', 5, 0);
}

public function testPaginationStartValueLargerThanMaxRows()
{
$this->enableSecurity();
$this->addAccessOnModuleExportForGuest();

/** setting max rows to 5, so it is less than start = 10 */
$this->adjustConfiguration(['plugins' => ['export' => ['default' => ['maxDocumentsGuest' => 5]]]]);

$this->dispatch('/export/index/csv/searchtype/all/export/xml/start/10/rows/10');

$this->assertResponseCode(200);

$body = $this->getResponse()->getBody();

// first line is CSV header, therefore it should be 6 lines
$this->assertEquals(6, substr_count($body, PHP_EOL));
}

/**
* end: tests for OPUSVIER-2488
*/
Expand Down Expand Up @@ -998,6 +1017,7 @@ public function testNonAdminAccessOnUnrestrictedMarc21ExportAllowed()
*/
private function addAccessOnModuleExportForGuest()
{
$this->_removeExportFromGuest = true;
return $this->addModuleAccess('export', 'guest');
}

Expand All @@ -1007,6 +1027,7 @@ private function addAccessOnModuleExportForGuest()
*/
private function removeAccessOnModuleExportForGuest()
{
$this->_removeExportFromGuest = false;
return $this->removeModuleAccess('export', 'guest');
}

Expand Down
74 changes: 74 additions & 0 deletions tests/modules/oai/format/XMetaDissPlusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

use Opus\Person;
use Opus\Model\ModelException;

/**
* @covers Oai_IndexController
*/
Expand Down Expand Up @@ -76,4 +79,75 @@ public function testXmlXsiSchemaDeclarationPresentForXMetaDissPlusMetadata()
$this->fail('element \'xMetaDiss:xMetaDiss\' not found');
}
}

public function personDataProvider()
{
return [
['author', 'dc:creator'],
['advisor', 'dc:contributor'],
['referee', 'dc:contributor'],
['editor', 'dc:contributor'],
];
}

/**
* @param string $role
* @param string $elementName
* @throws \Opus\Model\ModelException
* @dataProvider personDataProvider
*/
public function testPersonOrcidPresentInXmetaDissPlus($role, $elementName)
{
$doc = $this->createTestDocument();
$doc->setServerState('published');

$person = new Person();
$person->setLastName('author1');
$person->setIdentifierOrcid('1111-2222-3333-4444');
$documentPerson = $doc->addPerson($person);
$documentPerson->setRole($role);
$docId = $doc->store();

$this->dispatch('/oai?verb=GetRecord&metadataPrefix=xMetaDissPlus&identifier=oai::' . $docId);

$this->assertResponseCode(200);

$this->registerXpathNamespaces($this->xpathNamespaces);

$this->assertXpath('//xMetaDiss:xMetaDiss');
$this->assertXpath("//xMetaDiss:xMetaDiss/$elementName/pc:person/ddb:ORCID");
$this->assertXpathContentContains(
"//xMetaDiss:xMetaDiss/$elementName/pc:person/ddb:ORCID",
'1111-2222-3333-4444'
);
}

/**
* @param string $role
* @param string $elementName
* @throws \Opus\Model\ModelException
* @dataProvider personDataProvider
*/
public function testAuthorGndPresentInXmetaDissPlus($role, $elementName)
{
$doc = $this->createTestDocument();
$doc->setServerState('published');

$person = new Person();
$person->setLastName('author1');
$person->setIdentifierGnd('GndAuthor1');
$documentPerson = $doc->addPerson($person);
$documentPerson->setRole($role);

$docId = $doc->store();

$this->dispatch('/oai?verb=GetRecord&metadataPrefix=xMetaDissPlus&identifier=oai::' . $docId);

$this->assertResponseCode(200);

$this->registerXpathNamespaces($this->xpathNamespaces);

$this->assertXpath('//xMetaDiss:xMetaDiss');
$this->assertXpath("//xMetaDiss:xMetaDiss/$elementName/pc:person[@ddb:GND-Nr=\"GndAuthor1\"]");
}
}

0 comments on commit a669469

Please sign in to comment.