<commit_before># --
# Kernel/System/Ticket/State.pm - the sub module of the global Ticket.pm handle
# Copyright (C) 2001-2003 <NAME> <<EMAIL>>
# --
# $Id: State.pm,v 1.14 2003-04-12 22:06:21 martin Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --
package Kernel::System::Ticket::State;

use strict;

use vars qw($VERSION);
$VERSION = '$Revision: 1.14 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;

# --
sub GetState {
    my $Self = shift;
    my %Param = @_;
    my $State = '';
    # --
    # check needed stuff
    # --
    if (!$Param{TicketID}) {
      $Self->{LogObject}->Log(Priority => 'error', Message => "Need TicketID!");
      return;
    }
    my %TicketData = $Self->GetTicket(%Param);
    if ($TicketData{State}) {
        return $TicketData{State};
    }
    else {
        return;
    }
}
# --
sub StateLookup {
    my $Self = shift;
    my %Param = @_;
    my $State = $Param{State};
    # --
    # check needed stuff
    # --
    if (!$Param{State}) {
      $Self->{LogObject}->Log(Priority => 'error', Message => "Need State!");
      return;
    }
    # --
    # check if we ask the same request?
    # --
    if (exists $Self->{"Ticket::State::StateLookup::$State"}) {
        return $Self->{"Ticket::State::StateLookup::$State"};
    }
    # --
    # get data
    # --
    my $SQL = "SELECT id " .
    " FROM " .
    " ticket_state " .
    " WHERE " .
    " name = '$State'";
    $Self->{DBObject}->Prepare(SQL => $SQL);
    while (my @Row = $Self->{DBObject}->FetchrowArray()) {
        # store result
        $Self->{"Ticket::State::StateLookup::$State"} = $Row[0];
    }
    # --
    # check if data exists
    # --
    if (!exists $Self->{"Ticket::State::StateLookup::$State"}) {
        $Self->{LogObject}->Log(Priority => 'error', Message => "No StateID for $State found!");
        return;
    }

    return $Self->{"Ticket::State::StateLookup::$State"};
}
# --
sub StateIDLookup {
    my $Self = shift;
    my %Param = @_;
    my $StateID = $Param{StateID} || '';
    # --
    # check needed stuff
    # --
    if (!$Param{StateID}) {
      $Self->{LogObject}->Log(Priority => 'error', Message => "Need StateID!");
      return;
    }
    # --
    # check if we ask the same request?
    # --
    if (exists $Self->{"Ticket::State::StateLookupID::$StateID"}) {
        return $Self->{"Ticket::State::StateLookupID::$StateID"};
    }
    # --
    # get data 
    # --
    my $SQL = "SELECT name " .
    " FROM " .
    " ticket_state " .
    " WHERE " .
    " id = $StateID";
    $Self->{DBObject}->Prepare(SQL => $SQL);
    while (my @RowTmp = $Self->{DBObject}->FetchrowArray()) {
        # store result
        $Self->{"Ticket::State::StateLookupID::$StateID"} = $RowTmp[0];
    }
    # --
    # check if data exists
    # --
    if (!exists $Self->{"Ticket::State::StateLookupID::$StateID"}) {
        $Self->{LogObject}->Log(Priority => 'error', Message => "No State for $StateID found!");
        return;
    }

    return $Self->{"Ticket::State::StateLookupID::$StateID"};
}
# --
sub SetState {
    my $Self = shift;
    my %Param = @_;
    my $ArticleID = $Param{ArticleID} || '';
    # --
    # check needed stuff
    # --
    foreach (qw(TicketID UserID)) {
      if (!$Param{$_}) {
        $Self->{LogObject}->Log(Priority => 'error', Message => "Need $_!");
        return;
      }
    }
    if (!$Param{State} && !$Param{StateID}) {
        $Self->{LogObject}->Log(Priority => 'error', Message => "Need StateID or State!");
        return;
    }
    # --
    # state id lookup
    # --
    if (!$Param{StateID}) {
      $Param{StateID} = $Self->StateLookup(State => $Param{State}) || return;
    }
    # --
    # state lookup
    # --
    if (!$Param{State}) {
      $Param{State} = $Self->StateIDLookup(StateID => $Param{StateID}) || return;
    } 
    # --
    # check if update is needed
    # --
    my $CurrentState = $Self->GetState(TicketID => $Param{TicketID});
    if ($Param{State} eq $CurrentState) {
      # update is not needed
      return 1;
    }<commit_msg>removed StateIDLookup() and StateLookup() - not longer needed<commit_after># --
# Kernel/System/Ticket/State.pm - the sub module of the global Ticket.pm handle
# Copyright (C) 2001-2003 <NAME> <<EMAIL>>
# --
# $Id: State.pm,v 1.15 2003-07-10 02:26:57 martin Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --
package Kernel::System::Ticket::State;

use strict;

use vars qw($VERSION);
$VERSION = '$Revision: 1.15 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;

# --
sub GetState {
    my $Self = shift;
    my %Param = @_;
    my $State = '';
    # --
    # check needed stuff
    # --
    if (!$Param{TicketID}) {
      $Self->{LogObject}->Log(Priority => 'error', Message => "Need TicketID!");
      return;
    }
    my %TicketData = $Self->GetTicket(%Param);
    if ($TicketData{State}) {
        return $TicketData{State};
    }
    else {
        return;
    }
}
# --
sub SetState {
    my $Self = shift;
    my %Param = @_;
    my $ArticleID = $Param{ArticleID} || '';
    # --
    # check needed stuff
    # --
    foreach (qw(TicketID UserID)) {
      if (!$Param{$_}) {
        $Self->{LogObject}->Log(Priority => 'error', Message => "Need $_!");
        return;
      }
    }
    if (!$Param{State} && !$Param{StateID}) {
        $Self->{LogObject}->Log(Priority => 'error', Message => "Need StateID or State!");
        return;
    }
    # --
    # state id lookup
    # --
    if (!$Param{StateID}) {
        my %State = $Self->{StateObject}->StateGet(Name => $Param{State});
        $Param{StateID} = $State{ID} || return;
    }
    # --
    # state lookup
    # --
    if (!$Param{State}) {
        my %State = $Self->{StateObject}->StateGet(ID => $Param{StateID});
        $Param{State} = $State{Name} || return;
    } 
    # --
    # check if update is needed
    # --
    my $CurrentState = $Self->GetState(TicketID => $Param{TicketID});
    if ($Param{State} eq $CurrentState) {
      # update is not needed
      return 1;
    }
{'fraction_non_alphanumeric': 0.19809372517871326, 'fraction_numerical': 0.009849086576648134, 'mean_word_length': 2.3347457627118646, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5975249', 'n_tokens_mistral': 2211, 'n_tokens_neox': 2159, 'n_words': 476}