RSS

(root)/bugzilla/trunk : 7765 : Bugzilla/Search/Condition.pm

To get this branch, use:
bzr branch /bugzilla/trunk

« back to all changes in this revision

Viewing changes to Bugzilla/Search/Condition.pm

Max Kanat-Alexander
2011-04-02 09:49:04
Revision ID: mkanat@bugzilla.org-20110402164904-w1uh59wtyzd83qs7
Bug 640045: Convert Search.pm to use the new AND/OR system internally.
This includes creating new Search::Clause and Search::Condition objects.
r=mkanat, a=mkanat (module owner)

Show diffs side-by-side

added added

removed removed

 
1
# -*- Mode: perl; indent-tabs-mode: nil -*-
 
2
#
 
3
# The contents of this file are subject to the Mozilla Public
 
4
# License Version 1.1 (the "License"); you may not use this file
 
5
# except in compliance with the License. You may obtain a copy of
 
6
# the License at http://www.mozilla.org/MPL/
 
7
#
 
8
# Software distributed under the License is distributed on an "AS
 
9
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
10
# implied. See the License for the specific language governing
 
11
# rights and limitations under the License.
 
12
#
 
13
# The Original Code is the Bugzilla Bug Tracking System.
 
14
#
 
15
# The Initial Developer of the Original Code is BugzillaSource, Inc.
 
16
# Portions created by the Initial Developer are Copyright (C) 2011 the
 
17
# Initial Developer. All Rights Reserved.
 
18
#
 
19
# Contributor(s):
 
20
#   Max Kanat-Alexander <mkanat@bugzilla.org>
 
21
 
 
22
package Bugzilla::Search::Condition;
 
23
use strict;
 
24
use base qw(Exporter);
 
25
our @EXPORT_OK = qw(condition);
 
26
 
 
27
sub new {
 
28
    my ($class, $params) = @_;
 
29
    my %self = %$params;
 
30
    bless \%self, $class;
 
31
    return \%self;
 
32
}
 
33
 
 
34
sub field    { return $_[0]->{field}    }
 
35
sub operator { return $_[0]->{operator} }
 
36
sub value    { return $_[0]->{value}    }
 
37
 
 
38
sub fov {
 
39
    my ($self) = @_;
 
40
    return ($self->field, $self->operator, $self->value);
 
41
}
 
42
 
 
43
sub translated {
 
44
    my ($self, $params) = @_;
 
45
    if (@_ == 2) {
 
46
        $self->{translated} = $params;
 
47
    }
 
48
    return $self->{translated};
 
49
}
 
50
 
 
51
sub as_string {
 
52
    my ($self) = @_;
 
53
    return $self->translated->{term};
 
54
}
 
55
 
 
56
###########################
 
57
# Convenience Subroutines #
 
58
###########################
 
59
 
 
60
sub condition {
 
61
    my ($field, $operator, $value) = @_;
 
62
    return __PACKAGE__->new({ field => $field, operator => $operator,
 
63
                              value => $value });
 
64
}
 
65
 
 
66
1;
 
 
'\\ No newline at end of file'

Loggerhead 1.18.1 is a web-based interface for Bazaar branches