Skip to content

Commit

Permalink
Merge pull request #1168 from NFDI4Chem/remove-schema-by-name-methods
Browse files Browse the repository at this point in the history
fix: comment out methods to generate schema by name
  • Loading branch information
CS76 authored Nov 8, 2024
2 parents 7bc5702 + c4cdc8a commit 8647a05
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,46 +76,46 @@ class BioschemasController extends Controller
* )
* )
*/
public function modelSchemaByName(Request $request, $username, $projectName, $studyName = null, $datasetName = null)
{
$user = User::where('username', $username)->firstOrFail();
if ($user) {
$project = Project::where([['slug', $projectName], ['owner_id', $user->id]])->firstOrFail();
}
if ($project) {
if ($project->is_public) {
$projectSchema = $this->project($project);
if ($studyName) {
$study = Study::where([['slug', $studyName], ['owner_id', $user->id], ['project_id', $project->id]])->firstOrFail();
if ($study) {
if ($study->is_public) {
$studySchema = $this->study($study);
if ($datasetName) {
$dataset = Dataset::where([['slug', $datasetName], ['owner_id', $user->id], ['project_id', $project->id], ['study_id', $study->id]])->firstOrFail();
if ($dataset) {
if ($dataset->is_public) {
$datasetSchema = $this->dataset($dataset);
} else {
throw new AuthorizationException;
}

return $datasetSchema;
}
}

return $studySchema;
} else {
throw new AuthorizationException;
}
}
}

return $projectSchema;
} else {
throw new AuthorizationException;
}
}
}
// public function modelSchemaByName(Request $request, $username, $projectName, $studyName = null, $datasetName = null)
// {
// $user = User::where('username', $username)->firstOrFail();
// if ($user) {
// $project = Project::where([['slug', $projectName], ['owner_id', $user->id]])->firstOrFail();
// }
// if ($project) {
// if ($project->is_public) {
// $projectSchema = $this->project($project);
// if ($studyName) {
// $study = Study::where([['slug', $studyName], ['owner_id', $user->id], ['project_id', $project->id]])->firstOrFail();
// if ($study) {
// if ($study->is_public) {
// $studySchema = $this->study($study);
// if ($datasetName) {
// $dataset = Dataset::where([['slug', $datasetName], ['owner_id', $user->id], ['project_id', $project->id], ['study_id', $study->id]])->firstOrFail();
// if ($dataset) {
// if ($dataset->is_public) {
// $datasetSchema = $this->dataset($dataset);
// } else {
// throw new AuthorizationException;
// }

// return $datasetSchema;
// }
// }

// return $studySchema;
// } else {
// throw new AuthorizationException;
// }
// }
// }

// return $projectSchema;
// } else {
// throw new AuthorizationException;
// }
// }
// }

/**
* Implement Bioschemas upon request by model's id to generate a project, study, or dataset schema.
Expand Down
58 changes: 29 additions & 29 deletions app/Http/Controllers/API/Schemas/DataCite/DataCiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,38 +70,38 @@ class DataCiteController extends Controller
* )
* )
*/
public function modelSchemaByName(Request $request, $username, $projectName, $studyName = null, $datasetName = null)
{
$user = User::where('username', $username)->firstOrFail();
if ($user) {
$project = Project::where([['slug', $projectName], ['owner_id', $user->id]])->firstOrFail();
}
if ($project) {
if ($studyName) {
// send study back without project info added to it\
$study = Study::where([['slug', $studyName], ['owner_id', $user->id], ['project_id', $project->id]])->firstOrFail();
if ($study) {
if ($datasetName) {
$dataset = Dataset::where([['slug', $datasetName], ['owner_id', $user->id], ['project_id', $project->id], ['study_id', $study->id]])->firstOrFail();
// send dataset without project and study details
if ($dataset) {
$datasetDatacite = $dataset->datacite_schema;
// public function modelSchemaByName(Request $request, $username, $projectName, $studyName = null, $datasetName = null)
// {
// $user = User::where('username', $username)->firstOrFail();
// if ($user) {
// $project = Project::where([['slug', $projectName], ['owner_id', $user->id]])->firstOrFail();
// }
// if ($project) {
// if ($studyName) {
// // send study back without project info added to it\
// $study = Study::where([['slug', $studyName], ['owner_id', $user->id], ['project_id', $project->id]])->firstOrFail();
// if ($study) {
// if ($datasetName) {
// $dataset = Dataset::where([['slug', $datasetName], ['owner_id', $user->id], ['project_id', $project->id], ['study_id', $study->id]])->firstOrFail();
// // send dataset without project and study details
// if ($dataset) {
// $datasetDatacite = $dataset->datacite_schema;

return $datasetDatacite;
}
} else {
$studyDatacite = $study->datacite_schema;
// return $datasetDatacite;
// }
// } else {
// $studyDatacite = $study->datacite_schema;

return $studyDatacite;
}
}
} else {
$projectDatacite = $project->datacite_schema;
// return $studyDatacite;
// }
// }
// } else {
// $projectDatacite = $project->datacite_schema;

return $projectDatacite;
}
}
}
// return $projectDatacite;
// }
// }
// }

/**
* Implement DataCite upon request by model id to generate a project, study, or dataset schema.
Expand Down
4 changes: 2 additions & 2 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
Route::prefix('schemas')->group(function () {
Route::prefix('bioschemas')->group(function () {
Route::get('/', [DataCatalogController::class, 'dataCatalogSchema'])->name('bioschemas.datacatalog');
Route::get('/{username}/{project}/{study?}/{dataset?}', [BioschemasController::class, 'modelSchemaByName'])->name('bioschemas.model');
// Route::get('/{username}/{project}/{study?}/{dataset?}', [BioschemasController::class, 'modelSchemaByName'])->name('bioschemas.model');
Route::get('/{id}', [BioschemasController::class, 'modelSchemaByID'])->name('bioschemas.id');
});

Route::prefix('datacite')->group(function () {
Route::get('/{username}/{project}/{study?}/{dataset?}', [DataCiteController::class, 'modelSchemaByName']);
// Route::get('/{username}/{project}/{study?}/{dataset?}', [DataCiteController::class, 'modelSchemaByName']);
Route::get('/{id}', [DataCiteController::class, 'modelSchemaByID']);
Route::put('/{id}', [DOIController::class, 'update']);
});
Expand Down

0 comments on commit 8647a05

Please sign in to comment.