use utf8;
package Hydra::Schema::Result::JobsetInputs;
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->load_components("+Hydra::Component::ToJSON");
__PACKAGE__->table("jobsetinputs");
__PACKAGE__->add_columns(
"project",
{ data_type => "text", is_foreign_key => 1, is_nullable => 0 },
"jobset",
{ data_type => "text", is_foreign_key => 1, is_nullable => 0 },
"name",
{ data_type => "text", is_nullable => 0 },
"type",
{ data_type => "text", is_nullable => 0 },
"emailresponsible",
{ data_type => "integer", default_value => 0, is_nullable => 0 },
);
__PACKAGE__->set_primary_key("project", "jobset", "name");
__PACKAGE__->belongs_to(
"jobset",
"Hydra::Schema::Result::Jobsets",
{ name => "jobset", project => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
__PACKAGE__->has_many(
"jobsetinputalts",
"Hydra::Schema::Result::JobsetInputAlts",
{
"foreign.input" => "self.name",
"foreign.jobset" => "self.jobset",
"foreign.project" => "self.project",
},
undef,
);
use JSON::MaybeXS;
sub as_json {
my $self = shift;
my ($input) = $self->jobsetinputalts;
my %json = (
"name" => $self->get_column("name") // "",
"type" => $self->get_column("type") // "",
"value" => $input->value // "",
"emailresponsible" => $self->get_column("emailresponsible") ? JSON::MaybeXS::true : JSON::MaybeXS::false,
);
return \%json;
}
1;