add keywords during publishing
This commit is contained in:
parent
f3f17d9371
commit
d9b26afb3f
13 changed files with 332 additions and 96 deletions
|
@ -18,6 +18,7 @@ use Illuminate\Support\Facades\Response;
|
|||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\DatasetReference;
|
||||
use App\Models\Subject;
|
||||
use App\Models\GeolocationBox;
|
||||
use App\Models\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
@ -66,12 +67,17 @@ class IndexController extends Controller
|
|||
|
||||
$titleTypes = ['sub' => 'sub', 'alternative' => 'alternative', 'translated' => 'translated', 'other' => 'other'];
|
||||
|
||||
$keywordTypes = ['uncontrolled' => 'uncontrolled'];
|
||||
|
||||
$descriptionTypes = [ 'methods' => 'methods', 'series_information' => 'series_information', 'technical_info' => 'technical_info', 'other' => 'other'];
|
||||
|
||||
$page = Page::query()->where('page_slug', 'terms-and-conditions')->firstOrFail();
|
||||
|
||||
//$relationTypes = array('updates' => 'updates', 'updated-by' => 'updated-by', 'other' => 'other');
|
||||
return view('publish.create-step1', compact('licenses', 'languages', 'projects', 'relatedIdentifierTypes', 'relationTypes', 'titleTypes', 'descriptionTypes', 'page'));
|
||||
return view(
|
||||
'publish.create-step1',
|
||||
compact('licenses', 'languages', 'projects', 'relatedIdentifierTypes', 'relationTypes', 'titleTypes', 'keywordTypes', 'descriptionTypes', 'page')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -394,6 +400,14 @@ class IndexController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
//save keywords
|
||||
if (isset($data['keywords'])) {
|
||||
foreach ($request->get('keywords') as $key => $keyword) {
|
||||
$dataKeyword = new Subject($keyword);
|
||||
$dataset->subjects()->save($dataKeyword);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['geolocation'])) {
|
||||
$formGeolocation = $request->input('geolocation');
|
||||
if ($formGeolocation['xmin'] !== null && $formGeolocation['ymin'] !== null &&
|
||||
|
|
|
@ -5,7 +5,6 @@ use App\Http\Controllers\Controller;
|
|||
use App\Http\Requests\ProjectRequest;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class CategoryController extends Controller
|
||||
|
|
|
@ -7,6 +7,7 @@ use App\Models\License;
|
|||
use App\Models\Person;
|
||||
use App\Models\File;
|
||||
use App\Models\GeolocationBox;
|
||||
use App\Models\Subject;
|
||||
|
||||
/**
|
||||
* DatasetExtension short summary.
|
||||
|
@ -53,6 +54,11 @@ trait DatasetExtension
|
|||
'relation' => 'contributors',
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
'Subject' => array(
|
||||
'model' => Subject::class,
|
||||
'relation' => 'subjects',
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
'File' => array(
|
||||
'model' => File::class,
|
||||
'relation' => 'files',
|
||||
|
|
|
@ -186,7 +186,8 @@ class XmlModel
|
|||
$cache = XmlCache::where('document_id', $dataset->id)->first();
|
||||
return $cache->getDomDocument();
|
||||
} catch (Exception $e) {
|
||||
Log::warning(__METHOD__ . " Access to XML cache failed on " . get_class($dataset) . '#' . $dataset->id . ". Trying to recover.");
|
||||
Log::warning(__METHOD__ . " Access to XML cache failed on " . get_class($dataset) .
|
||||
'#' . $dataset->id . ". Trying to recover.");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -194,6 +194,11 @@ class Dataset extends Model
|
|||
return $this->hasMany(\App\Models\DatasetReference::class, 'document_id', 'id');
|
||||
}
|
||||
|
||||
public function subjects()
|
||||
{
|
||||
return $this->hasMany(\App\Models\Subject::class, 'document_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the xml-cache record associated with the dataset.
|
||||
|
|
19
app/Models/Subject.php
Normal file
19
app/Models/Subject.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Dataset;
|
||||
|
||||
class Subject extends Model
|
||||
{
|
||||
protected $table = 'document_subjects';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = ['value', 'type'];
|
||||
|
||||
public function dataset()
|
||||
{
|
||||
return $this->belongsTo(Dataset::class, 'document_id', 'id');
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ class XmlCache extends Model
|
|||
* @var string
|
||||
*/
|
||||
protected $table = 'document_xml_cache';
|
||||
public $timestamps = false;
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -56,14 +56,13 @@ class XmlCache extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if a document in a specific xml version is already cached or not.
|
||||
* Check if a dataset in a specific xml version is already cached or not.
|
||||
*
|
||||
* @param mixed $datasetId
|
||||
* @param mixed $xmlVersion
|
||||
* @param mixed $serverDateModified
|
||||
* @return bool Returns true on cached hit else false.
|
||||
*/
|
||||
public function hasValidEntry($datasetId, $serverDateModified)
|
||||
public function hasValidEntry($datasetId, $serverDateModified) : bool
|
||||
{
|
||||
$select = DB::table('document_xml_cache');
|
||||
$select->where('document_id', '=', $datasetId)
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue