-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #303 from Steinbeck-Lab/development
Development
- Loading branch information
Showing
99 changed files
with
14,988 additions
and
2,357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace App\Actions\Coconut; | ||
|
||
use App\Models\Collection; | ||
use App\Models\Ticker; | ||
use App\Services\DOI\DOIService; | ||
|
||
class AssignDOI | ||
{ | ||
private $doiService; | ||
|
||
/** | ||
* Create a new class instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(DOIService $doiService) | ||
{ | ||
$this->doiService = $doiService; | ||
} | ||
|
||
/** | ||
* Archive the given model. | ||
* | ||
* @param mixed $model | ||
* @return void | ||
*/ | ||
public function assign($model) | ||
{ | ||
$collection = null; | ||
if ($model instanceof Collection) { | ||
$collection = $model; | ||
} | ||
if ($collection) { | ||
$collectionIdentifier = $collection->identifier ? $collection->identifier : null; | ||
if ($collectionIdentifier == null) { | ||
$collectionTicker = Ticker::whereType('collection')->first(); | ||
$collectionIdentifier = $collectionTicker->index + 1; | ||
$collectionTicker->index = $collectionIdentifier; | ||
$collectionTicker->save(); | ||
|
||
$collection->identifier = $collectionIdentifier; | ||
$collection->save(); | ||
} | ||
$collection->fresh()->generateDOI($this->doiService); | ||
echo $collection->identifier."\r\n"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Actions\Coconut\AssignDOI; | ||
use App\Models\Collection; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class AssignDOIs extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'coconut:collection-assign-doi'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Assigns dois to all unassigned public collections'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle(AssignDOI $assigner) | ||
{ | ||
return DB::transaction(function () use ($assigner) { | ||
$collections = Collection::where([ | ||
['is_public', true], | ||
['doi', null], | ||
])->get(); | ||
|
||
foreach ($collections as $collection) { | ||
$collectionDOI = $collection->doi ? $collection->doi : null; | ||
$assigner->assign($collection); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.