Kernel::System::Configuration::Entity

NAME

Kernel::System::Configuration::Entity

DESCRIPTION

Base class for all configuration entities.

has Process

Attribute that holds the current process (Export/Import).

has Filters

Attribute that holds the filters to be applied in Export.

has UnitTest

Attribute that determine if entity is instantiated in unit test.

has UpdateAttributes

Attribute that holds the entity attributes that can be used in the process/action 'UpdateAttribute' as identifiers or to update.

Name()

Returns the entity name.

DependsOn()

Returns which entities the entity depends on.

Example

    {
        Valid => {
            ValidID => 'ID',
        },
    }

HasMany()

Returns which entities the entity can have multiple relations.

Example

    {
        Service => {
            ServiceIDs => 'ID',
        }
    }

ReferencedOn()

Returns which entities the entity relates to. This is specially useful in the 'Export' of a specific entity, where it alone is useless, e.g. 'CustomPageContent' and 'CustomPage'.

Example

    {
        CustomPageContent => {
            ID => 'CustomPageID',
        },
    }

List()

Returns a list with all the records for the entity (cached).

    my $List = $Entity->List();

Returns

    C<undef> - in case any error occurs
    [
        {...},
    ]

Get()

Returns the entity record that matches with given param (cached).

    my $Record = $Entity->Get( UID => '...' );

Returns

    C<undef> - in case any error occurs
    {}       - record not found
    {
        UID => '...',
    }

UpdateAttribute()

Update an attribute of the entity.

    my $Updated = $Entity->UpdateAttribute(
        Identifier      => '...',
        IdentifierValue => '...',
        Attribute       => '...',
        AttributeValue  => '...',
    );

Returns

    C<undef> - in case any error occurs
    1        - success

Export()

Export the entity records.

Returns

    C<undef> - in case of any error occurs.
    [
        {
            Entity => '...',
            Data   => {
                UID => '...',
            },
        },
        ...
    ]

ExportRecord()

Exports an entity record.

    my $Result = $Entity->ExportRecord( Record => {...} );

Returns

    [
        {
            Entity => '...',
            Data   => {
                UID => '...',
            },
        },
    ]

RecordDependencies()

Looks for the record dependencies.

    my $Dependencies = $Entity->RecordDependencies(
        Record   => {...},         # required
        SkipDeps => { Valid => 1 } # optional
    );

ImportRecord()

Import entity record.

    my $Result = $Entity->ImportRecord(
        Record   => {...}, # required
    );

Returns

    C<undef> - in case any error occurs
    1        - success

DeleteRecord()

Delete entity record if found, deletes caches and register record UID accordingly.

    my $Result = $Entity->DeleteRecord(
        Record => '...', # required
    );

Returns

    C<undef> - in case any error occurs
    1        - success

PRIVATE INTERFACE

_List()

Method that should be implement by each entity to return the list of records.

Should return

    C<undef> - in case any error occurs
    []       - empty array in case no records found
    [
        {
            UID => '...',
        }
    ]

_IsDifferentColsToSkip()

Returns which columns should be skipped when comparing entity records.

_ClearSystemCache()

Clear the entity system cache.

_IsDifferent()

Checks if two entity records are different.

Returns

    1 - different
    0 - equal

_Get()

Returns the entity record that matches with given param.

    my $Record = $Entity->_Get( UID => '...' );

Returns

    C<undef> - in case any error occurs
    {}       - record not found
    {
        UID => '...',
    }

_RecordDependencies()

Returns the entity record dependencies of the given type.

    my $Record = $Entity->_RecordDependencies(
        Record => {...},
        Type   => {...}, # (DependsOn|HasMany|ReferencedOn)
        Config => {...}, # dependency type configuration
        Skip   => {...}, # dependencies to be skipped
    );

Returns

    [
        {
            Data   => {...},
            Entity => '...',
        }
    ]

_RecordFixDependencies()

Used on the import process to fix the dependencies identifiers by the correct ones.

    $Entity->_RecordFixDependencies( Record => {...} );

_ApplyFilters()

Used on the export process, apply the list filters while exporting the entity records.

_RegisterIDs

Registers the records local id: – Adds the ones not present in the registry – Marks as deleted the ones not present in the list

Returns

    C<undef> - in case any errors occurs
    1        - success

_RegisterID

Registers the record local id.

    $my $Result = $Entity->_RegisterUID(
        SystemID => '...', # required
        Entity   => '...', # required
        GID      => '...', # required
        LocalID  => '...', # required
        Deleted  => '1|0', # optional (default 0)
    );

Returns

    C<undef> - in case any errors occurs
    1        - success

_Delete()

Marks the entity record as invalid or deletes the entity record.

    my $Result = $Entity->_Delete( CurrentRecord => {...} );

Returns

    1        - deleted
    0        - not deleted (possibly marked as invalid, or just not deleted)
    C<undef> - in case any error occurs

GetRecordSystemsInformation()

Returns the systems information for the entity record.

    my $Result = $Entity->GetRecordSystemsInformation( Record => {...} );

Returns

    C<undef> - in case any error occurs

    {
        OriginSystem => {
            GID      => '...',
            SystemID => '...',
        },
        OtherSystems => [
            {
                GID      => '...',
                SystemID => '...',
            },
        ],
    }

_FindCurrentRecord()

Used during the import, this method will try to find the entity record that matches in the current system. First tries to use the OtherSystems info, then the OriginSystem and at last the UID.

    my $CurrentRecord = $Entity->_FindCurrentRecord( Record => {...} );

Returns

    C<undef> - in case any error occurs

    {
        ID => '...',
    }

_GenerateUUID()

Returns a new UUID.

Scroll to Top