LabelTreeImport
class LabelTreeImport extends Import
Properties
protected string | $path | Path to the directory with the import files. |
from Import |
protected Collection | $importLabelTrees | Caches the decoded label tree import file. |
|
protected UserImport | $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 193
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 204
protected
validateFile(string $basename)
Validate a file of this import.
in
Import at line 98
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 124
protected
expectColumnsInCsv(string $file, array $expectation)
Validates a CSV file to contain the expected columns.
in
Import at line 148
protected Collection
collectJson(string $file)
Read a JSON file containing an array and wrap it in a Laravel collection.
at line 42
array
perform(array $onlyTrees = null, array $onlyLabels = null, array $nameConflictResolution = [], array $parentConflictResolution = [])
Perform the import.
at line 81
Collection
getImportLabelTrees()
Get the contents of the label tree import file.
at line 95
Collection
getLabelTreeImportCandidates()
Get label trees that can be imported and don't already exist.
at line 111
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 185
Collection
getUserImportCandidates()
Get users who might be implicitly imported along with a label tree.
at line 231
protected UserImport
getUserImport()
Get the user import instance that belongs to this import.
at line 247
protected Collection
getInsertLabelTrees(array|null $onlyTrees)
Get the array that can be used to insert the label trees that should be imported.
at line 285
protected array
insertLabelTrees(Collection $trees)
Insert label trees that should be imported in the database.
at line 309
protected
insertLabelTreeVersions(Collection $insertTrees, array $labelTreeIdMap)
Create label tree versions for imported versioned label trees.
at line 333
protected array
getInsertUserIds(Collection $trees)
Get IDs of label tree admins that should be imported.
at line 354
protected
attachLabelTreeMembers(Collection $trees, array $labelTreeIdMap, array $userIdMap)
Attach members to imported label trees.
at line 388
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 417
protected array
insertLabels(Collection $labels, array $labelTreeIdMap)
Insert labels that should be imported in the database.
at line 456
protected
updateInsertedLabelParentIds(Collection $labels, array $labelIdMap)
Update/set the parent_id of imported labels.
at line 478
protected
mergeLabels(Collection $mergeLabels, array $nameConflictResolution, array $parentConflictResolution, array $labelIdMap)
Merge conflicts between import labels and existing labels.