class VolumeImport extendsImport

Properties

protectedstring $path Path to the directory with the import files. from Import
protectedCollection $importVolumes Caches the decoded volume import file.
protectedUserImport $userImport The user import instance that belongs to this import.
protectedLabelTreeImport $labelTreeImport The label tree import instance that belongs to this import.

Methods

__construct(string$path)

Create a new instance.

from Import
bool
filesMatch()

Check if this import matches to the given import files.

from Import
validateFiles()

Check if the files of this import are valid.

from Import
array
expectedFiles()

The files expected by this import.

array
files()

Get the basename of each file of this import.

from Import
validateFile(string$basename)

Validate a file of this import.

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.

from Import
expectColumnsInCsv(string$file,array$expectation)

Validates a CSV file to contain the expected columns.

from Import
Collection
collectJson(string$file)

Read a JSON file containing an array and wrap it in a Laravel collection.

from Import
array
perform(Project$project,User$creator,array$only =null,array$newUrls =[],array$nameConflictResolution =[],array$parentConflictResolution =[])

Perform the import.

Collection
getImportVolumes()

Get the contents of the volume import file.

Collection
getImportLabelTrees()

Get the contents of the label tree import file.

Collection
getVolumeImportCandidates()

Get all volumes of this import augmented by the IDs of the users, label trees and labels that they require.

Collection
getLabelTreeImportCandidates()

Get all label trees that might have to be imported for the volumes.

Collection
getLabelImportCandidates()

Get all labels that might have to be imported for the volumes.

Collection
getUserImportCandidates()

Get the users who might have to be imported for the volumes.

getUserImport()

Get the user import instance that belongs to this import.

getLabelTreeImport()

Get the label tree import instance that belongs to this import.

Collection
getCsvIdMap(string$basename,string$value,string$key ='id')

Get a map of one CSV ID column to another.

array
getRequiredEntities()

Get the list of labels and users that whould need to be imported for each volume.

Collection
insertVolumes(Collection$candidates,User$creator,array$newUrls)

Insert import volumes into the database.

array
insertUsers(Collection$volumeCandidates)

Insert import users into the database.

array
insertLabelTreesAndLabels(Collection$volumeCandidates,array$nameConflictResolution,array$parentConflictResolution)

Insert import label trees and labels into the database.

array
insertImages(array$volumeIdMap)

Insert import images into the database.

insertImageLabels(array$imageIdMap,array$labelIdMap,array$userIdMap)

Insert import image labels into the database.

insertAnnotations(array$volumeIdMap,array$imageIdMap,array$labelIdMap,array$userIdMap)

Insert import annotations into the database.

Details

inImportat line23
__construct(string$path)

Create a new instance.

Parameters

string $path Path to the directory with the import files.

inImportat line33
bool filesMatch()

Check if this import matches to the given import files.

Return Value

bool

inImportat line48
validateFiles()

Check if the files of this import are valid.

Exceptions

Exception If any of the import files is invalid.

at line204
protectedarray expectedFiles()

The files expected by this import.

Return Value

array

inImportat line70
protectedarray files()

Get the basename of each file of this import.

Return Value

array

at line220
protected validateFile(string$basename)

Validate a file of this import.

Parameters

string $basename Basename of the file.

Exceptions

Exception If the file is invalid.

inImportat line98
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.

Parameters

string $file File name under $this->path
array $expectation Expected keys.
bool $array Specifies if the file to validate contains an array or not.

Exceptions

Exception If keys are missing.

inImportat line124
protected expectColumnsInCsv(string$file,array$expectation)

Validates a CSV file to contain the expected columns.

Parameters

string $file File name under $this->path
array $expectation Expected columns.

Exceptions

Exception If columns are missing.

inImportat line148
protectedCollection collectJson(string$file)

Read a JSON file containing an array and wrap it in a Laravel collection.

Parameters

string $file File name under $this->path

Return Value

Collection

at line57
array perform(Project$project,User$creator,array$only =null,array$newUrls =[],array$nameConflictResolution =[],array$parentConflictResolution =[])

