From 2638f6e091d1fc0e2960353be7691d26dde51d36 Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Tue, 22 Jan 2019 17:40:59 +0100 Subject: [PATCH] TT#46753 ama: 611, 199, 104 and 000 modules Change-Id: I3e1f201f4ce8c47b8836c75e5cd018e45b93756e --- .../BulkProcessor/Projects/Export/Ama/CDR.pm | 32 ++++++- .../Projects/Export/Ama/Format/Field.pm | 10 +- .../Format/Fields/AdditionalDigitsDialed.pm | 49 ++++++++++ .../Ama/Format/Fields/DataDescriptor.pm | 50 ++++++++++ .../Format/Fields/GenericContextIdentifier.pm | 91 +++++++++++++++++++ .../Export/Ama/Format/Fields/GenericIssue.pm | 4 +- .../Export/Ama/Format/Fields/ModuleCode.pm | 69 ++++++++++++++ .../Ama/Format/Fields/NetworkOperatorData.pm | 61 +++++++++++++ .../Fields/SignificantDigitsNextField.pm | 8 +- .../Ama/Format/Fields/TrunkIdentification.pm | 61 +++++++++++++ .../Projects/Export/Ama/Format/File.pm | 21 +++-- .../Projects/Export/Ama/Format/Module.pm | 2 + .../Export/Ama/Format/Modules/Module000.pm | 45 +++++++++ .../Export/Ama/Format/Modules/Module104.pm | 49 +++++++++- .../Export/Ama/Format/Modules/Module199.pm | 53 +++++++++++ .../Export/Ama/Format/Modules/Module611.pm | 55 +++++++++++ .../Ama/Format/Structures/Structure0510.pm | 4 +- 17 files changed, 640 insertions(+), 24 deletions(-) create mode 100644 lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/AdditionalDigitsDialed.pm create mode 100644 lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/DataDescriptor.pm create mode 100644 lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericContextIdentifier.pm create mode 100644 lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ModuleCode.pm create mode 100644 lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/NetworkOperatorData.pm create mode 100644 lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TrunkIdentification.pm create mode 100644 lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module000.pm diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/CDR.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/CDR.pm index 9e734e1..afb8969 100644 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/CDR.pm +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/CDR.pm @@ -41,6 +41,11 @@ use NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure051 use NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure9013 qw(); use NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure9014 qw(); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module000 qw(); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module104 qw(); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module199 qw(); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module611 qw(); + use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType qw(); use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date qw(); use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ServiceFeature qw(); @@ -49,6 +54,9 @@ use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::DomesticInternat use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime qw(); use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ElapsedTime qw(); use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber qw(); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericContextIdentifier qw(); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::NetworkOperatorData qw(); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TrunkIdentification qw(); use NGCP::BulkProcessor::ConnectorPool qw( get_xa_db @@ -261,7 +269,7 @@ sub _export_cdrs_init_context { my ($context,$cdr_id,$call_id) = @_; my $result = 0; - $context->{cdrs} = undef; + $context->{cdrs} = []; $context->{call_id} = $call_id; if (not exists $context->{file_cdr_id_map}->{$cdr_id}) { @@ -422,7 +430,27 @@ sub _get_record { connect_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime::get_connect_time($context->{dt}), elapsed_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ElapsedTime::get_elapsed_time($context->{duration}), - ) + ), + NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module611->new( + generic_context_identifier => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericContextIdentifier::IN_CORRELATION_ID, + parsing_rules => '7', + additional_digits_dialed => ((scalar @{$context->{cdrs}}) > 0 ? substr($context->{cdrs}->[0]->{id},-7) : undef), + ), + NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module199->new( + network_operator_data => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::NetworkOperatorData::get_network_operator_data($context->{source},'123456'), + ), + NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module104->new( + direction => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TrunkIdentification::INCOMING, + trunk_group_number => '2999', + trunk_member_number => '0000', + ), + NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module104->new( + direction => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TrunkIdentification::OUTGOING, + trunk_group_number => '2014', + trunk_member_number => '0000', + ), + NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module000->new( + ), ); } diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Field.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Field.pm index dc044b2..9d3a1ff 100644 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Field.pm +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Field.pm @@ -24,11 +24,13 @@ sub new { ( $self->{name}, $self->{length}, - $self->{instance}, + $self->{field_instance}, + $self->{module_instance}, ) = @params{qw/ name length - instance + field_instance + module_instance /}; $self->_set_params(@_); @@ -40,7 +42,7 @@ sub _get_params { my $self = shift; my %params = @_; my @vals = (); - foreach my $param_name ($self->_get_param_names()) { + foreach my $param_name (map { (length($self->{module_instance}) > 0 ? $self->{module_instance} . '_' : '') . $_; } $self->_get_param_names()) { push(@vals,$params{$param_name} // $self->{$param_name}); } return @vals; @@ -49,7 +51,7 @@ sub _get_params { sub _set_params { my $self = shift; my %params = @_; - foreach my $param_name ($self->_get_param_names()) { + foreach my $param_name (map { (length($self->{module_instance}) > 0 ? $self->{module_instance} . '_' : '') . $_; } $self->_get_param_names()) { $self->{$param_name} = $params{$param_name}; } } diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/AdditionalDigitsDialed.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/AdditionalDigitsDialed.pm new file mode 100644 index 0000000..7c6e956 --- /dev/null +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/AdditionalDigitsDialed.pm @@ -0,0 +1,49 @@ +package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::AdditionalDigitsDialed; +use strict; + +## no critic + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR); + +#use NGCP::BulkProcessor::Array qw(contains); + +require Exporter; +our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field); +our @EXPORT_OK = qw( + +); + +my $field_name = "digits string"; +my $length = 16; +my @param_names = qw/additional_digits_dialed/; + +sub new { + + my $class = shift; + my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new( + $class, + name => $field_name, + length => $length, + @_); + + return $self; + +} + +sub _get_param_names { + + my $self = shift; + return @param_names; + +} + +sub get_hex { + + my $self = shift; + my ($additional_digits_dialed) = $self->_get_params(@_); + die("invalid additional digits dialed '$additional_digits_dialed'") if (length($additional_digits_dialed) < 1 or length($additional_digits_dialed) > 15); + return sprintf('%015d',$additional_digits_dialed) . $TERMINATOR; + +} + +1; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/DataDescriptor.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/DataDescriptor.pm new file mode 100644 index 0000000..b6b1916 --- /dev/null +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/DataDescriptor.pm @@ -0,0 +1,50 @@ +package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::DataDescriptor; +use strict; + +## no critic + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR); + +#use NGCP::BulkProcessor::Array qw(contains); + +require Exporter; +our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field); +our @EXPORT_OK = qw( + +); + +my $field_name = "data descriptor"; +my $length = 4; +my @param_names = qw/data_descriptor/; + +sub new { + + my $class = shift; + my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new( + $class, + name => $field_name, + length => $length, + @_); + $self->{data_descriptor} //= 0; + + return $self; + +} + +sub _get_param_names { + + my $self = shift; + return @param_names; + +} + +sub get_hex { + + my $self = shift; + my ($data_descriptor) = $self->_get_params(@_); + die("invalid data descriptor '$data_descriptor'") if (length($data_descriptor) < 1 or length($data_descriptor) > 3); + return sprintf('%03d',$data_descriptor) . '1'; # . $TERMINATOR; + +} + +1; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericContextIdentifier.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericContextIdentifier.pm new file mode 100644 index 0000000..3f172ec --- /dev/null +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericContextIdentifier.pm @@ -0,0 +1,91 @@ +package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericContextIdentifier; +use strict; + +## no critic + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR); + +use NGCP::BulkProcessor::Array qw(contains); + +require Exporter; +our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field); +our @EXPORT_OK = qw( + $ADDITIONAL_BILLING + $ISUP_CARRIER + $ADDITIONAL_PARTY_CATEGORY + $IN_CORRELATION_ID + $CHARGE_AREA + $FORWARD_FACILITY_COUNT + $BACKWARD_FACILITY_COUNT + $FTUP_BACKWARD_CHARGE + $CLI_SCREENING + $ADDITIONAL_CALLING + $NUMBER_PORTABILITY + $NPI + $CPS +); + +my $field_name = "generic context identifier"; +my $length = 8; +my @param_names = qw/generic_context_identifier parsing_rules/; + +my @generic_context_ids = (); +our $ADDITIONAL_BILLING = '80005'; +push(@generic_context_ids,$ADDITIONAL_BILLING); +our $ISUP_CARRIER = '80006'; +push(@generic_context_ids,$ISUP_CARRIER); +our $ADDITIONAL_PARTY_CATEGORY = '80008'; +push(@generic_context_ids,$ADDITIONAL_PARTY_CATEGORY); +our $IN_CORRELATION_ID = '80014'; +push(@generic_context_ids,$IN_CORRELATION_ID); +our $CHARGE_AREA = '80016'; +push(@generic_context_ids,$CHARGE_AREA); +our $FORWARD_FACILITY_COUNT = '80021'; +push(@generic_context_ids,$FORWARD_FACILITY_COUNT); +our $BACKWARD_FACILITY_COUNT = '80022'; +push(@generic_context_ids,$BACKWARD_FACILITY_COUNT); +our $FTUP_BACKWARD_CHARGE = '80025'; +push(@generic_context_ids,$FTUP_BACKWARD_CHARGE); +our $CLI_SCREENING = '80026'; +push(@generic_context_ids,$CLI_SCREENING); +our $ADDITIONAL_CALLING = '80027'; +push(@generic_context_ids,$ADDITIONAL_CALLING); +our $NUMBER_PORTABILITY = '80030'; +push(@generic_context_ids,$NUMBER_PORTABILITY); +our $NPI = '80050'; +push(@generic_context_ids,$NPI); +our $CPS = '80080'; +push(@generic_context_ids,$CPS); + +sub new { + + my $class = shift; + my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new( + $class, + name => $field_name, + length => $length, + @_); + $self->{parsing_rules} //= 0; + + return $self; + +} + +sub _get_param_names { + + my $self = shift; + return @param_names; + +} + +sub get_hex { + + my $self = shift; + my ($generic_context_identifier,$parsing_rules) = $self->_get_params(@_); + die("invalid generic context identifier '$generic_context_identifier'") unless contains($generic_context_identifier,\@generic_context_ids); + die("invalid parsing rules '$parsing_rules'") if (length($parsing_rules) < 1 or length($parsing_rules) > 2); + return $generic_context_identifier . sprintf('%02d',$parsing_rules) . $TERMINATOR; + +} + +1; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericIssue.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericIssue.pm index d872242..b722a6c 100644 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericIssue.pm +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericIssue.pm @@ -44,8 +44,8 @@ sub get_hex { my $self = shift; my ($generic_issue_number,$point_issue_level,$overwrite_level) = $self->_get_params(@_); - die("invalid generic issue number '$generic_issue_number'") if length($generic_issue_number) < 1 or length($generic_issue_number) > 2; - die("invalid point issue level '$point_issue_level'") if length($point_issue_level) < 1 or length($point_issue_level) > 2; + die("invalid generic issue number '$generic_issue_number'") if (length($generic_issue_number) < 1 or length($generic_issue_number) > 2); + die("invalid point issue level '$point_issue_level'") if (length($point_issue_level) < 1 or length($point_issue_level) > 2); die("invalid overwrite level '$overwrite_level'") if length($overwrite_level) != 1; return sprintf('%02d',$generic_issue_number) . sprintf('%02d',$point_issue_level) . $overwrite_level . $TERMINATOR; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ModuleCode.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ModuleCode.pm new file mode 100644 index 0000000..026b337 --- /dev/null +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ModuleCode.pm @@ -0,0 +1,69 @@ +package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ModuleCode; +use strict; + +## no critic + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR); + +use NGCP::BulkProcessor::Array qw(contains); + +require Exporter; +our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field); +our @EXPORT_OK = qw( + $MODULE_CODE_611 + $MODULE_CODE_199 + $MODULE_CODE_104 + $MODULE_CODE_000 +); + +my $field_name = "module code"; +my $length = 4; +my @param_names = qw/module_code/; + +my @module_codes = (); +our $MODULE_CODE_611 = '611'; +push(@module_codes,$MODULE_CODE_611); +our $MODULE_CODE_199 = '199'; +push(@module_codes,$MODULE_CODE_199); +our $MODULE_CODE_104 = '104'; +push(@module_codes,$MODULE_CODE_104); +our $MODULE_CODE_000 = '000'; +push(@module_codes,$MODULE_CODE_000); + +sub new { + + my $class = shift; + my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new( + $class, + name => $field_name, + length => $length, + @_); + + return $self; + +} + +sub _get_param_names { + + my $self = shift; + return @param_names; + +} + +sub get_module_code { + + my $self = shift; + return $self->{module_code}; + +} + +sub get_hex { + + my $self = shift; + my ($module_code) = $self->_get_params(@_); + die("invalid module code '$module_code'") unless contains($module_code,\@module_codes); + return $module_code . $TERMINATOR; + +} + +1; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/NetworkOperatorData.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/NetworkOperatorData.pm new file mode 100644 index 0000000..5c19bfd --- /dev/null +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/NetworkOperatorData.pm @@ -0,0 +1,61 @@ +package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::NetworkOperatorData; +use strict; + +## no critic + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR); + +#use NGCP::BulkProcessor::Array qw(contains); + +require Exporter; +our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field); +our @EXPORT_OK = qw( + get_network_operator_data +); + +my $field_name = "network operator data"; +my $length = 49; +my @param_names = qw/network_operator_data/; + +sub new { + + my $class = shift; + my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new( + $class, + name => $field_name, + length => $length, + @_); + + return $self; + +} + +sub _get_param_names { + + my $self = shift; + return @param_names; + +} + +sub get_hex { + + my $self = shift; + my ($network_operator_data) = $self->_get_params(@_); + die("invalid network operator data '$network_operator_data'") if length($network_operator_data) != 39; + return $network_operator_data . '1'; #$TERMINATOR; + +} + +sub get_network_operator_data { + my ($originating_digits,$switch_number_digits) = @_; + my $result = $originating_digits; + my $padlength = 16 - length($originating_digits); + $result .= 'f' x $padlength; + $result .= $switch_number_digits; + $padlength = 20 - length($switch_number_digits); + $result .= 'f' x $padlength; + $result .= '800'; + return $result; +} + +1; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SignificantDigitsNextField.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SignificantDigitsNextField.pm index bde0902..bd69632 100644 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SignificantDigitsNextField.pm +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SignificantDigitsNextField.pm @@ -36,11 +36,7 @@ sub new { sub _get_param_names { my $self = shift; - if (defined $self->{instance}) { - return ($self->{instance} . '_significant_digits'); - } else { - return ('significant_digits'); - } + return ((length($self->{field_instance}) > 0 ? $self->{field_instance} . '_' : '') . 'significant_digits'); } @@ -48,7 +44,7 @@ sub get_hex { my $self = shift; my ($significant_digits) = $self->_get_params(@_); - die('invalid ' . (defined $self->{instance} ? $self->{instance} . ' ' : '') . "significant digits '$significant_digits'") if ($significant_digits <= 0 or $significant_digits > 20); + die('invalid ' . (length($self->{field_instance}) > 0 ? $self->{field_instance} . ' ' : '') . "significant digits '$significant_digits'") if ($significant_digits <= 0 or $significant_digits > 20); return sprintf('%03d',$significant_digits) . $TERMINATOR; } diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TrunkIdentification.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TrunkIdentification.pm new file mode 100644 index 0000000..cf46ac3 --- /dev/null +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TrunkIdentification.pm @@ -0,0 +1,61 @@ +package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TrunkIdentification; +use strict; + +## no critic + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR); + +use NGCP::BulkProcessor::Array qw(contains); + +require Exporter; +our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field); +our @EXPORT_OK = qw( + $PADDING + $INCOMING + $OUTGOING +); + +my $field_name = "trunk identification number"; +my $length = 10; +my @param_names = qw/direction trunk_group_number trunk_member_number/; + +my @directions = (); +our $PADDING = '0'; +push(@directions,$PADDING); +our $INCOMING = '1'; +push(@directions,$INCOMING); +our $OUTGOING = '2'; +push(@directions,$OUTGOING); + +sub new { + + my $class = shift; + my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new( + $class, + name => $field_name, + length => $length, + @_); + + return $self; + +} + +sub _get_param_names { + + my $self = shift; + return @param_names; + +} + +sub get_hex { + + my $self = shift; + my ($direction,$trunk_group_number,$trunk_member_number) = $self->_get_params(@_); + die("invalid direction '$direction'") unless contains($direction,\@directions); + die("invalid trunk group number '$trunk_group_number'") if length($trunk_group_number) != 4; + die("invalid trunk member number '$trunk_member_number'") if length($trunk_member_number) != 4; + return $direction . sprintf('%04d',$trunk_group_number) . sprintf('%04d',$trunk_member_number) . $TERMINATOR; + +} + +1; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/File.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/File.pm index 3c73384..4786b35 100644 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/File.pm +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/File.pm @@ -122,19 +122,28 @@ sub flush { commit_cb /}; #unlink 'test.ama'; - if ((scalar @{$self->{blocks}}) > 0 and (my $filename = ($export_cdr_use_temp_files ? $self->{tempfilename} : $self->get_filename()))) { - if (not $export_cdr_use_temp_files and -e $filename) { + if ((scalar @{$self->{blocks}}) > 0 and (my $filename = $self->get_filename())) { + if (-e $filename) { fileerror($filename . ' already exists',getlogger(__PACKAGE__)); return 0; } else { - if (open(my $fh,">:raw",$filename)) { + if (open(my $fh,">:raw",($export_cdr_use_temp_files ? $self->{tempfilename} : $filename))) { foreach my $block (@{$self->{blocks}}) { print $fh pack('H*',$block->get_hex()); } close $fh; if (defined $commit_cb) { - if (&$commit_cb(@_) and (not $export_cdr_use_temp_files or $self->_rename($self->get_filename()))) { - return 1; + if (&$commit_cb(@_)) { + if (not $export_cdr_use_temp_files or $self->_rename($filename)) { + return 1; + } else { + my $err = $!; + eval { + unlink $self->{tempfilename}; + }; + fileerror("failed to rename $self->{tempfilename} to $filename: $err",getlogger(__PACKAGE__)); + return 0; + } } else { eval { unlink $filename unless $export_cdr_use_temp_files; @@ -147,7 +156,7 @@ sub flush { } #restdebug($self,"$self->{crt_path} saved",getlogger(__PACKAGE__)); } else { - fileerror('failed to open ' . $filename . ": $!",getlogger(__PACKAGE__)); + fileerror('failed to open ' . ($export_cdr_use_temp_files ? $self->{tempfilename} : $filename) . ": $!",getlogger(__PACKAGE__)); return 0; } } diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Module.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Module.pm index f1355f6..446d223 100644 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Module.pm +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Module.pm @@ -25,8 +25,10 @@ sub new { my %params = @_; ( $self->{enabled}, + $self->{module_instance}, ) = @params{qw/ enabled + module_instance /}; $self->{enabled} //= 1; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module000.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module000.pm new file mode 100644 index 0000000..7919d93 --- /dev/null +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module000.pm @@ -0,0 +1,45 @@ +package NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module000; +use strict; + +## no critic + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Module qw(); + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ModuleCode qw($MODULE_CODE_000); + +require Exporter; +our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet NGCP::BulkProcessor::Projects::Export::Ama::Format::Module); +our @EXPORT_OK = qw( + $length +); + +our $length = 4; + +sub new { + + my $class = shift; + my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Module->new( + $class, + length => $length, + #structure_name => $structure_name, + @_); + $self->{module_code} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ModuleCode->new( + module_code => $MODULE_CODE_000, + @_, + ); + $self->_add_field($self->{module_code}); + + return $self; + +} + +sub get_module_code_field { + my $self = shift; + return $self->{module_code}; +} + +#sub get_instance { +# return +#} + +1; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module104.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module104.pm index cf9e89b..69f23af 100644 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module104.pm +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module104.pm @@ -1,4 +1,49 @@ +package NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module104; +use strict; +## no critic -TRUNK_FACILITY_ID 129990000C -TRUNK_FACILITY_ID 220140000C \ No newline at end of file +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Module qw(); + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ModuleCode qw($MODULE_CODE_104); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TrunkIdentification qw(); + +require Exporter; +our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet NGCP::BulkProcessor::Projects::Export::Ama::Format::Module); +our @EXPORT_OK = qw( + $length +); + +our $length = 14; + +sub new { + + my $class = shift; + my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Module->new( + $class, + length => $length, + #structure_name => $structure_name, + @_); + $self->{module_code} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ModuleCode->new( + module_code => $MODULE_CODE_104, + @_, + ); + $self->_add_field($self->{module_code}); + $self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TrunkIdentification->new( + @_, + )); + + return $self; + +} + +sub get_module_code_field { + my $self = shift; + return $self->{module_code}; +} + +#sub get_instance { +# return +#} + +1; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module199.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module199.pm index e69de29..7eded3d 100644 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module199.pm +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module199.pm @@ -0,0 +1,53 @@ +package NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module199; +use strict; + +## no critic + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Module qw(); + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ModuleCode qw($MODULE_CODE_199); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::DataDescriptor qw(); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::NetworkOperatorData qw(); + +require Exporter; +our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet NGCP::BulkProcessor::Projects::Export::Ama::Format::Module); +our @EXPORT_OK = qw( + $length +); + +our $length = 48; + +sub new { + + my $class = shift; + my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Module->new( + $class, + length => $length, + #structure_name => $structure_name, + @_); + $self->{module_code} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ModuleCode->new( + module_code => $MODULE_CODE_199, + @_, + ); + $self->_add_field($self->{module_code}); + $self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::DataDescriptor->new( + @_, + )); + $self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::NetworkOperatorData->new( + @_, + )); + + return $self; + +} + +sub get_module_code_field { + my $self = shift; + return $self->{module_code}; +} + +#sub get_instance { +# return +#} + +1; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module611.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module611.pm index e69de29..550175f 100644 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module611.pm +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module611.pm @@ -0,0 +1,55 @@ +package NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module611; +use strict; + +## no critic + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Module qw(); + +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ModuleCode qw($MODULE_CODE_611); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericContextIdentifier qw(); +use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::AdditionalDigitsDialed qw(); + +require Exporter; +our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet NGCP::BulkProcessor::Projects::Export::Ama::Format::Module); +our @EXPORT_OK = qw( + $length +); + +our $length = 28; + +sub new { + + my $class = shift; + my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Module->new( + $class, + length => $length, + #structure_name => $structure_name, + @_); + $self->{module_code} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ModuleCode->new( + module_code => $MODULE_CODE_611, + @_, + ); + $self->_add_field($self->{module_code}); + $self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericContextIdentifier->new( + #generic_context_identifier => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericContextIdentifier::IN_CORRELATION_ID, + #parsing_rules => '7', + @_, + )); + $self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::AdditionalDigitsDialed->new( + @_, + )); + + return $self; + +} + +sub get_module_code_field { + my $self = shift; + return $self->{module_code}; +} + +#sub get_instance { +# return +#} + +1; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure0510.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure0510.pm index 19a066f..b74e544 100644 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure0510.pm +++ b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure0510.pm @@ -95,7 +95,7 @@ sub new { @_, )); $self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField->new( - instance => 'originating', + field_instance => 'originating', @_, )); $self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OriginatingOpenDigits1->new( @@ -111,7 +111,7 @@ sub new { @_, )); $self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField->new( - instance => 'terminating', + field_instance => 'terminating', @_, )); $self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TerminatingOpenDigits1->new(