From 69f6f250b90004628053b340e4038bd5511959c9 Mon Sep 17 00:00:00 2001 From: Arno Kaimbacher Date: Mon, 16 Sep 2019 13:47:30 +0200 Subject: [PATCH] - capitalize type attribute for datacite standard - DatasetExtension filter persons --- .../Controllers/Publish/IndexController.php | 4 +-- app/Library/Xml/DatasetExtension.php | 25 ++++++++++++------- app/Models/Person.php | 2 +- composer.lock | 24 +++++++++--------- ...2019_08_28_094055_create_persons_table.php | 2 +- ..._29_075029_create_dataset_titles_table.php | 2 +- ..._075729_create_dataset_abstracts_table.php | 2 +- public/prefixes/oai_datacite.xslt | 7 +++++- .../views/settings/person/_form.blade.php | 2 +- 9 files changed, 41 insertions(+), 29 deletions(-) diff --git a/app/Http/Controllers/Publish/IndexController.php b/app/Http/Controllers/Publish/IndexController.php index 8a0f5cc..4d692bc 100644 --- a/app/Http/Controllers/Publish/IndexController.php +++ b/app/Http/Controllers/Publish/IndexController.php @@ -62,11 +62,11 @@ class IndexController extends Controller $relationTypes = ["IsCitedBy", "Cites", "IsSupplementTo", "IsSupplementedBy", "IsContinuedBy", "Continues", "HasMetadata", "IsMetadataFor","IsNewVersionOf", "IsPreviousVersionOf", "IsPartOf", "HasPart", "IsReferencedBy", "References", "IsDocumentedBy", "Documents", "IsCompiledBy", "Compiles", "IsVariantFormOf", "IsOriginalFormOf", "IsIdenticalTo", "IsReviewedBy", "Reviews", "IsDerivedFrom", "IsSourceOf"]; $relationTypes = array_combine($relationTypes, $relationTypes); - $titleTypes = ['sub' => 'sub', 'alternative' => 'alternative', 'translated' => 'translated', 'other' => 'other']; + $titleTypes = ['sub' => 'Sub', 'alternative' => 'Alternative', 'translated' => 'Translated', 'other' => 'Other']; $keywordTypes = ['uncontrolled' => 'uncontrolled']; - $descriptionTypes = ['methods' => 'methods', 'series_information' => 'series_information', 'technical_info' => 'technical_info', 'translated' => 'translated', 'other' => 'other']; + $descriptionTypes = ['methods' => 'Methods', 'series_information' => 'Series_information', 'technical_info' => 'Technical_info', 'translated' => 'Translated', 'other' => 'Other']; $page = Page::query()->where('page_slug', 'terms-and-conditions')->firstOrFail(); diff --git a/app/Library/Xml/DatasetExtension.php b/app/Library/Xml/DatasetExtension.php index 50e68f0..42a61f3 100644 --- a/app/Library/Xml/DatasetExtension.php +++ b/app/Library/Xml/DatasetExtension.php @@ -268,11 +268,13 @@ trait DatasetExtension //$licenses = $select->with('datasets')->get(); //$rows = $supplier->datasets; $rows = $this->{$relation}; - //if (isset($this->externalFields[$fieldname]['pivot'])) - //{ - // $pivArray = $this->externalFields[$fieldname]['pivot']; - // $rows = $rows->wherePivot('role', $pivArray['role']); - //} + if (isset($this->externalFields[$fieldname]['pivot'])) { + $pivArray = $this->externalFields[$fieldname]['pivot']; + $pivotValue = $pivArray['role']; + //$through = $this->externalFields[$fieldname]['through']; + $rows = $this->{$relation}()->wherePivot('role', $pivotValue)->get(); + //$rows = $this->belongsToMany($modelclass, $through, 'document_id')->wherePivot('role', $pivotValue)->get(); + } } else { $rows = $select->whereHas('dataset', function ($q) use ($datasetId) { $q->where('id', $datasetId); @@ -287,10 +289,15 @@ trait DatasetExtension $objArray = []; foreach ($attributes as $property_name) { $fieldName = self::convertColumnToFieldname($property_name); - // $field =new Field($fieldName); - $fieldval = $row->{$property_name}; - // $field->setValue($fieldval); - // $this->_mapField($field, $dom, $rootNode); + $fieldval = ""; + if ($fieldName == "Type") { + $fieldval = ucfirst($row->{$property_name}); + } else { + // $field =new Field($fieldName); + $fieldval = $row->{$property_name}; + // $field->setValue($fieldval); + // $this->_mapField($field, $dom, $rootNode); + } $objArray[$fieldName] = $fieldval; } $result[] = $objArray; diff --git a/app/Models/Person.php b/app/Models/Person.php index fa557bf..18050f8 100644 --- a/app/Models/Person.php +++ b/app/Models/Person.php @@ -24,7 +24,7 @@ class Person extends Model public function documents() { return $this->belongsToMany(Dataset::class, 'link_documents_persons', 'person_id', 'document_id') - ->withPivot('role'); + ->withPivot('role', 'sort_order', 'allow_email_contact'); } // public function scopeNotLimit($query) diff --git a/composer.lock b/composer.lock index db80c0d..abf6737 100755 --- a/composer.lock +++ b/composer.lock @@ -3958,16 +3958,16 @@ }, { "name": "phpunit/phpunit", - "version": "7.5.15", + "version": "7.5.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "d79c053d972856b8b941bb233e39dc521a5093f0" + "reference": "316afa6888d2562e04aeb67ea7f2017a0eb41661" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d79c053d972856b8b941bb233e39dc521a5093f0", - "reference": "d79c053d972856b8b941bb233e39dc521a5093f0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/316afa6888d2562e04aeb67ea7f2017a0eb41661", + "reference": "316afa6888d2562e04aeb67ea7f2017a0eb41661", "shasum": "" }, "require": { @@ -4027,8 +4027,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "role": "lead", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], "description": "The PHP Unit Testing framework.", @@ -4038,7 +4038,7 @@ "testing", "xunit" ], - "time": "2019-08-21T07:05:16+00:00" + "time": "2019-09-14T09:08:39+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -4260,16 +4260,16 @@ }, { "name": "sebastian/exporter", - "version": "3.1.1", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "06a9a5947f47b3029d76118eb5c22802e5869687" + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/06a9a5947f47b3029d76118eb5c22802e5869687", - "reference": "06a9a5947f47b3029d76118eb5c22802e5869687", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", "shasum": "" }, "require": { @@ -4323,7 +4323,7 @@ "export", "exporter" ], - "time": "2019-08-11T12:43:14+00:00" + "time": "2019-09-14T09:02:43+00:00" }, { "name": "sebastian/global-state", diff --git a/database/migrations/2019_08_28_094055_create_persons_table.php b/database/migrations/2019_08_28_094055_create_persons_table.php index 6a3efd2..0d79b5c 100644 --- a/database/migrations/2019_08_28_094055_create_persons_table.php +++ b/database/migrations/2019_08_28_094055_create_persons_table.php @@ -27,7 +27,7 @@ class CreatePersonsTable extends Migration $table->string('identifier_misc', 50)->nullable(); $table->boolean('status')->nullable()->default(1); $table->integer('registered_at')->nullable(); - $table->string('name_type', 50)->nullable(); + $table->enum('name_type', ['author', 'contributor', 'other'])->nullable(); }); Schema::create('link_documents_persons', function (Blueprint $table) { diff --git a/database/migrations/2019_08_29_075029_create_dataset_titles_table.php b/database/migrations/2019_08_29_075029_create_dataset_titles_table.php index 7c8d858..676f977 100644 --- a/database/migrations/2019_08_29_075029_create_dataset_titles_table.php +++ b/database/migrations/2019_08_29_075029_create_dataset_titles_table.php @@ -20,7 +20,7 @@ class CreateDatasetTitlesTable extends Migration $table->foreign('document_id')->references('id')->on('documents') ->onUpdate('cascade')->onDelete('cascade'); - $table->enum('type', ['main' => 'main', 'sub' => 'sub', 'alternative' => 'alternative', 'translated' => 'translated', 'other' => 'other']); + $table->enum('type', ['main' => 'Main', 'sub' => 'sub', 'Alternative' => 'alternative', 'translated' => 'Translated', 'other' => 'Other']); $table->string('value', 255); $table->string('language', 3); }); diff --git a/database/migrations/2019_08_29_075729_create_dataset_abstracts_table.php b/database/migrations/2019_08_29_075729_create_dataset_abstracts_table.php index 76b9a26..f1cd008 100644 --- a/database/migrations/2019_08_29_075729_create_dataset_abstracts_table.php +++ b/database/migrations/2019_08_29_075729_create_dataset_abstracts_table.php @@ -22,7 +22,7 @@ class CreateDatasetAbstractsTable extends Migration $table->enum( 'type', - ['abstract' => 'abstract', 'methods' => 'methods', 'series_information' => 'series_information', 'technical_info' => 'technical_info', 'translated' => 'translated', 'other' => 'other'] + ['abstract' => 'Abstract', 'methods' => 'Methods', 'series_information' => 'Series_information', 'technical_info' => 'Technical_info', 'translated' => 'Translated', 'other' => 'Other'] ); $table->string('value', 255); $table->string('language', 3); diff --git a/public/prefixes/oai_datacite.xslt b/public/prefixes/oai_datacite.xslt index d5bd20f..ae2e1be 100644 --- a/public/prefixes/oai_datacite.xslt +++ b/public/prefixes/oai_datacite.xslt @@ -141,7 +141,7 @@ - + @@ -153,6 +153,11 @@ + + + + + diff --git a/resources/views/settings/person/_form.blade.php b/resources/views/settings/person/_form.blade.php index e537cfb..b55e640 100644 --- a/resources/views/settings/person/_form.blade.php +++ b/resources/views/settings/person/_form.blade.php @@ -40,7 +40,7 @@
{!! Form::label('name_type', 'Name Type') !!}
- {!! Form::select('name_type', ['personal' => 'personal', 'organizational' => 'organizational'], null, ['id' => 'name_type', 'placeholder' => '-- no name type --']) !!} + {!! Form::select('name_type', ['personal' => 'Personal', 'organizational' => 'Organizational'], null, ['id' => 'name_type', 'placeholder' => '-- no name type --']) !!}
name type is optional