Fix building SQL for ExistsInFileSystem PostCondition. Fix how we turn the rows into Event objects. Fix value handling in ExistsInFileSystem post condition.
This commit is contained in:
parent
cd3359c3eb
commit
248ca9a5f9
|
@ -127,9 +127,11 @@ sub Execute {
|
||||||
foreach my $term ( @{$$self{PostSQLConditions}} ) {
|
foreach my $term ( @{$$self{PostSQLConditions}} ) {
|
||||||
if ( $$term{attr} eq 'ExistsInFileSystem' ) {
|
if ( $$term{attr} eq 'ExistsInFileSystem' ) {
|
||||||
foreach my $row ( @results ) {
|
foreach my $row ( @results ) {
|
||||||
my $event = new ZoneMinder::Event($row);
|
my $event = new ZoneMinder::Event($$row{Id}, $row);
|
||||||
if ( -e $event->Path() ) {
|
if ( -e $event->Path() ) {
|
||||||
push @filtered_events, $row;
|
push @filtered_events, $row if $$term{val} eq 'true';
|
||||||
|
} else {
|
||||||
|
push @filtered_events, $row if $$term{val} eq 'false';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,9 +166,14 @@ sub Sql {
|
||||||
if ( exists($term->{obr}) ) {
|
if ( exists($term->{obr}) ) {
|
||||||
$self->{Sql} .= str_repeat('(', $term->{obr}).' ';
|
$self->{Sql} .= str_repeat('(', $term->{obr}).' ';
|
||||||
}
|
}
|
||||||
|
if (!$term->{attr}) {
|
||||||
|
Error("Invalid term in filter $$self{Id}. Empty attr");
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
my $value = $term->{val};
|
my $value = $term->{val};
|
||||||
my @value_list;
|
my @value_list;
|
||||||
if ( $term->{attr} ) {
|
|
||||||
if ( $term->{attr} eq 'AlarmedZoneId' ) {
|
if ( $term->{attr} eq 'AlarmedZoneId' ) {
|
||||||
$term->{op} = 'EXISTS';
|
$term->{op} = 'EXISTS';
|
||||||
} elsif ( $term->{attr} =~ /^Monitor/ ) {
|
} elsif ( $term->{attr} =~ /^Monitor/ ) {
|
||||||
|
@ -182,7 +189,7 @@ sub Sql {
|
||||||
$self->{Sql} .= '(SELECT Storage.ServerId FROM Storage WHERE Storage.Id=E.StorageId)';
|
$self->{Sql} .= '(SELECT Storage.ServerId FROM Storage WHERE Storage.Id=E.StorageId)';
|
||||||
} elsif ( $term->{attr} eq 'FilterServerId' ) {
|
} elsif ( $term->{attr} eq 'FilterServerId' ) {
|
||||||
$self->{Sql} .= $Config{ZM_SERVER_ID};
|
$self->{Sql} .= $Config{ZM_SERVER_ID};
|
||||||
# StartTime options
|
# StartTime options
|
||||||
} elsif ( $term->{attr} eq 'DateTime' ) {
|
} elsif ( $term->{attr} eq 'DateTime' ) {
|
||||||
$self->{Sql} .= 'E.StartDateTime';
|
$self->{Sql} .= 'E.StartDateTime';
|
||||||
} elsif ( $term->{attr} eq 'Date' ) {
|
} elsif ( $term->{attr} eq 'Date' ) {
|
||||||
|
@ -194,7 +201,7 @@ sub Sql {
|
||||||
} elsif ( $term->{attr} eq 'Weekday' or $term->{attr} eq 'StartWeekday' ) {
|
} elsif ( $term->{attr} eq 'Weekday' or $term->{attr} eq 'StartWeekday' ) {
|
||||||
$self->{Sql} .= 'weekday( E.StartDateTime )';
|
$self->{Sql} .= 'weekday( E.StartDateTime )';
|
||||||
|
|
||||||
# EndTIme options
|
# EndTIme options
|
||||||
} elsif ( $term->{attr} eq 'EndDateTime' ) {
|
} elsif ( $term->{attr} eq 'EndDateTime' ) {
|
||||||
$self->{Sql} .= 'E.EndDateTime';
|
$self->{Sql} .= 'E.EndDateTime';
|
||||||
} elsif ( $term->{attr} eq 'EndDate' ) {
|
} elsif ( $term->{attr} eq 'EndDate' ) {
|
||||||
|
@ -295,7 +302,6 @@ sub Sql {
|
||||||
}
|
}
|
||||||
push @value_list, $value;
|
push @value_list, $value;
|
||||||
} # end foreach temp_value
|
} # end foreach temp_value
|
||||||
} # end if has an attr
|
|
||||||
|
|
||||||
if ( $term->{op} ) {
|
if ( $term->{op} ) {
|
||||||
if ( $term->{op} eq '=~' ) {
|
if ( $term->{op} eq '=~' ) {
|
||||||
|
|
Loading…
Reference in New Issue