Perform the import.

Parameters

Project $project Project to attach the imported volumes to
User $creator Creator of the new projects.
array $only IDs of the volume import candidates to limit the import to.
array $newUrls New URLs of imported volumes.
array $nameConflictResolution Array mapping label IDs to 'import' or 'existing' for how to resolve name conflicts.
array $parentConflictResolution Array mapping label IDs to 'import' or 'existing' for how to resolve parent conflicts.

Return Value

array Array containing 'volumes', 'labelTrees', 'labels' and 'users', mapping external IDs (from the import file) to IDs of the database.

at line104
Collection getImportVolumes()

Get the contents of the volume import file.

Return Value

Collection

at line118
Collection getImportLabelTrees()

Get the contents of the label tree import file.

Return Value

Collection

at line129
Collection getVolumeImportCandidates()

Get all volumes of this import augmented by the IDs of the users, label trees and labels that they require.

Return Value

Collection

at line175
Collection getLabelTreeImportCandidates()

Get all label trees that might have to be imported for the volumes.

Return Value

Collection

at line185
Collection getLabelImportCandidates()

Get all labels that might have to be imported for the volumes.

Return Value

Collection

at line196
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.

Return Value

Collection

at line276
protectedUserImport getUserImport()

Get the user import instance that belongs to this import.

Return Value

UserImport

at line290
protectedLabelTreeImport getLabelTreeImport()

Get the label tree import instance that belongs to this import.

Return Value

LabelTreeImport

at line309
protectedCollection 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.

Parameters

string $basename Name of the CSV file
string $value Name of the value column
string $key Name of the key column

Return Value

Collection

at line332
protectedarray getRequiredEntities()

Get the list of labels and users that whould need to be imported for each volume.

This is based on annotation and image labels of each volume.

Return Value

array Maps volume IDs to a list of label IDs and a list of user IDs.

at line379
protectedCollection insertVolumes(Collection$candidates,User$creator,array$newUrls)

Insert import volumes into the database.

Parameters

Collection $candidates The import volumes to insert.
User $creator The creator of the new volumes.
array $newUrls Array mapping a volume ID to a new volume URL (optional).

Return Value

Collection

Exceptions

UnprocessableEntityHttpException If a volume URL is invalid.

at line421
protectedarray insertUsers(Collection$volumeCandidates)

Insert import users into the database.

Parameters

Collection $volumeCandidates The import volumes to insert.

Return Value

array Map of import user IDs to existing user IDs.

at line440
protectedarray insertLabelTreesAndLabels(Collection$volumeCandidates,array$nameConflictResolution,array$parentConflictResolution)

Insert import label trees and labels into the database.

Parameters

Collection $volumeCandidates The import volumes to insert.
array $nameConflictResolution Array mapping label IDs to 'import' or 'existing' for how to resolve name conflicts.
array $parentConflictResolution Array mapping label IDs to 'import' or 'existing' for how to resolve parent conflicts.

Return Value

array Map of import IDs to existing IDs of 'users' (who belong to imported label trees), 'labelTrees', and 'labels'.

at line466
protectedarray insertImages(array$volumeIdMap)

Insert import images into the database.

Parameters

array $volumeIdMap Map of import volume IDs to existing volume IDs.

Return Value

array Map of import image IDs to existing image IDs.

at line519
protected insertImageLabels(array$imageIdMap,array$labelIdMap,array$userIdMap)

Insert import image labels into the database.

Parameters

array $imageIdMap Map of import image IDs to existing image IDs.
array $labelIdMap Map of import label IDs to existing label IDs.
array $userIdMap Map of import user IDs to existing user IDs.

at line547
protected insertAnnotations(array$volumeIdMap,array$imageIdMap,array$labelIdMap,array$userIdMap)

Insert import annotations into the database.

Parameters

array $volumeIdMap Map of import volume IDs to existing volume IDs.
array $imageIdMap Map of import image IDs to existing image IDs.
array $labelIdMap Map of import label IDs to existing label IDs.
array $userIdMap Map of import user IDs to existing user IDs.