From 933fe72425f6e657c152950246735370f0f06dcf Mon Sep 17 00:00:00 2001 From: rojanu Date: Fri, 15 Jan 2016 14:40:10 +0000 Subject: Bug 922549: Bugzilla::Migrate.pm should provide hook in load function. r=gerv. --- extensions/Example/Extension.pm | 6 ++ extensions/Example/lib/Migrate/ImportBugs.pm | 102 +++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 extensions/Example/lib/Migrate/ImportBugs.pm (limited to 'extensions/Example') diff --git a/extensions/Example/Extension.pm b/extensions/Example/Extension.pm index 1649957fd..ad96066f7 100644 --- a/extensions/Example/Extension.pm +++ b/extensions/Example/Extension.pm @@ -635,6 +635,12 @@ sub mailer_before_send { $email->header_set('X-Bugzilla-Example-Header', 'Example'); } +sub migrate_modules { + my ($self, $args) = @_; + $args->{path} = bz_locations->{'extensionsdir'} . "/Example/lib/Migrate"; + $args->{prefix} = "Bugzilla::Extension::Example:Migrate"; +} + sub object_before_create { my ($self, $args) = @_; diff --git a/extensions/Example/lib/Migrate/ImportBugs.pm b/extensions/Example/lib/Migrate/ImportBugs.pm new file mode 100644 index 000000000..42a393c73 --- /dev/null +++ b/extensions/Example/lib/Migrate/ImportBugs.pm @@ -0,0 +1,102 @@ +# 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. + + +=head1 NAME + +Bugzilla::Extension::Example::Migrate::ImportBugs - Bugzilla example bug importer + +=head1 DESCRIPTION + +This is not a complete implementation of a Import module. For a working +implementation see L. + +=cut + +package Bugzilla::Extension::Example::Migrate::ImportBugs; +use strict; +use base qw(Bugzilla::Migrate); + +use Bugzilla::Constants; +use Bugzilla::Install::Util qw(indicate_progress); +use Bugzilla::Util qw(format_time trim generate_random_password); + +use constant REQUIRED_MODULES => [ + { + package => 'Email-Simple-FromHandle', + module => 'Email::Simple::FromHandle', + version => 0.050, + }, +]; + +use constant FIELD_MAP => { + 'Number' => 'bug_id', + 'Category' => 'product', +}; + +use constant VALUE_MAP => { + bug_severity => { + 'serious' => 'major', + 'non-critical' => 'normal', + }, + bug_status => { + 'feedback' => 'RESOLVED', + 'released' => 'VERIFIED', + }, +}; + +use constant IMPORTBUGS_CONFIG_VARS => ( + { + name => 'default_email_domain', + default => 'example.com', + desc => <<'END', +# Some users do not have full email addresses, but Bugzilla requires +# every user to have an email address. What domain should be appended to +# usernames that don't have emails, to make them into email addresses? +# (For example, if you leave this at the default, "unknown" would become +# "unknown@example.com".) +END + }, +); + +######### +# Hooks # +######### + +sub before_insert { + my $self = shift; +} + +######### +# Users # +######### + +sub _read_users { + my $self = shift; +} + +############ +# Products # +############ + +sub _read_products { + my $self = shift; +} + +################ +# Reading Bugs # +################ + +sub _read_bugs { + my $self = shift; +} + +sub _parse_project { + my ($self, $directory) = @_; +} + +1; -- cgit v1.2.3-24-g4f1b