From 4c06c4d6f85d8794f2f078cf354e37fde57a432a Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Mon, 14 Apr 2014 11:39:36 +0200 Subject: [PATCH] MT#6693 Add subscriber profile tables. --- .../Result/provisioning_voip_subscribers.pm | 9 ++ lib/NGCP/Schema/Result/resellers.pm | 7 + .../voip_subscriber_profile_attributes.pm | 122 ++++++++++++++++++ .../Schema/Result/voip_subscriber_profiles.pm | 122 ++++++++++++++++++ 4 files changed, 260 insertions(+) create mode 100644 lib/NGCP/Schema/Result/voip_subscriber_profile_attributes.pm create mode 100644 lib/NGCP/Schema/Result/voip_subscriber_profiles.pm diff --git a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm index 1dfae74a..65a1c6a9 100644 --- a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm +++ b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm @@ -39,6 +39,8 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 1, size => 40 }, "pbx_group_id", { data_type => "integer", extra => { unsigned => 1 }, is_nullable => 1 }, + "profile_id", + { data_type => "integer", extra => { unsigned => 1 }, is_nullable => 1 }, "is_pbx_group", { data_type => "tinyint", default_value => 0, is_nullable => 0 }, "modify_timestamp", @@ -205,6 +207,13 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->belongs_to( + "voip_subscriber_profile", + "NGCP::Schema::Result::voip_subscriber_profiles", + { "foreign.id" => "self.profile_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + sub TO_JSON { my ($self) = @_; return { diff --git a/lib/NGCP/Schema/Result/resellers.pm b/lib/NGCP/Schema/Result/resellers.pm index bdd2dd60..5574ad07 100644 --- a/lib/NGCP/Schema/Result/resellers.pm +++ b/lib/NGCP/Schema/Result/resellers.pm @@ -131,6 +131,13 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->has_many( + "voip_subscriber_profiles", + "NGCP::Schema::Result::voip_subscriber_profiles", + { "foreign.reseller_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + __PACKAGE__->has_many( "autoprov_devices", "NGCP::Schema::Result::autoprov_devices", diff --git a/lib/NGCP/Schema/Result/voip_subscriber_profile_attributes.pm b/lib/NGCP/Schema/Result/voip_subscriber_profile_attributes.pm new file mode 100644 index 00000000..5faad8a1 --- /dev/null +++ b/lib/NGCP/Schema/Result/voip_subscriber_profile_attributes.pm @@ -0,0 +1,122 @@ +package NGCP::Schema::Result::voip_subscriber_profile_attributes; +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_subscriber_profile_attributes"); + + +__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_nullable => 0 }, + "attribute_id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_foreign_key => 1, + is_nullable => 0, + }, +); + + +__PACKAGE__->set_primary_key("id"); + + +__PACKAGE__->add_unique_constraint("prof_attr_idx", ["profile_id", "attribute_id"]); + + +__PACKAGE__->belongs_to( + "attribute", + "NGCP::Schema::Result::voip_preferences", + { id => "attribute_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); +sub TO_JSON { + my ($self) = @_; + return { + map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method } + }; +} +=encoding UTF-8 + +=head1 NAME + +NGCP::Schema::Result::voip_subscriber_profile_attributes + +=head1 COMPONENTS LOADED + +=over 4 + +=item * L + +=item * L + +=back + +=head1 TABLE: C + +=head1 ACCESSORS + +=head2 id + + data_type: 'integer' + extra: {unsigned => 1} + is_auto_increment: 1 + is_nullable: 0 + +=head2 profile_id + + data_type: 'integer' + extra: {unsigned => 1} + is_nullable: 0 + +=head2 attribute_id + + data_type: 'integer' + extra: {unsigned => 1} + is_foreign_key: 1 + is_nullable: 0 + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=item * L + +=back + +=head1 RELATIONS + +=head2 attribute + +Type: belongs_to + +Related object: L + +=cut + + +1; diff --git a/lib/NGCP/Schema/Result/voip_subscriber_profiles.pm b/lib/NGCP/Schema/Result/voip_subscriber_profiles.pm new file mode 100644 index 00000000..f0552276 --- /dev/null +++ b/lib/NGCP/Schema/Result/voip_subscriber_profiles.pm @@ -0,0 +1,122 @@ +package NGCP::Schema::Result::voip_subscriber_profiles; +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_subscriber_profiles"); + + +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_auto_increment => 1, + is_nullable => 0, + }, + "reseller_id", + { data_type => "integer", extra => { unsigned => 1 }, is_nullable => 0 }, + "name", + { data_type => "varchar", is_nullable => 0, size => 255 }, + "description", + { data_type => "varchar", is_nullable => 0, size => 255 }, +); + + +__PACKAGE__->set_primary_key("id"); + +__PACKAGE__->belongs_to( + "reseller", + "NGCP::Schema::Result::resellers", + { id => "reseller_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +__PACKAGE__->has_many( + "profile_attributes", + "NGCP::Schema::Result::voip_subscriber_profile_attributes", + { "foreign.profile_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +__PACKAGE__->add_unique_constraint("vsp_resname_idx", ["reseller_id", "name"]); +sub TO_JSON { + my ($self) = @_; + return { + map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method } + }; +} +=encoding UTF-8 + +=head1 NAME + +NGCP::Schema::Result::voip_subscriber_profiles + +=head1 COMPONENTS LOADED + +=over 4 + +=item * L + +=item * L + +=back + +=head1 TABLE: C + +=head1 ACCESSORS + +=head2 id + + data_type: 'integer' + extra: {unsigned => 1} + is_auto_increment: 1 + is_nullable: 0 + +=head2 reseller_id + + data_type: 'integer' + extra: {unsigned => 1} + is_nullable: 0 + +=head2 name + + data_type: 'varchar' + is_nullable: 0 + size: 255 + +=head2 description + + data_type: 'varchar' + is_nullable: 0 + size: 255 + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=item * L + +=back + +=cut + + +1;