LabelTreeImport
class LabelTreeImport extends Import
Properties
protected string | $path | Path to the directory with the import files. |
from Import |
protected Collection|null | $importLabelTrees | Caches the decoded label tree import file. |
|
protected UserImport|null | $userImport | The user 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.
Perform the import.
Get the contents of the label tree import file.
Get label trees that can be imported and don't already exist.
Get labels of existing label trees that can be imported.
Get users who might be implicitly imported along with a label tree.
Get the user import instance that belongs to this import.
Get the array that can be used to insert the label trees that should be imported.
Insert label trees that should be imported in the database.
Create label tree versions for imported versioned label trees.
Get IDs of label tree admins that should be imported.
Attach members to imported label trees.
Get the array that can be used to insert the labels that should be imported.
Insert labels that should be imported in the database.
Update/set the parent_id of imported labels.
Merge conflicts between import labels and existing labels.
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 191
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 202
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 41
array
perform(array $onlyTrees = null, array $onlyLabels = null, array $nameConflictResolution = [], array $parentConflictResolution = [])
Perform the import.
at line 78
Collection
getImportLabelTrees()
Get the contents of the label tree import file.
at line 92
Collection
getLabelTreeImportCandidates()
Get label trees that can be imported and don't already exist.
at line 108
Collection
getLabelImportCandidates()
Get labels of existing label trees that can be imported.
If an import label exists but has a conflicting name or parent_id, it will get the additional conflicting_name and/or conflicting_parent_id attributes.
at line 183
Collection
getUserImportCandidates()
Get users who might be implicitly imported along with a label tree.
at line 229
protected UserImport
getUserImport()
Get the user import instance that belongs to this import.
at line 245
protected Collection
getInsertLabelTrees(array|null $onlyTrees)
Get the array that can be used to insert the label trees that should be imported.
at line 278
protected array
insertLabelTrees(Collection $trees)
Insert label trees that should be imported in the database.
at line 302
protected
insertLabelTreeVersions(Collection $insertTrees, array $labelTreeIdMap)
Create label tree versions for imported versioned label trees.
at line 325
protected array
getInsertUserIds(Collection $trees)
Get IDs of label tree admins that should be imported.
at line 344
protected
attachLabelTreeMembers(Collection $trees, array $labelTreeIdMap, array $userIdMap)
Attach members to imported label trees.
at line 376
protected Collection
getInsertLabels(array|null $onlyLabels, array $labelTreeIdMap)
Get the array that can be used to insert the labels that should be imported.
at line 403
protected array
insertLabels(Collection $labels, array $labelTreeIdMap)
Insert labels that should be imported in the database.
at line 442
protected
updateInsertedLabelParentIds(Collection $labels, array $labelIdMap)
Update/set the parent_id of imported labels.
at line 465
protected
mergeLabels(Collection $mergeLabels, array $nameConflictResolution, array $parentConflictResolution, array $labelIdMap)
Merge conflicts between import labels and existing labels.