Kernel::System::ProcessManagement::DB::Process

NAME

Kernel::System::ProcessManagement::DB::Process

DESCRIPTION

Process Management DB Process backend

METHODS

new()

Don't use the constructor directly, use the ObjectManager instead:

    my $ProcessDBObject = $Kernel::OM->Get('Kernel::System::ProcessManagement::DB::Process');

ProcessAdd()

add new Process

returns the id of the created process if success or undef otherwise

    my $ID = $ProcessDBObject->ProcessAdd(
        EntityID       => 'P1'             # mandatory, exportable unique identifier
        Name           => 'NameOfProcess', # mandatory
        StateEntityID  => 'S1',
        Layout         => $LayoutHashRef,  # mandatory, diagram objects positions to be stored in
                                           #   YAML format
        Config         => $ConfigHashRef,  # mandatory, process configuration to be stored in YAML
                                           #   format
        UserID         => 123,             # mandatory
    );

Returns:

    $ID = 567;

ProcessDelete()

delete a Process

returns 1 if success or undef otherwise

    my $Success = $ProcessDBObject->ProcessDelete(
        ID      => 123,
        UserID  => 123,
    );

ProcessGet()

get Process attributes

    my $Process = $ProcessDBObject->ProcessGet(
        ID              => 123,          # ID or EntityID is needed
        EntityID        => 'P1',
        ActivityNames   => 1,            # default 0, 1 || 0, if 0 returns an Activities array
                                         #     with the activity entity IDs, if 1 returns an
                                         #     Activities hash with the activity entity IDs as
                                         #     keys and Activity Names as values
        SequenceFlowNames => 1,          # default 0, 1 || 0, if 0 returns an Sequence Flows array
                                         #     with the sequence flow entity IDs, if 1 returns an
                                         #     SequenceFlows hash with the sequence flow entity IDs as
                                         #     keys and SequenceFlow Names as values
        SequenceFlowActionNames => 1,    # default 0, 1 || 0, if 0 returns an SequenceFlowActions array
                                         #     with the SequenceFlowAction entity IDs, if 1 returns an
                                         #     SequenceFlowAction hash with the SequenceFlowAction entity IDs as
                                         #     keys and SequenceFlowAction Names as values
        UserID          => 123,          # mandatory
    );

Returns:

    $Process = {
        ID            => 123,
        EntityID      => 'P1',
        Name          => 'some name',
        StateEntityID => 'S1',
        State         => 'Active',
        Layout        => $LayoutHashRef,
        Config        => $ConfigHashRef,
        Activities    => ['A1','A2','A3'],
        Activities    => ['T1','T2','T3'],
        CreateTime    => '2012-07-04 15:08:00',
        ChangeTime    => '2012-07-04 15:08:00',
    };

    $Process = {
        ID            => 123,
        EntityID      => 'P1',
        Name          => 'some name',
        StateEntityID => 'S1',
        State         => 'Active',
        Layout        => $LayoutHashRef,
        Config        => $ConfigHashRef,
        Activities    => {
            'A1' => 'Activity1',
            'A2' => 'Activity2',
            'A3' => 'Activity3',
        };
        SequenceFlows   => {
            'T1' => 'SequenceFlow1',
            'T2' => 'SequenceFlow2',
            'T3' => 'SequenceFlow3',
        };
        SequenceFlowActions => {
            'TA1' => 'SequenceFlowAction1',
            'TA2' => 'SequenceFlowAction2',
            'TA3' => 'SequenceFlowAction3',
        };
        CreateTime => '2012-07-04 15:08:00',
        ChangeTime => '2012-07-04 15:08:00',
    };

ProcessUpdate()

update Process attributes

returns 1 if success or undef otherwise

    my $Success = $ProcessDBObject->ProcessUpdate(
        ID            => 123,             # mandatory
        EntityID      => 'P1'             # mandatory, exportable unique identifier
        Name          => 'NameOfProcess', # mandatory
        StateentityID => 'S1',
        Layout        => $LayoutHashRef,  # mandatory, diagram objects positions to be stored in
                                          #   YAML format
        Config        => $ConfigHashRef,  # mandatory, process configuration to be stored in YAML
                                          #   format
        UserID        => 123,             # mandatory
    );

