- all editor cano now updates DOI's in backend

- composer updates
This commit is contained in:
Arno Kaimbacher 2021-05-19 15:10:46 +02:00
parent b5abcef327
commit 4e44d9d996
9 changed files with 325 additions and 73 deletions

View File

@ -1,26 +1,29 @@
<?php
namespace App\Http\Controllers;
namespace App\Http\Controllers\Publish;
use App\Interfaces\DOIInterface;
use App\Http\Controllers\Controller;
use App\Interfaces\DoiInterface;
use App\Models\Dataset;
use App\Models\DatasetIdentifier;
use Illuminate\Http\Request;
use App\Models\Oai\OaiModelError;
use App\Exceptions\OaiModelException;
use Illuminate\Support\Facades\View;
use App\Exceptions\GeneralException;
class DoiController extends Controller
{
protected $doiService;
protected $LaudatioUtils;
/**
/**
* Holds xml representation of document information to be processed.
*
* @var \DomDocument Defaults to null.
*/
protected $xml = null;
/**
/**
* Holds the stylesheet for the transformation.
*
* @var \DomDocument Defaults to null.
@ -41,7 +44,7 @@ class DoiController extends Controller
public function __construct(DoiInterface $DoiClient)
{
$this->doiClient = $DoiClient;
$this->xml = new \DomDocument();
$this->proc = new \XSLTProcessor();
}
@ -49,11 +52,21 @@ class DoiController extends Controller
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Contracts\View\View
*/
public function index()
// public function index()
// {
// //
// }
public function index(): \Illuminate\Contracts\View\View
{
//
$datasets = Dataset::query()
->has('identifier')
->orderBy('server_date_modified', 'desc')
->get();
return View::make('workflow.doi.index', [
'datasets' => $datasets,
]);
}
/**
@ -63,7 +76,7 @@ class DoiController extends Controller
*/
public function create(Request $request)
{
//
//
}
/**
@ -75,11 +88,11 @@ class DoiController extends Controller
public function store(Request $request)
{
$dataId = $request->input('publish_id');
// Setup stylesheet
$this->loadStyleSheet(public_path() .'/prefixes/doi_datacite.xslt');
// set timestamp
// Setup stylesheet
$this->loadStyleSheet(public_path() . '/prefixes/doi_datacite.xslt');
// set timestamp
$date = new \DateTime();
$unixTimestamp = $date->getTimestamp();
$this->proc->setParameter('', 'unixTimestamp', $unixTimestamp);
@ -108,7 +121,7 @@ class DoiController extends Controller
$this->xml->documentElement->appendChild($node);
$xmlMeta = $this->proc->transformToXML($this->xml);
// Log::alert($xmlMeta);
//create doiValue and correspunfing landingpage of tehtys
//create doiValue and correspunfing landingpage of tehtys
$doiValue = $prefix . '/tethys.' . $dataset->publish_id;
$appUrl = config('app.url');
$landingPageUrl = $appUrl . "/dataset/" . $dataset->publish_id;
@ -141,9 +154,19 @@ class DoiController extends Controller
* @param \App\Models\DatasetIdentifier $doi
* @return \Illuminate\Http\Response
*/
public function edit(DatasetIdentifier $doi)
public function edit($id)
{
//
$dataset = Dataset::query()
->with([
'titles',
'persons' => function ($query) {
$query->wherePivot('role', 'author');
},
])->findOrFail($id);
return View::make('workflow.doi.edit', [
'dataset' => $dataset,
]);
}
/**
@ -153,9 +176,81 @@ class DoiController extends Controller
* @param \App\Models\DatasetIdentifier $doi
* @return \Illuminate\Http\Response
*/
public function update(Request $request, DatasetIdentifier $doi)
public function update(Request $request, $publish_id)
{
//
$dataId = $publish_id; //$request->input('publish_id');
// Setup stylesheet
$this->loadStyleSheet(public_path() . '/prefixes/doi_datacite.xslt');
// set timestamp
$date = new \DateTime();
$unixTimestamp = $date->getTimestamp();
$this->proc->setParameter('', 'unixTimestamp', $unixTimestamp);
$prefix = "";
$base_domain = "";
$datacite_environment = config('tethys.datacite_environment');
if ($datacite_environment == "debug") {
$prefix = config('tethys.datacite_test_prefix');
$base_domain = config('tethys.test_base_domain');
} elseif ($datacite_environment == "production") {
$prefix = config('tethys.datacite_prefix');
$base_domain = config('tethys.base_domain');
}
// $prefix = config('tethys.datacite_prefix');
$this->proc->setParameter('', 'prefix', $prefix);
$repIdentifier = "tethys";
$this->proc->setParameter('', 'repIdentifier', $repIdentifier);
$this->xml->appendChild($this->xml->createElement('Datasets'));
$dataset = Dataset::where('publish_id', '=', $dataId)->firstOrFail();
if (is_null($dataset)) {
throw new OaiModelException('Dataset is not available for registering DOI!', OaiModelError::NORECORDSMATCH);
}
$dataset->fetchValues();
$xmlModel = new \App\Library\Xml\XmlModel();
$xmlModel->setModel($dataset);
$xmlModel->excludeEmptyFields();
$cache = ($dataset->xmlCache) ? $dataset->xmlCache : new \App\Models\XmlCache();
$xmlModel->setXmlCache($cache);
$domNode = $xmlModel->getDomDocument()->getElementsByTagName('Rdr_Dataset')->item(0);
$node = $this->xml->importNode($domNode, true);
$this->addSpecInformation($node, 'data-type:' . $dataset->type);
$this->xml->documentElement->appendChild($node);
$newXmlMeta = $this->proc->transformToXML($this->xml);
// Log::alert($xmlMeta);
//create doiValue and correspunfing landingpage of tehtys
$doiValue = $prefix . '/tethys.' . $dataset->publish_id;
$response = $this->doiClient->updateMetadataForDoi($doiValue, $newXmlMeta);
// if operation successful, store dataste identifier
if ($response->getStatusCode() == 201) {
$doi = $dataset->identifier();
// $doi['value'] = $doiValue;
// $doi['type'] = "doi";
// $doi['status'] = "findable";
// $doi->save();
$doi->touch();
return redirect()
->route('publish.workflow.doi.index')
->with('flash_message', 'You have successfully updated a DOI for the dataset!');
// if ($doi->save()) {
// // update server_date_modified for triggering nex xml cache (doi interface)
// $time = new \Illuminate\Support\Carbon();
// $dataset->server_date_modified = $time;
// $dataset->save();
// return redirect()
// ->route('publish.workflow.editor.index')
// ->with('flash_message', 'You have successfully created a DOI for the dataset!');
// }
} else {
$message = 'unexpected DataCite MDS response code ' . $response->getStatusCode();
// $this->log($message, 'err');
throw new GeneralException($message);
}
}
/**
@ -169,9 +264,9 @@ class DoiController extends Controller
//
}
/**
* Load an xslt stylesheet.
*

View File

@ -635,7 +635,7 @@ class EditorController extends Controller
* @param int $id
* @return \Illuminate\View\View
*/
public function doi($id): \Illuminate\Contracts\View\View
public function doiCreate($id): \Illuminate\Contracts\View\View
{
$dataset = Dataset::query()
->with([
@ -714,9 +714,10 @@ class EditorController extends Controller
$doi['status'] = "findable";
if ($doi->save()) {
// update server_date_modified for triggering nex xml cache (doi interface)
$time = new \Illuminate\Support\Carbon();
$dataset->server_date_modified = $time;
$dataset->save();
// $time = new \Illuminate\Support\Carbon();
// $dataset->server_date_modified = $time;
// $dataset->save();
// dataset gets automatically updated because of touches array
return redirect()
->route('publish.workflow.editor.index')
->with('flash_message', 'You have successfully created a DOI for the dataset!');

View File

@ -8,6 +8,10 @@ class DatasetIdentifier extends Model
{
protected $table = 'dataset_identifiers';
protected $guarded = array();
public $timestamps = true;
//See the array called $touches? This is where you put all the relationships you want to get updated_at as soon as this Model is updated
protected $touches = ['dataset'];
/**
* The dataset that belong to the DocumentIdentifier.

View File

@ -235,6 +235,7 @@ class DoiClient implements DoiInterface
// $this->log($message, 'err');
throw new DoiClientException($message);
}
return $response;
}
/**

96
composer.lock generated
View File

@ -221,16 +221,16 @@
},
{
"name": "doctrine/cache",
"version": "1.11.0",
"version": "1.11.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "a9c1b59eba5a08ca2770a76eddb88922f504e8e0"
"reference": "163074496dc7c3c7b8ccbf3d4376c0187424ed81"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/a9c1b59eba5a08ca2770a76eddb88922f504e8e0",
"reference": "a9c1b59eba5a08ca2770a76eddb88922f504e8e0",
"url": "https://api.github.com/repos/doctrine/cache/zipball/163074496dc7c3c7b8ccbf3d4376c0187424ed81",
"reference": "163074496dc7c3c7b8ccbf3d4376c0187424ed81",
"shasum": ""
},
"require": {
@ -300,7 +300,7 @@
],
"support": {
"issues": "https://github.com/doctrine/cache/issues",
"source": "https://github.com/doctrine/cache/tree/1.11.0"
"source": "https://github.com/doctrine/cache/tree/1.11.1"
},
"funding": [
{
@ -316,7 +316,7 @@
"type": "tidelift"
}
],
"time": "2021-04-13T14:46:17+00:00"
"time": "2021-05-18T16:45:32+00:00"
},
{
"name": "doctrine/dbal",
@ -3016,16 +3016,16 @@
},
{
"name": "symfony/console",
"version": "v4.4.23",
"version": "v4.4.24",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "1ab187ac21d41d7d34a4f529091a1f5d0bb2924f"
"reference": "1b15ca1b1bedda86f98064da9ff5d800560d4c6d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/1ab187ac21d41d7d34a4f529091a1f5d0bb2924f",
"reference": "1ab187ac21d41d7d34a4f529091a1f5d0bb2924f",
"url": "https://api.github.com/repos/symfony/console/zipball/1b15ca1b1bedda86f98064da9ff5d800560d4c6d",
"reference": "1b15ca1b1bedda86f98064da9ff5d800560d4c6d",
"shasum": ""
},
"require": {
@ -3085,7 +3085,7 @@
"description": "Eases the creation of beautiful and testable command line interfaces",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/console/tree/v4.4.23"
"source": "https://github.com/symfony/console/tree/v4.4.24"
},
"funding": [
{
@ -3101,20 +3101,20 @@
"type": "tidelift"
}
],
"time": "2021-05-10T12:53:15+00:00"
"time": "2021-05-13T06:28:07+00:00"
},
{
"name": "symfony/css-selector",
"version": "v5.2.7",
"version": "v5.2.9",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "59a684f5ac454f066ecbe6daecce6719aed283fb"
"reference": "5d5f97809015102116208b976eb2edb44b689560"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/59a684f5ac454f066ecbe6daecce6719aed283fb",
"reference": "59a684f5ac454f066ecbe6daecce6719aed283fb",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/5d5f97809015102116208b976eb2edb44b689560",
"reference": "5d5f97809015102116208b976eb2edb44b689560",
"shasum": ""
},
"require": {
@ -3150,7 +3150,7 @@
"description": "Converts CSS selectors to XPath expressions",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/css-selector/tree/v5.3.0-BETA1"
"source": "https://github.com/symfony/css-selector/tree/v5.2.9"
},
"funding": [
{
@ -3166,7 +3166,7 @@
"type": "tidelift"
}
],
"time": "2021-04-07T16:07:52+00:00"
"time": "2021-05-16T13:07:46+00:00"
},
{
"name": "symfony/debug",
@ -3537,16 +3537,16 @@
},
{
"name": "symfony/finder",
"version": "v4.4.23",
"version": "v4.4.24",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "67b77716f517e3f864759232e1201e7aa2ab0e82"
"reference": "a96bc19ed87c88eec78e1a4c803bdc1446952983"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/67b77716f517e3f864759232e1201e7aa2ab0e82",
"reference": "67b77716f517e3f864759232e1201e7aa2ab0e82",
"url": "https://api.github.com/repos/symfony/finder/zipball/a96bc19ed87c88eec78e1a4c803bdc1446952983",
"reference": "a96bc19ed87c88eec78e1a4c803bdc1446952983",
"shasum": ""
},
"require": {
@ -3578,7 +3578,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v4.4.23"
"source": "https://github.com/symfony/finder/tree/v4.4.24"
},
"funding": [
{
@ -3594,7 +3594,7 @@
"type": "tidelift"
}
],
"time": "2021-05-09T09:13:09+00:00"
"time": "2021-05-16T12:27:45+00:00"
},
{
"name": "symfony/http-client-contracts",
@ -3744,16 +3744,16 @@
},
{
"name": "symfony/http-kernel",
"version": "v4.4.23",
"version": "v4.4.24",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "95bb42312503a212f4467529bac8735f01226ff9"
"reference": "59925ee79f2541b4c6e990843e1a42768e898254"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/95bb42312503a212f4467529bac8735f01226ff9",
"reference": "95bb42312503a212f4467529bac8735f01226ff9",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/59925ee79f2541b4c6e990843e1a42768e898254",
"reference": "59925ee79f2541b4c6e990843e1a42768e898254",
"shasum": ""
},
"require": {
@ -3828,7 +3828,7 @@
"description": "Provides a structured process for converting a Request into a Response",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-kernel/tree/v4.4.23"
"source": "https://github.com/symfony/http-kernel/tree/v4.4.24"
},
"funding": [
{
@ -3844,20 +3844,20 @@
"type": "tidelift"
}
],
"time": "2021-05-12T13:13:32+00:00"
"time": "2021-05-19T12:12:19+00:00"
},
{
"name": "symfony/mime",
"version": "v5.2.7",
"version": "v5.2.9",
"source": {
"type": "git",
"url": "https://github.com/symfony/mime.git",
"reference": "7af452bf51c46f18da00feb32e1ad36db9426515"
"reference": "64258e870f8cc75c3dae986201ea2df58c210b52"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/mime/zipball/7af452bf51c46f18da00feb32e1ad36db9426515",
"reference": "7af452bf51c46f18da00feb32e1ad36db9426515",
"url": "https://api.github.com/repos/symfony/mime/zipball/64258e870f8cc75c3dae986201ea2df58c210b52",
"reference": "64258e870f8cc75c3dae986201ea2df58c210b52",
"shasum": ""
},
"require": {
@ -3911,7 +3911,7 @@
"mime-type"
],
"support": {
"source": "https://github.com/symfony/mime/tree/v5.2.7"
"source": "https://github.com/symfony/mime/tree/v5.2.9"
},
"funding": [
{
@ -3927,7 +3927,7 @@
"type": "tidelift"
}
],
"time": "2021-04-29T20:47:09+00:00"
"time": "2021-05-16T13:07:46+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -4640,16 +4640,16 @@
},
{
"name": "symfony/routing",
"version": "v4.4.22",
"version": "v4.4.24",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
"reference": "049e7c5c41f98511959668791b4adc0898a821b3"
"reference": "b42c3631fd9e3511610afb2ba081ea7e38d9fa38"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/049e7c5c41f98511959668791b4adc0898a821b3",
"reference": "049e7c5c41f98511959668791b4adc0898a821b3",
"url": "https://api.github.com/repos/symfony/routing/zipball/b42c3631fd9e3511610afb2ba081ea7e38d9fa38",
"reference": "b42c3631fd9e3511610afb2ba081ea7e38d9fa38",
"shasum": ""
},
"require": {
@ -4708,7 +4708,7 @@
"url"
],
"support": {
"source": "https://github.com/symfony/routing/tree/v4.4.22"
"source": "https://github.com/symfony/routing/tree/v4.4.24"
},
"funding": [
{
@ -4724,7 +4724,7 @@
"type": "tidelift"
}
],
"time": "2021-04-11T12:59:39+00:00"
"time": "2021-05-16T09:52:47+00:00"
},
{
"name": "symfony/service-contracts",
@ -4807,16 +4807,16 @@
},
{
"name": "symfony/translation",
"version": "v4.4.23",
"version": "v4.4.24",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "ff6e63c7b5de874464642969968f61f8dc649ac3"
"reference": "424d29dfcc15575af05196de0100d7b52f650602"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/ff6e63c7b5de874464642969968f61f8dc649ac3",
"reference": "ff6e63c7b5de874464642969968f61f8dc649ac3",
"url": "https://api.github.com/repos/symfony/translation/zipball/424d29dfcc15575af05196de0100d7b52f650602",
"reference": "424d29dfcc15575af05196de0100d7b52f650602",
"shasum": ""
},
"require": {
@ -4875,7 +4875,7 @@
"description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/translation/tree/v4.4.23"
"source": "https://github.com/symfony/translation/tree/v4.4.24"
},
"funding": [
{
@ -4891,7 +4891,7 @@
"type": "tidelift"
}
],
"time": "2021-04-28T06:59:52+00:00"
"time": "2021-05-16T09:52:47+00:00"
},
{
"name": "symfony/translation-contracts",

View File

@ -107,6 +107,9 @@
<li class="pure-menu-item {{ Route::is('publish.workflow.editor*') ? 'active' : '' }}">
<a class="pure-menu-link" href="{{ URL::route('publish.workflow.editor.index') }}"><i class="fas fa-list"></i> EDITOR PAGE: Released datasets</a>
</li>
<li class="pure-menu-item {{ Route::is('publish.workflow.doi*') ? 'active' : '' }}">
<a class="pure-menu-link" href="{{ URL::route('publish.workflow.doi.index') }}"><i class="fas fa-list"></i> DOI UPDATE LIST</a>
</li>
@endpermission
@permission('dataset-review-list')
<li class="pure-menu-item {{ Route::is('publish.workflow.review*') ? 'active' : '' }}">

View File

@ -0,0 +1,79 @@
@extends('settings.layouts.app')
@section('content')
<div class="header">
<h3 class="header-title">
<i class="fa fa-share"></i> Publish reviewed dataset
</h3>
</div>
<div class="pure-g box-content">
<div class="pure-u-1 pure-u-md-1">
<div>
<a href="{{ route('publish.workflow.doi.index') }}" class="pure-button button-small">
<i class="fa fa-chevron-left"></i>
<span>BACK</span>
</a>
</div>
<div id="app1">
{!! Form::model($dataset, [ 'method' => 'POST', 'route' => ['publish.workflow.doi.update',
$dataset->publish_id],
'id' => 'doiUpdateForm', 'class' => 'pure-form', 'enctype' => 'multipart/form-data', 'v-on:submit.prevent' =>
'checkForm'])
!!}
<fieldset id="fieldset-General">
<h3>Selected Dataset</h3>
<table style="margin-left: 2em">
<tbody>
<tr>
<td style="vertical-align: top; padding-right: 1em">{{ $dataset->id }}</td>
<td>
@foreach($dataset->titles as $title)
<div class="title" style="font-weight: bold">
{{ $title->value }}
</div>
@endforeach
<div class="authors">
@foreach($dataset->persons as $author)
{{ $author->full_name }}
@endforeach
</div>
<input type="hidden" name="selected[]" value="49">
</td>
</tr>
</tbody>
</table>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('publisher_name', 'Publisher Name') !!}
{!! Form::text('publisher_name', 'Geologische Bundesanstalt (GBA)', ['readonly', 'class' =>
'pure-u-23-24', ]) !!}
</div>
<div class="pure-controls instruction ">
<p>
Are you sure you want to update the DOI for the selected dataset?
</p>
<button type="submit" class="pure-button">
<i class="fa fa-share"></i>
<span>Update DOI</span>
</button>
</div>
</fieldset>
<br />
{!! Form::close() !!}
</div>
</div>
</div>
@stop
@section('after-scripts')
@stop

View File

@ -0,0 +1,55 @@
@extends('settings.layouts.app')
@section('content')
<div class="header">
<h3 class="header-title">
<i class="fas fa-list"></i> DOI LIST:update registerede DOI datasets
</h3>
</div>
<div class="pure-g box-content">
<div class="pure-u-1">
<table class="pure-table pure-table-horizontal">
<thead>
<th>Dataset Title</th>
<th>Tethys ID</th>
<th>Server State</th>
<th>Date of last modification</th>
<th></th>
</thead>
<tbody>
@foreach($datasets as $dataset)
<tr class="released">
<td>
@if ($dataset->titles()->first())
{{ $dataset->titles()->first()->value }}
@else
no title
@endif
</td>
<td>
{{ $dataset->publish_id }}
</td>
<td>
{{ $dataset->server_state }}
</td>
<td>
{{ $dataset->server_date_modified }}
</td>
<td>
@if ($dataset->server_state == "published")
<a href="{{ URL::route('publish.workflow.doi.edit', $dataset->id) }}" class="pure-button">
<i class="fa fa-edit"></i>
<span>Update DOI</span>
</a>
@endif
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@stop

View File

@ -141,13 +141,27 @@ Route::group(
]);
Route::get('workflow/editor/doi/{id}', [
'middleware' => ['permission:dataset-publish'],
'as' => 'workflow.editor.doi', 'uses' => 'EditorController@doi',
'as' => 'workflow.editor.doi', 'uses' => 'EditorController@doiCreate',
]);
Route::post('workflow/editor/doi/{publish_id}', [
'middleware' => ['permission:dataset-publish'],
'as' => 'workflow.editor.doiStore', 'uses' => 'EditorController@doiStore',
]);
//doi
Route::get('workflow/doi/index', [
'middleware' => ['permission:dataset-editor-list'],
'as' => 'workflow.doi.index', 'uses' => 'DoiController@index',
]);
Route::get('workflow/doi/edit/{id}', [
'middleware' => ['permission:dataset-publish'],
'as' => 'workflow.doi.edit', 'uses' => 'DoiController@edit',
]);
Route::post('workflow/doi/update/{publish_id}', [
'middleware' => ['permission:dataset-publish'],
'as' => 'workflow.doi.update', 'uses' => 'DoiController@update',
]);
//reviewer
Route::get('workflow/review/index', [
'middleware' => ['permission:dataset-review-list'],