ghendricks%novell.com ab3a43f6a6 Sync with 2431
git-svn-id: svn://10.0.0.236/trunk@216268 18797224-902f-48f8-a5cc-f745e15eee43
2006-12-01 18:06:58 +00:00

268 lines
5.0 KiB
Perl

# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
# Dallas Harken <dharken@novell.com>
package Bugzilla::WebService::Testopia::TestPlan;
use strict;
use base qw(Bugzilla::WebService);
use Bugzilla::Constants;
use Bugzilla::User;
use Bugzilla::Testopia::TestPlan;
use Bugzilla::Testopia::Search;
use Bugzilla::Testopia::Table;
# Utility method called by the list method
sub _list
{
my ($query) = @_;
my $cgi = Bugzilla->cgi;
$cgi->param("current_tab", "plan");
foreach (keys(%$query))
{
$cgi->param($_, $$query{$_});
}
my $search = Bugzilla::Testopia::Search->new($cgi);
# Result is an array of test plan hash maps
return Bugzilla::Testopia::Table->new('plan',
'tr_xmlrpc.cgi',
$cgi,
undef,
$search->query()
)->list();
}
sub get
{
my $self = shift;
my ($test_plan_id) = @_;
$self->login;
#Result is a test plan hash map
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
$self->logout;
return $test_plan;
}
sub list
{
my $self = shift;
my ($query) = @_;
$self->login;
my $list = _list($query);
$self->logout;
return $list;
}
sub create
{
my $self =shift;
my ($new_values) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($new_values);
my $result = $test_plan->store();
$self->logout;
# Result is new test plan id
return $result;
}
sub update
{
my $self =shift;
my ($test_plan_id, $new_values) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canedit)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->update($new_values);
$self->logout;
# Result is zero on success, otherwise an exception will be thrown
return $test_plan;
}
sub get_test_cases
{
my $self =shift;
my ($test_plan_id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->test_cases();
$self->logout;
# Result is list of test cases for the given test plan
return $result;
}
sub get_test_runs
{
my $self =shift;
my ($test_plan_id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->test_runs();
$self->logout;
# Result is list of test runs for the given test plan
return $result;
}
sub get_categories
{
my $self =shift;
my ($test_plan_id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan($test_plan_id);
if (not defined $test_plan)
{
$self->logout;
die "Testplan, " . $test_plan_id . ", not found";
}
if (not $test_plan->canview)
{
$self->logout;
die "User Not Authorized";
}
my $result = $test_plan->product->categories();
$self->logout;
# Result is list of test runs for the given test plan
return $result;
}
sub lookup_type_name_by_id
{
my $self =shift;
my ($id) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan({});
my $result = $test_plan->lookup_type($id);
$self->logout;
# Result is test plan type name for the given test plan type id
return $result;
}
sub lookup_type_id_by_name
{
my $self =shift;
my ($name) = @_;
$self->login;
my $test_plan = new Bugzilla::Testopia::TestPlan({});
my $result = $test_plan->lookup_type_by_name($name);
$self->logout;
if (!defined $result)
{
$result = 0;
};
# Result is test plan type id for the given test plan type name
return $result;
}
1;