[otrs-cvs] ITSMConfigItem/Kernel/System/ITSMConfigItem Version.pm, 1.39, 1.40
CVS commits notifications of OTRS.org
cvs-log at otrs.org
Fri May 2 19:37:08 GMT 2008
Comments:
Update of /home/cvs/ITSMConfigItem/Kernel/System/ITSMConfigItem
In directory lancelot:/tmp/cvs-serv6682/Kernel/System/ITSMConfigItem
Modified Files:
Version.pm
Log Message:
Fixed bug# 2841 - NameSearch fails in the VersionSearch() function.
Author: mh
Index: Version.pm
===================================================================
RCS file: /home/cvs/ITSMConfigItem/Kernel/System/ITSMConfigItem/Version.pm,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** Version.pm 26 Apr 2008 11:58:16 -0000 1.39
--- Version.pm 2 May 2008 19:37:03 -0000 1.40
***************
*** 160,163 ****
--- 160,164 ----
$Version{ClassID}
$Version{Class}
+ $Version{LastVersionID}
$Version{Name}
$Version{DefinitionID}
***************
*** 283,288 ****
--- 284,300 ----
Cache => 0,
);
+
+ # check config item data
+ if ( !$ConfigItem || ref $ConfigItem ne 'HASH' ) {
+ $Self->{LogObject}->Log(
+ Priority => 'error',
+ Message => "Can't get config item $Version{ConfigItemID}!",
+ );
+ return;
+ }
+
$Version{ClassID} = $ConfigItem->{ClassID};
$Version{Class} = $ConfigItem->{Class};
+ $Version{LastVersionID} = $ConfigItem->{LastVersionID};
$Version{Number} = $ConfigItem->{Number};
$Version{CurDeplStateID} = $ConfigItem->{CurDeplStateID};
***************
*** 457,462 ****
}
# add xml data
! if ( $VersionID && $Param{XMLData} && ref $Param{XMLData} eq 'ARRAY' ) {
$Self->_XMLVersionAdd(
ClassID => $ConfigItem->{ClassID},
--- 469,483 ----
}
+ # check version id
+ if ( !$VersionID ) {
+ $Self->{LogObject}->Log(
+ Priority => 'error',
+ Message => "Can't get the new version id!",
+ );
+ return;
+ }
+
# add xml data
! if ( $Param{XMLData} && ref $Param{XMLData} eq 'ARRAY' ) {
$Self->_XMLVersionAdd(
ClassID => $ConfigItem->{ClassID},
***************
*** 467,473 ****
}
! # update cur_depl_state_id, cur_inci_state_id, change_time and change_by
$Self->{DBObject}->Do(
! SQL => "UPDATE configitem SET cur_depl_state_id = $Param{DeplStateID}, "
. "cur_inci_state_id = $Param{InciStateID}, "
. "change_time = '$CreateTime', change_by = $Param{UserID} "
--- 488,495 ----
}
! # update last_version_id, cur_depl_state_id, cur_inci_state_id, change_time and change_by
$Self->{DBObject}->Do(
! SQL => "UPDATE configitem SET last_version_id = $VersionID,"
! . "cur_depl_state_id = $Param{DeplStateID}, "
. "cur_inci_state_id = $Param{InciStateID}, "
. "change_time = '$CreateTime', change_by = $Param{UserID} "
***************
*** 506,510 ****
# check needed stuff
if ( !$Param{UserID} ) {
! $Self->{LogObject}->Log( Priority => 'error', Message => "Need UserID!" );
return;
}
--- 528,535 ----
# check needed stuff
if ( !$Param{UserID} ) {
! $Self->{LogObject}->Log(
! Priority => 'error',
! Message => "Need UserID!",
! );
return;
}
***************
*** 525,529 ****
# get version list
! my $VersionList = $Self->VersionList(
ConfigItemID => $Param{ConfigItemID},
);
--- 550,554 ----
# get version list
! $VersionList = $Self->VersionList(
ConfigItemID => $Param{ConfigItemID},
);
***************
*** 535,539 ****
for my $VersionID ( @{$VersionList} ) {
$Self->_XMLVersionDelete(
! VersionID => $Param{VersionID},
UserID => $Param{UserID},
);
--- 560,564 ----
for my $VersionID ( @{$VersionList} ) {
$Self->_XMLVersionDelete(
! VersionID => $VersionID,
UserID => $Param{UserID},
);
***************
*** 556,567 ****
=item VersionSearch()
! return a config item list as array reference
! my $ConfigItemListRef = $ConfigItemObject->VersionSearch(
ClassIDs => [ 9, 8, 7, 6 ], # (optional)
DeplStateIDs => [ 321, 123 ], # (optional)
InciStateIDs => [ 321, 123 ], # (optional)
! Name => 'The Name', # (optional)
! PreviousVersionSearch => 1, # (optional) default 0 (0|1)
);
--- 581,599 ----
=item VersionSearch()
! return a config item list as an array reference
! my $ConfigItemIDs = $ConfigItemObject->VersionSearch(
! Name => 'The Name', # (optional)
ClassIDs => [ 9, 8, 7, 6 ], # (optional)
DeplStateIDs => [ 321, 123 ], # (optional)
InciStateIDs => [ 321, 123 ], # (optional)
!
! PreviousVersionSearch => 1, # (optional) default 0 (0|1)
!
! OrderBy => 'Name', # (optional) default ConfigItemID
! # (ConfigItemID, Name, ClassID, DeplStateID, InciStateID)
!
! Limit => 122, # (optional)
! UsingWildcards => 0, # (optional) default 1
);
***************
*** 571,587 ****
my ( $Self, %Param ) = @_;
! # sql where array
! my @SQLWhere;
# add name to sql where array
if ( $Param{Name} ) {
# quote
! $Param{Name} = $Self->{DBObject}->Quote( $Param{Name} );
! # prepare like string
! $Self->_PrepareLikeString( \$Param{Name} );
! push @SQLWhere, "vr.name LIKE '$Param{Name}'";
}
--- 603,632 ----
my ( $Self, %Param ) = @_;
! # set default values
! if ( !defined $Param{UsingWildcards} ) {
! $Param{UsingWildcards} = 1;
! }
! $Param{OrderBy} ||= 'id';
# add name to sql where array
+ my @SQLWhere;
if ( $Param{Name} ) {
+ # duplicate the name
+ my $Name = $Param{Name};
+
# quote
! $Name = $Self->{DBObject}->Quote($Name);
! if ( $Param{UsingWildcards} ) {
! # prepare like string
! $Self->_PrepareLikeString( \$Name );
!
! push @SQLWhere, "vr.name LIKE '$Name'";
! }
! else {
! push @SQLWhere, "vr.name = '$Name'";
! }
}
***************
*** 597,601 ****
next ARRAYPARAM if !$Param{$ArrayParam};
! next ARRAYPARAM if ref $Param{$ArrayParam} ne 'ARRAY';
next ARRAYPARAM if !@{ $Param{$ArrayParam} };
--- 642,654 ----
next ARRAYPARAM if !$Param{$ArrayParam};
!
! if ( ref $Param{$ArrayParam} ne 'ARRAY' ) {
! $Self->{LogObject}->Log(
! Priority => 'error',
! Message => "$ArrayParam must be an array reference!",
! );
! return;
! }
!
next ARRAYPARAM if !@{ $Param{$ArrayParam} };
***************
*** 611,618 ****
}
# create where string
! my $WhereString = '';
! if (@SQLWhere) {
! $WhereString = ' WHERE ' . join q{ AND }, @SQLWhere;
}
--- 664,690 ----
}
+ # add previous version param
+ if ( !$Param{PreviousVersionSearch} ) {
+ push @SQLWhere, 'ci.last_version_id = vr.id';
+ }
+
# create where string
! my $WhereString = @SQLWhere ? ' WHERE ' . join q{ AND }, @SQLWhere : '';
!
! # define order table
! my %OrderByTable = (
! ConfigItemID => 'vr.configitem_id',
! Name => 'vr.name',
! ClassID => 'ci.class_id',
! DeplStateID => 'vr.depl_state_id',
! InciStateID => 'vr.inci_state_id',
! );
!
! # set order by
! my $OrderBy = $OrderByTable{ $Param{OrderBy} } || $OrderByTable{ConfigItemID};
!
! # set limit
! if ( $Param{Limit} ) {
! $Param{Limit} = $Self->{DBObject}->Quote( $Param{Limit}, 'Integer' );
}
***************
*** 621,625 ****
SQL => "SELECT DISTINCT(vr.configitem_id) "
. "FROM configitem ci, configitem_version vr "
! . "$WhereString ",
);
--- 693,698 ----
SQL => "SELECT DISTINCT(vr.configitem_id) "
. "FROM configitem ci, configitem_version vr "
! . "$WhereString ORDER BY $OrderBy ASC",
! Limit => $Param{Limit},
);
***************
*** 627,712 ****
my @ConfigItemList;
while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
! push( @ConfigItemList, $Row[0] );
! }
!
! return \@ConfigItemList if $Param{PreviousVersionSearch};
!
! # push ids in temp hash
! my %ConfigItemListTmp;
! for my $ConfigItemID (@ConfigItemList) {
! $ConfigItemListTmp{$ConfigItemID} = 1;
! }
!
! CONFIGITEMID:
! for my $ConfigItemID (@ConfigItemList) {
!
! # get last version
! my $LastVersion = $Self->VersionGet(
! ConfigItemID => $ConfigItemID,
! );
!
! # check name in last version
! if ( $Param{Name} ) {
!
! my $Name = $Param{Name};
! $Name =~ s/\*/.*/g;
!
! if ( $LastVersion->{Name} !~ /$Name/ ) {
! delete $ConfigItemListTmp{$ConfigItemID};
! next CONFIGITEMID;
! }
! }
!
! # check deployment state ids in last version
! if (
! $Param{DeplStateIDs}
! && ref $Param{DeplStateIDs} eq 'ARRAY'
! && @{ $Param{DeplStateIDs} }
! )
! {
! my $Exists = 0;
!
! DEPLSTATEID:
! for my $DeplStateID ( @{ $Param{DeplStateIDs} } ) {
!
! next DEPLSTATEID if $LastVersion->{DeplStateID} ne $DeplStateID;
!
! $Exists = 1;
! last DEPLSTATEID;
! }
!
! if ( !$Exists ) {
! delete $ConfigItemListTmp{$ConfigItemID};
! next CONFIGITEMID;
! }
! }
!
! # check incident state ids in last version
! if (
! $Param{InciStateIDs}
! && ref $Param{InciStateIDs} eq 'ARRAY'
! && @{ $Param{InciStateIDs} }
! )
! {
! my $Exists = 0;
!
! INCISTATEID:
! for my $InciStateID ( @{ $Param{InciStateIDs} } ) {
!
! next INCISTATEID if $LastVersion->{InciStateID} ne $InciStateID;
!
! $Exists = 1;
! last INCISTATEID;
! }
!
! if ( !$Exists ) {
! delete $ConfigItemListTmp{$ConfigItemID};
! next INCISTATEID;
! }
! }
}
- @ConfigItemList = keys %ConfigItemListTmp;
-
return \@ConfigItemList;
}
--- 700,706 ----
my @ConfigItemList;
while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
! push @ConfigItemList, $Row[0];
}
return \@ConfigItemList;
}
More information about the cvs-log
mailing list