Skip to content

Commit

Permalink
Merge pull request #522 from NFDI4Chem/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NishaSharma14 authored Oct 20, 2022
2 parents 9275b14 + 6bb9925 commit b57269b
Show file tree
Hide file tree
Showing 132 changed files with 7,656 additions and 9,221 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name : Deploy to GKE
name : Deploy to Dev

on:
push:
Expand All @@ -16,7 +16,7 @@ env:

jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
name: Deploy to Dev
if: github.ref == 'refs/heads/development'
runs-on: ubuntu-latest
#needs: build
Expand Down
6 changes: 6 additions & 0 deletions app/Actions/Jetstream/DeleteTeam.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Actions\Jetstream;

use Illuminate\Validation\ValidationException;
use Laravel\Jetstream\Contracts\DeletesTeams;

class DeleteTeam implements DeletesTeams
Expand All @@ -14,6 +15,11 @@ class DeleteTeam implements DeletesTeams
*/
public function delete($team)
{
if ($team->projects()->count() > 0) {
throw ValidationException::withMessages([
'hasProject' => __('This team cannot be deletd as it has project associated with it. Please do not forget to wait for the cool off period of 30 days for your project to be deleted permanently.'),
]);
}
$team->purge();

return redirect()->route('dashboard')->with('success', 'Team deleted successfully');
Expand Down
105 changes: 105 additions & 0 deletions app/Actions/Project/AssignIdentifier.php
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);
}
}
5 changes: 5 additions & 0 deletions app/Actions/Project/CreateNewProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Project;
use App\Models\User;
use App\Models\Validation;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -57,6 +58,10 @@ public function create(array $input)
$user, ['role' => 'creator']
);
}
$validaton = new Validation();
$validaton->save();
$project->associate($validation);
$project->save();
});
});
}
Expand Down
6 changes: 6 additions & 0 deletions app/Actions/Project/DeleteProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ public function delete($project)
if ($project->is_public) {
$project->studies()->update(['is_archived' => true]);
foreach ($project->studies as $study) {
$study->update(['is_archived' => true]);
$study->datasets()->update(['is_archived' => true]);
}
$project->is_archived = true;
$project->save();
} else {
$project->studies()->update(['is_deleted' => true]);
foreach ($project->studies as $study) {
$study->update(['is_deleted' => true]);
$study->datasets()->update(['is_deleted' => true]);
}
$draft = $project->draft;
if ($draft) {
$draft->update(['is_deleted' => true]);
}
$project->is_deleted = true;
$project->save();
}
Expand Down
30 changes: 30 additions & 0 deletions app/Actions/Project/PublishProject.php
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();
}
}
}
}
31 changes: 31 additions & 0 deletions app/Actions/Project/UnPublishProject.php
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();
}
}
}
}
39 changes: 23 additions & 16 deletions app/Actions/Project/UpdateProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Actions\Project;

use App\Models\Project;
use Carbon\Carbon;
use App\Models\Validation;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
Expand Down Expand Up @@ -47,10 +47,6 @@ public function update(Project $project, array $input)
$licenseExists = array_key_exists('license_id', $input);
$license_id = $licenseExists ? $input['license_id'] : $project->license_id;

if ($is_public == true) {
$release_date = Carbon::now()->toDateTimeString();
}

$project
->forceFill([
'name' => $input['name'],
Expand All @@ -76,8 +72,6 @@ public function update(Project $project, array $input)
: 'viewer',
'team_id' => $input['team_id'],
'owner_id' => $input['owner_id'],
'is_public' => $is_public,
'release_date' => $release_date,
'license_id' => $license_id,
'project_photo_path' => $s3filePath ? $s3filePath : $project->project_photo_path,
])
Expand All @@ -94,10 +88,7 @@ public function update(Project $project, array $input)
$study->license_id = $license_id;
}
}
if ($is_public) {
$study->is_public = $is_public;
$study->release_date = $release_date;
}

$study->save();

$datasets = $study->datasets;
Expand All @@ -107,13 +98,29 @@ public function update(Project $project, array $input)
$dataset->license_id = $license_id;
}
}
if ($is_public) {
$dataset->is_public = $is_public;
$dataset->release_date = $release_date;
}

$dataset->save();
}
}

$validation = $project->validation;

if (! $validation) {
$validation = new Validation();
$validation->save();
$project->validation()->associate($validation);
$project->save();

foreach ($project->studies as $study) {
$study->validation()->associate($validation);
$study->save();
foreach ($study->datasets as $dataset) {
$dataset->validation()->associate($validation);
$dataset->save();
}
}
}
$validation->process();
});
}

Expand All @@ -126,7 +133,7 @@ public function updateAuthors(Project $project, $authors)

public function updateCitation(Project $project, $citations, $user)
{
$project->citations()->syncWithPivotValues(
$project->citations()->sync(
$citations, ['user' => $user->id]
);
}
Expand Down
40 changes: 40 additions & 0 deletions app/Actions/Study/UpdateStudy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Actions\Study;

use App\Models\Study;
use App\Models\Ticker;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -54,6 +55,34 @@ public function update(Study $study, array $input)

if ($is_public == true) {
$release_date = Carbon::now()->timestamp;

$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;
Expand All @@ -64,6 +93,17 @@ public function update(Study $study, array $input)
}
}
if ($is_public) {
$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->is_public = $is_public;
$dataset->release_date = $release_date;
}
Expand Down
Loading

0 comments on commit b57269b

Please sign in to comment.