-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1130 from NFDI4Chem/related_indentifiers
feat: add DataCite relatedIdentifier to link projects, studies, datasets.
- Loading branch information
Showing
4 changed files
with
126 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace App\Actions\Project; | ||
|
||
use App\Models\Dataset; | ||
use App\Models\Project; | ||
use App\Models\Study; | ||
use App\Services\DOI\DOIService; | ||
use Illuminate\Support\Collection; | ||
|
||
class UpdateDOI | ||
{ | ||
private $doiService; | ||
|
||
/** | ||
* Create a new class instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(DOIService $doiService) | ||
{ | ||
$this->doiService = $doiService; | ||
} | ||
|
||
/** | ||
* Update the given model DOI metadata. | ||
* | ||
* @param mixed $model | ||
* @return void | ||
*/ | ||
public function update($model) | ||
{ | ||
$project = null; | ||
$studies = null; | ||
if ($model instanceof Project) { | ||
$project = $model; | ||
} elseif ($model instanceof Collection) { | ||
$studies = $model; | ||
} | ||
|
||
if ($project) { | ||
$project->addRelatedIdentifiers($this->doiService); | ||
$studies = $project->studies; | ||
} | ||
if ($studies) { | ||
foreach ($studies as $study) { | ||
if ($study instanceof Study) { | ||
$study->addRelatedIdentifiers($this->doiService); | ||
$datasets = $study->datasets; | ||
foreach ($datasets as $dataset) { | ||
if ($dataset instanceof Dataset) { | ||
$dataset->addRelatedIdentifiers($this->doiService); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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