Skip to content

Commit

Permalink
[API] Project Dicoms endpoint works with ObjectProvisioner
Browse files Browse the repository at this point in the history
  • Loading branch information
spell00 committed Nov 4, 2020
1 parent 32d997f commit 601a5e6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 134 deletions.
14 changes: 10 additions & 4 deletions modules/api/php/endpoints/project/dicoms.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,17 @@ class Dicoms extends Endpoint implements \LORIS\Middleware\ETagCalculator
$provisioner = new \LORIS\api\Provisioners\ProjectDicomsObjectProvisioner(
$this->_project,
$since,
'\LORIS\api\Models\ProjectDicomsRow'
'\LORIS\api\Models\ProjectDicomsObject'
);
$dicoms = (new \LORIS\Data\Table())
->withDataFrom($provisioner)
->toArray($request->getAttribute('user'));
$dicoms = [];
$all = $provisioner->getAllInstances();
foreach ($all as $value) {
array_push($dicoms, $value);
}

//$dicoms = (new \LORIS\Data\Table())
// ->withDataFrom($provisioner)
// ->toArray($request->getAttribute('user'));

$this->_cache = new \LORIS\Http\Response\JsonResponse(
['Dicoms' => $dicoms]
Expand Down
34 changes: 34 additions & 0 deletions modules/api/php/models/projectdicomsobject.class.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php declare(strict_types=1);
/**
* PHP Version 7
*
* @category API
* @package Loris
* @author Simon Pelletier <simon.pelletier@mcin.ca>
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
* @link https://www.github.com/aces/Loris/
*/

namespace LORIS\api\Models;

/**
* A ProjectDicomsObject contains values from an image of a project.
*
* @category API
* @package Loris
* @author Simon Pelletier <simon.pelletier@mcin.ca>
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
* @link https://www.github.com/aces/Loris/
*/
class ProjectDicomsObject implements \LORIS\Data\DataInstance
{
/**
* Implements \LORIS\Data\DataInstance interface for this object.
*
* @return array the object data.
*/
public function jsonSerialize() : array
{
return get_object_vars($this);
}
}
123 changes: 0 additions & 123 deletions modules/api/php/models/projectdicomsrow.class.inc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace LORIS\api\Provisioners;

use \LORIS\Data\Provisioners\DBObjectProvisioner;
use \LORIS\api\Models\ProjectDicomsRow;
use \LORIS\api\Models\ProjectDicomsObject;
/**
* This file implements a data provisioner to get all dicoms of a project
* created since a given date.
Expand All @@ -31,7 +31,7 @@ use \LORIS\api\Models\ProjectDicomsRow;
class ProjectDicomsObjectProvisioner extends DBObjectProvisioner
{
/**
* Create a RowProvisioner
* Create a ObjectProvisioner
*
* @param \Project $project The project from which dicoms are requested
* @param \DateTime $since The date from which dicoms are requested
Expand All @@ -58,7 +58,7 @@ class ProjectDicomsObjectProvisioner extends DBObjectProvisioner
t.TarchiveID as tarchiveid,
t.DicomArchiveID as DicomArchiveID,
t.ArchiveLocation as Archive,
t.SourceLocation as Source,
t.SourceLocation as Source
FROM
tarchive t
LEFT JOIN session s
Expand All @@ -70,12 +70,11 @@ class ProjectDicomsObjectProvisioner extends DBObjectProvisioner
LEFT JOIN Project project
ON (c.RegistrationProjectID = project.ProjectID)
WHERE
c.Active = "Y" AND
s.Active = "Y" AND
c.Active = \'Y\' AND
s.Active = \'Y\' AND
project.Name = :v_projectname AND
t.DateLastArchived > :v_time
ORDER BY t.DateLastArchived ASC
',
ORDER BY t.DateLastArchived ASC; ',
[
'v_projectname' => $project->getName(),
'v_time' => $since->getTimestamp(),
Expand Down

0 comments on commit 601a5e6

Please sign in to comment.