-
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 #522 from NFDI4Chem/development
Development
- Loading branch information
Showing
132 changed files
with
7,656 additions
and
9,221 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
namespace App\Actions\Project; | ||
|
||
use App\Models\Project; | ||
use App\Models\Ticker; | ||
use App\Services\DOI\DOIService; | ||
|
||
class AssignIdentifier | ||
{ | ||
private $doiService; | ||
|
||
/** | ||
* Create a new class instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(DOIService $doiService) | ||
{ | ||
$this->doiService = $doiService; | ||
} | ||
|
||
/** | ||
* Archive the given project. | ||
* | ||
* @param mixed $project | ||
* @return void | ||
*/ | ||
public function assign($project) | ||
{ | ||
$projectIdentifier = $project->identifier ? $project->identifier : null; | ||
|
||
if ($projectIdentifier == null) { | ||
$projectTicker = Ticker::whereType('project')->first(); | ||
$projectIdentifier = $projectTicker->index + 1; | ||
$projectTicker->index = $projectIdentifier; | ||
$projectTicker->save(); | ||
|
||
$project->identifier = $projectIdentifier; | ||
$project->save(); | ||
} | ||
|
||
$studies = $project->studies; | ||
foreach ($studies as $study) { | ||
$studyIdentifier = $study->identifier ? $study->identifier : null; | ||
|
||
if ($studyIdentifier == null) { | ||
$studyTicker = Ticker::whereType('study')->first(); | ||
$studyIdentifier = $studyTicker->index + 1; | ||
$study->identifier = $studyIdentifier; | ||
$studyTicker->index = $studyIdentifier; | ||
$studyTicker->save(); | ||
} | ||
|
||
$sample = $study->sample; | ||
$sampleIdentifier = $sample->identifier ? $sample->identifier : null; | ||
|
||
if ($sampleIdentifier == null) { | ||
$sampleTicker = Ticker::whereType('sample')->first(); | ||
$sampleIdentifier = $sampleTicker->index + 1; | ||
$sample->identifier = $sampleIdentifier; | ||
$sample->save(); | ||
|
||
$sampleTicker->index = $sampleIdentifier; | ||
$sampleTicker->save(); | ||
} | ||
|
||
$molecules = $sample->molecules; | ||
|
||
foreach ($molecules as $molecule) { | ||
$moleculeIdentifier = $molecule->identifier ? $molecule->identifier : null; | ||
if ($moleculeIdentifier == null) { | ||
$moleculeTicker = Ticker::whereType('molecule')->first(); | ||
$moleculeIdentifier = $moleculeTicker->index + 1; | ||
$molecule->identifier = $moleculeIdentifier; | ||
$molecule->save(); | ||
|
||
$moleculeTicker->index = $moleculeIdentifier; | ||
$moleculeTicker->save(); | ||
} | ||
} | ||
|
||
$datasets = $study->datasets; | ||
foreach ($datasets as $dataset) { | ||
$dsIdentifier = $dataset->identifier ? $dataset->identifier : null; | ||
|
||
if ($dsIdentifier == null) { | ||
$dsTicker = Ticker::whereType('dataset')->first(); | ||
$dsIdentifier = $dsTicker->index + 1; | ||
$dataset->identifier = $dsIdentifier; | ||
|
||
$dsTicker->index = $dsIdentifier; | ||
$dsTicker->save(); | ||
} | ||
|
||
$dataset->save(); | ||
$dataset->generateDOI($this->doiService); | ||
} | ||
|
||
$study->save(); | ||
$study->generateDOI($this->doiService); | ||
} | ||
$project->fresh()->generateDOI($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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Actions\Project; | ||
|
||
use App\Models\Project; | ||
|
||
class PublishProject | ||
{ | ||
/** | ||
* Publish the given project. | ||
* | ||
* @param mixed $project | ||
* @return void | ||
*/ | ||
public function publish($project) | ||
{ | ||
$project->is_public = true; | ||
$project->save(); | ||
$studies = $project->studies; | ||
foreach ($studies as $study) { | ||
$study->is_public = true; | ||
$study->save(); | ||
$datasets = $study->datasets; | ||
foreach ($datasets as $dataset) { | ||
$dataset->is_public = true; | ||
$dataset->save(); | ||
} | ||
} | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace App\Actions\Project; | ||
|
||
use App\Models\Project; | ||
|
||
class UnPublishProject | ||
{ | ||
/** | ||
* Publish the given project. | ||
* | ||
* @param mixed $project | ||
* @return void | ||
*/ | ||
public function unPublish($project) | ||
{ | ||
$project->is_public = false; | ||
$project->release_date = null; | ||
$project->save(); | ||
$studies = $project->studies; | ||
foreach ($studies as $study) { | ||
$study->is_public = false; | ||
$study->save(); | ||
$datasets = $study->datasets; | ||
foreach ($datasets as $dataset) { | ||
$dataset->is_public = false; | ||
$dataset->save(); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.