-
Notifications
You must be signed in to change notification settings - Fork 174
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
[data_release] refactoring to use data framework. #9051
Merged
driusan
merged 3 commits into
aces:main
from
racostas:2024-02-12-data_release-module-refactoring_dataFramework
Mar 12, 2024
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* This class implements a data provisioner to get all data released files | ||
* for the data_release menu page. | ||
* | ||
* PHP Version 7 | ||
* | ||
* @category Core | ||
* @package Main | ||
* @subpackage Core | ||
* @author Rolando Acosta <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
|
||
namespace LORIS\data_release; | ||
|
||
/** | ||
* This class implements a data provisioner to get all data released files | ||
* for the data_release menu page. | ||
* | ||
* PHP Version 7 | ||
* | ||
* @category Core | ||
* @package Main | ||
* @subpackage Core | ||
* @author Rolando Acosta <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
|
||
class DataReleaseProvisioner extends \LORIS\Data\Provisioners\DBRowProvisioner | ||
{ | ||
/** | ||
* Create a DataReleaseProvisioner, which gets releases for the | ||
* data release menu table. | ||
*/ | ||
function __construct() | ||
{ | ||
$user =& \User::singleton(); | ||
$query = " | ||
SELECT | ||
file_name AS fileName, | ||
IF(version is null or version ='','Unversioned', version) AS version, | ||
upload_date AS uploadDate, | ||
dr.id as dataReleaseID | ||
FROM data_release dr"; | ||
|
||
if (!$user->hasPermission("superuser")) { | ||
$query .= " | ||
INNER JOIN | ||
data_release_permissions drp | ||
ON | ||
(dr.id=drp.data_release_id) | ||
WHERE | ||
drp.UserID=".$user->getID(); | ||
} | ||
|
||
$query .= " ORDER BY uploadDate"; | ||
|
||
parent::__construct($query, []); | ||
} | ||
|
||
/** | ||
* Returns an instance of a DataReleaseRow object for a given | ||
* table row. | ||
* | ||
* @param array $row The database row from the LORIS Database class. | ||
* | ||
* @return \LORIS\Data\DataInstance An instance representing this row. | ||
*/ | ||
public function getInstance($row) : \LORIS\Data\DataInstance | ||
{ | ||
return new DataReleaseRow($row); | ||
} | ||
} |
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 declare(strict_types=1); | ||
/** | ||
* This class implements a data Instance which represents a single | ||
* entry in the data_release menu table. | ||
* | ||
* PHP Version 7 | ||
* | ||
* @category Core | ||
* @package Main | ||
* @subpackage Core | ||
* @author Rolando Acosta <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
|
||
namespace LORIS\data_release; | ||
|
||
/** | ||
* A DataReleaseRow represents a row in the data_release menu table. | ||
* | ||
* @category Core | ||
* @package Main | ||
* @subpackage Core | ||
* @author Rolando Acosta <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
class DataReleaseRow implements \LORIS\Data\DataInstance | ||
{ | ||
protected $DBRow; | ||
|
||
/** | ||
* Create a new DataReleaseRow | ||
* | ||
* @param array $row The row | ||
*/ | ||
public function __construct(array $row) | ||
{ | ||
$this->DBRow = $row; | ||
} | ||
|
||
/** | ||
* Implements \LORIS\Data\DataInstance interface for this row. | ||
* | ||
* @return array which can be serialized by json_encode() | ||
*/ | ||
public function jsonSerialize() : array | ||
{ | ||
return $this->DBRow; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be mistaken, but this documentation comment does not seem to coincide with the documentation of the base method, no ? It seems to me that returning
null
means the provisionner does not support theHasAnyPermissionOrUserSiteMatch
filter.Other than that LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @maximemulder, thank you for the review. Very appreciated.
This is what I found in the declaration of the method.
The data release docs are not site tied. That's way I'm returning null in the implementation. The page don't use site filtering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it will be more accurate to specify this in the documentation of the implementation itself: That this page don't use site filtering ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be more accurate, or you could use the
{@inheritDoc}
annotationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the wait, but yes, just like Dave said, specifying either that or inheriting the parent documentation should do the job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, somehow this escaped to my attention. Should be fixed now. Thank you.