Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiltri committed Jan 23, 2020
2 parents c51f946 + 9169271 commit 9ff2c24
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 1 deletion.
45 changes: 45 additions & 0 deletions app/Console/Commands/Report/ReportOsci.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace App\Console\Commands\Report;

use League\Csv\Writer;
use Illuminate\Support\Facades\Storage;

use Aic\Hub\Foundation\AbstractCommand as BaseCommand;

class ReportOsci extends BaseCommand
{

protected $signature = 'report:osci';

protected $description = 'Export OSCI mapping';

public function handle()
{
$csv = Writer::createFromString('');

$csv->insertOne([
'artwork_citi_id',
'publication_title',
'section_title',
'web_url',
]);

$sections = \App\Models\Dsc\Section::whereNotNull('artwork_citi_id');

foreach ($sections->cursor() as $section) {
$row = [
'artwork_citi_id' => $section->artwork_citi_id,
'publication_title' => $section->publication->title,
'section_title' => $section->title,
'web_url' => $section->web_url,
];

$this->info(json_encode(array_values($row)));
$csv->insertOne($row);
}

Storage::put('artwork-sections.csv', $csv->getContent());
}

}
47 changes: 47 additions & 0 deletions app/Console/Commands/Report/ReportUlan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace App\Console\Commands\Report;

use League\Csv\Writer;
use Illuminate\Support\Facades\Storage;

use Aic\Hub\Foundation\AbstractCommand as BaseCommand;

class ReportUlan extends BaseCommand
{

protected $signature = 'report:ulan';

protected $description = 'Export ULAN mapping';

public function handle()
{
$csv = Writer::createFromString('');

$csv->insertOne([
'id',
'ulan_uri',
'title',
'birth_date',
'death_date',
]);

$artists = \App\Models\Collections\Agent::whereNotNull('ulan_uri');

foreach ($artists->cursor() as $artist) {
$row = [
'id' => $artist->citi_id,
'ulan_uri' => $artist->ulan_uri,
'title' => $artist->title,
'birth_date' => $artist->birth_date,
'death_date' => $artist->death_date,
];

$this->info(json_encode(array_values($row)));
$csv->insertOne($row);
}

Storage::put('agents-ulan.csv', $csv->getContent());
}

}
4 changes: 4 additions & 0 deletions app/Models/Collections/Artwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ public function themes()
return $this->categories()->themes();
}

public function dateQualifier() {
return $this->belongsTo('App\Models\Collections\ArtworkDateQualifier', 'artwork_date_qualifier_citi_id');
}

public function dates()
{
return $this->hasMany('App\Models\Collections\ArtworkDate');
Expand Down
1 change: 1 addition & 0 deletions app/Transformers/Inbound/Collections/Artwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected function getExtraFields(Datum $datum)
'copyright_notice' => $copyright_notice,
'gallery_citi_id' => $datum->gallery_id,
'internal_department_id' => $datum->department_id,
'artwork_date_qualifier_citi_id' => $datum->date_qualifier_id,
// TODO: ArtworkTypes may need to be attached via string comparison
//'artwork_type_citi_id' => , // Redmine #2431
];
Expand Down
16 changes: 16 additions & 0 deletions app/Transformers/Outbound/Collections/Artwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,22 @@ protected function getFields()
'type' => 'text',
],
],
'date_qualifier_title' => [
'doc' => 'Readable, text qualifer to the dates provided for this record.',
'type' => 'string',
'elasticsearch' => 'keyword',
'value' => function ($item) {
return $item->dateQualifier->title ?? '';
},
],
'date_qualifier_id' => [
'doc' => 'Unique identifier of the qualifer to the dates provided for this record.',
'type' => 'integer',
'elasticsearch' => 'integer',
'value' => function ($item) {
return $item->artwork_date_qualifier_citi_id;
},
],
'artist_display' => [
'doc' => 'Readable description of the creator of this work. Includes artist names, nationality and lifespan dates',
'type' => 'string',
Expand Down
2 changes: 1 addition & 1 deletion config/aic.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
| or any other location as required by the application or its packages.
*/

'version' => '1.0-rc8',
'version' => '1.0-rc9',

/*
|--------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddArtworkDateQualifierCitiIdToArtworksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('artworks', function (Blueprint $table) {
$table->integer('artwork_date_qualifier_citi_id')->default(null)->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('artworks', function (Blueprint $table) {
$table->dropColumn(['artwork_date_qualifier_citi_id']);
});
}
}

0 comments on commit 9ff2c24

Please sign in to comment.