From a69dfcb6dbb7f574c16af7137247713152035e28 Mon Sep 17 00:00:00 2001 From: Gerhard Jungwirth Date: Fri, 23 Sep 2016 14:58:22 +0200 Subject: [PATCH] TT#2395 add anumber upn rewrite tables Change-Id: Iecc36c437d200bac1b3e3fb9da3936ea5e98ead3 --- .../Result/provisioning_voip_subscribers.pm | 13 ++++ lib/NGCP/Schema/Result/upn_rewrite_set.pm | 59 +++++++++++++++++++ lib/NGCP/Schema/Result/upn_rewrite_sources.pm | 46 +++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 lib/NGCP/Schema/Result/upn_rewrite_set.pm create mode 100644 lib/NGCP/Schema/Result/upn_rewrite_sources.pm diff --git a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm index d27198d9..557df165 100644 --- a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm +++ b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm @@ -98,6 +98,13 @@ __PACKAGE__->belongs_to( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->has_many( + "upn_rewrite_sets", + "NGCP::Schema::Result::upn_rewrite_set", + { "foreign.subscriber_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + __PACKAGE__->has_many( "voip_cc_mappings", "NGCP::Schema::Result::voip_cc_mappings", @@ -452,6 +459,12 @@ Type: belongs_to Related object: L +=head2 upn_rewrite_sets + +Type: has_many + +Related object: L + =head2 voip_cc_mappings Type: has_many diff --git a/lib/NGCP/Schema/Result/upn_rewrite_set.pm b/lib/NGCP/Schema/Result/upn_rewrite_set.pm new file mode 100644 index 00000000..4c8ecf27 --- /dev/null +++ b/lib/NGCP/Schema/Result/upn_rewrite_set.pm @@ -0,0 +1,59 @@ +package NGCP::Schema::Result::upn_rewrite_set; +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.upn_rewrite_set"); + +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_auto_increment => 1, + is_nullable => 0, + }, + "subscriber_id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_foreign_key => 1, + is_nullable => 1, + }, + "new_cli", + { data_type => "varchar", is_nullable => 1, size => 45 }, +); + +__PACKAGE__->set_primary_key("id"); + +__PACKAGE__->belongs_to( + "subscriber", + "NGCP::Schema::Result::provisioning_voip_subscribers", + { id => "subscriber_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + +__PACKAGE__->has_many( + "upn_rewrite_sources", + "NGCP::Schema::Result::upn_rewrite_sources", + { "foreign.upn_rewrite_set_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +sub TO_JSON { + my ($self) = @_; + return { + map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method } + }; +} + +1; diff --git a/lib/NGCP/Schema/Result/upn_rewrite_sources.pm b/lib/NGCP/Schema/Result/upn_rewrite_sources.pm new file mode 100644 index 00000000..ab126245 --- /dev/null +++ b/lib/NGCP/Schema/Result/upn_rewrite_sources.pm @@ -0,0 +1,46 @@ +package NGCP::Schema::Result::upn_rewrite_sources; +use Scalar::Util qw(blessed); +use parent 'DBIx::Class::Core'; + +our $VERSION = '2.007'; + +__PACKAGE__->load_components("Helper::Row::ToJSON"); + +__PACKAGE__->table("provisioning.upn_rewrite_sources"); + +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_auto_increment => 1, + is_nullable => 0, + }, + "upn_rewrite_set_id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_foreign_key => 1, + is_nullable => 0, + }, + "pattern", + { data_type => "varchar", is_nullable => 1, size => 45 }, +); + +__PACKAGE__->set_primary_key("id"); + +__PACKAGE__->belongs_to( + "upn_rewrite_set", + "NGCP::Schema::Result::upn_rewrite_set", + { id => "upn_rewrite_set_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;