Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAI Refactoring #1094

Merged
merged 59 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
068bdd0
Separation of the formats regarding the format xslt files and made th…
haogatyp Aug 17, 2023
112b330
#766 Refactor configuration, added options (currently only xslt file…
haogatyp Aug 20, 2023
d7e2477
#766 Including the prefix xslt in the base xslt instead of the other …
haogatyp Aug 23, 2023
83a0a4e
#766 ServerFactory directly reads oai options from configuration and …
haogatyp Aug 25, 2023
84e700e
#766 Fix absolut path for xsltFile
haogatyp Aug 25, 2023
d0fcdcd
#766 Fix some coding style.
haogatyp Aug 25, 2023
5fa63f7
Fix coding style.
haogatyp Aug 28, 2023
32f8269
Adjust visibility of some option getter methods.
haogatyp Aug 29, 2023
b78a459
#766 Add basic option getter tests for the BaseServer.
haogatyp Aug 29, 2023
e92fc9b
#766 Removed usage of getcwd().
haogatyp Aug 29, 2023
ce5004d
#766 Fix method access level
haogatyp Aug 29, 2023
4039c6e
#766 Split ServerFactory test methods.
haogatyp Aug 29, 2023
b167ac2
#766 Merge default and format specific options.
haogatyp Aug 31, 2023
aa07706
#766 Remove unnecessary check on "true".
haogatyp Aug 31, 2023
b9585c9
#766 Removed throwing the exception, as this is already happening at …
haogatyp Aug 31, 2023
97311cc
#766 Set the value for xsltFile so that it can be overwritten again u…
haogatyp Aug 31, 2023
2d24448
#1097 Made ViewHelper configurable.
haogatyp Aug 31, 2023
a711037
#766 Replaced options array with single properties.
haogatyp Sep 1, 2023
9a5da62
#1097 Default and format-specific ViewHelper options are combined add…
haogatyp Sep 1, 2023
098856f
#1097 Check if viewhelpers exist.
haogatyp Sep 1, 2023
88b9275
#766 Replace marker comment with a more technical marker.
haogatyp Sep 1, 2023
2388d8b
#766 Removed some double spaces.
haogatyp Sep 1, 2023
90b25f2
#766 Removed some double blank lines.
haogatyp Sep 1, 2023
a84057c
#766 Remove some hard coded format specific code and reduced oai form…
haogatyp Sep 5, 2023
23621bc
#1101 Generate OAI ListMetadataFormats from configuration.
haogatyp Sep 5, 2023
1b27ea9
#1101 Add xslt viewhelper for generating the OAI ListMetadataFormats.
haogatyp Sep 5, 2023
99c919e
#1101 Made string composition more readable.
haogatyp Sep 6, 2023
a24cf61
#1101 Reworked the behavior of the incremental option merging so that…
haogatyp Sep 6, 2023
f551e13
#1101 Fix option merging.
haogatyp Sep 7, 2023
4963cf7
#1101 Fix coding style.
haogatyp Sep 7, 2023
f8cd379
#1101 Added tests for ListMetadataFormats viewhelper.
haogatyp Sep 7, 2023
52593fc
#1101 Removed deprecated property.
haogatyp Sep 7, 2023
79cac6d
#1101 Fix some coding style.
haogatyp Sep 7, 2023
c4a8ba6
#766 Added comments to OAI config
j3nsch Sep 25, 2023
a8d230c
#766 Rename option "viewHelper"
haogatyp Oct 5, 2023
7967b50
#766 Fixed some typos.
haogatyp Oct 5, 2023
42c37f6
#766 Fix return empty string for integer variables. Renaming maxRecor…
haogatyp Oct 5, 2023
882c038
#766 Now also checking for array.
haogatyp Oct 5, 2023
8c5cec9
#766 Using DocumentInterface instead of Document.
haogatyp Oct 5, 2023
70b7504
#766 Added class comment.
haogatyp Oct 5, 2023
e979a6a
#766 Fix class comment.
haogatyp Oct 6, 2023
6f70e08
#766 Adjust option getters and setters for NULL values.
haogatyp Oct 6, 2023
b773cf1
#766 Using shorter parameter names in setter methods.
haogatyp Oct 6, 2023
111b442
#766 Fix some comments.
haogatyp Oct 6, 2023
c28ecb2
#766 Removed unnecessary ternary operator.
haogatyp Oct 6, 2023
403318e
#766 Removed outdated todo comment.
haogatyp Oct 6, 2023
f25c07a
#766 Renaming the marker for metadata format replacement.
haogatyp Oct 6, 2023
d83ab74
#766 Adjust error message.
haogatyp Oct 6, 2023
bc3f3ac
#766 Renamed OaiConfig to match the class name.
haogatyp Oct 6, 2023
e61c90c
#766 Fixed coding style
j3nsch Oct 9, 2023
f27d9da
#766 Empty line after header (coding style)
j3nsch Oct 9, 2023
719d66b
#766 Shorten class variable comments.
haogatyp Oct 10, 2023
bb48b41
#766 Added a comment to make things hopefully more clear.
haogatyp Oct 10, 2023
43072df
#766 Removed unused method.
haogatyp Oct 10, 2023
1ca259f
#766 Use class name only ones in the function.
haogatyp Oct 10, 2023
01de758
#766 Moved oai server test classes to oai test.
haogatyp Oct 10, 2023
ec8f82d
#766 Updated comment
j3nsch Oct 10, 2023
59b25c3
#766 Removed unnecessary mock test class and moved remaining mock tes…
haogatyp Oct 10, 2023
6527e7b
#766 Added a function to add view helpers to a oai server.
haogatyp Oct 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions modules/oai/models/DefaultServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,13 @@ class Oai_Model_DefaultServer extends Application_Model_Abstract
{
use Oai_Model_OptionsTrait;

/**
* Holds xml representation of document information to be processed.
*
* @var DOMDocument Defaults to null.
*/
/** @var DOMDocument Document data. */
protected $xml;

/**
* Holds the stylesheet for the transformation.
*
* @var DOMDocument Defaults to null.
*/
/** @var DOMDocument Transformation stylesheet. */
protected $xslt;

/**
* Holds the xslt processor.
*
* @var XSLTProcessor Defaults to null.
*/
/** @var XSLTProcessor */
protected $proc;

/** @var Oai_Model_XmlFactory */
Expand Down Expand Up @@ -125,7 +113,7 @@ class Oai_Model_DefaultServer extends Application_Model_Abstract
/** @var array */
haogatyp marked this conversation as resolved.
Show resolved Hide resolved
private $documentTypesAllowed;

/** @var array Holds information about which document state aka server_state are delivered out. */
/** @var array Document states aka server_states to be delivered out. */
private $documentStatesAllowed = ['published', 'deleted']; // maybe deleted documents too
haogatyp marked this conversation as resolved.
Show resolved Hide resolved

/** @var bool */
Expand Down
24 changes: 9 additions & 15 deletions modules/oai/models/ServerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,25 @@ public function create($metaDataPrefix = null)
$serverClass = $options['class'];
} elseif (isset($defaults['class'])) {
$serverClass = $defaults['class'];
} else {
$serverClass = Oai_Model_DefaultServer::class;
}

