2022-03-24 18:52:35 +01:00
|
|
|
package Peace::Model::Release;
|
|
|
|
|
|
|
|
use v5.30.0;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Params::ValidationCompiler qw/validation_for/;
|
|
|
|
use Types::Standard qw/InstanceOf Str HasMethods/;
|
|
|
|
|
|
|
|
{
|
|
|
|
my $validator = validation_for(
|
|
|
|
params => {
|
|
|
|
uuid => { type => Str, optional => 1 },
|
|
|
|
date_creation => { type => InstanceOf ['DateTime'], optional => 1 },
|
|
|
|
application => {
|
|
|
|
type => InstanceOf ['Peace::Model::Application'],
|
|
|
|
optional => 1
|
|
|
|
},
|
|
|
|
application_uuid => { type => Str, optional => 1 },
|
|
|
|
dbh => { type => HasMethods ['selectrow_hashref'], optional => 1 },
|
|
|
|
tag => { type => Str },
|
|
|
|
name => { type => Str },
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my $class = shift;
|
|
|
|
my %params = $validator->(@_);
|
|
|
|
die
|
|
|
|
'application or application_uuid with dbh should be passed on construct'
|
|
|
|
unless exists $params{application}
|
|
|
|
|| ( exists $params{application_uuid} && exists $params{dbh} );
|
|
|
|
|
|
|
|
return bless {%params}, $class;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-24 19:06:01 +01:00
|
|
|
sub _dbh {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->{dbh};
|
|
|
|
}
|
|
|
|
|
2022-03-24 18:52:35 +01:00
|
|
|
{
|
|
|
|
my $validator =
|
|
|
|
validation_for( params => [ { type => Str, optional => 1 } ] );
|
|
|
|
|
|
|
|
sub uuid {
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
|
|
|
my ($new_uuid) = $validator->(@_);
|
|
|
|
$self->{uuid} = $new_uuid;
|
|
|
|
}
|
|
|
|
return $self->{uuid};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
my $validator =
|
|
|
|
validation_for(
|
|
|
|
params => [ { type => InstanceOf ['DateTime'], optional => 1 } ] );
|
|
|
|
|
|
|
|
sub date_creation {
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
|
|
|
my ($new_date_creation) = $validator->(@_);
|
|
|
|
$self->{date_creation} = $new_date_creation;
|
|
|
|
}
|
|
|
|
return $self->{date_creation};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
my $validator = validation_for(
|
|
|
|
params => [
|
|
|
|
{ type => InstanceOf ['Peace::Model::Application'], optional => 1 }
|
|
|
|
]
|
|
|
|
);
|
|
|
|
sub application {
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
|
|
|
my ($new_application) = $validator->(@_);
|
|
|
|
$self->{application} = $new_application;
|
|
|
|
}
|
|
|
|
unless ( exists $self->{developer} ) {
|
|
|
|
my $application_uuid = $self->{application_uuid};
|
|
|
|
my $application_dao =
|
|
|
|
Peace::DAO::Application->new( dbh => $self->_dbh );
|
|
|
|
$self->{application} =
|
|
|
|
$application_dao->recover_by_uuid( uuid => $application_uuid );
|
|
|
|
}
|
|
|
|
return $self->{application};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
my $validator = validation_for(
|
|
|
|
params => [
|
|
|
|
{
|
|
|
|
type => Str, optional => 1,
|
|
|
|
}
|
|
|
|
]
|
|
|
|
);
|
|
|
|
sub tag {
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
|
|
|
my $new_tag = $validator->(@_);
|
|
|
|
$self->{tag} = $new_tag;
|
|
|
|
}
|
|
|
|
return $self->{tag};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
my $validator = validation_for(
|
|
|
|
params => [
|
|
|
|
{ type => Str, optional => 1 },
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
sub name {
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
|
|
|
my ($new_name) = $validator->(@_);
|
|
|
|
$self->{name} = $new_name;
|
|
|
|
}
|
|
|
|
return $self->{name};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
|
|
|
|
=encoding utf8
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
Peace::Model::Release - The release object representation.
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
my $release = Peace::Model::Release->new(
|
|
|
|
application => $application,
|
|
|
|
tag => $tag,
|
|
|
|
name => $name,
|
|
|
|
);
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
Describes a release from an application from Peace.
|
|
|
|
|
|
|
|
=head1 INSTANCE METHODS
|
|
|
|
|
|
|
|
Peace::Model::Release implements the following instance
|
|
|
|
methods:
|
|
|
|
|
|
|
|
=head2 new
|
|
|
|
|
|
|
|
my $release = Peace::Model::Release->new(
|
|
|
|
uuid => $uuid, # optional
|
|
|
|
date_creation => $date_creation, # optional
|
|
|
|
application => $application, # required or application_uuid should be passed.
|
|
|
|
application_uuid => $application_uuid, # required or application should be passed
|
|
|
|
dbh => $dbh, # needed if application_uuid is passed
|
|
|
|
tag => $tag,
|
|
|
|
name => $name,
|
|
|
|
);
|
|
|
|
|
|
|
|
=head1 METHODS
|
|
|
|
|
|
|
|
Peace::Model::Release implements the following methods:
|
|
|
|
|
|
|
|
=head2 uuid
|
|
|
|
|
|
|
|
my $uuid = $release->uuid;
|
|
|
|
|
|
|
|
$release->uuid($uuid);
|
|
|
|
|
|
|
|
Allows to retrieve and set the release uuid.
|
|
|
|
|
|
|
|
=head2 date_creation
|
|
|
|
|
|
|
|
my $date_creation = $release->date_creation;
|
|
|
|
|
|
|
|
$release->date_creation($date_creation);
|
|
|
|
|
|
|
|
Allows to retrieve and set the release date creation as a L<DateTime>.
|
|
|
|
|
|
|
|
=head2 application
|
|
|
|
|
|
|
|
my $application = $release->application;
|
|
|
|
|
|
|
|
$release->application($application);
|
|
|
|
|
|
|
|
Allows to retrieve and set the release application as a L<Peace::Model::Application>.
|
|
|
|
|
|
|
|
=head2 tag
|
|
|
|
|
|
|
|
my $tag = $release->tag;
|
|
|
|
|
|
|
|
$release->tag($tag);
|
|
|
|
|
|
|
|
Allows to retrieve and set the release tag.
|
|
|
|
|
|
|
|
=head2 name
|
|
|
|
|
|
|
|
my $name = $release->name
|
|
|
|
|
|
|
|
$release->name($name);
|
|
|
|
|
|
|
|
Allows to retrieve and set the release name.
|
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
|
|
|
L<Peace::Model::Application>, L<Peace::DAO::Release>
|
|
|
|
|
|
|
|
=cut
|