summaryrefslogtreecommitdiffstats
path: root/extensions/BzAPI/lib/Constants.pm
blob: fb611aae6427c510d19f459e3444ebed4291e057 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.

package Bugzilla::Extension::BzAPI::Constants;

use 5.10.1;
use strict;
use warnings;

use base qw(Exporter);
our @EXPORT = qw(
    USER_FIELDS
    BUG_FIELD_MAP
    BOOLEAN_TYPE_MAP
    ATTACHMENT_FIELD_MAP
    DEFAULT_BUG_FIELDS
    DEFAULT_ATTACHMENT_FIELDS

    BZAPI_DOC
);

# These are fields that are normally exported as a single value such
# as the user's email. BzAPI needs to convert them to user objects
# where possible.
use constant USER_FIELDS => (qw(
    assigned_to
    cc
    creator
    qa_contact
    reporter
));

# Convert old field names from old to new
use constant BUG_FIELD_MAP => {
    'opendate'            => 'creation_time', # query
    'creation_ts'         => 'creation_time',
    'changeddate'         => 'last_change_time', # query
    'delta_ts'            => 'last_change_time',
    'bug_id'              => 'id',
    'rep_platform'        => 'platform',
    'bug_severity'        => 'severity',
    'bug_status'          => 'status',
    'short_desc'          => 'summary',
    'bug_file_loc'        => 'url',
    'status_whiteboard'   => 'whiteboard',
    'reporter'            => 'creator',
    'reporter_realname'   => 'creator_realname',
    'cclist_accessible'   => 'is_cc_accessible',
    'reporter_accessible' => 'is_creator_accessible',
    'everconfirmed'       => 'is_confirmed',
    'dependson'           => 'depends_on',
    'blocked'             => 'blocks',
    'attachment'          => 'attachments',
    'flag'                => 'flags',
    'flagtypes.name'      => 'flag',
    'bug_group'           => 'group',
    'group'               => 'groups',
    'longdesc'            => 'comment',
    'bug_file_loc_type'   => 'url_type',
    'bugidtype'           => 'id_mode',
    'longdesc_type'       => 'comment_type',
    'short_desc_type'     => 'summary_type',
    'status_whiteboard_type' => 'whiteboard_type',
    'emailassigned_to1'   => 'email1_assigned_to',
    'emailassigned_to2'   => 'email2_assigned_to',
    'emailcc1'            => 'email1_cc',
    'emailcc2'            => 'email2_cc',
    'emailqa_contact1'    => 'email1_qa_contact',
    'emailqa_contact2'    => 'email2_qa_contact',
    'emailreporter1'      => 'email1_creator',
    'emailreporter2'      => 'email2_creator',
    'emaillongdesc1'      => 'email1_comment_creator',
    'emaillongdesc2'      => 'email2_comment_creator',
    'emailtype1'          => 'email1_type',
    'emailtype2'          => 'email2_type',
    'chfieldfrom'         => 'changed_after',
    'chfieldto'           => 'changed_before',
    'chfield'             => 'changed_field',
    'chfieldvalue'        => 'changed_field_to',
    'deadlinefrom'        => 'deadline_after',
    'deadlineto'          => 'deadline_before',
    'attach_data.thedata' => 'attachment.data',
    'longdescs.isprivate' => 'comment.is_private',
    'commenter'           => 'comment.creator',
    'requestees.login_name' => 'flag.requestee',
    'setters.login_name'  => 'flag.setter',
    'days_elapsed'        => 'idle',
    'owner_idle_time'     => 'assignee_idle',
    'dup_id'              => 'dupe_of',
    'isopened'            => 'is_open',
    'flag_type'           => 'flag_types',
    'attachments.submitter'   => 'attachment.attacher',
    'attachments.filename'    => 'attachment.file_name',
    'attachments.description' => 'attachment.description',
    'attachments.delta_ts'    => 'attachment.last_change_time',
    'attachments.isobsolete'  => 'attachment.is_obsolete',
    'attachments.ispatch'     => 'attachment.is_patch',
    'attachments.isprivate'   => 'attachment.is_private',
    'attachments.mimetype'    => 'attachment.content_type',
    'attachments.date'        => 'attachment.creation_time',
    'attachments.attachid'    => 'attachment.id',
    'attachments.flag'        => 'attachment.flags',
    'attachments.token'       => 'attachment.update_token'
};

# Convert from old boolean chart type names to new names
use constant BOOLEAN_TYPE_MAP => {
    'equals'                 => 'equals',
    'not_equals'             => 'notequals',
    'equals_any'             => 'anyexact',
    'contains'               => 'substring',
    'not_contains'           => 'notsubstring',
    'case_contains'          => 'casesubstring',
    'contains_any'           => 'anywordssubstr',
    'not_contains_any'       => 'nowordssubstr',
    'contains_all'           => 'allwordssubstr',
    'contains_any_words'     => 'anywords',
    'not_contains_any_words' => 'nowords',
    'contains_all_words'     => 'allwords',
    'regex'                  => 'regexp',
    'not_regex'              => 'notregexp',
    'less_than'              => 'lessthan',
    'greater_than'           => 'greaterthan',
    'changed_before'         => 'changedbefore',
    'changed_after'          => 'changedafter',
    'changed_from'           => 'changedfrom',
    'changed_to'             => 'changedto',
    'changed_by'             => 'changedby',
    'matches'                => 'matches'
};

# Convert old attachment field names from old to new
use constant ATTACHMENT_FIELD_MAP => {
    'submitter'   => 'attacher',
    'description' => 'description',
    'filename'    => 'file_name',
    'delta_ts'    => 'last_change_time',
    'isobsolete'  => 'is_obsolete',
    'ispatch'     => 'is_patch',
    'isprivate'   => 'is_private',
    'mimetype'    => 'content_type',
    'contenttypeentry' => 'content_type',
    'date'        => 'creation_time',
    'attachid'    => 'id',
    'desc'        => 'description',
    'flag'        => 'flags',
    'type'        => 'content_type',
};

# A base link to the current BzAPI Documentation.
use constant BZAPI_DOC => 'https://wiki.mozilla.org/Bugzilla:BzAPI';

1;