if (empty($serverClass) || ! ClassLoaderHelper::classExists($serverClass)) {
$server = new Oai_Model_DefaultServer();
} else {
$server = new $serverClass();
$serverClass = Oai_Model_DefaultServer::class;
}

$server = new $serverClass();

$server->setOaiConfig($this->getOaiConfig());
$server->initDefaults();

if ($options) {
if (isset($options['viewHelpers'])) {
haogatyp marked this conversation as resolved.
Show resolved Hide resolved
/*
In order to prevent required view helpers (configured in the default configuration or directly
in a derived server class) from being unintentionally removed by configuring a specific format,
they will be always just appended to the existing ones.
*/

$previousViewHelpers = $server->getViewHelpers();
$viewHelpers = $options['viewHelpers'];

Expand Down Expand Up @@ -133,14 +137,4 @@ public function createByResumptionToken($resumptionToken)

return $this->create($token->getMetadataPrefix());
}

/**
* Gets all configured format prefixes
*
* @return string[]
*/
public function getFormats()
{
return $this->getOaiConfig()->getFormats();
}
}
1 change: 1 addition & 0 deletions tests/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, [
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'oai'. DIRECTORY_SEPARATOR . 'models',
haogatyp marked this conversation as resolved.
Show resolved Hide resolved
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'support', // Support-Klassen fuer Tests
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'library', // tests/library
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'library', // Server library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

class DefaultOaiServer extends Oai_Model_DefaultServer
class MockDefaultOaiServer extends Oai_Model_DefaultServer
haogatyp marked this conversation as resolved.
Show resolved Hide resolved
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

class XMetaDissPlusServer extends Oai_Model_Prefix_XMetaDissPlus_XMetaDissPlusServer
class MockXMetaDissPlusServer extends Oai_Model_Prefix_XMetaDissPlus_XMetaDissPlusServer
{
protected function initFormatDefaults()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/modules/oai/models/OaiConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function getTestConfiguration()
],
'format' => [
'default' => [
'class' => DefaultOaiServer::class,
'class' => MockDefaultOaiServer::class,
'viewHelpers' => 'optionValue, fileUrl, frontdoorUrl, transferUrl, dcmiType, dcType, openAireType',
'xsltFile' => 'oaiFile.xslt',
],
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testGetDefaults()
'resumptionTokenPath' => '/vagrant/tests/workspace/tmp/resumption',
'emailContact' => 'opus4ci@example.org',
'xsltFile' => 'oaiFile.xslt',
'class' => DefaultOaiServer::class,
'class' => MockDefaultOaiServer::class,
'viewHelpers' => 'optionValue, fileUrl, frontdoorUrl, transferUrl, dcmiType, dcType, openAireType',
];

Expand Down
16 changes: 8 additions & 8 deletions tests/modules/oai/models/ServerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function getTestConfiguration()
],
'format' => [
'default' => [
'class' => DefaultOaiServer::class,
'class' => MockDefaultOaiServer::class,
'viewHelpers' => 'optionValue, fileUrl, frontdoorUrl, transferUrl, dcmiType, dcType, openAireType',
'xsltFile' => 'oaiFile.xslt',
'hasFilesVisibleInOai' => 1,
Expand Down Expand Up @@ -102,7 +102,7 @@ public function testCreate()
$serverFactory = new Oai_Model_ServerFactory();
$serverFactory->setOaiConfig($this->getOaiConfig());
$server = $serverFactory->create();
$this->assertEquals(DefaultOaiServer::class, get_class($server));
$this->assertEquals(MockDefaultOaiServer::class, get_class($server));
}

public function testCreateWithMetadataPrefix()
Expand All @@ -118,7 +118,7 @@ public function testCreateWithUnknownMetadataPrefix()
$serverFactory = new Oai_Model_ServerFactory();
$serverFactory->setOaiConfig($this->getOaiConfig());
$server = $serverFactory->create('unknownPrefix');
$this->assertEquals(DefaultOaiServer::class, get_class($server));
$this->assertEquals(MockDefaultOaiServer::class, get_class($server));
}

