From 5879605b9dd063beb288c5c80ae56b82bb31cae1 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Tue, 18 Nov 2014 15:53:50 +0100 Subject: [PATCH] MT#10199 Add subscriber profile preferences. --- lib/NGCP/Schema/Result/voip_preferences.pm | 9 ++ .../Schema/Result/voip_preferences_enum.pm | 87 +------------------ .../Schema/Result/voip_prof_preferences.pm | 67 ++++++++++++++ .../Schema/Result/voip_subscriber_profiles.pm | 7 ++ 4 files changed, 85 insertions(+), 85 deletions(-) create mode 100644 lib/NGCP/Schema/Result/voip_prof_preferences.pm diff --git a/lib/NGCP/Schema/Result/voip_preferences.pm b/lib/NGCP/Schema/Result/voip_preferences.pm index 0f9e6da6..c9ededbf 100644 --- a/lib/NGCP/Schema/Result/voip_preferences.pm +++ b/lib/NGCP/Schema/Result/voip_preferences.pm @@ -33,6 +33,8 @@ __PACKAGE__->add_columns( { data_type => "tinyint", extra => { unsigned => 1 }, is_nullable => 0 }, "usr_pref", { data_type => "tinyint", default_value => 0, is_nullable => 0 }, + "prof_pref", + { data_type => "tinyint", default_value => 0, is_nullable => 0 }, "dom_pref", { data_type => "tinyint", default_value => 0, is_nullable => 0 }, "peer_pref", @@ -101,6 +103,13 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->has_many( + "voip_prof_preferences", + "NGCP::Schema::Result::voip_prof_preferences", + { "foreign.attribute_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + __PACKAGE__->has_many( "voip_contract_preferences", "NGCP::Schema::Result::voip_contract_preferences", diff --git a/lib/NGCP/Schema/Result/voip_preferences_enum.pm b/lib/NGCP/Schema/Result/voip_preferences_enum.pm index a388f3a0..79c28e93 100644 --- a/lib/NGCP/Schema/Result/voip_preferences_enum.pm +++ b/lib/NGCP/Schema/Result/voip_preferences_enum.pm @@ -24,6 +24,8 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 1, size => 128 }, "usr_pref", { data_type => "tinyint", default_value => 0, is_nullable => 1 }, + "prof_pref", + { data_type => "tinyint", default_value => 0, is_nullable => 1 }, "dom_pref", { data_type => "tinyint", default_value => 0, is_nullable => 1 }, "peer_pref", @@ -56,88 +58,3 @@ sub TO_JSON { } 1; -__END__ - -=encoding UTF-8 - -=head1 NAME - -NGCP::Schema::Result::voip_preferences_enum - -=head1 COMPONENTS LOADED - -=over 4 - -=item * L - -=item * L - -=back - -=head1 TABLE: C - -=head1 ACCESSORS - -=head2 id - - data_type: 'integer' - is_auto_increment: 1 - is_nullable: 0 - -=head2 preference_id - - data_type: 'integer' - extra: {unsigned => 1} - is_foreign_key: 1 - is_nullable: 1 - -=head2 label - - data_type: 'varchar' - is_nullable: 1 - size: 128 - -=head2 value - - data_type: 'varchar' - is_nullable: 1 - size: 128 - -=head2 usr_pref - - data_type: 'tinyint' - default_value: 0 - is_nullable: 1 - -=head2 dom_pref - - data_type: 'tinyint' - default_value: 0 - is_nullable: 1 - -=head2 peer_pref - - data_type: 'tinyint' - default_value: 0 - is_nullable: 1 - -=head2 default_val - - data_type: 'tinyint' - is_nullable: 1 - -=head1 PRIMARY KEY - -=over 4 - -=item * L - -=back - -=head1 RELATIONS - -=head2 preference - -Type: belongs_to - -Related object: L diff --git a/lib/NGCP/Schema/Result/voip_prof_preferences.pm b/lib/NGCP/Schema/Result/voip_prof_preferences.pm new file mode 100644 index 00000000..0f4f4256 --- /dev/null +++ b/lib/NGCP/Schema/Result/voip_prof_preferences.pm @@ -0,0 +1,67 @@ +package NGCP::Schema::Result::voip_prof_preferences; +use Scalar::Util qw(blessed); +use parent 'DBIx::Class::Core'; + +our $VERSION = '2.007'; + +__PACKAGE__->load_components("InflateColumn::DateTime", "Helper::Row::ToJSON"); + +__PACKAGE__->table("provisioning.voip_prof_preferences"); + +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_auto_increment => 1, + is_nullable => 0, + }, + "profile_id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_foreign_key => 1, + is_nullable => 0, + }, + "attribute_id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_foreign_key => 1, + is_nullable => 0, + }, + "value", + { data_type => "varchar", is_nullable => 0, size => 128 }, + "modify_timestamp", + { + data_type => "timestamp", + datetime_undef_if_invalid => 1, + default_value => \"current_timestamp", + is_nullable => 0, + }, +); + +__PACKAGE__->set_primary_key("id"); + +__PACKAGE__->belongs_to( + "attribute", + "NGCP::Schema::Result::voip_preferences", + { id => "attribute_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +__PACKAGE__->belongs_to( + "profile", + "NGCP::Schema::Result::voip_subscriber_profiles", + { id => "profile_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +sub TO_JSON { + my ($self) = @_; + return { + map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method } + }; +} + +1; diff --git a/lib/NGCP/Schema/Result/voip_subscriber_profiles.pm b/lib/NGCP/Schema/Result/voip_subscriber_profiles.pm index 990340a6..56d439c8 100644 --- a/lib/NGCP/Schema/Result/voip_subscriber_profiles.pm +++ b/lib/NGCP/Schema/Result/voip_subscriber_profiles.pm @@ -45,6 +45,13 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->has_many( + "voip_prof_preferences", + "NGCP::Schema::Result::voip_prof_preferences", + { "foreign.profile_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + __PACKAGE__->add_unique_constraint("vsp_resname_idx", ["set_id", "name"]); sub TO_JSON {