-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstract OAI sets, add virtual sets. refs #8238
Mark Triggs has contributed work to abstract OAI-PMH sets and allow virtual sets, such as a list of top-level descriptions, to be defined. Detailed in: #136 * Generalise the OAI set implementation Allow OAI sets to be defined by arbitrary criteria rather than requiring them to correspond to a single collection. * Change OAI terminology from "collection" to "OAI set" Reflect the fact that an OAI set may no longer correspond to a single collection. * Add a new "virtual" OAI set matching top-level records * Add new configuration option for additional OAI sets (disabled by default to preserve backward compatibility) * If the requested OAI set doesn't exist, return an error.
- Loading branch information
Showing
18 changed files
with
317 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Access to Memory (AtoM) software. | ||
* | ||
* Access to Memory (AtoM) is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Access to Memory (AtoM) 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 Access to Memory (AtoM). If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* An OAI set for a single collection | ||
* | ||
* @package AccesstoMemory | ||
* @subpackage oai | ||
* @author Mark Triggs <mark@teaspoon-consulting.com> | ||
*/ | ||
|
||
class QubitOaiCollectionSet implements QubitOaiSet | ||
{ | ||
private $collection; | ||
|
||
public function __construct($collection) { | ||
$this->collection = $collection; | ||
} | ||
|
||
public function contains($record) { | ||
$lft = $record->getLft(); | ||
return ($this->collection['lft'] <= $lft AND $this->collection['rgt'] > $lft); | ||
} | ||
|
||
public function setSpec() { | ||
return $this->collection->getOaiIdentifier(); | ||
} | ||
|
||
public function getName() { | ||
return new sfIsadPlugin($this->collection); | ||
} | ||
|
||
public function apply($criteria) { | ||
$criteria->add(QubitInformationObject::LFT, $this->collection['lft'], Criteria::GREATER_EQUAL); | ||
$criteria->add(QubitInformationObject::RGT, $this->collection['rgt'], Criteria::LESS_EQUAL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Access to Memory (AtoM) software. | ||
* | ||
* Access to Memory (AtoM) is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Access to Memory (AtoM) 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 Access to Memory (AtoM). If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* The interface provided by OAI set implementations | ||
* | ||
* @package AccesstoMemory | ||
* @subpackage oai | ||
* @author Mark Triggs <mark@teaspoon-consulting.com> | ||
*/ | ||
|
||
interface QubitOaiSet | ||
{ | ||
/** | ||
* Query OAI set membership by record | ||
* | ||
* @param mixed $record A record that can be part of an OAI set | ||
* | ||
* @return boolean true if $record is contained in this OAI set. | ||
*/ | ||
|
||
public function contains($record); | ||
|
||
/** | ||
* The OAI set specification for the current set | ||
* | ||
* @return string An OAI set specification | ||
*/ | ||
|
||
public function setSpec(); | ||
|
||
/** | ||
* The name of the current OAI set | ||
* | ||
* @return string A display name | ||
*/ | ||
|
||
public function getName(); | ||
|
||
/** | ||
* Apply the current set's restrictions to $criteria | ||
* | ||
* @param Criteria $criteria The search criteria to be modified | ||
* | ||
*/ | ||
|
||
public function apply($criteria); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Access to Memory (AtoM) software. | ||
* | ||
* Access to Memory (AtoM) is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Access to Memory (AtoM) 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 Access to Memory (AtoM). If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* An OAI set for all top-level (collection) records | ||
* | ||
* @package AccesstoMemory | ||
* @subpackage oai | ||
* @author Mark Triggs <mark@teaspoon-consulting.com> | ||
*/ | ||
|
||
class QubitOaiTopLevelSet implements QubitOaiSet | ||
{ | ||
public function contains($record) { | ||
/* Allow the collection set to take responsibility for records to preserve | ||
* the current behaviour. */ | ||
return false; | ||
} | ||
|
||
public function setSpec() { | ||
return "oai:virtual:top-level-records"; | ||
} | ||
|
||
public function getName() { | ||
return "Top-level collection record set"; | ||
} | ||
|
||
public function apply($criteria) { | ||
$criteria->addAlias('parent', QubitInformationObject::TABLE_NAME); | ||
$criteria->addJoin(QubitInformationObject::PARENT_ID, 'parent.id'); | ||
|
||
$criteria->add(QubitInformationObject::RGT, QubitInformationObject::RGT.' > ('.QubitInformationObject::LFT.' + 1)', Criteria::CUSTOM); | ||
$criteria->add('parent.lft', 1); | ||
} | ||
} |
Oops, something went wrong.