Skip to content

Commit

Permalink
Merge pull request #1123 from NFDI4Chem/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NishaSharma14 authored Apr 5, 2024
2 parents bde2fd3 + 4f9aa27 commit b4eb382
Show file tree
Hide file tree
Showing 21 changed files with 583 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,17 @@ public function prepareMoleculesSchemas($sample)
*/
public function getSample($study)
{
$prefix = '';
if (property_exists($study, 'project')) {
$prefix = $study->project->name.'.';
}
$sample = $study->sample;
$molecules = $this->prepareMoleculesSchemas($sample);

$sampleSchema = Schema::ChemicalSubstance();
$sampleSchema['@id'] = $study->doi;
$sampleSchema['dct:conformsTo'] = BioschemasHelper::conformsTo(['https://bioschemas.org/types/ChemicalSubstance/0.3-RELEASE-2019_09_02']);
$sampleSchema->name($study->project->name.'.'.$sample->name);
$sampleSchema->name($prefix.$sample->name);
$sampleSchema->description($sample->description);
$sampleSchema->url(env('APP_URL').'/'.explode(':', $study->identifier ? $study->identifier : ':')[1]);
$sampleSchema->hasBioChemEntityPart($this->prepareMoleculesSchemas($sample));
Expand Down Expand Up @@ -451,7 +455,11 @@ public function datasetLite($dataset)
{
$nmriumInfo = $this->prepareNMRiumInfo($dataset);
if ($nmriumInfo) {
$prefix = $dataset->study->project->name.':'.$dataset->study->name.'.';
$study = $dataset->study;
$prefix = $dataset->study->name.'.';
if (property_exists($study, 'project')) {
$prefix = $study->project->name.':'.$prefix;
}
$datasetSchema = Schema::Dataset();
$datasetSchema['@id'] = $dataset->doi;
$datasetSchema['dct:conformsTo'] = BioschemasHelper::conformsTo(['https://schema.org/Dataset', 'https://isa-specs.readthedocs.io/en/latest/isamodel.html#assay']);
Expand Down Expand Up @@ -504,7 +512,10 @@ public function dataset($dataset)
*/
public function studyLite($study)
{
$prefix = $study->project->name.':';
$prefix = '';
if (property_exists($study, 'project')) {
$prefix = $study->project->name.':';
}
$studySchema = Bioschemas::Study();
$studySchema['@id'] = $study->doi;
$studySchema['dct:conformsTo'] = BioschemasHelper::conformsTo(['https://bioschemas.org/types/Study/0.3-DRAFT', 'https://isa-specs.readthedocs.io/en/latest/isamodel.html#study']);
Expand Down Expand Up @@ -534,7 +545,9 @@ public function studyLite($study)
public function study($study)
{
$studySchema = $this->studyLite($study);
$studySchema->isPartOf($this->projectLite($study->project));
if (property_exists($study, 'project')) {
$studySchema->isPartOf($this->projectLite($study->project));
}
$studySchema->hasPart($this->prepareDatasets($study));

return $studySchema;
Expand Down
11 changes: 8 additions & 3 deletions app/Http/Controllers/API/Schemas/Bioschemas/BioschemasHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public static function prepareCitations($model)
$citationsSchemas = [];
foreach ($model->citations as &$citation) {
$citationSchema = Schema::CreativeWork();
$citationSchema->abstract($citation->abstract);
$citationSchema->author($citation->authors);
$citationSchema->headline($citation->title);
$citationSchema->identifier($citation->doi);
Expand All @@ -149,11 +148,17 @@ public static function prepareDataDownload($dataset)
{
$url = env('APP_URL');
$user = $dataset->owner->username;
$slug = $dataset->project->slug;
if (property_exists($dataset, 'project')) {
$slug = $dataset->project->slug;
$name = $dataset->project->name;
} else {
$slug = $dataset->study->slug;
$name = $dataset->study->name;
}
$contentURL = $url.'/'.$user.'/datasets/'.$slug;

$DataDownloadSchema = Schema::DataDownload();
$DataDownloadSchema->name($dataset->project->name);
$DataDownloadSchema->name($name);
$DataDownloadSchema->encodingFormat('zip');
$DataDownloadSchema->contentURL($contentURL);

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function dashboard(Request $request)
return Inertia::render('Dashboard', [
'filters' => $request->all('action', 'draft_id'),
'team' => $team,
'projects' => $projects->load('tags'),
'projects' => $projects->load('tags', 'draft'),
'samples' => $samples->load('sample.molecules'),
'teamRole' => $user->teamRole($team),
]);
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/DraftController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public function update(Request $request, Draft $draft)
}
$draft->name = $request->get('name') ? $request->get('name') : $draft->name;
$draft->project_enabled = $project_enabled;
$draft->current_step = $request->get('current_step') ? $request->get('current_step') : 1;
$draft->save();

return $draft;
Expand Down Expand Up @@ -424,7 +425,7 @@ public function process(Request $request, Draft $draft)
}
}

$draft->current_step = 2;
//$draft->current_step = 2;
$draft->save();

$studies = json_decode($project->studies()->orderBy('name')->get()->load(['datasets', 'sample.molecules', 'tags']));
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function upload(Request $request)
{
return Inertia::render('Upload', [
'draft_id' => $request->get('draft_id'),
'step' => $request->get('step'),
]);
}

Expand Down
1 change: 1 addition & 0 deletions app/Http/Resources/ProjectResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function toArray($request)
'updated_at' => $this->updated_at,
'download_url' => $this->download_url,
'species' => json_decode($this->species),
'release_date' => $this->release_date,
'stats' => [
'likes' => $this->likesCount(),
],
Expand Down
1 change: 1 addition & 0 deletions app/Models/Draft.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Draft extends Model
'settings',
'info',
'project_enabled',
'current_step',
];

public function files()
Expand Down
Loading

0 comments on commit b4eb382

Please sign in to comment.