VolumeImport
class VolumeImport extends Import
Properties
| protected string | $path | Path to the directory with the import files. |
from Import |
| protected Collection|null | $importVolumes | Caches the decoded volume import file. |
|
| protected UserImport|null | $userImport | The user import instance that belongs to this import. |
|
| protected LabelTreeImport|null | $labelTreeImport | The label tree import instance that belongs to this import. |
Methods
The files expected by this import.
Validate a file of this import.
Validates a JSON file to contain an array of objects, each of which has all the expected keys.
Validates a CSV file to contain the expected columns.
Read a JSON file containing an array and wrap it in a Laravel collection.
Get the contents of the volume import file.
Get the contents of the label tree import file.
Get all volumes of this import augmented by the IDs of the users, label trees and labels that they require.
Get all label trees that might have to be imported for the volumes.
Get all labels that might have to be imported for the volumes.
Get the users who might have to be imported for the volumes.
Get the user import instance that belongs to this import.
Get the label tree import instance that belongs to this import.
Get a map of one CSV ID column to another.
Get the list of labels and users that whould need to be imported for each volume.
Insert import volumes into the database.
Insert import users into the database.
Insert import label trees and labels into the database.
Insert import files into the database.
Insert import images into the database.
Insert import videos into the database.
Insert import image labels into the database.
Insert import video labels into the database.
Insert import image annotations into the database.
Insert import video annotations into the database.
Details
in
Import at line 23
__construct(string $path)
Create a new instance.
in
Import at line 33
bool
filesMatch()
Check if this import matches to the given import files.
in
Import at line 48
validateFiles()
Check if the files of this import are valid.
at line 206
protected array
expectedFiles()
The files expected by this import.
in
Import at line 70
protected array
files()
Get the basename of each file of this import.
at line 226
protected
validateFile(string $basename)
Validate a file of this import.
in
Import at line 96
protected
expectKeysInJson(string $file, array $expectation, bool $array = true)
Validates a JSON file to contain an array of objects, each of which has all the expected keys.
in
Import at line 122
protected
expectColumnsInCsv(string $file, array $expectation)
Validates a CSV file to contain the expected columns.
in
Import at line 146
protected Collection
collectJson(string $file)
Read a JSON file containing an array and wrap it in a Laravel collection.
at line 59
array
perform(Project $project, User $creator, array|null $only = null, array $newUrls = [], array $nameConflictResolution = [], array $parentConflictResolution = [])
Perform the import.
at line 108
Collection
getImportVolumes()
Get the contents of the volume import file.
at line 122
Collection
getImportLabelTrees()
Get the contents of the label tree import file.
at line 133
Collection
getVolumeImportCandidates()
Get all volumes of this import augmented by the IDs of the users, label trees and labels that they require.
at line 177
Collection
getLabelTreeImportCandidates()
Get all label trees that might have to be imported for the volumes.
at line 187
Collection
getLabelImportCandidates()
Get all labels that might have to be imported for the volumes.
at line 198
Collection
getUserImportCandidates()
Get the users who might have to be imported for the volumes.
These may be creators of annotation/image labels or admins of required label trees.
at line 314
protected UserImport
getUserImport()
Get the user import instance that belongs to this import.
at line 328
protected LabelTreeImport
getLabelTreeImport()
Get the label tree import instance that belongs to this import.
at line 347
protected Collection
getCsvIdMap(string $basename, string $value, string $key = 'id')
Get a map of one CSV ID column to another.
E.g. a map of the image 'id' in column 0 to the 'volume_id' in column 2.
at line 371
protected array
getRequiredEntities()
Get the list of labels and users that whould need to be imported for each volume.
This is based on image annotation labels, image labels, video annotation labels and video labels of each volume.
at line 436
protected Collection
insertVolumes(Collection $candidates, User $creator, array $newUrls)
Insert import volumes into the database.
at line 487
protected array
insertUsers(Collection $volumeCandidates)
Insert import users into the database.
at line 506
protected array
insertLabelTreesAndLabels(Collection $volumeCandidates, array $nameConflictResolution, array $parentConflictResolution)
Insert import label trees and labels into the database.
at line 534
protected array
insertFiles(array $volumeIdMap, string $csv, string $modelClass)
Insert import files into the database.
at line 585
protected array
insertImages(array $volumeIdMap)
Insert import images into the database.
at line 597
protected array
insertVideos(array $volumeIdMap)
Insert import videos into the database.
at line 609
protected
insertImageLabels(array $imageIdMap, array $labelIdMap, array $userIdMap)
Insert import image labels into the database.
at line 636
protected
insertVideoLabels(array $videoIdMap, array $labelIdMap, array $userIdMap)
Insert import video labels into the database.
at line 664
protected
insertImageAnnotations(array $volumeIdMap, array $imageIdMap, array $labelIdMap, array $userIdMap)
Insert import image annotations into the database.
at line 755
protected
insertVideoAnnotations(array $volumeIdMap, array $videoIdMap, array $labelIdMap, array $userIdMap)
Insert import video annotations into the database.