public function testCreateWithNoFormatConfiguration()
Expand Down Expand Up @@ -194,15 +194,15 @@ public function testDefaultServerOptionsWithDefaultConfiguration()
'checkEmbargo' => false,
];

$this->assertEquals(DefaultOaiServer::class, get_class($server));
$this->assertEquals(MockDefaultOaiServer::class, get_class($server));
$this->assertEquals($expectedOptions, $server->getOptions(array_keys($expectedOptions)));
}

public function testFormatServerClassOverwritesDefaults()
{
$testConfiguration = $this->getTestConfiguration();
$testConfiguration['oai']['format']['xmetadissplus'] = [
'class' => XMetaDissPlusServer::class,
'class' => MockXMetaDissPlusServer::class,
];
$oaiConfig = $this->getOaiConfig($testConfiguration);
$serverFactory = new Oai_Model_ServerFactory();
Expand All @@ -227,15 +227,15 @@ public function testFormatServerClassOverwritesDefaults()
'metadataNamespaceUrl' => 'http://www.d-nb.de/standards/xmetadissplus/',
];

$this->assertEquals(XMetaDissPlusServer::class, get_class($server));
$this->assertEquals(MockXMetaDissPlusServer::class, get_class($server));
$this->assertEquals($expectedOptions, $server->getOptions(array_keys($expectedOptions)));
}

public function testFormatServerClassOptionsOverwrittenByFormatConfiguration()
{
$testConfiguration = $this->getTestConfiguration();
$testConfiguration['oai']['format']['xmetadissplus'] = [
'class' => XMetaDissPlusServer::class,
'class' => MockXMetaDissPlusServer::class,
'viewHelpers' => 'additionalViewHelper1, additionalViewHelper2',
'xsltFile' => 'configuredXMetaDissPlus.xslt',
'checkEmbargo' => 0,
Expand Down Expand Up @@ -263,7 +263,7 @@ public function testFormatServerClassOptionsOverwrittenByFormatConfiguration()
'metadataNamespaceUrl' => 'http://www.d-nb.de/standards/xmetadissplus/',
];

$this->assertEquals(XMetaDissPlusServer::class, get_class($server));
$this->assertEquals(MockXMetaDissPlusServer::class, get_class($server));
$this->assertEquals($expectedOptions, $server->getOptions(array_keys($expectedOptions)));
}

Expand Down
34 changes: 0 additions & 34 deletions tests/support/OaiDcServer.php

This file was deleted.

Loading