From 5befb25cad54a829ddd61efd9f000ea3a47e1ef3 Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Sun, 26 Oct 2014 03:26:24 +0200 Subject: [PATCH] MT#9177 Move vendor credentials to db --- lib/NGCP/Schema/Result/autoprov_devices.pm | 2 +- .../Schema/Result/autoprov_sync_parameters.pm | 2 +- .../Result/contract_vendor_credentials.pm | 106 ++++++++++++++++++ lib/NGCP/Schema/Result/contracts.pm | 7 ++ 4 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 lib/NGCP/Schema/Result/contract_vendor_credentials.pm diff --git a/lib/NGCP/Schema/Result/autoprov_devices.pm b/lib/NGCP/Schema/Result/autoprov_devices.pm index 44e4e3e2..7cc6ab64 100644 --- a/lib/NGCP/Schema/Result/autoprov_devices.pm +++ b/lib/NGCP/Schema/Result/autoprov_devices.pm @@ -34,7 +34,7 @@ __PACKAGE__->add_columns( { data_type => "enum", default_value => "http", - extra => { list => ["http","ztp_panasonic","ztp_linksys"] }, + extra => { list => ["http","redirect_panasonic","redirect_linksys"] }, is_nullable => 0, }, ); diff --git a/lib/NGCP/Schema/Result/autoprov_sync_parameters.pm b/lib/NGCP/Schema/Result/autoprov_sync_parameters.pm index ab9242d6..0db91d7f 100644 --- a/lib/NGCP/Schema/Result/autoprov_sync_parameters.pm +++ b/lib/NGCP/Schema/Result/autoprov_sync_parameters.pm @@ -20,7 +20,7 @@ __PACKAGE__->add_columns( { data_type => "enum", default_value => "http", - extra => { list => ["http","ztp_panasonic","ztp_linksys"] }, + extra => { list => ["http","redirect_panasonic","redirect_linksys"] }, is_nullable => 0, }, "parameter_name", diff --git a/lib/NGCP/Schema/Result/contract_vendor_credentials.pm b/lib/NGCP/Schema/Result/contract_vendor_credentials.pm new file mode 100644 index 00000000..1ca2d04c --- /dev/null +++ b/lib/NGCP/Schema/Result/contract_vendor_credentials.pm @@ -0,0 +1,106 @@ +package NGCP::Schema::Result::contract_vendor_credentials; +use Scalar::Util qw(blessed); +use parent 'DBIx::Class::Core'; + +our $VERSION = '2.007'; + +__PACKAGE__->load_components("InflateColumn::DateTime", "Helper::Row::ToJSON"); + +__PACKAGE__->table("billing.contract_vendor_credentials"); + +__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_nullable => 0, + }, + "vendor", + { + data_type => "enum", + default_value => "http", + extra => { list => ["http","redirect_panasonic","redirect_linksys"] }, + is_nullable => 0, + }, + "user", + { data_type => "varchar", is_nullable => 0, size => 255 }, + "password", + { data_type => "varchar", is_nullable => 0, size => 255 }, +); + +__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" }, +); + +sub TO_JSON { + my ($self) = @_; + return { + map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method } + }; +} + +1; +__END__ + +=encoding UTF-8 + +=head1 NAME + +NGCP::Schema::provisioning::Result::contract_vendor_credentials + +=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 contract_id + + data_type: 'integer' + extra: {unsigned => 1} + is_foreign_key: 1 + is_nullable: 0 + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=head1 RELATIONS + +=head2 contract + +Type: belongs_to + +Related object: L + diff --git a/lib/NGCP/Schema/Result/contracts.pm b/lib/NGCP/Schema/Result/contracts.pm index b9eb61c0..e9b2b870 100644 --- a/lib/NGCP/Schema/Result/contracts.pm +++ b/lib/NGCP/Schema/Result/contracts.pm @@ -197,6 +197,13 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->has_many( + "vendor_credentials", + "NGCP::Schema::Result::contract_vendor_credentials", + { "foreign.contract_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + __PACKAGE__->has_many( "voip_sound_sets", "NGCP::Schema::Result::voip_sound_sets",