ProcessList()

get a Process list

    my $List = $ProcessDBObject->ProcessList(
        UseEntities     => 0,                   # default 0, 1 || 0. if 0 the return hash keys are
                                                #    the process IDs otherwise keys are the
                                                #    process entity IDs
        StateEntityIDs  => ['S1','S2'],         # optional, to filter processes that match listed
                                                #    state entity IDs
        UserID          => 1,
    );

    Returns:

    $List = {
        1 => 'NameOfProcess',
    }

    or

    $List = {
        'P1' => 'NameOfProcess',
    }

ProcessListGet()

get a Process list with all process details

    my $List = $ProcessDBObject->ProcessListGet(
        UserID      => 1,
    );

Returns:

    $List = [
        {
            ID            => 123,
            EntityID      => 'P1',
            Name          => 'some name',
            StateEntityID => 'S1',
            State         => 'Active',
            Layout        => $LayoutHashRef,
            Config        => $ConfigHashRef,
            Activities    => ['A1','A2','A3'],
            CreateTime    => '2012-07-04 15:08:00',
            ChangeTime    => '2012-07-04 15:08:00',
        },
        {
            ID            => 456,
            EntityID      => 'P2',
            Name          => 'some name',
            StateEntityID => 'S1',
            State         => 'Active',
            Layout        => $LayoutHashRef,
            Config        => $ConfigHashRef,
            Activities    => ['A3','A4','A5'],
            CreateTime    => '2012-07-04 15:10:00',
            ChangeTime    => '2012-07-04 15:10:00',
        },
    ];

ProcessSearch()

search processes by process name

    my $ProcessEntityIDs = $ProcessDBObject->ProcessSearch(
        ProcessName => 'SomeText',       # e. g. "SomeText*", "Some*ext" or ['*SomeTest1*', '*SomeTest2*']
    );

    Returns:

    $ProcessEntityIDs = [ 'Process-e11e2e9aa83344a235279d4f6babc6ec', 'Process-f8194a25ab0ccddefeb4240c281c1f56' ];

ProcessDump()

gets a complete processes information dump from the DB including: Process State, Activities, ActivityDialogs, SequenceFlows and SequenceFlowActions

    my $ProcessDump = $ProcessDBObject->ProcessDump(
        ResultType  => 'SCALAR'                     # 'SCALAR' || 'HASH'
        UserID      => 1,
    );

