From bad18afc55f55a631cbcdb7ed52acbaef313d63a Mon Sep 17 00:00:00 2001 From: Venkata Chandra Sekhar Nainala Date: Thu, 19 Oct 2023 16:17:44 +0200 Subject: [PATCH] fix: enabled nmredata detection and other minor ui changes --- app/Http/Controllers/DraftController.php | 78 +++++++++++++++++------- resources/js/Shared/SpectraEditor.vue | 4 +- resources/js/Shared/Submission.vue | 14 ++--- 3 files changed, 64 insertions(+), 32 deletions(-) diff --git a/app/Http/Controllers/DraftController.php b/app/Http/Controllers/DraftController.php index 3431127f..df0f088d 100644 --- a/app/Http/Controllers/DraftController.php +++ b/app/Http/Controllers/DraftController.php @@ -96,6 +96,14 @@ public function files(Request $request, Draft $draft) ]); } + public function update(Request $request, Draft $draft) + { + $draft->name = $request->get('name'); + $draft->save(); + + return $draft; + } + public function deleteFSO(Request $request, Draft $draft, FileSystemObject $filesystemobject) { $fsoIds = $this->getChildrenIds($filesystemobject, []); @@ -131,7 +139,7 @@ public function complete(Request $request, Draft $draft) // ProcessDraft::dispatch($draft); return response()->json([ - 'project' => Project::with(['studies.datasets', 'owner'])->where('draft_id', $draft->id)->first(), + 'project' => Project::with(['studies.datasets', 'owner', 'citations', 'authors'])->where('draft_id', $draft->id)->first(), 'validation' => $validation, ]); } @@ -246,7 +254,6 @@ public function process(Request $request, Draft $draft) ['draft_id', $draft->id], ['status', '<>', 'missing'], ['model_type', 'study'], - ['is_processed', false], ]) ->orderBy('type') ->get(); @@ -285,14 +292,13 @@ public function process(Request $request, Draft $draft) $study->sample()->save($sample); $folder->study_id = $study->id; - $folder->is_processed = true; $folder->save(); } $sChildren = $folder->children; foreach ($sChildren as $sChild) { - if ($sChild->instrument_type != null) { + if ($sChild->instrument_type != null && $sChild->instrument_type != 'nmredata') { // associate all children with the study_id, project_id, dataset_id // create samples // create assays @@ -403,7 +409,7 @@ public function process(Request $request, Draft $draft) } return response()->json([ - 'project' => $project->load(['owner']), + 'project' => $project->load(['owner', 'citations', 'authors']), 'studies' => $studies, ]); }); @@ -438,31 +444,40 @@ public function processFolder($folders) { foreach ($folders as $folder) { if ($folder->type == 'directory') { - if ($folder->instrument_type == null) { - if ($this->isBruker($folder)) { - $this->saveInstrumentType($folder, 'bruker'); - $this->saveModelType($folder->parent); - } elseif ($this->isVarian($folder)) { - $this->saveInstrumentType($folder, 'varian'); - $this->saveModelType($folder->parent); - } else { - $this->processFolder($folder->children); - } + if ($this->isBruker($folder)) { + $this->saveInstrumentType($folder, 'bruker'); + $this->saveModelType($folder->parent); + } elseif ($this->isVarian($folder)) { + $this->saveInstrumentType($folder, 'varian'); + $this->saveModelType($folder->parent); + } else { + $this->processFolder($folder->children); } } else { - if ($folder->instrument_type == null) { - if ($this->isJOEL($folder)) { - $this->saveInstrumentType($folder, 'joel'); - $this->saveModelType($folder->parent); - } elseif ($this->isJcampDX($folder)) { - $this->saveInstrumentType($folder, 'jcamp'); - $this->saveModelType($folder->parent); - } + if ($this->isJOEL($folder)) { + $this->saveInstrumentType($folder, 'joel'); + $this->saveModelType($folder->parent); + } elseif ($this->isJcampDX($folder)) { + $this->saveInstrumentType($folder, 'jcamp'); + $this->saveModelType($folder->parent); + } elseif ($this->isNMReData($folder)) { + $this->saveInstrumentType($folder, 'nmredata'); + $this->saveAnnotationsDetected($folder->parent); } } } } + public function saveAnnotationsDetected($folder) + { + $study = $folder->study; + + if ($study) { + $study->has_nmredata = true; + $study->save(); + } + } + public function saveModelType($folder) { if ($folder) { @@ -526,6 +541,23 @@ public function isJcampDX($folder) return false; } + public function isNMReData($folder) + { + $fileTypes = ['nmredata']; + $names = [$folder->name]; + $extensions = array_map(fn ($s) => substr("$s", (strrpos($s, '.') + 1)), $names); + $isNMReData = false; + if (array_intersect($fileTypes, $extensions) == $fileTypes) { + $isNMReData = true; + } + + if ($isNMReData) { + return true; + } + + return false; + } + public function isJOEL($folder) { $fileTypes = ['jdf']; diff --git a/resources/js/Shared/SpectraEditor.vue b/resources/js/Shared/SpectraEditor.vue index 8b7ed3ca..679db030 100644 --- a/resources/js/Shared/SpectraEditor.vue +++ b/resources/js/Shared/SpectraEditor.vue @@ -1,7 +1,7 @@