Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: comment out methods to generate schema by name #1168

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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