So far it was always necessary to go through the hierarchies like Job -> Step -> Task. Now it is possible to directly retrieve all the rows in any table.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/ObjectModel/DetailrefPropertyDescriptor.pm | 17 ++++++++++++++++- testbot/lib/ObjectModel/Item.pm | 4 +--- testbot/lib/ObjectModel/PropertyDescriptor.pm | 1 + testbot/lib/WineTestBot/Jobs.pm | 1 + testbot/lib/WineTestBot/PendingPatchSets.pm | 1 + testbot/lib/WineTestBot/PendingPatches.pm | 16 ++++++++++++++-- testbot/lib/WineTestBot/RecordGroups.pm | 1 + testbot/lib/WineTestBot/Steps.pm | 16 +++++++++++----- testbot/lib/WineTestBot/Tasks.pm | 14 ++++++++++++-- testbot/lib/WineTestBot/UserRoles.pm | 13 +++++++++++-- testbot/lib/WineTestBot/Users.pm | 1 + 11 files changed, 70 insertions(+), 15 deletions(-)
diff --git a/testbot/lib/ObjectModel/DetailrefPropertyDescriptor.pm b/testbot/lib/ObjectModel/DetailrefPropertyDescriptor.pm index dbef8ac21..d60fe6395 100644 --- a/testbot/lib/ObjectModel/DetailrefPropertyDescriptor.pm +++ b/testbot/lib/ObjectModel/DetailrefPropertyDescriptor.pm @@ -29,7 +29,7 @@ use vars qw(@ISA @EXPORT);
require Exporter; @ISA = qw(ObjectModel::PropertyDescriptor Exporter); -@EXPORT = qw(&CreateDetailrefPropertyDescriptor); +@EXPORT = qw(&CreateDetailrefPropertyDescriptor &SetDetailrefKeyPrefix);
sub _initialize($$) { @@ -66,4 +66,19 @@ sub CreateDetailrefPropertyDescriptor($$$$$) return ObjectModel::DetailrefPropertyDescriptor->new($Name, $DisplayName, $IsKey, $IsRequired, $Creator); }
+sub SetDetailrefKeyPrefix($@) +{ + my $KeyPrefix = shift; + foreach my $PropertyDescriptor (@_) + { + if ($PropertyDescriptor->{IsKey}) + { + # Defines the prefix to prepend to the field name when the key is + # inherited by a child object through a DetailrefPropertyDescriptor + # relation. + $PropertyDescriptor->{KeyPrefix} = $KeyPrefix; + } + } +} + 1; diff --git a/testbot/lib/ObjectModel/Item.pm b/testbot/lib/ObjectModel/Item.pm index 424826f23..201577c98 100644 --- a/testbot/lib/ObjectModel/Item.pm +++ b/testbot/lib/ObjectModel/Item.pm @@ -305,8 +305,6 @@ sub GetMasterKey($) { my ($self) = @_;
- my $ColNamePrefix = ref($self); - $ColNamePrefix =~ s/.*://; my @MasterColNames, my @MasterColValues; if (defined($self->{MasterColNames})) { @@ -319,7 +317,7 @@ sub GetMasterKey($) { foreach my $ColName (@{$PropertyDescriptor->GetColNames()}) { - push @MasterColNames, $ColNamePrefix . $ColName; + push @MasterColNames, $PropertyDescriptor->{KeyPrefix} . $ColName; push @MasterColValues, $self->GetColValue($ColName); } } diff --git a/testbot/lib/ObjectModel/PropertyDescriptor.pm b/testbot/lib/ObjectModel/PropertyDescriptor.pm index 9c13b1ca2..583082e81 100644 --- a/testbot/lib/ObjectModel/PropertyDescriptor.pm +++ b/testbot/lib/ObjectModel/PropertyDescriptor.pm @@ -50,6 +50,7 @@ sub new($$$$$@) IsKey => $IsKey, IsRequired => $IsRequired, Class => undef}; + $self->{KeyPrefix} = "" if ($IsKey); $self = bless $self, $class; $self->_initialize(@_); return $self; diff --git a/testbot/lib/WineTestBot/Jobs.pm b/testbot/lib/WineTestBot/Jobs.pm index bcbcae91f..f810b4f12 100644 --- a/testbot/lib/WineTestBot/Jobs.pm +++ b/testbot/lib/WineTestBot/Jobs.pm @@ -431,6 +431,7 @@ my @PropertyDescriptors = ( CreateItemrefPropertyDescriptor("Patch", "Submitted from patch", !1, !1, &WineTestBot::Patches::CreatePatches, ["PatchId"]), CreateDetailrefPropertyDescriptor("Steps", "Steps", !1, !1, &CreateSteps), ); +SetDetailrefKeyPrefix("Job", @PropertyDescriptors);
=pod =over 12 diff --git a/testbot/lib/WineTestBot/PendingPatchSets.pm b/testbot/lib/WineTestBot/PendingPatchSets.pm index 520fb653c..d51652221 100644 --- a/testbot/lib/WineTestBot/PendingPatchSets.pm +++ b/testbot/lib/WineTestBot/PendingPatchSets.pm @@ -180,6 +180,7 @@ my @PropertyDescriptors = ( CreateBasicPropertyDescriptor("TotalParts", "Expected number of parts in series", 1, 1, "N", 2), CreateDetailrefPropertyDescriptor("Parts", "Parts received so far", !1, !1, &CreatePendingPatches), ); +SetDetailrefKeyPrefix("PendingPatchSet", @PropertyDescriptors);
=pod =over 12 diff --git a/testbot/lib/WineTestBot/PendingPatches.pm b/testbot/lib/WineTestBot/PendingPatches.pm index 053f7123d..281db60ef 100644 --- a/testbot/lib/WineTestBot/PendingPatches.pm +++ b/testbot/lib/WineTestBot/PendingPatches.pm @@ -69,13 +69,24 @@ my @PropertyDescriptors = ( CreateBasicPropertyDescriptor("No", "Part no", 1, 1, "N", 2), CreateItemrefPropertyDescriptor("Patch", "Submitted via patch", !1, 1, &WineTestBot::Patches::CreatePatches, ["PatchId"]), ); +my @FlatPropertyDescriptors = ( + CreateBasicPropertyDescriptor("PendingPatchSetEMail", "EMail of series author", 1, 1, "A", 40), + CreateBasicPropertyDescriptor("PendingPatchSetTotalParts", "Expected number of parts in series", 1, 1, "N", 2), + @PropertyDescriptors +);
=pod =over 12
=item C<CreatePendingPatches()>
-Creates a collection of PendingPatch objects. +When given a PendingPatchSet object returns a collection containing the +corresponding parts. In this case the PendingPatch objects don't store the +key of their parent. + +If no PendingPatchSet object is specified all the table rows are returned and +the PendingPatch objects have PendingPatchSetEMail and +PendingPatchSetTotalParts properties.
=back =cut @@ -86,7 +97,8 @@ sub CreatePendingPatches(;$$)
return WineTestBot::PendingPatches->new( "PendingPatches", "PendingPatches", "PendingPatch", - @PropertyDescriptors, $ScopeObject, $PendingPatchSet); + $PendingPatchSet ? @PropertyDescriptors : @FlatPropertyDescriptors, + $ScopeObject, $PendingPatchSet); }
1; diff --git a/testbot/lib/WineTestBot/RecordGroups.pm b/testbot/lib/WineTestBot/RecordGroups.pm index 252545569..1e5dbbdd4 100644 --- a/testbot/lib/WineTestBot/RecordGroups.pm +++ b/testbot/lib/WineTestBot/RecordGroups.pm @@ -80,6 +80,7 @@ my @PropertyDescriptors = ( CreateBasicPropertyDescriptor("Timestamp", "Timestamp", !1, 1, "DT", 19), CreateDetailrefPropertyDescriptor("Records", "Records", !1, !1, &CreateRecords), ); +SetDetailrefKeyPrefix("RecordGroup", @PropertyDescriptors);
=pod =over 12 diff --git a/testbot/lib/WineTestBot/Steps.pm b/testbot/lib/WineTestBot/Steps.pm index f91b70e3f..ef2b3872b 100644 --- a/testbot/lib/WineTestBot/Steps.pm +++ b/testbot/lib/WineTestBot/Steps.pm @@ -216,17 +216,22 @@ my @PropertyDescriptors = ( CreateBasicPropertyDescriptor("ReportSuccessfulTests", "Report successful tests (WINETEST_REPORT_SUCCESS)", !1, 1, "B", 1), CreateDetailrefPropertyDescriptor("Tasks", "Tasks", !1, !1, &CreateTasks), ); +SetDetailrefKeyPrefix("Step", @PropertyDescriptors); +my @FlatPropertyDescriptors = ( + CreateBasicPropertyDescriptor("JobId", "Job id", 1, 1, "S", 5), + @PropertyDescriptors +);
=pod =over 12
=item C<CreateSteps()>
-Creates a collection containing the steps of the specified Job. In -this case the Step objects don't store the key of their parent. +When given a Job object returns a collection containing the corresponding +steps. In this case the Step objects don't store the key of their parent.
-If no Job is specified all the table rows are returned and the -Step objects have a JobId property. +If no Job object is specified all the table rows are returned and the Step +objects have a JobId property.
=back =cut @@ -236,7 +241,8 @@ sub CreateSteps(;$$) my ($ScopeObject, $Job) = @_;
return WineTestBot::Steps->new("Steps", "Steps", "Step", - @PropertyDescriptors, $ScopeObject, $Job); + $Job ? @PropertyDescriptors : @FlatPropertyDescriptors, + $ScopeObject, $Job); }
1; diff --git a/testbot/lib/WineTestBot/Tasks.pm b/testbot/lib/WineTestBot/Tasks.pm index dcc222b52..f16dfe201 100644 --- a/testbot/lib/WineTestBot/Tasks.pm +++ b/testbot/lib/WineTestBot/Tasks.pm @@ -233,13 +233,22 @@ my @PropertyDescriptors = ( CreateBasicPropertyDescriptor("Ended", "Execution ended", !1, !1, "DT", 19), CreateBasicPropertyDescriptor("TestFailures", "Number of test failures", !1, !1, "N", 6), ); +my @FlatPropertyDescriptors = ( + CreateBasicPropertyDescriptor("JobId", "Job id", 1, 1, "S", 5), + CreateBasicPropertyDescriptor("StepNo", "Step no", 1, 1, "N", 2), + @PropertyDescriptors +);
=pod =over 12
=item C<CreateTasks()>
-Creates a collection of Patch objects. +When given a Step object returns a collection containing the corresponding +tasks. In this case the Task objects don't store the key of their parent. + +If no Step object is specified all the table rows are returned and the Task +objects have JobId and StepNo properties.
=back =cut @@ -248,7 +257,8 @@ sub CreateTasks(;$$) { my ($ScopeObject, $Step) = @_; return WineTestBot::Tasks->new("Tasks", "Tasks", "Task", - @PropertyDescriptors, $ScopeObject, $Step); + $Step ? @PropertyDescriptors : @FlatPropertyDescriptors, + $ScopeObject, $Step); }
1; diff --git a/testbot/lib/WineTestBot/UserRoles.pm b/testbot/lib/WineTestBot/UserRoles.pm index 417baf994..972bdc0e9 100644 --- a/testbot/lib/WineTestBot/UserRoles.pm +++ b/testbot/lib/WineTestBot/UserRoles.pm @@ -62,13 +62,21 @@ sub CreateItem($) my @PropertyDescriptors = ( CreateItemrefPropertyDescriptor("Role", "Role", 1, 1, &CreateRoles, ["RoleName"]), ); +my @FlatPropertyDescriptors = ( + CreateBasicPropertyDescriptor("UserName", "Username", 1, 1, "A", 40), + @PropertyDescriptors +);
=pod =over 12
=item C<CreateUserRoles()>
-Creates a collection of UserRole objects. +When given a User object returns a collection containing the corresponding +roles. In this case the Role objects don't store the key of their parent. + +If no User object is specified all the table rows are returned and the UserRole +objects have a UserName property.
=back =cut @@ -77,7 +85,8 @@ sub CreateUserRoles(;$$) { my ($ScopeObject, $User) = @_; return WineTestBot::UserRoles->new("UserRoles", "UserRoles", "UserRole", - @PropertyDescriptors, $ScopeObject, $User); + $User ? @PropertyDescriptors : @FlatPropertyDescriptors, + $ScopeObject, $User); }
1; diff --git a/testbot/lib/WineTestBot/Users.pm b/testbot/lib/WineTestBot/Users.pm index 95c7c2561..178b377b9 100644 --- a/testbot/lib/WineTestBot/Users.pm +++ b/testbot/lib/WineTestBot/Users.pm @@ -326,6 +326,7 @@ my @PropertyDescriptors = ( CreateBasicPropertyDescriptor("ResetCode", "Password reset code", !1, !1, "A", 32), CreateDetailrefPropertyDescriptor("Roles", "Roles", !1, !1, &CreateUserRoles), ); +SetDetailrefKeyPrefix("User", @PropertyDescriptors);
=pod =over 12