Returns:

    $ProcessDump = '
        $Self->{'Process'} = {
          'P1' => {
            'Name' => 'Process 1',
            'CreateTime' => '2012-07-21 08:11:33',
            'ChangeTime' => '2012-07-21 08:11:33',
            'Path' => {
              'A1' => {
                'T1' => {
                  'Action' => [
                    'TA1',
                  ],
              }
            },
            'StartActivity' => 'A1',
            'StartActivityDialog' => 'AD1',
            'State' => 'S1'
          },
          # ...
        };

        $Self->{'Process::State'} = {
          'S1' => 'Active',
          'S2' => 'Inactive',
          'S3' => 'FadeAway'
        };

        $Self->{'Process::Activity'} = {
          'A1' => {
            'Name' => 'Activity 1'
            'CreateTime' => '2012-07-21 08:11:33',
            'ChangeTime' => '2012-07-21 08:11:33',
            'ActivityDialog' => {
              '1' => 'AD1',
              }
            },
          },
          # ...
        };

        $Self->{'Process::ActivityDialog'} = {
          'AD1' => {
            'Name' => 'Activity Dialog 1',
            'CreateTime' => '2012-07-21 08:11:33',
            'ChangeTime' => '2012-07-21 08:11:33',
            'DescriptionLong' => 'Longer description',
            'DescriptionShort' => 'Short description',
            'FieldOrder' => [
              'StateID',
              'DynamicField_Marke',
            ],
            'Fields' => {
              'StateID' => {
                'DefaultValue' => '1',
                'DescriptionLong' => 'Longer description',
                'DescriptionShort' => 'Short description',
                'Display' => '0'
              },
              'DynamicField_Marke' => {
                'DescriptionLong' => 'Longer description',
                'DescriptionShort' => 'Short description',
                'Display' => '2'
              },
            },
            #...
        };

        $Self->{'Process::SequenceFlow'} = {
          'T1' => {
            'Name' => 'SequenceFlow 1'
            'ChangeTime' => '2012-07-21 08:11:33',
            'CreateTime' => '2012-07-21 08:11:33',
            'Condition' => {
              'Type' => 'and',
              'Cond1' => {
                'Fields' => {
                  'DynamicField_Marke' => {
                    'Match' => 'Teststring',
                    'Type' => 'String',
                  },
                },
                'Type' => 'and',
              },
            },
          },
          # ...
        };

        $Self->{'Process::Action'} = {
          'TA1' => {
            'Name' => 'Queue Move',
            'CreateTime' => '2012-07-21 08:11:33',
            'ChangeTime' => '2012-07-21 08:11:33',
            'Module' => 'Kernel::System::Process::SequenceFlow::Action::QueueMove',
            'Config' => {
              'NewOwner' => 'root@localhost',
              'TargetQueue' => 'Raw',
            },
          },
          # ...
        };
     ';

    my $ProcessDump = $ProcessDBObject->ProcessDump(
        ResultType  => 'HASH'                       # 'SCALAR' || 'HASH' || 'FILE'
        Location    => '/opt/otrs/var/myfile.txt'   # mandatory for ResultType = 'FILE'
        UserID      => 1,
    );

Returns:

    $ProcessDump = {
        Process => {
          'P1' => {
            'Name' => 'Process 1',
            'CreateTime' => '2012-07-21 08:11:33',
            'ChangeTime' => '2012-07-21 08:11:33',
            'Path' => {
              'A1' => {
                'T1' => {
                  'Action' => [
                    'TA1',
                  ],
              }
            },
            'StartActivity' => 'A1',
            'StartActivityDialog' => 'AD1',
            'State' => 'S1'
          },
          # ...
        };

        State => {
          'S1' => 'Active',
          'S2' => 'Inactive',
          'S3' => 'FadeAway'
        };

        Activity => {
          'A1' => {
            'Name' => 'Activity 1'
            'CreateTime' => '2012-07-21 08:11:33',
            'ChangeTime' => '2012-07-21 08:11:33',
            'ActivityDialog' => {
              '1' => 'AD1',
              }
            },
          },
          # ...
        };

        ActivityDialog => {
          'AD1' => {
            'Name' => 'Activity Dialog 1',
            'CreateTime' => '2012-07-21 08:11:33',
            'ChangeTime' => '2012-07-21 08:11:33',
            'DescriptionLong' => 'Longer description',
            'DescriptionShort' => 'Short description',
            'FieldOrder' => [
              'StateID',
              'DynamicField_Marke',
            ],
            'Fields' => {
              'StateID' => {
                'DefaultValue' => '1',
                'DescriptionLong' => 'Longer description',
                'DescriptionShort' => 'Short description',
                'Display' => '0'
              },
              'DynamicField_Marke' => {
                'DescriptionLong' => 'Longer description',
                'DescriptionShort' => 'Short description',
                'Display' => '2'
              },
            },
            #...
        };

        SequenceFlow => {
          'T1' => {
            'Name' => 'SequenceFlow 1'
            'ChangeTime' => '2012-07-21 08:11:33',
            'CreateTime' => '2012-07-21 08:11:33',
            'Condition' => {
              'Type' => 'and',
              'Cond1' => {
                'Fields' => {
                  'DynamicField_Marke' => {
                    'Match' => 'Teststring',
                    'Type' => 'String',
                  },
                },
                'Type' => 'and',
              },
            },
          },
          # ...
        };

        SequenceFlowAction => {
          'TA1' => {
            'Name' => 'Queue Move',
            'CreateTime' => '2012-07-21 08:11:33',
            'ChangeTime' => '2012-07-21 08:11:33',
            'Module' => 'Kernel::System::Process::SequenceFlow::Action::QueueMove',
            'Config' => {
              'NewOwner' => 'root@localhost',
              'TargetQueue' => 'Raw',
            },
          },
          # ...
        };
    }

ProcessImport()

import a process YAML file/content

    my %ProcessImport = $ProcessDBObject->ProcessImport(
        Content                   => $YAMLContent, # mandatory, YAML format
        OverwriteExistingEntities => 0,            # 0 || 1
        UserID                    => 1,            # mandatory
    );

Returns:

    %ProcessImport = (
        Message => 'The Message to show.', # error or success message
        Comment => 'Any comment',          # optional
        Success => 1,                      # 1 if success or undef otherwise
    );

ProcessDeploy()

Deploys Processes from DB to a perl file and stores deployment information back into the DB.

    my $DeploymentID = $ProcessDBObject->ProcessDeploy(
        UserID => 123,
    );

Returns:

    $DeploymentID = 123;        # or false in case of an error

ProcessDeploymentRead()

Reads deployment information from the written File.

    my %Deployment = $ProcessDBObject->ProcessDeploymentRead();

Returns:

    %Deployment = (
        Success            => 1,
        DeploymentUUID     => '14906327941360ed8455f125d0450277',
        EffectiveValueStrg => $ProcesEffectiveValues,             # string with the value of all settings,
                                                                  #   as seen in the Perl configuration file.
        Inode              => 8041482,
        ModifiedTime       => 1685422853,
        StatusTime         => 1685422853,
    );

ProcessDeploymentGet()

Gets deployment information.

    my %Deployment = $ProcessDBObject->ProcessDeploymentGet(
        DeploymentID   => 123,
        DeploymentUUID => '14906327941360ed8455f125d0450277',
    );

Returns:

    %Deployment = (
        DeploymentID       => 123,
        DeploymentUUID     => 14906327941360ed8455f125d0450277,
        EffectiveValueStrg => $ProcesEffectiveValues,      # String with the value of all Process,
                                                            #   as seen in the Perl cache file.
        CreateTime         => "2016-05-29 11:04:04",
        CreateBy           => 123,
    );

ProcessDeploymentListGet()

Get Process deployment list with complete data.

    my @List = $ProcessDBObject->ProcessDeploymentListGet();

Returns:

    @List = (
        {
            DeploymentID       => 123,
            DeploymentUUID     => 14906327941360ed8455f125d0450277,
            EffectiveValueStrg => $ProcesEffectiveValues,      # String with the value of all Process,
                                                            #   as seen in the Perl cache file.
            CreateTime         => "2016-05-29 11:04:04",
            CreateBy           => 123,
        },
        {
            DeploymentID       => 456,
            DeploymentUUID     => 14906327941360ed8455f125d0450288,
            EffectiveValueStrg => $ProcesEffectiveValues2,     # String with the value of all Process,
                                                            #   as seen in the Perl cache file.
            CreateTime         => "2016-05-29 12:00:01",
            CreateBy           => 123,
        },
        # ...
    );

ProcessDeploymentGetLast()

Get last last ACL deployment.

    my %Deployment = $ProcessDBObject->ProcessDeploymentGetLast();

Returns:

    %Deployment = (
        DeploymentID       => 123,
        DeploymentUUID     => 14906327941360ed8455f125d0450277,
        Comments           => 'Some Comments',
        EffectiveValueStrg => $SettingEffectiveValues,
        CreateTime         => "2016-05-29 11:04:04",
        CreateBy           => 123,
    );

ProcessDeploymentSync() Updates ZZZProcessManagement.pm to the latest deployment found in the database.

    my $Success = $ProcessDBObject->ProcessDeploymentSync();

ProcessDeploymentDelete()

Delete a deployment from the database.

    my $Success = $ProcessDBObject->ProcessDeploymentDelete(
        DeploymentID => 123,
    );

Returns:

    $Success = 1;       # or false in case of an error

ProcessDeploymentCleanup()

Cleanup old deployments from the database.

    my $Success = $ProcessDBObject->ProcessDeploymentCleanup();

Returns:

    $Success = 1;       # or false in case of an error

_FileWriteAtomic()

Writes a file in an atomic operation. This is achieved by creating a temporary file, filling and renaming it. This avoids inconsistent states when the file is updated.

    my $Success = $ProcessDBObject->_FileWriteAtomic(
        Filename => "$Self->{Home}/Kernel/Config/Files/ZZZProcessManagement.pm",
        Content  => \$NewContent,
    );
Scroll to Top