From d5932b5644976a7e83dd6f6c3437bafd4e893359 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Tue, 22 Apr 2014 12:05:18 +0200 Subject: [PATCH] MT#6693 Move pbx group features to subscriber. --- lib/NGCP/Schema/Result/contracts.pm | 7 - .../Result/provisioning_voip_subscribers.pm | 35 ++-- lib/NGCP/Schema/Result/voip_pbx_groups.pm | 176 ------------------ 3 files changed, 22 insertions(+), 196 deletions(-) delete mode 100644 lib/NGCP/Schema/Result/voip_pbx_groups.pm diff --git a/lib/NGCP/Schema/Result/contracts.pm b/lib/NGCP/Schema/Result/contracts.pm index 06a8a9d2..29903180 100644 --- a/lib/NGCP/Schema/Result/contracts.pm +++ b/lib/NGCP/Schema/Result/contracts.pm @@ -155,13 +155,6 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); -__PACKAGE__->has_many( - "voip_pbx_groups", - "NGCP::Schema::Result::voip_pbx_groups", - { "foreign.contract_id" => "self.id" }, - { cascade_copy => 0, cascade_delete => 0 }, -); - __PACKAGE__->has_many( "autoprov_field_devices", "NGCP::Schema::Result::autoprov_field_devices", diff --git a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm index 263a83a5..44244f4e 100644 --- a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm +++ b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm @@ -39,6 +39,21 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 1, size => 40 }, "pbx_group_id", { data_type => "integer", extra => { unsigned => 1 }, is_nullable => 1 }, + "pbx_hunt_policy", + { + data_type => "enum", + default_value => "serial", + extra => { list => ["serial", "parallel"] }, + is_nullable => 1, + }, + "pbx_hunt_timeout", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_nullable => 1, + }, + "pbx_extension", + { data_type => "varchar", is_nullable => 1, size => 255 }, "profile_set_id", { data_type => "integer", extra => { unsigned => 1 }, is_nullable => 1 }, "profile_id", @@ -139,6 +154,13 @@ __PACKAGE__->might_have( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->belongs_to( + "voip_pbx_group", + "NGCP::Schema::Result::voip_subscribers", + { "foreign.id" => "self.pbx_group_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + __PACKAGE__->might_have( "voip_reminder", "NGCP::Schema::Result::voip_reminder", @@ -167,13 +189,6 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); -__PACKAGE__->belongs_to( - "voip_pbx_group", - "NGCP::Schema::Result::voip_pbx_groups", - { 'foreign.id' => 'self.pbx_group_id' }, - { cascade_copy => 0, cascade_delete => 0 }, -); - __PACKAGE__->has_many( "autoprov_field_device_lines", "NGCP::Schema::Result::autoprov_field_device_lines", @@ -452,9 +467,3 @@ Related object: L Type: has_many Related object: L - -=head2 voip_pbx_group - -Type: belongs_to - -Related object: L diff --git a/lib/NGCP/Schema/Result/voip_pbx_groups.pm b/lib/NGCP/Schema/Result/voip_pbx_groups.pm deleted file mode 100644 index b38ad91a..00000000 --- a/lib/NGCP/Schema/Result/voip_pbx_groups.pm +++ /dev/null @@ -1,176 +0,0 @@ -package NGCP::Schema::Result::voip_pbx_groups; -use Scalar::Util qw(blessed); -use parent 'DBIx::Class::Core'; - -our $VERSION = '2.007'; - -__PACKAGE__->load_components("Helper::Row::ToJSON"); - -__PACKAGE__->table("provisioning.voip_pbx_groups"); - -__PACKAGE__->add_columns( - "id", - { - data_type => "integer", - extra => { unsigned => 1 }, - is_auto_increment => 1, - is_nullable => 0, - }, - "contract_id", - { - data_type => "integer", - extra => { unsigned => 1 }, - is_foreign_key => 1, - is_nullable => 0, - }, - "subscriber_id", - { - data_type => "integer", - extra => { unsigned => 1 }, - is_foreign_key => 1, - is_nullable => 0, - }, - "name", - { data_type => "varchar", is_nullable => 0, size => 255 }, - "extension", - { data_type => "varchar", is_nullable => 0, size => 255 }, - "hunt_policy", - { - data_type => "enum", - default_value => "serial", - extra => { list => ["serial", "parallel"] }, - is_nullable => 0, - }, - "hunt_policy_timeout", - { - data_type => "integer", - extra => { unsigned => 1 }, - is_nullable => 0, - }, -); - -__PACKAGE__->set_primary_key("id"); - -__PACKAGE__->belongs_to( - "contract", - "NGCP::Schema::Result::contracts", - { id => "contract_id" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, -); - -__PACKAGE__->belongs_to( - "provisioning_voip_subscriber", - "NGCP::Schema::Result::provisioning_voip_subscribers", - { id => "subscriber_id" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, -); - -__PACKAGE__->has_many( - "provisioning_voip_subscribers", - "NGCP::Schema::Result::provisioning_voip_subscribers", - { "foreign.pbx_group_id" => "self.id" }, - #{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, - { cascade_copy => 0, cascade_delete => 0 }, -); - -sub TO_JSON { - my ($self) = @_; - return { - map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method } - }; -} - -1; -__END__ - -=encoding UTF-8 - -=head1 NAME - -NGCP::Schema::Result::voip_pbx_groups - -=head1 COMPONENTS LOADED - -=over 4 - -=item * L - -=back - -=head1 TABLE: C - -=head1 ACCESSORS - -=head2 id - - data_type: 'integer' - extra: {unsigned => 1} - is_auto_increment: 1 - is_nullable: 0 - -=head2 contract_id - - data_type: 'integer' - extra: {unsigned => 1} - is_foreign_key: 1 - is_nullable: 0 - -=head2 subscriber_id - - data_type: 'integer' - extra: {unsigned => 1} - is_foreign_key: 1 - is_nullable: 0 - -=head2 name - - data_type: 'varchar' - is_nullable: 0 - size: 255 - -=head2 extension - - data_type: 'varchar' - is_nullable: 0 - size: 255 - -=head2 hunt_policy - - data_type: 'enum' - default_value: 'serial' - extra: {list => ["serial","parallel"]} - is_nullable: 0 - -=head2 hunt_policy_timeout - - data_type: 'integer' - extra: {unsigned => 1} - is_nullable: 0 - -=head1 PRIMARY KEY - -=over 4 - -=item * L - -=back - -=head1 RELATIONS - -=head2 contract - -Type: belongs_to - -Related object: L - -=head2 provisioning_voip_subscriber - -Type: belongs_to - -Related object: L - -=head2 provisioning_voip_subscribers - -Type: has_many - -Related object: L