- add api methods for frontend

- change oai paging size inside config/oai.php to 100
- change .user.ini file upload size
- change OIA RequestController for validations
This commit is contained in:
kaimbacher 2022-01-18 09:51:31 +01:00
parent 3004e5bb9b
commit 25ea8d40e1
6 changed files with 87 additions and 16 deletions

View File

@ -121,8 +121,10 @@ class RequestController extends Controller
$this->proc->setParameter('', 'unixTimestamp', $unixTimestamp);
// set OAI base url
$frontend = config('tethys.frontend');
$uri = explode('?', $_SERVER['REQUEST_URI'], 2);
$this->proc->setParameter('', 'baseURL', url('/') . $uri[0]);
// $this->proc->setParameter('', 'baseURL', url('/') . $uri[0]);
$this->proc->setParameter('', 'baseURL', $frontend. '/oai');// . $uri[0]);
$this->proc->setParameter('', 'repURL', url('/'));
$this->proc->setParameter('', 'downloadLink', url('/') . '/file/download/');
$this->proc->setParameter('', 'doiLink', 'https://doi.org/');
@ -437,7 +439,9 @@ class RequestController extends Controller
if (array_key_exists('from', $oaiRequest) && array_key_exists('until', $oaiRequest)) {
$from = $oaiRequest['from'];
$fromDate = \Illuminate\Support\Carbon::parse($from);
$until = $oaiRequest['until'];
$untilDate = \Illuminate\Support\Carbon::parse($until);
if (strlen($from) != strlen($until)) {
throw new OaiModelException(
@ -445,9 +449,10 @@ class RequestController extends Controller
OaiModelError::BADARGUMENT
);
}
}
if (array_key_exists('until', $oaiRequest)) {
$finder->whereDate('server_date_published', '>=', $fromDate)
->whereDate('server_date_published', '<=', $untilDate);
$test = $finder->toSql();
} else if (array_key_exists('until', $oaiRequest) && !array_key_exists('from', $oaiRequest)) {
$until = $oaiRequest['until'];
try {
$untilDate = \Illuminate\Support\Carbon::parse($until);
@ -473,9 +478,7 @@ class RequestController extends Controller
OaiModelError::BADARGUMENT
);
}
}
if (array_key_exists('from', $oaiRequest)) {
} else if (array_key_exists('from', $oaiRequest) && !array_key_exists('until', $oaiRequest)) {
$from = $oaiRequest['from'];
try {
$fromDate = \Illuminate\Support\Carbon::parse($from);
@ -550,7 +553,8 @@ class RequestController extends Controller
*/
private function setParamResumption($res, $cursor, $totalIds)
{
$tomorrow = str_replace('+00:00', 'Z', Carbon::now()->addHour(1)->setTimeZone('UTC'));
// $tomorrow = str_replace('+00:00', 'Z', Carbon::now()->addHour(1)->setTimeZone('UTC'));
$tomorrow = Carbon::now()->addDay(1)->toIso8601ZuluString();
$this->proc->setParameter('', 'dateDelete', $tomorrow);
$this->proc->setParameter('', 'res', $res);
$this->proc->setParameter('', 'cursor', $cursor);

View File

@ -16,7 +16,7 @@ return [
'workspacePath' => public_path() . DIRECTORY_SEPARATOR . "workspace",
'max' => [
'listidentifiers' => 15,
'listrecords' => 15
'listidentifiers' => 100,
'listrecords' => 100
],
];

View File

@ -18,5 +18,6 @@ return [
'datacite_test_service_url' => env('DATACITE_TEST_SERVICE_URL'),
'base_domain' => env('BASE_DOMAIN', 'https://tethys.at'),
'test_base_domain' => env('TEST_BASE_DOMAIN')
'test_base_domain' => env('TEST_BASE_DOMAIN'),
'frontend' => env('FRONTEND', 'https://tethys.at')
];

View File

@ -1,4 +1,4 @@
; Override value of upload_max_filesize
upload_max_filesize = 100M
post_max_size = 100M
memory_limit = 128M
upload_max_filesize = 200M
post_max_size = 200M
memory_limit = 200M

View File

@ -79,7 +79,7 @@
{{-- <a href="https://www.geologie.ac.at/" target="_blank" class="logo">
<img src="/images/gba_logo.png" alt="Logo white" width="60" height="30">
</a> --}}
<a href="/" class="logo">
<a href="{{route('frontend.home.index')}}" class="logo">
TETHYS
</a>
<div class="container">
@ -87,7 +87,7 @@
<!-- <li><a href="#hero">Home</a></li> -->
<li>
<a class="{{ Route::currentRouteName() == 'frontend.home.index' ? 'current' : '' }}"
href="{{ url('/') }}">Home</a>
href="{{route('frontend.home.index')}}">Home</a>
</li>
<!-- <li><a href="#introduction">Introduction</a></li> -->
<li>

View File

@ -3,6 +3,8 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Models\Person;
use App\Models\Dataset;
use Illuminate\Support\Facades\DB;
/*
|--------------------------------------------------------------------------
@ -36,6 +38,70 @@ $appRoutes = function () {
});
Route::get('/oai', 'Oai\RequestController@identify');
Route::get('/api/years', function () {
//return["2019", "2020", "2021"];
$serverState = 'published';
$select = DB::table('documents')
->where('server_state', 'LIKE', "%" . $serverState . "%");
$select
->select(DB::raw('EXTRACT(YEAR FROM server_date_published) as published_date'))
// ->select(DB::raw("DATE_PART('year', server_date_published) as published_date"))
// ->select(DB::raw("YEAR(server_date_published) AS published_date"))
->distinct(true);
$years = $select->pluck('published_date')->toArray();
return response()
->json($years)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET');
});
Route::get('api/sitelinks/{year}', function($year) {
//$select = DB::table('documents')
//->where('server_state','LIKE', "%".$serverState."%");
$serverState = 'published';
$select = Dataset::with('titles', 'authors')
->where('server_state', 'LIKE', "%" . $serverState . "%");
$from = (int) $year;
$until = $year + 1;
$select
->whereYear('server_date_published', '>=', $from)
->whereYear('server_date_published', '<', $until);
$documents = $select->orderBy('publish_id', 'asc')
->get();
return response()
->json($documents)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET');
});
Route::get('/api/dataset/{id}', function($id) {
$dataset = Dataset::where('publish_id', '=', $id)
->with([
'titles',
'abstracts',
'user',
'authors',
'contributors',
'subjects',
'coverage',
'licenses',
'project',
'files',
'identifier'
])
->firstOrFail();
// $dataset->load('titles');
// $dataset->load('abstracts');
return response()
->json($dataset)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET');
});
Route::get('/api/persons', function () {
$request = request();