From 4b2c0587f07794c70eeeadc8f9db33bdada7e3f9 Mon Sep 17 00:00:00 2001 From: "ghendricks%novell.com" Date: Thu, 21 Feb 2008 17:58:16 +0000 Subject: [PATCH] Check for foreign key constraints before listing with JSON. git-svn-id: svn://10.0.0.236/trunk@246207 18797224-902f-48f8-a5cc-f745e15eee43 --- .../testopia/Bugzilla/Testopia/Attachment.pm | 2 +- .../testopia/Bugzilla/Testopia/Environment.pm | 2 +- .../testopia/Bugzilla/Testopia/TestCase.pm | 8 ++++---- .../testopia/Bugzilla/Testopia/TestCaseRun.pm | 18 +++++++++--------- .../testopia/Bugzilla/Testopia/TestPlan.pm | 2 +- .../testopia/Bugzilla/Testopia/TestRun.pm | 12 ++++++------ 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Attachment.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Attachment.pm index b6709827bc5..7f4d2e7527d 100644 --- a/mozilla/webtools/testopia/Bugzilla/Testopia/Attachment.pm +++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Attachment.pm @@ -250,7 +250,7 @@ sub to_json { # Add the calculated fields $obj->{'isviewable'} = $self->is_browser_safe($cgi); $obj->{'datasize'} = $self->datasize; - $obj->{'submitter'} = $self->submitter->name; + $obj->{'submitter'} = $self->submitter->name if $self->submitter; $obj->{'canedit'} = $self->canedit; $obj->{'candelete'} = $self->candelete; diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment.pm index 438218f4734..9cc2c8ada90 100644 --- a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment.pm +++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment.pm @@ -623,7 +623,7 @@ sub to_json { $obj->{$field} = $self->{$field}; } - $obj->{'product_name'} = $self->product->name; + $obj->{'product_name'} = $self->product->name if $self->product; $obj->{'case_run_count'} = $self->case_run_count; $obj->{'run_count'} = $self->get_run_count; diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm index 83a60c0c615..b5272e1f62e 100644 --- a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm +++ b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm @@ -1623,8 +1623,8 @@ sub to_json { } $obj->{'run_count'} = $self->run_count; - $obj->{'author_name'} = $self->author->name; - $obj->{'default_tester'} = $self->default_tester->name; + $obj->{'author_name'} = $self->author->name if $self->author; + $obj->{'default_tester'} = $self->default_tester->name if $self->default_tester; $obj->{'status'} = $self->status; $obj->{'priority'} = $self->priority; $obj->{'plan_id'} = $plan_ids[0]; @@ -1634,8 +1634,8 @@ sub to_json { $obj->{'canedit'} = $self->canedit; $obj->{'canview'} = $self->canview; $obj->{'candelete'} = $self->candelete; - $obj->{'category_name'} = $self->category->name; - $obj->{'product_id'} = $self->plans->[0]->product_id; + $obj->{'category_name'} = $self->category->name if $self->category; + $obj->{'product_id'} = $self->plans->[0]->product_id if $self->plans; return $json->objToJson($obj); } diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm index f89a7b43436..028de37d36c 100644 --- a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm +++ b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm @@ -295,17 +295,17 @@ sub to_json { $obj->{$field} = $self->{$field}; } - $obj->{'assignee_name'} = $self->assignee->login; - $obj->{'testedby'} = $self->testedby->login; + $obj->{'assignee_name'} = $self->assignee->login if $self->assignee; + $obj->{'testedby'} = $self->testedby->login if $self->testedby; $obj->{'status'} = $self->status; - $obj->{'build_name'} = $self->build->name; - $obj->{'env_name'} = $self->environment->name; - $obj->{'env_id'} = $self->environment->id; - $obj->{'category'} = $self->case->category->name; - $obj->{'priority'} = $self->case->priority; + $obj->{'build_name'} = $self->build->name if $self->build; + $obj->{'env_name'} = $self->environment->name if $self->environment; + $obj->{'env_id'} = $self->environment->id if $self->environment; + $obj->{'category'} = $self->case->category->name if $self->case && $self->case->category; + $obj->{'priority'} = $self->case->priority if $self->case; $obj->{'bug_count'} = $self->bug_count; - $obj->{'case_summary'} = $self->case->summary; - $obj->{'component'} = @{$self->case->components}[0]->name if (scalar @{$self->case->components}); + $obj->{'case_summary'} = $self->case->summary if $self->case; + $obj->{'component'} = @{$self->case->components}[0]->name if ($self->case && scalar @{$self->case->components}); $obj->{'type'} = $self->type; $obj->{'id'} = $self->id; $obj->{'sortkey'} = $self->sortkey; diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/TestPlan.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/TestPlan.pm index da046099f93..37af1c68e56 100644 --- a/mozilla/webtools/testopia/Bugzilla/Testopia/TestPlan.pm +++ b/mozilla/webtools/testopia/Bugzilla/Testopia/TestPlan.pm @@ -947,7 +947,7 @@ sub to_json { $obj->{$field} = $self->{$field}; } - $obj->{'product_name'} = $self->product->name; + $obj->{'product_name'} = $self->product->name if $self->product; $obj->{'run_count'} = $self->test_run_count; $obj->{'case_count'} = $self->test_case_count; $obj->{'author_name'} = $self->author->login; diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/TestRun.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/TestRun.pm index e71081fcb99..18f760ea8b9 100644 --- a/mozilla/webtools/testopia/Bugzilla/Testopia/TestRun.pm +++ b/mozilla/webtools/testopia/Bugzilla/Testopia/TestRun.pm @@ -539,19 +539,19 @@ sub to_json { foreach my $field ($self->DB_COLUMNS){ $obj->{$field} = $self->{$field}; } - $obj->{'plan'} = { id => $self->plan->id, product_id => $self->plan->product_id}; - $obj->{'build'} = { id => $self->build->id, name => $self->build->name}; - $obj->{'environment'} = { id => $self->environment->id, name => $self->environment->name}; + $obj->{'plan'} = { id => $self->plan->id, product_id => $self->plan->product_id} if $self->plan; + $obj->{'build'} = { id => $self->build->id, name => $self->build->name} if $self->build; + $obj->{'environment'} = { id => $self->environment->id, name => $self->environment->name} if $self->environment; $obj->{'case_count'} = $self->case_run_count; - $obj->{'manager'} = { login_name => $self->manager->login, name => $self->manager->name}; - $obj->{'manager_name'} = $self->manager->name; + $obj->{'manager'} = { login_name => $self->manager->login, name => $self->manager->name} if $self->manager; + $obj->{'manager_name'} = $self->manager->name if $self->manager; $obj->{'canedit'} = $self->canedit; $obj->{'canview'} = $self->canview; $obj->{'candelete'} = $self->candelete; $obj->{'status'} = $self->stop_date ? 'STOPPED' : 'RUNNING'; $obj->{'type'} = $self->type; $obj->{'id'} = $self->id; - $obj->{'product_id'} = $self->plan->product_id; + $obj->{'product_id'} = $self->plan->product_id if $self->plan; return $json->objToJson($obj); }