and remaining migration tools
Change-Id: I71e6633bb0aff4a4d2bfcc94231639462e472882
(cherry picked from commit d3123ff1c4)
changes/58/37758/1
parent
df217952c6
commit
c56441a0f8
File diff suppressed because it is too large
Load Diff
@ -1,293 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Ccs::Settings;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Globals qw(
|
||||
$working_path
|
||||
$enablemultithreading
|
||||
$cpucount
|
||||
create_path
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Logging qw(
|
||||
getlogger
|
||||
scriptinfo
|
||||
configurationinfo
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::LogError qw(
|
||||
fileerror
|
||||
filewarn
|
||||
configurationwarn
|
||||
configurationerror
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::LoadConfig qw(
|
||||
split_tuple
|
||||
parse_regexp
|
||||
);
|
||||
use NGCP::BulkProcessor::Utils qw(prompt timestampdigits); #stringtobool
|
||||
#format_number check_ipnet
|
||||
use NGCP::BulkProcessor::Array qw(contains);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
update_settings
|
||||
|
||||
$input_path
|
||||
|
||||
$defaultsettings
|
||||
$defaultconfig
|
||||
|
||||
|
||||
$skip_errors
|
||||
$force
|
||||
|
||||
$export_cdr_multithreading
|
||||
$export_cdr_numofthreads
|
||||
$export_cdr_blocksize
|
||||
$export_cdr_joins
|
||||
$export_cdr_conditions
|
||||
$export_cdr_limit
|
||||
$export_cdr_stream
|
||||
$export_cdr_rollover_fsn
|
||||
|
||||
$ama_sensor_id
|
||||
$ama_recording_office_id
|
||||
$ama_incoming_trunk_group_number
|
||||
$ama_outgoing_trunk_group_number
|
||||
$ama_originating_digits_cdr_field
|
||||
$ama_terminating_digits_cdr_field
|
||||
$offnet_anonymous_fallback
|
||||
$anonymous_originating_digits
|
||||
|
||||
@ivr_u2u_headers
|
||||
$primary_alias_pattern
|
||||
|
||||
$switch_number_pattern
|
||||
$switch_number_replacement
|
||||
|
||||
$originating_pattern
|
||||
$originating_replacement
|
||||
|
||||
$terminating_pattern
|
||||
$terminating_replacement
|
||||
|
||||
$terminating_open_digits_6001
|
||||
);
|
||||
#$ivr_duration_limit
|
||||
|
||||
our $defaultconfig = 'config.cfg';
|
||||
our $defaultsettings = 'settings.cfg';
|
||||
|
||||
our $input_path = $working_path . 'input/';
|
||||
|
||||
our $force = 0;
|
||||
#our $dry = 0;
|
||||
our $skip_errors = 0;
|
||||
|
||||
our $export_cdr_multithreading = $enablemultithreading;
|
||||
our $export_cdr_numofthreads = $cpucount;
|
||||
our $export_cdr_blocksize = undef;
|
||||
our $export_cdr_joins = [];
|
||||
our $export_cdr_conditions = [];
|
||||
our $export_cdr_limit = undef;
|
||||
our $export_cdr_stream = undef;
|
||||
our $export_cdr_rollover_fsn = 0;
|
||||
|
||||
our $ama_sensor_id;
|
||||
our $ama_recording_office_id;
|
||||
our $ama_incoming_trunk_group_number;
|
||||
our $ama_outgoing_trunk_group_number;
|
||||
our $ama_originating_digits_cdr_field;
|
||||
our $ama_terminating_digits_cdr_field;
|
||||
|
||||
our $offnet_anonymous_fallback = 1; #see rate-o-mat
|
||||
our $anonymous_originating_digits = '00000000000';
|
||||
|
||||
#our $ivr_duration_limit = 5;
|
||||
our @ivr_u2u_headers = ();
|
||||
our $primary_alias_pattern = undef;
|
||||
our $switch_number_pattern = undef;
|
||||
our $switch_number_replacement = undef;
|
||||
our $terminating_open_digits_6001 = undef;
|
||||
our $originating_pattern = undef;
|
||||
our $originating_replacement = undef;
|
||||
our $terminating_pattern = undef;
|
||||
our $terminating_replacement = undef;
|
||||
|
||||
sub update_settings {
|
||||
|
||||
my ($data,$configfile) = @_;
|
||||
|
||||
if (defined $data) {
|
||||
|
||||
my $result = 1;
|
||||
|
||||
$result &= _prepare_working_paths(1);
|
||||
|
||||
$skip_errors = $data->{skip_errors} if exists $data->{skip_errors};
|
||||
|
||||
$export_cdr_multithreading = $data->{export_cdr_multithreading} if exists $data->{export_cdr_multithreading};
|
||||
$export_cdr_numofthreads = _get_numofthreads($cpucount,$data,'export_cdr_numofthreads');
|
||||
$export_cdr_blocksize = $data->{export_cdr_blocksize} if exists $data->{export_cdr_blocksize};
|
||||
|
||||
my $parse_result;
|
||||
($parse_result,$export_cdr_joins) = _parse_export_joins($data->{export_cdr_joins},$configfile);
|
||||
$result &= $parse_result;
|
||||
($parse_result,$export_cdr_conditions) = _parse_export_joins($data->{export_cdr_conditions},$configfile);
|
||||
$result &= $parse_result;
|
||||
|
||||
$export_cdr_limit = $data->{export_cdr_limit} if exists $data->{export_cdr_limit};
|
||||
$export_cdr_stream = $data->{export_cdr_stream} if exists $data->{export_cdr_stream};
|
||||
$export_cdr_rollover_fsn = $data->{export_cdr_rollover_fsn} if exists $data->{export_cdr_rollover_fsn};
|
||||
|
||||
$ama_sensor_id = $data->{ama_sensor_id} if exists $data->{ama_sensor_id};
|
||||
$ama_recording_office_id = $data->{ama_recording_office_id} if exists $data->{ama_recording_office_id};
|
||||
$ama_incoming_trunk_group_number = $data->{ama_incoming_trunk_group_number} if exists $data->{ama_incoming_trunk_group_number};
|
||||
$ama_outgoing_trunk_group_number = $data->{ama_outgoing_trunk_group_number} if exists $data->{ama_outgoing_trunk_group_number};
|
||||
|
||||
$ama_originating_digits_cdr_field = $data->{ama_originating_digits_cdr_field} if exists $data->{ama_originating_digits_cdr_field};
|
||||
unless (contains($ama_originating_digits_cdr_field,[qw(source_user source_user_out source_cli)])) {
|
||||
configurationerror($configfile,'unknown ama_originating_digits_cdr_field',getlogger(__PACKAGE__));
|
||||
}
|
||||
$ama_terminating_digits_cdr_field = $data->{ama_terminating_digits_cdr_field} if exists $data->{ama_terminating_digits_cdr_field};
|
||||
unless (contains($ama_terminating_digits_cdr_field,[qw(destination_user destination_user_out destination_user_dialed destination_user_in)])) {
|
||||
configurationerror($configfile,'unknown ama_terminating_digits_cdr_field',getlogger(__PACKAGE__));
|
||||
}
|
||||
$anonymous_originating_digits = $data->{anonymous_originating_digits} if exists $data->{anonymous_originating_digits};
|
||||
|
||||
#$ivr_duration_limit = $data->{ivr_duration_limit} if exists $data->{ivr_duration_limit};
|
||||
@ivr_u2u_headers = split_tuple($data->{ivr_u2u_headers}) if exists $data->{ivr_u2u_headers};
|
||||
|
||||
my $regexp_result;
|
||||
$primary_alias_pattern = $data->{primary_alias_pattern} if exists $data->{primary_alias_pattern};
|
||||
($regexp_result,$primary_alias_pattern) = parse_regexp($primary_alias_pattern,$configfile);
|
||||
$result &= $regexp_result;
|
||||
|
||||
$switch_number_pattern = $data->{switch_number_pattern} if exists $data->{switch_number_pattern};
|
||||
($regexp_result,$switch_number_pattern) = parse_regexp($switch_number_pattern,$configfile);
|
||||
$result &= $regexp_result;
|
||||
|
||||
$switch_number_replacement = $data->{switch_number_replacement} if exists $data->{switch_number_replacement};
|
||||
|
||||
$originating_pattern = $data->{originating_pattern} if exists $data->{originating_pattern};
|
||||
($regexp_result,$originating_pattern) = parse_regexp($originating_pattern,$configfile);
|
||||
$result &= $regexp_result;
|
||||
|
||||
$originating_replacement = $data->{originating_replacement} if exists $data->{originating_replacement};
|
||||
|
||||
$terminating_pattern = $data->{terminating_pattern} if exists $data->{terminating_pattern};
|
||||
($regexp_result,$terminating_pattern) = parse_regexp($terminating_pattern,$configfile);
|
||||
$result &= $regexp_result;
|
||||
|
||||
$terminating_replacement = $data->{terminating_replacement} if exists $data->{terminating_replacement};
|
||||
|
||||
$terminating_open_digits_6001 = $data->{terminating_open_digits_6001} if exists $data->{terminating_open_digits_6001};
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
sub _prepare_working_paths {
|
||||
|
||||
my ($create) = @_;
|
||||
my $result = 1;
|
||||
my $path_result;
|
||||
|
||||
($path_result,$input_path) = create_path($working_path . 'input',$input_path,$create,\&fileerror,getlogger(__PACKAGE__));
|
||||
$result &= $path_result;
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub _parse_export_joins {
|
||||
my ($token,$file) = @_;
|
||||
my @joins = ();
|
||||
if (defined $token and length($token) > 0) {
|
||||
foreach my $f (_split(\$token)) {
|
||||
next unless($f);
|
||||
$f =~ s/^\s*\{?\s*//;
|
||||
$f =~ s/\}\s*\}\s*$/}/;
|
||||
my ($a, $b) = split(/\s*=>\s*{\s*/, $f);
|
||||
$a =~ s/^\s*\'//;
|
||||
$a =~ s/\'$//g;
|
||||
$b =~ s/\s*\}\s*$//;
|
||||
my ($c, $d) = split(/\s*=>\s*/, $b);
|
||||
$c =~ s/^\s*\'//g;
|
||||
$c =~ s/\'\s*//;
|
||||
$d =~ s/^\s*\'//g;
|
||||
$d =~ s/\'\s*//;
|
||||
push @joins, { $a => { $c => $d } };
|
||||
}
|
||||
}
|
||||
return (1,\@joins);
|
||||
}
|
||||
|
||||
sub _parse_export_conditions {
|
||||
my ($token,$file) = @_;
|
||||
my @conditions = ();
|
||||
if (defined $token and length($token) > 0) {
|
||||
foreach my $f (_split(\$token)) {
|
||||
next unless($f);
|
||||
$f =~ s/^\s*\{?\s*//;
|
||||
$f =~ s/\}\s*\}\s*$/}/;
|
||||
my ($a, $b) = split(/\s*=>\s*{\s*/, $f);
|
||||
$a =~ s/^\s*\'//;
|
||||
$a =~ s/\'$//g;
|
||||
$b =~ s/\s*\}\s*$//;
|
||||
my ($c, $d) = split(/\s*=>\s*/, $b);
|
||||
$c =~ s/^\s*\'//g;
|
||||
$c =~ s/\'\s*//;
|
||||
$d =~ s/^\s*\'//g;
|
||||
$d =~ s/\'\s*//;
|
||||
push @conditions, { $a => { $c => $d } };
|
||||
}
|
||||
}
|
||||
return (1,\@conditions);
|
||||
}
|
||||
|
||||
sub _get_numofthreads {
|
||||
my ($default_value,$data,$key) = @_;
|
||||
my $_numofthreads = $default_value;
|
||||
$_numofthreads = $data->{$key} if exists $data->{$key};
|
||||
$_numofthreads = $cpucount if $_numofthreads > $cpucount;
|
||||
return $_numofthreads;
|
||||
}
|
||||
|
||||
sub _split {
|
||||
|
||||
my $buffer_ref = shift;
|
||||
my $pos = 0;
|
||||
my @tokens = ();
|
||||
my $is_literal = 0;
|
||||
my $token = '';
|
||||
while ($pos < length($$buffer_ref)) {
|
||||
if ("'" eq substr($$buffer_ref,$pos,length("'"))) {
|
||||
$is_literal = not $is_literal;
|
||||
$token .= "'";
|
||||
$pos += length("'");
|
||||
} elsif ("," eq substr($$buffer_ref,$pos,length(","))) {
|
||||
if ($is_literal) {
|
||||
$token .= ",";
|
||||
} else {
|
||||
push(@tokens,$token);
|
||||
$token = '';
|
||||
}
|
||||
$pos += length(",");
|
||||
} else {
|
||||
$token .= substr($$buffer_ref,$pos,1);
|
||||
$pos += 1;
|
||||
}
|
||||
}
|
||||
push(@tokens,$token);
|
||||
return @tokens;
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,64 +0,0 @@
|
||||
##general settings:
|
||||
working_path = /var/sipwise
|
||||
#cpucount = 4
|
||||
enablemultithreading = 0
|
||||
|
||||
rowblock_transactional = 0
|
||||
|
||||
##gearman/service listener config:
|
||||
jobservers = 127.0.0.1:4730
|
||||
|
||||
##NGCP MySQL connectivity - "accounting" db:
|
||||
accounting_host = localhost
|
||||
accounting_port = 3306
|
||||
accounting_databasename = accounting
|
||||
accounting_username = root
|
||||
accounting_password =
|
||||
|
||||
##NGCP MySQL connectivity - "billing" db:
|
||||
billing_host = localhost
|
||||
billing_port = 3306
|
||||
billing_databasename = billing
|
||||
billing_username = root
|
||||
billing_password =
|
||||
|
||||
##NGCP MySQL connectivity - "provisioning" db:
|
||||
provisioning_host = localhost
|
||||
provisioning_port = 3306
|
||||
provisioning_databasename = provisioning
|
||||
provisioning_username = root
|
||||
provisioning_password =
|
||||
|
||||
##NGCP MySQL connectivity - "kamailio" db:
|
||||
kamailio_host = localhost
|
||||
kamailio_port = 3306
|
||||
kamailio_databasename = kamailio
|
||||
kamailio_username = root
|
||||
kamailio_password =
|
||||
|
||||
##NGCP MySQL connectivity - default db for distributed transactions (XA) to connect to:
|
||||
xa_host = localhost
|
||||
xa_port = 3306
|
||||
xa_databasename = billing
|
||||
xa_username = root
|
||||
xa_password =
|
||||
|
||||
##NGCP REST-API connectivity:
|
||||
ngcprestapi_uri = https://10.0.2.15:1443
|
||||
ngcprestapi_username = administrator
|
||||
ngcprestapi_password = administrator
|
||||
ngcprestapi_realm = api_admin_http
|
||||
|
||||
##sending email:
|
||||
emailenable = 0
|
||||
erroremailrecipient =
|
||||
warnemailrecipient =
|
||||
completionemailrecipient = rkrenn@sipwise.com
|
||||
doneemailrecipient =
|
||||
|
||||
##logging:
|
||||
fileloglevel = DEBUG
|
||||
#DEBUG
|
||||
screenloglevel = INFO
|
||||
#INFO
|
||||
emailloglevel = OFF
|
||||
@ -1,64 +0,0 @@
|
||||
##general settings:
|
||||
working_path = /home/rkrenn/temp/export
|
||||
#cpucount = 4
|
||||
enablemultithreading = 0
|
||||
|
||||
rowblock_transactional = 0
|
||||
|
||||
##gearman/service listener config:
|
||||
jobservers = 127.0.0.1:4730
|
||||
|
||||
##NGCP MySQL connectivity - "accounting" db:
|
||||
accounting_host = 192.168.0.29
|
||||
accounting_port = 3306
|
||||
accounting_databasename = accounting
|
||||
accounting_username = root
|
||||
accounting_password =
|
||||
|
||||
##NGCP MySQL connectivity - "billing" db:
|
||||
billing_host = 192.168.0.29
|
||||
billing_port = 3306
|
||||
billing_databasename = billing
|
||||
billing_username = root
|
||||
billing_password =
|
||||
|
||||
##NGCP MySQL connectivity - "provisioning" db:
|
||||
provisioning_host = 192.168.0.29
|
||||
provisioning_port = 3306
|
||||
provisioning_databasename = provisioning
|
||||
provisioning_username = root
|
||||
provisioning_password =
|
||||
|
||||
##NGCP MySQL connectivity - "kamailio" db:
|
||||
kamailio_host = 192.168.0.29
|
||||
kamailio_port = 3306
|
||||
kamailio_databasename = kamailio
|
||||
kamailio_username = root
|
||||
kamailio_password =
|
||||
|
||||
##NGCP MySQL connectivity - default db for distributed transactions (XA) to connect to:
|
||||
xa_host = 192.168.0.29
|
||||
xa_port = 3306
|
||||
xa_databasename = ngcp
|
||||
xa_username = root
|
||||
xa_password =
|
||||
|
||||
##NGCP REST-API connectivity:
|
||||
ngcprestapi_uri = https://127.0.0.1:1443
|
||||
ngcprestapi_username = administrator
|
||||
ngcprestapi_password = administrator
|
||||
ngcprestapi_realm = api_admin_http
|
||||
|
||||
##sending email:
|
||||
emailenable = 0
|
||||
erroremailrecipient =
|
||||
warnemailrecipient =
|
||||
completionemailrecipient = rkrenn@sipwise.com
|
||||
doneemailrecipient =
|
||||
|
||||
##logging:
|
||||
fileloglevel = DEBUG
|
||||
#DEBUG
|
||||
screenloglevel = DEBUG
|
||||
#INFO
|
||||
emailloglevel = OFF
|
||||
@ -1,291 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use File::Basename;
|
||||
use Cwd;
|
||||
use lib Cwd::abs_path(File::Basename::dirname(__FILE__) . '/../../../../../../');
|
||||
|
||||
use Getopt::Long qw(GetOptions);
|
||||
use Fcntl qw(LOCK_EX LOCK_NB);
|
||||
|
||||
use NGCP::BulkProcessor::Globals qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Settings qw(
|
||||
$output_path
|
||||
$tempfile_path
|
||||
);
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Ccs::Settings qw(
|
||||
$defaultsettings
|
||||
$defaultconfig
|
||||
$skip_errors
|
||||
$force
|
||||
);
|
||||
#$dry
|
||||
#check_dry
|
||||
#@provider_config
|
||||
#@providers
|
||||
#$providers_yml
|
||||
|
||||
use NGCP::BulkProcessor::Logging qw(
|
||||
init_log
|
||||
getlogger
|
||||
$attachmentlogfile
|
||||
scriptinfo
|
||||
cleanuplogfiles
|
||||
$currentlogfile
|
||||
);
|
||||
use NGCP::BulkProcessor::LogError qw (
|
||||
completion
|
||||
done
|
||||
scriptwarn
|
||||
scripterror
|
||||
filewarn
|
||||
fileerror
|
||||
);
|
||||
use NGCP::BulkProcessor::LoadConfig qw(
|
||||
load_config
|
||||
$SIMPLE_CONFIG_TYPE
|
||||
$YAML_CONFIG_TYPE
|
||||
$ANY_CONFIG_TYPE
|
||||
);
|
||||
use NGCP::BulkProcessor::Array qw(removeduplicates);
|
||||
use NGCP::BulkProcessor::Utils qw(getscriptpath prompt cleanupdir);
|
||||
use NGCP::BulkProcessor::Mail qw(
|
||||
cleanupmsgfiles
|
||||
);
|
||||
use NGCP::BulkProcessor::SqlConnectors::CSVDB qw(cleanupcvsdirs);
|
||||
use NGCP::BulkProcessor::SqlConnectors::SQLiteDB qw(cleanupdbfiles);
|
||||
use NGCP::BulkProcessor::RestConnectors::NGCPRestApi qw(cleanupcertfiles);
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(destroy_dbs);
|
||||
|
||||
#use NGCP::BulkProcessor::Projects::Massive::Generator::Dao::Blah qw();
|
||||
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::accounting::cdr qw();
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::billing::contracts qw();
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers qw();
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Ccs::CDR qw(
|
||||
export_cdrs
|
||||
reset_fsn
|
||||
reset_export_status
|
||||
);
|
||||
|
||||
scripterror(getscriptpath() . ' already running',getlogger(getscriptpath())) unless flock DATA, LOCK_EX | LOCK_NB; # not tested on windows yet
|
||||
|
||||
my @TASK_OPTS = ();
|
||||
|
||||
my $tasks = [];
|
||||
my $from = undef,
|
||||
my $to = undef;
|
||||
my $call_ids = [];
|
||||
|
||||
my $cleanup_task_opt = 'cleanup';
|
||||
push(@TASK_OPTS,$cleanup_task_opt);
|
||||
my $cleanup_all_task_opt = 'cleanup_all';
|
||||
push(@TASK_OPTS,$cleanup_all_task_opt);
|
||||
|
||||
my $export_cdr_task_opt = 'export_cdr';
|
||||
push(@TASK_OPTS,$export_cdr_task_opt);
|
||||
|
||||
my $reset_fsn_task_opt = 'reset_fsn';
|
||||
push(@TASK_OPTS,$reset_fsn_task_opt);
|
||||
|
||||
my $reset_export_status_task_opt = 'reset_export_status';
|
||||
push(@TASK_OPTS,$reset_export_status_task_opt);
|
||||
|
||||
if (init()) {
|
||||
main();
|
||||
exit(0);
|
||||
} else {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sub init {
|
||||
|
||||
my $configfile = $defaultconfig;
|
||||
my $settingsfile = $defaultsettings;
|
||||
|
||||
return 0 unless GetOptions(
|
||||
"config=s" => \$configfile,
|
||||
"settings=s" => \$settingsfile,
|
||||
"task=s" => $tasks,
|
||||
#"dry" => \$dry,
|
||||
"skip-errors" => \$skip_errors,
|
||||
"force" => \$force,
|
||||
"from=s" => \$from,
|
||||
"to=s" => \$to,
|
||||
"call-id=s" => $call_ids,
|
||||
); # or scripterror('error in command line arguments',getlogger(getscriptpath()));
|
||||
|
||||
$tasks = removeduplicates($tasks,1);
|
||||
$call_ids = removeduplicates($call_ids);
|
||||
|
||||
my $result = load_config($configfile);
|
||||
init_log();
|
||||
$result &= load_config($settingsfile,\&NGCP::BulkProcessor::Projects::Export::Ama::Format::Settings::update_settings,$SIMPLE_CONFIG_TYPE);
|
||||
$result &= load_config($settingsfile,\&NGCP::BulkProcessor::Projects::Export::Ama::Ccs::Settings::update_settings,$SIMPLE_CONFIG_TYPE);
|
||||
#$result &= load_config($providers_yml,\&update_provider_config,$YAML_CONFIG_TYPE);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub main() {
|
||||
|
||||
my @messages = ();
|
||||
my @attachmentfiles = ();
|
||||
my $result = 1;
|
||||
my $completion = 0;
|
||||
|
||||
if (defined $tasks and 'ARRAY' eq ref $tasks and (scalar @$tasks) > 0) {
|
||||
scriptinfo('skip-errors: processing won\'t stop upon errors',getlogger(__PACKAGE__)) if $skip_errors;
|
||||
foreach my $task (@$tasks) {
|
||||
|
||||
if (lc($cleanup_task_opt) eq lc($task)) {
|
||||
$result &= cleanup_task(\@messages,0) if taskinfo($cleanup_task_opt,$result);
|
||||
} elsif (lc($cleanup_all_task_opt) eq lc($task)) {
|
||||
$result &= cleanup_task(\@messages,1) if taskinfo($cleanup_all_task_opt,$result);
|
||||
|
||||
} elsif (lc($export_cdr_task_opt) eq lc($task)) {
|
||||
if (taskinfo($export_cdr_task_opt,$result,1)) {
|
||||
#next unless check_dry();
|
||||
$result &= export_cdr_task(\@messages);
|
||||
$completion |= 1;
|
||||
}
|
||||
|
||||
} elsif (lc($reset_fsn_task_opt) eq lc($task)) {
|
||||
if (taskinfo($reset_fsn_task_opt,$result,1)) {
|
||||
#next unless check_dry();
|
||||
$result &= reset_fsn_task(\@messages);
|
||||
}
|
||||
|
||||
} elsif (lc($reset_export_status_task_opt) eq lc($task)) {
|
||||
if (taskinfo($reset_export_status_task_opt,$result,1)) {
|
||||
#next unless check_dry();
|
||||
$result &= reset_export_status_task(\@messages);
|
||||
}
|
||||
|
||||
} else {
|
||||
$result = 0;
|
||||
scripterror("unknow task option '" . $task . "', must be one of " . join(', ',@TASK_OPTS),getlogger(getscriptpath()));
|
||||
last;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result = 0;
|
||||
scripterror('at least one task option is required. supported tasks: ' . join(', ',@TASK_OPTS),getlogger(getscriptpath()));
|
||||
}
|
||||
|
||||
push(@attachmentfiles,$attachmentlogfile);
|
||||
if ($completion) {
|
||||
completion(join("\n\n",@messages),\@attachmentfiles,getlogger(getscriptpath()));
|
||||
} else {
|
||||
done(join("\n\n",@messages),\@attachmentfiles,getlogger(getscriptpath()));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub taskinfo {
|
||||
my ($task,$result) = @_;
|
||||
scriptinfo($result ? "starting task: '$task'" : "skipping task '$task' due to previous problems",getlogger(getscriptpath()));
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub cleanup_task {
|
||||
my ($messages,$clean_generated) = @_;
|
||||
my $result = 0;
|
||||
if (!$clean_generated or $force or 'yes' eq lc(prompt("Type 'yes' to proceed: "))) {
|
||||
eval {
|
||||
cleanupcvsdirs() if $clean_generated;
|
||||
cleanupdbfiles() if $clean_generated;
|
||||
cleanuplogfiles(\&fileerror,\&filewarn,($currentlogfile,$attachmentlogfile));
|
||||
cleanupmsgfiles(\&fileerror,\&filewarn);
|
||||
cleanupcertfiles();
|
||||
cleanupdir($output_path,1,\&filewarn,getlogger(getscriptpath())) if $clean_generated;
|
||||
cleanupdir($tempfile_path,1,\&filewarn,getlogger(getscriptpath()));
|
||||
$result = 1;
|
||||
};
|
||||
}
|
||||
if ($@ or !$result) {
|
||||
push(@$messages,'working directory cleanup INCOMPLETE');
|
||||
return 0;
|
||||
} else {
|
||||
push(@$messages,'working directory folders cleaned up');
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub export_cdr_task {
|
||||
|
||||
my ($messages) = @_;
|
||||
my ($result,$warning_count,$ama_files) = (0,0,[]);
|
||||
eval {
|
||||
($result,$warning_count,$ama_files) = export_cdrs();
|
||||
};
|
||||
my $err = $@;
|
||||
my $stats = ": " . (scalar @$ama_files) . ' files'; # . ((scalar @$ama_files) > 0 ? "\n " : '') . join("\n ",@$ama_files);
|
||||
foreach my $ama_file (@$ama_files) {
|
||||
$stats .= "\n " . $ama_file;
|
||||
}
|
||||
#eval {
|
||||
# #stats .= "\n total CDRs: " .
|
||||
# # NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::countby_ratingstatus(undef) . ' rows';
|
||||
#};
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"export cdrs INCOMPLETE$stats");
|
||||
} else {
|
||||
push(@$messages,"export cdrs completed$stats");
|
||||
}
|
||||
destroy_dbs();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub reset_fsn_task {
|
||||
|
||||
my ($messages) = @_;
|
||||
my ($result) = (0);
|
||||
eval {
|
||||
($result) = reset_fsn();
|
||||
};
|
||||
my $err = $@;
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"reset file sequence number INCOMPLETE");
|
||||
} else {
|
||||
push(@$messages,"reset file sequence number completed");
|
||||
}
|
||||
destroy_dbs();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub reset_export_status_task {
|
||||
|
||||
my ($messages) = @_;
|
||||
my ($result) = (0);
|
||||
eval {
|
||||
($result) = reset_export_status($from,$to,$call_ids);
|
||||
};
|
||||
my $err = $@;
|
||||
my $fromto = 'from ' . ($from ? $from : '-') . ' to ' . ($to ? $to : '-');
|
||||
if (defined $call_ids and (scalar @$call_ids) > 0) {
|
||||
$fromto = ", call-id(s)\n" . join("\n",@$call_ids);
|
||||
}
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"reset export status $fromto INCOMPLETE");
|
||||
} else {
|
||||
push(@$messages,"reset export status $fromto completed");
|
||||
}
|
||||
destroy_dbs();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
__DATA__
|
||||
This exists to allow the locking code at the beginning of the file to work.
|
||||
DO NOT REMOVE THESE LINES!
|
||||
@ -1,52 +0,0 @@
|
||||
#skip_errors=0
|
||||
|
||||
export_cdr_multithreading = 1
|
||||
export_cdr_numofthreads = 2
|
||||
export_cdr_blocksize = 1000
|
||||
export_cdr_limit = 10000
|
||||
export_cdr_stream = ama_ccs
|
||||
export_cdr_rollover_fsn = 1
|
||||
|
||||
#export_cdr_conditions = { 'accounting.cdr.destination_domain' => { 'IN' => '("80.110.2.164","ccs.upc.at")' } }
|
||||
#export_cdr_conditions = { 'accounting.cdr.destination_domain' => { '=' => '"ccs.upc.at"' } }
|
||||
#{ 'accounting.cdr.export_status' => { '=' => '"unexported"' } }, { 'accounting.cdr.call_status' => { '=' => '"ok"' } }, { 'accounting.cdr.rating_status' => { '=' => '"ok"' } }
|
||||
#export_cdr_joins = { 'billing.voip_subscribers source_voip_subscribers' => { 'source_voip_subscribers.uuid' => 'accounting.cdr.source_user_id' } }, { 'billing.voip_subscribers destination_voip_subscribers' => { 'destination_voip_subscribers.uuid' => 'accounting.cdr.destination_user_id' } }, { 'billing.billing_zones_history source_carrier_bbz' => { 'source_carrier_bbz.id' => 'accounting.cdr.source_carrier_billing_zone_id' } }, { 'billing.billing_zones_history source_reseller_bbz' => { 'source_reseller_bbz.id' => 'accounting.cdr.source_reseller_billing_zone_id' } }, { 'billing.billing_zones_history source_customer_bbz' => { 'source_customer_bbz.id' => 'accounting.cdr.source_customer_billing_zone_id' } }, { 'billing.billing_zones_history destination_carrier_bbz' => { 'destination_carrier_bbz.id' => 'accounting.cdr.destination_carrier_billing_zone_id' } }, { 'billing.billing_zones_history destination_reseller_bbz' => { 'destination_reseller_bbz.id' => 'accounting.cdr.destination_reseller_billing_zone_id' } }, { 'billing.billing_zones_history destination_customer_bbz' => { 'destination_customer_bbz.id' => 'accounting.cdr.destination_customer_billing_zone_id' } }
|
||||
|
||||
use_tempfiles = 1
|
||||
make_dir = 1
|
||||
ama_filename_format = %1$sP%3$02d%4$02d%5$02d%6$02d%7$02d%9$02dAMA%10$s
|
||||
copy_output_path =
|
||||
files_owner =
|
||||
files_group =
|
||||
files_mask =
|
||||
|
||||
ama_max_blocks = 1000
|
||||
|
||||
ama_sensor_id = 438716
|
||||
ama_recording_office_id = 438716
|
||||
ama_incoming_trunk_group_number = 2999
|
||||
ama_outgoing_trunk_group_number = 2014
|
||||
ama_originating_digits_cdr_field = source_cli
|
||||
ama_terminating_digits_cdr_field = destination_user_in
|
||||
|
||||
anonymous_originating_digits = 00000000000
|
||||
|
||||
#ivr_duration_limit = 5
|
||||
primary_alias_pattern = 431976
|
||||
ivr_u2u_headers = IVRmenu,announcements
|
||||
|
||||
switch_number_pattern = ^43
|
||||
switch_number_replacement =
|
||||
|
||||
originating_pattern = ^0
|
||||
originating_replacement =
|
||||
|
||||
terminating_pattern = ^0
|
||||
terminating_replacement =
|
||||
|
||||
terminating_open_digits_6001 = 4319558290
|
||||
|
||||
#international_destination_pattern =
|
||||
#domestic_destination_pattern =
|
||||
#international_destination_not_pattern =
|
||||
#domestic_destination_not_pattern =
|
||||
@ -1,54 +0,0 @@
|
||||
#skip_errors=0
|
||||
|
||||
export_cdr_multithreading = 1
|
||||
export_cdr_numofthreads = 2
|
||||
export_cdr_blocksize = 1000
|
||||
export_cdr_stream = ama_ccs
|
||||
export_cdr_limit = 10000
|
||||
export_cdr_rollover_fsn = 1
|
||||
|
||||
#export_cdr_conditions = { 'accounting.cdr.destination_domain' => { 'IN' => '("80.110.2.164","ccs.upc.at")' } }
|
||||
#export_cdr_conditions = { 'accounting.cdr.destination_domain' => { '=' => '"ccs.upc.at"' } }
|
||||
#, { 'accounting.cdr.rating_status' => { '=' => '"ok"' } }
|
||||
#{ 'accounting.cdr.call_status' => { '=' => '"ok"' } }
|
||||
#export_cdr_joins = { 'accounting.cdr_export_status_data esd' => { 'esd.cdr_id' => 'accounting.cdr.id' } }, { 'accounting.cdr_export_status es' => { 'es.id' => 'esd.status_id' } }
|
||||
export_cdr_conditions = { 'accounting.cdr.id' => { 'IN' => '(51,53, 87,89, 55, 79, 65,67,69, 81,83,85, 111, 113)' } }
|
||||
|
||||
use_tempfiles = 1
|
||||
make_dir = 1
|
||||
ama_filename_format = %1$sdebug/P%3$02d%4$02d%5$02d%6$02d%7$02d%9$02dAMA.debug%10$s
|
||||
copy_output_path = /home/rkrenn/temp/export_copy
|
||||
files_owner =
|
||||
files_group =
|
||||
files_mask =
|
||||
|
||||
ama_max_blocks = 1000
|
||||
|
||||
ama_sensor_id = 438716
|
||||
ama_recording_office_id = 438716
|
||||
ama_incoming_trunk_group_number = 2999
|
||||
ama_outgoing_trunk_group_number = 2014
|
||||
ama_originating_digits_cdr_field = source_cli
|
||||
ama_terminating_digits_cdr_field = destination_user_in
|
||||
|
||||
anonymous_originating_digits = 00000000000
|
||||
|
||||
#ivr_duration_limit = 5
|
||||
#primary_alias_pattern = 431976
|
||||
ivr_u2u_headers = IVRmenu,announcements
|
||||
|
||||
switch_number_pattern = ^43
|
||||
switch_number_replacement =
|
||||
|
||||
originating_pattern = ^0
|
||||
originating_replacement =
|
||||
|
||||
terminating_pattern = ^0
|
||||
terminating_replacement =
|
||||
|
||||
terminating_open_digits_6001 = 4319558290
|
||||
|
||||
international_destination_pattern = abc
|
||||
#domestic_destination_pattern =
|
||||
#international_destination_not_pattern =
|
||||
#domestic_destination_not_pattern =
|
||||
Binary file not shown.
@ -1,147 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use File::Basename;
|
||||
use Cwd;
|
||||
use lib Cwd::abs_path(File::Basename::dirname(__FILE__) . '/../../../../../../');
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Ccs::Settings qw(
|
||||
update_settings
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::LoadConfig qw(
|
||||
load_config
|
||||
$SIMPLE_CONFIG_TYPE
|
||||
$YAML_CONFIG_TYPE
|
||||
$ANY_CONFIG_TYPE
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Calendar qw(current_local);
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::File qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Record qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure0510 qw();
|
||||
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::Fields::CallType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ServiceFeature qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::DomesticInternational qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ElapsedTime qw();
|
||||
|
||||
load_config('config.cfg');
|
||||
load_config('settings.cfg',\&update_settings,$SIMPLE_CONFIG_TYPE);
|
||||
|
||||
my $dt = current_local();
|
||||
my $source = "43011001";
|
||||
my $destination = "43011002";
|
||||
my $duration = 123.456;
|
||||
|
||||
my $file = NGCP::BulkProcessor::Projects::Export::Ama::Format::File->new(
|
||||
|
||||
);
|
||||
|
||||
my $limit = 5000;
|
||||
my $i = 0;
|
||||
my $file_sequence_number = 123;
|
||||
|
||||
sub get_transfer_in {
|
||||
return NGCP::BulkProcessor::Projects::Export::Ama::Format::Record->new(
|
||||
NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure9013->new(
|
||||
|
||||
rewritten => 0,
|
||||
sensor_id => '008708', # Graz
|
||||
|
||||
padding => 0,
|
||||
recording_office_id => '008708',
|
||||
|
||||
date => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date::get_ama_date($dt),
|
||||
|
||||
connect_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime::get_connect_time($dt),
|
||||
|
||||
file_sequence_number => $file_sequence_number,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
sub get_record {
|
||||
return NGCP::BulkProcessor::Projects::Export::Ama::Format::Record->new(
|
||||
NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure0510->new(
|
||||
call_type => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType::STATION_PAID,
|
||||
|
||||
rewritten => 0,
|
||||
sensor_id => '008708', # Graz
|
||||
|
||||
padding => 0,
|
||||
recording_office_id => '008708',
|
||||
|
||||
date => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date::get_ama_date($dt),
|
||||
|
||||
service_feature => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ServiceFeature::OTHER,
|
||||
|
||||
originating_significant_digits => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField::get_number_length($source),
|
||||
originating_open_digits_1 => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField::get_number_digits_1($source),
|
||||
originating_open_digits_2 => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField::get_number_digits_2($source),
|
||||
|
||||
domestic_international => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::DomesticInternational::get_number_domestic_international($destination),
|
||||
|
||||
terminating_significant_digits => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField::get_number_length($destination),
|
||||
terminating_open_digits_1 => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField::get_number_digits_1($destination),
|
||||
terminating_open_digits_2 => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField::get_number_digits_2($destination),
|
||||
|
||||
connect_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime::get_connect_time($dt),
|
||||
elapsed_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ElapsedTime::get_elapsed_time($duration),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
sub get_transfer_out {
|
||||
|
||||
return NGCP::BulkProcessor::Projects::Export::Ama::Format::Record->new(
|
||||
NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure9014->new(
|
||||
|
||||
rewritten => 0,
|
||||
sensor_id => '008708', # Graz
|
||||
|
||||
padding => 0,
|
||||
recording_office_id => '008708',
|
||||
|
||||
date => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date::get_ama_date($dt),
|
||||
|
||||
connect_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime::get_connect_time($dt),
|
||||
|
||||
file_sequence_number => $file_sequence_number,
|
||||
|
||||
#=> (scalar @records),
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
sub commit_cb {
|
||||
print $file_sequence_number . "\n";
|
||||
$file_sequence_number++;
|
||||
}
|
||||
|
||||
while ($i < $limit) {
|
||||
$file->write_record(
|
||||
get_transfer_in => \&get_transfer_in,
|
||||
get_record => \&get_record,
|
||||
get_transfer_out => \&get_transfer_out,
|
||||
commit_cb => \&commit_cb,
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
$file->close(
|
||||
get_transfer_out => \&get_transfer_out,
|
||||
commit_cb => \&commit_cb,
|
||||
);
|
||||
|
||||
#print $test->{structure}->to_string()."\n";
|
||||
#print $test->get_hex();
|
||||
@ -1,91 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Block;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
|
||||
);
|
||||
|
||||
my $block_descriptor_word_length = 8;
|
||||
my $max_block_length = 2048; #bytes
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = bless {}, $class;
|
||||
$self->{records} = [];
|
||||
$self->{padded} = 0;
|
||||
$self->{length} = $block_descriptor_word_length;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub add_record {
|
||||
my $self = shift;
|
||||
my $record = shift;
|
||||
my $length;
|
||||
if (not $self->{padded} and ($length = $self->get_length() + $record->get_length()) <= 2 * $max_block_length) {
|
||||
push(@{$self->{records}},$record);
|
||||
$self->{length} = $length;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
sub records_fit {
|
||||
my $self = shift;
|
||||
my @records = @_;
|
||||
if (not $self->{padded}) {
|
||||
my $length = $self->get_length();
|
||||
foreach my $record (@records) {
|
||||
if (not ref $record) {
|
||||
$length += $record;
|
||||
} else {
|
||||
$length += $record->get_length();
|
||||
}
|
||||
}
|
||||
if ($length <= 2 * $max_block_length) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my $result = $self->_get_block_descriptor_word();
|
||||
foreach my $record (@{$self->{records}}) {
|
||||
$result .= $record->get_hex();
|
||||
}
|
||||
if ($self->{padded}) {
|
||||
$result .= 'a' x (2 * $max_block_length - length($result));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
sub get_length {
|
||||
my $self = shift;
|
||||
return $self->{length};
|
||||
}
|
||||
|
||||
|
||||
sub _get_block_descriptor_word {
|
||||
my $self = shift;
|
||||
return sprintf('%04x',$self->get_length() / 2) . '0000';
|
||||
#return total length in bytes (up to 256*256 bytes)
|
||||
}
|
||||
|
||||
sub set_padded {
|
||||
my $self = shift;
|
||||
$self->{padded} = shift;
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,89 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Field;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::LogError qw(
|
||||
notimplementederror
|
||||
);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
$TERMINATOR
|
||||
);
|
||||
|
||||
our $TERMINATOR = 'c';
|
||||
|
||||
sub new {
|
||||
|
||||
my $base_class = shift;
|
||||
my $class = shift;
|
||||
my $self = bless {}, $class;
|
||||
my %params = @_;
|
||||
(
|
||||
$self->{name},
|
||||
$self->{length},
|
||||
$self->{field_instance},
|
||||
$self->{module_instance},
|
||||
) = @params{qw/
|
||||
name
|
||||
length
|
||||
field_instance
|
||||
module_instance
|
||||
/};
|
||||
$self->_set_params(@_);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_params {
|
||||
my $self = shift;
|
||||
my %params = @_;
|
||||
my @vals = ();
|
||||
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;
|
||||
}
|
||||
|
||||
sub _set_params {
|
||||
my $self = shift;
|
||||
my %params = @_;
|
||||
foreach my $param_name (map { (length($self->{module_instance}) > 0 ? $self->{module_instance} . '_' : '') . $_; } $self->_get_param_names()) {
|
||||
$self->{$param_name} = $params{$param_name};
|
||||
}
|
||||
}
|
||||
|
||||
sub get_name {
|
||||
my $self = shift;
|
||||
return $self->{name};
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my (@params) = @_;
|
||||
|
||||
notimplementederror((ref $self) . ': ' . (caller(0))[3] . ' not implemented',getlogger(__PACKAGE__));
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
notimplementederror((ref $self) . ': ' . (caller(0))[3] . ' not implemented',getlogger(__PACKAGE__));
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
sub get_length {
|
||||
my $self = shift;
|
||||
return $self->{length} if defined $self->{length};
|
||||
return length($self->get_hex(@_));
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,88 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::LogError qw(
|
||||
notimplementederror
|
||||
);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
$line_terminator
|
||||
);
|
||||
|
||||
my $field_separator = ": ";
|
||||
our $line_terminator = "\n";
|
||||
my $indentation = " ";
|
||||
my $padding = ' ';
|
||||
|
||||
sub new {
|
||||
|
||||
my $base_class = shift;
|
||||
my $class = shift;
|
||||
my $self = bless {}, $class;
|
||||
my %params = @_;
|
||||
(
|
||||
$self->{length},
|
||||
) = @params{qw/
|
||||
length
|
||||
/};
|
||||
$self->{fields} = [];
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _add_field {
|
||||
my $self = shift;
|
||||
push(@{$self->{fields}},@_);
|
||||
}
|
||||
|
||||
sub get_name {
|
||||
my $self = shift;
|
||||
#my (@params) = @_;
|
||||
|
||||
notimplementederror((ref $self) . ': ' . (caller(0))[3] . ' not implemented',getlogger(__PACKAGE__));
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my $result = '';
|
||||
foreach my $field (@{$self->{fields}}) {
|
||||
$result .= $field->get_hex(@_);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub get_length {
|
||||
my $self = shift;
|
||||
return $self->{length} if defined $self->{length};
|
||||
my $length = 0;
|
||||
foreach my $field (@{$self->{fields}}) {
|
||||
$length += $field->get_length(@_);
|
||||
}
|
||||
return $length;
|
||||
}
|
||||
|
||||
sub to_string {
|
||||
|
||||
my $self = shift;
|
||||
my @lines = ();
|
||||
my $maxlen = 0;
|
||||
if (length($padding) > 0) {
|
||||
foreach my $field (@{$self->{fields}}) {
|
||||
$maxlen = length($field->get_name()) if $maxlen < length($field->get_name());
|
||||
}
|
||||
}
|
||||
foreach my $field (@{$self->{fields}}) {
|
||||
push(@lines,$indentation . uc($field->get_name()) . $field_separator . ($maxlen > 0 ? ($padding x ($maxlen - length($field->get_name()))) : '') . uc($field->get_hex(@_)));
|
||||
}
|
||||
return join($line_terminator,@lines);
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,49 +0,0 @@
|
||||
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;
|
||||
@ -1,49 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::BlockCount;
|
||||
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 = "block count";
|
||||
my $length = 6;
|
||||
my @param_names = qw/block_count/;
|
||||
|
||||
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 ($block_count) = $self->_get_params(@_);
|
||||
die("invalid block count '$block_count'") if ($block_count < 0 or $block_count > 99999);
|
||||
return sprintf('%05d',$block_count) . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,66 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field);
|
||||
our @EXPORT_OK = qw(
|
||||
$STATION_PAID
|
||||
$STATION_SPECIAL_CALLING
|
||||
$FLAT_RATE
|
||||
$FREE_CALL
|
||||
$TRANSFER
|
||||
$OPERATING_COMPANY_NUMBER_SERVICE_CALLS
|
||||
$MDRRAO
|
||||
$ON_NET_PRIVATE_VIRTUAL_NETWORK
|
||||
$OFF_NET_PRIVATE_VIRTUAL_NETWORK
|
||||
);
|
||||
|
||||
my $field_name = "call type code";
|
||||
my $length = 4;
|
||||
my @param_names = qw/call_type/;
|
||||
|
||||
our $STATION_PAID = '006';
|
||||
our $STATION_SPECIAL_CALLING = '015';
|
||||
our $FLAT_RATE = '067';
|
||||
our $FREE_CALL = '074';
|
||||
our $TRANSFER = '092';
|
||||
our $OPERATING_COMPANY_NUMBER_SERVICE_CALLS = '142';
|
||||
our $MDRRAO = '159';
|
||||
our $ON_NET_PRIVATE_VIRTUAL_NETWORK = '160';
|
||||
our $OFF_NET_PRIVATE_VIRTUAL_NETWORK = '160';
|
||||
#800-999 = Generic Record
|
||||
|
||||
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 ($call_type) = $self->_get_params(@_);
|
||||
die("invalid call type '$call_type'") unless length($call_type) == 3;
|
||||
return $call_type . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,50 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CalledPartyOffHook;
|
||||
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 = "called party off-hook";
|
||||
my $length = 2;
|
||||
my @param_names = qw/unanswered/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
$self->{unanswered} //= 0;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($unanswered) = $self->_get_params(@_);
|
||||
#die("invalid recording office type '$recording_office_type'") unless contains($recording_office_type,[$NOT_USED, $DMS_100_FAMILY]);
|
||||
return ($unanswered ? '1' : '0') . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,60 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR);
|
||||
|
||||
#use NGCP::BulkProcessor::Utils qw(zerofill);
|
||||
#use NGCP::BulkProcessor::Calendar qw(datetime_from_string);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field);
|
||||
our @EXPORT_OK = qw(
|
||||
get_connect_time
|
||||
);
|
||||
|
||||
my $field_name = "connect time";
|
||||
my $length = 8;
|
||||
my @param_names = qw/connect_time/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
#$self->{padding} //= 0;
|
||||
#$self->{sensor_id} = substr($self->{sensor_id},1( if defined $self->{sensor_id};
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($connect_time) = $self->_get_params(@_);
|
||||
die("invalid connect time '$connect_time'") unless length($connect_time) == 7;
|
||||
return $connect_time . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
sub get_connect_time {
|
||||
|
||||
my $dt = shift; #datetime_from_string(shift);
|
||||
return sprintf('%02d',$dt->hour()) . sprintf('%02d',$dt->minute()) . sprintf('%02d',$dt->second()) .
|
||||
substr(sprintf("%03d",$dt->millisecond // 0),0,1);
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,50 +0,0 @@
|
||||
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;
|
||||
@ -1,59 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR);
|
||||
|
||||
#use NGCP::BulkProcessor::Utils qw(zerofill);
|
||||
#use NGCP::BulkProcessor::Calendar qw(datetime_from_string);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field);
|
||||
our @EXPORT_OK = qw(
|
||||
get_ama_date
|
||||
);
|
||||
|
||||
my $field_name = "date";
|
||||
my $length = 6;
|
||||
my @param_names = qw/date/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
#$self->{padding} //= 0;
|
||||
#$self->{sensor_id} = substr($self->{sensor_id},1( if defined $self->{sensor_id};
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($date) = $self->_get_params(@_);
|
||||
die("invalid date '$date'") unless length($date) == 5;
|
||||
return $date . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
sub get_ama_date {
|
||||
|
||||
my $dt = shift; #datetime_from_string(shift);
|
||||
return substr($dt->year(),-1) . sprintf('%02d',$dt->month()) . sprintf('%02d',$dt->day());
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,96 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::DomesticInternational;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Settings qw(
|
||||
$domestic_destination_pattern
|
||||
$international_destination_pattern
|
||||
$domestic_destination_not_pattern
|
||||
$international_destination_not_pattern
|
||||
);
|
||||
|
||||
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_number_domestic_international
|
||||
);
|
||||
|
||||
my $field_name = "domestic/international indicator";
|
||||
my $length = 2;
|
||||
my @param_names = qw/domestic_international/;
|
||||
|
||||
my @domestic_international_modes = ();
|
||||
our $DOMESTIC = '1';
|
||||
push(@domestic_international_modes,$DOMESTIC);
|
||||
our $INTERNATIONAL = '2';
|
||||
push(@domestic_international_modes,$INTERNATIONAL);
|
||||
our $UNKNOWN = '9';
|
||||
push(@domestic_international_modes,$UNKNOWN);
|
||||
|
||||
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 ($domestic_international) = $self->_get_params(@_);
|
||||
die("invalid domestic international '$domestic_international'") unless contains($domestic_international,\@domestic_international_modes);
|
||||
return $domestic_international . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
sub get_number_domestic_international {
|
||||
my $number = shift; #called number (destination)
|
||||
if (defined $number) {
|
||||
if (defined $international_destination_pattern) {
|
||||
if ($number =~ $international_destination_pattern) {
|
||||
return $INTERNATIONAL;
|
||||
} else {
|
||||
return $DOMESTIC;
|
||||
}
|
||||
} elsif (defined $domestic_destination_pattern) {
|
||||
if ($number =~ $domestic_destination_pattern) {
|
||||
return $DOMESTIC;
|
||||
} else {
|
||||
return $INTERNATIONAL;
|
||||
}
|
||||
} elsif (defined $international_destination_not_pattern) {
|
||||
if ($number !~ $international_destination_not_pattern) {
|
||||
return $INTERNATIONAL;
|
||||
} else {
|
||||
return $DOMESTIC;
|
||||
}
|
||||
} elsif (defined $domestic_destination_not_pattern) {
|
||||
if ($number !~ $domestic_destination_not_pattern) {
|
||||
return $DOMESTIC;
|
||||
} else {
|
||||
return $INTERNATIONAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $UNKNOWN;
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,60 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ElapsedTime;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR);
|
||||
|
||||
use NGCP::BulkProcessor::Utils qw(to_duration_string);
|
||||
#use NGCP::BulkProcessor::Calendar qw(datetime_from_string);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field);
|
||||
our @EXPORT_OK = qw(
|
||||
get_elapsed_time
|
||||
);
|
||||
|
||||
my $field_name = "elapsed time";
|
||||
my $length = 10;
|
||||
my @param_names = qw/elapsed_time/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
#$self->{padding} //= 0;
|
||||
#$self->{sensor_id} = substr($self->{sensor_id},1( if defined $self->{sensor_id};
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($elapsed_time) = $self->_get_params(@_);
|
||||
die("invalid elapsed time '$elapsed_time'") unless length($elapsed_time) == 9;
|
||||
return $elapsed_time . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
sub get_elapsed_time {
|
||||
|
||||
my $duration_secs = shift;
|
||||
my ($pretty,$years,$months,$days,$hours,$minutes,$seconds) = to_duration_string($duration_secs,'minutes','seconds',3,undef);
|
||||
return '0' . sprintf('%05d',$minutes) . sprintf('%02d',$seconds) . substr(sprintf("%03d",int(($seconds - int($seconds)) * 1000.0)),0,1);
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,53 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber;
|
||||
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(
|
||||
$min_fsn
|
||||
$max_fsn
|
||||
);
|
||||
|
||||
my $field_name = "file sequence number";
|
||||
my $length = 4;
|
||||
my @param_names = qw/file_sequence_number/;
|
||||
|
||||
our $min_fsn = 0; #1;
|
||||
our $max_fsn = 99; #999;
|
||||
|
||||
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 ($file_sequence_number) = $self->_get_params(@_);
|
||||
die("invalid file sequence number '$file_sequence_number'") if ($file_sequence_number < $min_fsn or $file_sequence_number > $max_fsn);
|
||||
return sprintf('%03d',$file_sequence_number) . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,95 +0,0 @@
|
||||
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
|
||||
|
||||
$IN_CORRELATION_ID_PARSING_RULES
|
||||
);
|
||||
|
||||
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);
|
||||
|
||||
our $IN_CORRELATION_ID_PARSING_RULES = 7;
|
||||
|
||||
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;
|
||||
@ -1,54 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericIssue;
|
||||
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 = "generic issue";
|
||||
my $length = 6;
|
||||
my @param_names = qw/generic_issue_number point_issue_level overwrite_level/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
$self->{generic_issue_number} //= 0;
|
||||
$self->{point_issue_level} //= 0;
|
||||
$self->{overwrite_level} //= 0;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
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 overwrite level '$overwrite_level'") if length($overwrite_level) != 1;
|
||||
return sprintf('%02d',$generic_issue_number) . sprintf('%02d',$point_issue_level) . $overwrite_level . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,47 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::HexId;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field);
|
||||
our @EXPORT_OK = qw(
|
||||
|
||||
);
|
||||
|
||||
my $field_name = "hex id";
|
||||
my $length = 2;
|
||||
my @param_names = qw/is_error/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
$self->{is_error} //= 0;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($is_error) = $self->_get_params(@_);
|
||||
return ($is_error ? 'ab' : 'aa');
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,69 +0,0 @@
|
||||
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;
|
||||
@ -1,69 +0,0 @@
|
||||
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 = 40;
|
||||
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) != 40;
|
||||
return $network_operator_data; # . '1'; #$TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
sub get_network_operator_data {
|
||||
my ($originating_digits,$switch_number_digits,$mode) = @_;
|
||||
my $result = $originating_digits;
|
||||
my $padlength = 16 - length($originating_digits);
|
||||
if ($padlength >= 0) {
|
||||
$result .= 'f' x $padlength;
|
||||
} else {
|
||||
die("invalid network operator data/originating_digits '$originating_digits'");
|
||||
}
|
||||
$result .= $switch_number_digits;
|
||||
$padlength = 20 - length($switch_number_digits);
|
||||
if ($padlength >= 0) {
|
||||
$result .= 'f' x $padlength;
|
||||
} else {
|
||||
die("invalid network operator data/switch_number_digits '$switch_number_digits'");
|
||||
}
|
||||
$result .= $mode;
|
||||
return $result;
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,49 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OperatorAction;
|
||||
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 = "operator action";
|
||||
my $length = 2;
|
||||
my @param_names = ();
|
||||
|
||||
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 ($unanswered) = $self->_get_params(@_);
|
||||
#die("invalid recording office type '$recording_office_type'") unless contains($recording_office_type,[$NOT_USED, $DMS_100_FAMILY]);
|
||||
return '0' . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,53 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OriginatingChargeInformation;
|
||||
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 = "originating charge information";
|
||||
my $length = 4;
|
||||
my @param_names = qw/originating_charge_information/;
|
||||
|
||||
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 ($originating_charge_information) = $self->_get_params(@_);
|
||||
if (length($originating_charge_information) > 0) {
|
||||
die("invalid originating charge information '$originating_charge_information'") unless length($originating_charge_information) == 3; #($originating_charge_information < 0 or $originating_charge_information > 255);
|
||||
return $originating_charge_information . $TERMINATOR;
|
||||
} else {
|
||||
return 'ffff';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,50 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OriginatingOpenDigits1;
|
||||
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 = "originating open digits 1";
|
||||
my $length = 12;
|
||||
my @param_names = qw/originating_open_digits_1/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
#$self->{significant_digits} //= 0;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($originating_open_digits_1) = $self->_get_params(@_);
|
||||
die("invalid originating open digits 1 '$originating_open_digits_1'") unless $originating_open_digits_1 =~ /^\d{1,11}$/;
|
||||
return sprintf('%011d',$originating_open_digits_1) . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,54 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OriginatingOpenDigits2;
|
||||
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 = "originating open digits 2";
|
||||
my $length = 10;
|
||||
my @param_names = qw/originating_open_digits_2/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
#$self->{significant_digits} //= 0;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($originating_open_digits_2) = $self->_get_params(@_);
|
||||
if (length($originating_open_digits_2) > 0) {
|
||||
die("invalid originating open digits 2 '$originating_open_digits_2'") unless $originating_open_digits_2 =~ /^\d{1,9}$/;
|
||||
return sprintf('%09d',$originating_open_digits_2) . $TERMINATOR;
|
||||
} else {
|
||||
return 'ffffffffff';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,49 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordCount;
|
||||
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 = "record count";
|
||||
my $length = 8;
|
||||
my @param_names = qw/record_count/;
|
||||
|
||||
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 ($record_count) = $self->_get_params(@_);
|
||||
die("invalid record count '$record_count'") if ($record_count < 0 or $record_count > 9999999);
|
||||
return sprintf('%07d',$record_count) . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,51 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeId;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR);
|
||||
|
||||
#use NGCP::BulkProcessor::Utils qw(zerofill);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field);
|
||||
our @EXPORT_OK = qw(
|
||||
|
||||
);
|
||||
|
||||
my $field_name = "recording office id";
|
||||
my $length = 8;
|
||||
my @param_names = qw/padding recording_office_id/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
$self->{padding} //= 0;
|
||||
#$self->{sensor_id} = substr($self->{sensor_id},1( if defined $self->{sensor_id};
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($padding,$recording_office_id) = $self->_get_params(@_);
|
||||
die("invalid recording office id '$recording_office_id'") unless length($recording_office_id) == 6;
|
||||
return ($padding ? '1' : '0') . $recording_office_id . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,51 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeType;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR);
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorType qw($NOT_USED $DMS_100_FAMILY);
|
||||
|
||||
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 = "recording office type";
|
||||
my $length = 4;
|
||||
my @param_names = qw/recording_office_type/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
$self->{recording_office_type} //= $DMS_100_FAMILY;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($recording_office_type) = $self->_get_params(@_);
|
||||
die("invalid recording office type '$recording_office_type'") unless contains($recording_office_type,[$NOT_USED, $DMS_100_FAMILY]);
|
||||
return $recording_office_type . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,51 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorId;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR);
|
||||
|
||||
#use NGCP::BulkProcessor::Utils qw(zerofill);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field);
|
||||
our @EXPORT_OK = qw(
|
||||
|
||||
);
|
||||
|
||||
my $field_name = "sensor id";
|
||||
my $length = 8;
|
||||
my @param_names = qw/rewritten sensor_id/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
$self->{rewritten} //= 0;
|
||||
#$self->{sensor_id} = substr($self->{sensor_id},1( if defined $self->{sensor_id};
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($rewritten,$sensor_id) = $self->_get_params(@_);
|
||||
die("invalid sensor id '$sensor_id'") unless length($sensor_id) == 6;
|
||||
return ($rewritten ? '1' : '0') . $sensor_id . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,54 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorType;
|
||||
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(
|
||||
$NOT_USED
|
||||
$DMS_100_FAMILY
|
||||
);
|
||||
|
||||
my $field_name = "sensor type";
|
||||
my $length = 4;
|
||||
my @param_names = qw/sensor_type/;
|
||||
|
||||
our $NOT_USED = '000';
|
||||
our $DMS_100_FAMILY = '036';
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
$self->{sensor_type} //= $DMS_100_FAMILY;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($sensor_type) = $self->_get_params(@_);
|
||||
die("invalid sensor type '$sensor_type'") unless contains($sensor_type,[$NOT_USED, $DMS_100_FAMILY]);
|
||||
return $sensor_type . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,63 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ServiceFeature;
|
||||
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(
|
||||
$OTHER
|
||||
$THREE_WAY
|
||||
$CF_LEG
|
||||
$CFB_LEG
|
||||
$BTUP_CBWF
|
||||
$ROUTE_OPT_IND
|
||||
);
|
||||
|
||||
my $field_name = "service feature";
|
||||
my $length = 4;
|
||||
my @param_names = qw/service_feature/;
|
||||
|
||||
our $OTHER = '000';
|
||||
our $THREE_WAY = '010';
|
||||
our $CF_LEG = '012';
|
||||
our $CFB_LEG = '014';
|
||||
our $BTUP_CBWF = '029';
|
||||
our $ROUTE_OPT_IND = '156';
|
||||
#800-999 = generic value
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
#$self->{service_feature} //= 0;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($service_feature) = $self->_get_params(@_);
|
||||
die("invalid service feature '$service_feature'") unless length($service_feature) == 3;
|
||||
return sprintf("%03d",$service_feature) . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,75 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ServiceObserved;
|
||||
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(
|
||||
$NOT_OBSERVED_NOT_SAMPLED
|
||||
$OBSERVED_NOT_SAMPLED
|
||||
$NOT_OBSERVED_SAMPLED
|
||||
$OBSERVED_SAMPLED
|
||||
$SMDR_APPLICABLE
|
||||
$OBSERVED_NOT_SAMPLED_SMDR_APPLICABLE
|
||||
$NOT_OBSERVED_SAMPLED_SMDR_APPLICABLE
|
||||
$OBSERVED_SAMPLED_SMDR_APPLICABLE
|
||||
);
|
||||
|
||||
my $field_name = "service observed";
|
||||
my $length = 2;
|
||||
my @param_names = qw/observed_sampled/;
|
||||
|
||||
my @observed_sampled_modes = ();
|
||||
our $NOT_OBSERVED_NOT_SAMPLED = '0';
|
||||
push(@observed_sampled_modes,$NOT_OBSERVED_NOT_SAMPLED);
|
||||
our $OBSERVED_NOT_SAMPLED = '1';
|
||||
push(@observed_sampled_modes,$OBSERVED_NOT_SAMPLED);
|
||||
our $NOT_OBSERVED_SAMPLED = '2';
|
||||
push(@observed_sampled_modes,$NOT_OBSERVED_SAMPLED);
|
||||
our $OBSERVED_SAMPLED = '3';
|
||||
push(@observed_sampled_modes,$OBSERVED_SAMPLED);
|
||||
our $SMDR_APPLICABLE = '4';
|
||||
push(@observed_sampled_modes,$SMDR_APPLICABLE);
|
||||
our $OBSERVED_NOT_SAMPLED_SMDR_APPLICABLE = '5';
|
||||
push(@observed_sampled_modes,$OBSERVED_NOT_SAMPLED_SMDR_APPLICABLE);
|
||||
our $NOT_OBSERVED_SAMPLED_SMDR_APPLICABLE = '6';
|
||||
push(@observed_sampled_modes,$NOT_OBSERVED_SAMPLED_SMDR_APPLICABLE);
|
||||
our $OBSERVED_SAMPLED_SMDR_APPLICABLE = '7';
|
||||
push(@observed_sampled_modes,$OBSERVED_SAMPLED_SMDR_APPLICABLE);
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
$self->{observed_sampled} //= $NOT_OBSERVED_NOT_SAMPLED;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($observed_sampled) = $self->_get_params(@_);
|
||||
die("invalid observed sampled '$observed_sampled'") unless contains($observed_sampled,\@observed_sampled_modes);
|
||||
return $observed_sampled . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,64 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField;
|
||||
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_number_length
|
||||
get_number_digits_1
|
||||
get_number_digits_2
|
||||
);
|
||||
|
||||
my $field_name = "significant digits in next field";
|
||||
my $length = 4;
|
||||
#my @param_names = qw/significant_digits/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
#$self->{significant_digits} //= 0;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return ((length($self->{field_instance}) > 0 ? $self->{field_instance} . '_' : '') . 'significant_digits');
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($significant_digits) = $self->_get_params(@_);
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
sub get_number_length {
|
||||
return length(shift);
|
||||
}
|
||||
|
||||
sub get_number_digits_1 {
|
||||
return substr(shift,0,11);
|
||||
}
|
||||
|
||||
sub get_number_digits_2 {
|
||||
return substr(shift,11);
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,86 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::StructureCode;
|
||||
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(
|
||||
$STRUCTURE_CODE_0510
|
||||
$STRUCTURE_CODE_0511
|
||||
$STRUCTURE_CODE_0512
|
||||
$STRUCTURE_CODE_0513
|
||||
$STRUCTURE_CODE_0514
|
||||
|
||||
$STRUCTURE_CODE_9013
|
||||
$STRUCTURE_CODE_9014
|
||||
);
|
||||
|
||||
my $field_name = "structure code";
|
||||
my $length = 6;
|
||||
my @param_names = qw/has_modules structure_code/;
|
||||
|
||||
my @structure_codes = ();
|
||||
our $STRUCTURE_CODE_0510 = '0510';
|
||||
push(@structure_codes,$STRUCTURE_CODE_0510);
|
||||
our $STRUCTURE_CODE_0511 = '0511';
|
||||
push(@structure_codes,$STRUCTURE_CODE_0511);
|
||||
our $STRUCTURE_CODE_0512 = '0512';
|
||||
push(@structure_codes,$STRUCTURE_CODE_0512);
|
||||
our $STRUCTURE_CODE_0513 = '0513';
|
||||
push(@structure_codes,$STRUCTURE_CODE_0513);
|
||||
our $STRUCTURE_CODE_0514 = '0514';
|
||||
push(@structure_codes,$STRUCTURE_CODE_0514);
|
||||
our $STRUCTURE_CODE_9013 = '9013';
|
||||
push(@structure_codes,$STRUCTURE_CODE_9013);
|
||||
our $STRUCTURE_CODE_9014 = '9014';
|
||||
push(@structure_codes,$STRUCTURE_CODE_9014);
|
||||
|
||||
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 set_has_modules {
|
||||
|
||||
my $self = shift;
|
||||
$self->{has_modules} = shift;
|
||||
|
||||
}
|
||||
|
||||
sub get_structure_code {
|
||||
|
||||
my $self = shift;
|
||||
return $self->{structure_code};
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($has_modules,$structure_code) = $self->_get_params(@_);
|
||||
die("invalid structure code '$structure_code'") unless contains($structure_code,\@structure_codes);
|
||||
return ($has_modules ? '4' : '0') . $structure_code . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,103 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::StudyIndicator;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR);
|
||||
|
||||
#use NGCP::BulkProcessor::Utils qw(zerofill);
|
||||
use NGCP::BulkProcessor::Array qw(contains);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field);
|
||||
our @EXPORT_OK = qw(
|
||||
$STUDY_TYPE_A_NA
|
||||
$STUDY_TYPE_A_SLUS
|
||||
$STUDY_TYPE_B_NA
|
||||
$STUDY_TYPE_B_OBSERVED
|
||||
$STUDY_TYPE_B_UNANSWERED_CALL_RECORDING
|
||||
$STUDY_TYPE_B_OBSERVED_UNANSWERED_CALL_RECORDING
|
||||
$STUDY_TYPE_C_NA
|
||||
$STUDY_TYPE_C_GENERATED
|
||||
$TEST_CALL_NA
|
||||
$TEST_CALL
|
||||
$NUMBER_NANP_NA
|
||||
$NUMBER_NANP_CALLER
|
||||
$NUMBER_NANP_CALLEE
|
||||
$NUMBER_NANP_CALLER_CALLEE
|
||||
);
|
||||
|
||||
my $field_name = "study indicator";
|
||||
my $length = 8;
|
||||
my @param_names = qw/study_type_a study_type_b study_type_c test_call_ind number_nanp_ind/;
|
||||
|
||||
my @study_a_modes = ();
|
||||
our $STUDY_TYPE_A_NA = '0';
|
||||
push(@study_a_modes,$STUDY_TYPE_A_NA);
|
||||
our $STUDY_TYPE_A_SLUS = '2';
|
||||
push(@study_a_modes,$STUDY_TYPE_A_SLUS);
|
||||
my @study_b_modes = ();
|
||||
our $STUDY_TYPE_B_NA = '0';
|
||||
push(@study_b_modes,$STUDY_TYPE_B_NA);
|
||||
our $STUDY_TYPE_B_OBSERVED = '1';
|
||||
push(@study_b_modes,$STUDY_TYPE_B_OBSERVED);
|
||||
our $STUDY_TYPE_B_UNANSWERED_CALL_RECORDING = '2';
|
||||
push(@study_b_modes,$STUDY_TYPE_B_UNANSWERED_CALL_RECORDING);
|
||||
our $STUDY_TYPE_B_OBSERVED_UNANSWERED_CALL_RECORDING = '3';
|
||||
push(@study_b_modes,$STUDY_TYPE_B_OBSERVED_UNANSWERED_CALL_RECORDING);
|
||||
my @study_c_modes = ();
|
||||
our $STUDY_TYPE_C_NA = '0';
|
||||
push(@study_c_modes,$STUDY_TYPE_C_NA);
|
||||
our $STUDY_TYPE_C_GENERATED = '2';
|
||||
push(@study_c_modes,$STUDY_TYPE_C_GENERATED);
|
||||
our $TEST_CALL_NA = '0';
|
||||
our $TEST_CALL = '1';
|
||||
my @number_nanp_modes = ();
|
||||
our $NUMBER_NANP_NA = '0';
|
||||
push(@number_nanp_modes,$NUMBER_NANP_NA);
|
||||
our $NUMBER_NANP_CALLER = '1';
|
||||
push(@number_nanp_modes,$NUMBER_NANP_CALLER);
|
||||
our $NUMBER_NANP_CALLEE = '2';
|
||||
push(@number_nanp_modes,$NUMBER_NANP_CALLEE);
|
||||
our $NUMBER_NANP_CALLER_CALLEE = '3';
|
||||
push(@number_nanp_modes,$NUMBER_NANP_CALLER_CALLEE);
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
$self->{study_type_a} //= $STUDY_TYPE_A_NA;
|
||||
$self->{study_type_b} //= $STUDY_TYPE_B_NA;
|
||||
$self->{study_type_c} //= $STUDY_TYPE_C_NA;
|
||||
$self->{test_call_ind} //= $TEST_CALL_NA;
|
||||
$self->{number_nanp_ind} //= $NUMBER_NANP_NA;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($study_type_a,$study_type_b,$study_type_c,$test_call_ind,$number_nanp_ind) = $self->_get_params(@_);
|
||||
die("invalid study type a '$study_type_a'") unless contains($study_type_a,\@study_a_modes);
|
||||
die("invalid study type b '$study_type_b'") unless contains($study_type_b,\@study_b_modes);
|
||||
die("invalid study type c '$study_type_c'") unless contains($study_type_c,\@study_c_modes);
|
||||
die("invalid test call ind '$test_call_ind'") unless contains($test_call_ind,[$TEST_CALL_NA, $TEST_CALL]);
|
||||
die("invalid number nanp ind '$number_nanp_ind'") unless contains($number_nanp_ind,\@number_nanp_modes);
|
||||
return $study_type_a . $study_type_b . $study_type_c . $test_call_ind . '0' . $number_nanp_ind . '0' . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,50 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TerminatingOpenDigits1;
|
||||
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 = "terminating open digits 1";
|
||||
my $length = 12;
|
||||
my @param_names = qw/terminating_open_digits_1/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
#$self->{significant_digits} //= 0;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($terminating_open_digits_1) = $self->_get_params(@_);
|
||||
die("invalid terminating open digits 1 '$terminating_open_digits_1'") unless $terminating_open_digits_1 =~ /^\d{1,11}$/;
|
||||
return sprintf('%011d',$terminating_open_digits_1) . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,54 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TerminatingOpenDigits2;
|
||||
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 = "terminating open digits 2";
|
||||
my $length = 10;
|
||||
my @param_names = qw/terminating_open_digits_2/;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
#$self->{significant_digits} //= 0;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($terminating_open_digits_2) = $self->_get_params(@_);
|
||||
if (length($terminating_open_digits_2) > 0) {
|
||||
die("invalid terminating open digits 2 '$terminating_open_digits_2'") unless $terminating_open_digits_2 =~ /^\d{1,9}$/;
|
||||
return sprintf('%09d',$terminating_open_digits_2) . $TERMINATOR;
|
||||
} else {
|
||||
return 'ffffffffff';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,76 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TimingIndicator;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Field qw($TERMINATOR);
|
||||
|
||||
#use NGCP::BulkProcessor::Utils qw(zerofill);
|
||||
use NGCP::BulkProcessor::Array qw(contains);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::Field);
|
||||
our @EXPORT_OK = qw(
|
||||
$TIMING_GUARD_DEFAULT
|
||||
$TIMING_GUARD_ELAPSED_TIME_ESTIMATED
|
||||
$CALLED_PARTY_DEFAULT
|
||||
$CALLED_PARTY_OFF_HOOK
|
||||
$LONG_DURATION_DEFAULT
|
||||
$LONG_DURATION_START
|
||||
$LONG_DURATION_CONTINUE
|
||||
$LONG_DURATION_END
|
||||
);
|
||||
|
||||
my $field_name = "timing indicator";
|
||||
my $length = 6;
|
||||
my @param_names = qw/timing_guard called_party long_duration/;
|
||||
|
||||
our $TIMING_GUARD_DEFAULT = '0';
|
||||
our $TIMING_GUARD_ELAPSED_TIME_ESTIMATED = '2';
|
||||
our $CALLED_PARTY_DEFAULT = '0';
|
||||
our $CALLED_PARTY_OFF_HOOK = '1';
|
||||
my @long_duration_modes = ();
|
||||
our $LONG_DURATION_DEFAULT = '0';
|
||||
push(@long_duration_modes,$LONG_DURATION_DEFAULT);
|
||||
our $LONG_DURATION_START = '1';
|
||||
push(@long_duration_modes,$LONG_DURATION_START);
|
||||
our $LONG_DURATION_CONTINUE = '2';
|
||||
push(@long_duration_modes,$LONG_DURATION_CONTINUE);
|
||||
our $LONG_DURATION_END = '3';
|
||||
push(@long_duration_modes,$LONG_DURATION_END);
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Field->new(
|
||||
$class,
|
||||
name => $field_name,
|
||||
length => $length,
|
||||
@_);
|
||||
$self->{timing_guard} //= $TIMING_GUARD_DEFAULT;
|
||||
$self->{called_party} //= $CALLED_PARTY_DEFAULT;
|
||||
$self->{long_duration} //= $LONG_DURATION_DEFAULT;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub _get_param_names {
|
||||
|
||||
my $self = shift;
|
||||
return @param_names;
|
||||
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my ($timing_guard,$called_party,$long_duration) = $self->_get_params(@_);
|
||||
die("invalid timing guard '$timing_guard'") unless contains($timing_guard,[$TIMING_GUARD_DEFAULT, $TIMING_GUARD_ELAPSED_TIME_ESTIMATED]);
|
||||
die("invalid called party '$called_party'") unless contains($called_party,[$CALLED_PARTY_DEFAULT, $CALLED_PARTY_OFF_HOOK]);
|
||||
die("invalid long duration '$long_duration'") unless contains($long_duration,\@long_duration_modes);
|
||||
return $timing_guard . $called_party . $long_duration . '00' . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,65 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TracerType;
|
||||
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(
|
||||
$TRANSFER_IN
|
||||
$TRANSFER_OUT
|
||||
$AMATPS_PRIMARY
|
||||
$AMATPS_SECONDARY
|
||||
$DMS100F_HOURLY
|
||||
);
|
||||
|
||||
my $field_name = "tracer type";
|
||||
my $length = 4;
|
||||
my @param_names = qw/tracer_type/;
|
||||
|
||||
my @tracer_types = ();
|
||||
our $TRANSFER_IN = '007';
|
||||
push(@tracer_types,$TRANSFER_IN);
|
||||
our $TRANSFER_OUT = '008';
|
||||
push(@tracer_types,$TRANSFER_OUT);
|
||||
our $AMATPS_PRIMARY = '032';
|
||||
push(@tracer_types,$AMATPS_PRIMARY);
|
||||
our $AMATPS_SECONDARY = '033';
|
||||
push(@tracer_types,$AMATPS_SECONDARY);
|
||||
our $DMS100F_HOURLY = '037';
|
||||
push(@tracer_types,$DMS100F_HOURLY);
|
||||
|
||||
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 ($tracer_type) = $self->_get_params(@_);
|
||||
die("invalid tracer type '$tracer_type'") unless contains($tracer_type,\@tracer_types);
|
||||
return $tracer_type . $TERMINATOR;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,61 +0,0 @@
|
||||
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;
|
||||
@ -1,362 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::File;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use File::Basename qw(fileparse);
|
||||
use File::Copy qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Settings qw(
|
||||
$output_path
|
||||
$copy_output_path
|
||||
$ama_filename_format
|
||||
$use_tempfiles
|
||||
$tempfile_path
|
||||
$make_dir
|
||||
$ama_max_blocks
|
||||
$files_owner
|
||||
$files_group
|
||||
$files_mask
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Block qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure9014 qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime qw();
|
||||
|
||||
use NGCP::BulkProcessor::Logging qw(
|
||||
getlogger
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::LogError qw(
|
||||
fileerror
|
||||
filewarn
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Utils qw(tempfilename makepath);
|
||||
use NGCP::BulkProcessor::Calendar qw(current_local from_epoch);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
|
||||
);
|
||||
|
||||
my $ama_file_extension = '.ama';
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = bless {}, $class;
|
||||
$self->reset();
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub reset {
|
||||
my $self = shift;
|
||||
$self->{current_block} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Block->new();
|
||||
$self->{blocks} = [ $self->{current_block} ];
|
||||
$self->{record_count} = 0;
|
||||
$self->_save_transfer_in(undef);
|
||||
$self->_save_transfer_out(undef);
|
||||
$self->{tempfilename} = tempfilename('XXXX',$tempfile_path,$ama_file_extension) if $use_tempfiles;
|
||||
$self->{now} = current_local();
|
||||
$self->{min_start_time} = undef;
|
||||
$self->{max_end_time} = undef;
|
||||
return;
|
||||
}
|
||||
|
||||
sub update_start_end_time {
|
||||
my $self = shift;
|
||||
my ($start_time,$end_time) = @_;
|
||||
#my $end_time = $start_time + $duration;
|
||||
$self->{min_start_time} = $start_time if (not defined $self->{min_start_time} or $self->{min_start_time} > $start_time);
|
||||
$self->{max_end_time} = $end_time if (not defined $self->{max_end_time} or $self->{max_end_time} < $end_time);
|
||||
}
|
||||
|
||||
sub get_record_count {
|
||||
my $self = shift;
|
||||
return $self->{record_count};
|
||||
}
|
||||
|
||||
sub get_block_count {
|
||||
my $self = shift;
|
||||
return scalar @{$self->{blocks}};
|
||||
}
|
||||
|
||||
sub add_record {
|
||||
my $self = shift;
|
||||
my ($record,$pad) = @_;
|
||||
my $result;
|
||||
if (not $pad and (scalar @{$self->{blocks}}) >= $ama_max_blocks and not $self->{current_block}->records_fit($record,
|
||||
$NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure9014::length)) {
|
||||
$result = 0;
|
||||
} else {
|
||||
if (not $self->{current_block}->add_record($record)) {
|
||||
if ((scalar @{$self->{blocks}}) >= $ama_max_blocks) {
|
||||
$result = 0;
|
||||
} else {
|
||||
$self->{current_block}->set_padded(1);
|
||||
$self->{current_block} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Block->new();
|
||||
push(@{$self->{blocks}},$self->{current_block});
|
||||
$result = $self->{current_block}->add_record($record);
|
||||
$self->{record_count} += 1;
|
||||
}
|
||||
} else {
|
||||
$self->{record_count} += 1;
|
||||
$self->{current_block}->set_padded(1) if $pad;
|
||||
$result = 1;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub get_filename {
|
||||
my $self = shift;
|
||||
my ($show_tempfilename,$basepath) = @_;
|
||||
return $self->{tempfilename} if ($use_tempfiles and $show_tempfilename);
|
||||
return sprintf($ama_filename_format,
|
||||
$basepath // $output_path, #%1
|
||||
$self->{now}->year, #%2
|
||||
substr($self->{now}->year,-2), #%3
|
||||
$self->{now}->month, #%4
|
||||
$self->{now}->day, #%5
|
||||
$self->{now}->hour, #%6
|
||||
$self->{now}->minute, #%7
|
||||
$self->{now}->second, #%8
|
||||
$self->{transfer_in}->get_structure()->get_file_sequence_number_field()->{file_sequence_number}, #%9
|
||||
$ama_file_extension, #%10
|
||||
);
|
||||
}
|
||||
|
||||
sub get_filesize {
|
||||
my $self = shift;
|
||||
return -s ($use_tempfiles ? $self->{tempfilename} : $self->get_filename());
|
||||
}
|
||||
|
||||
sub _rename {
|
||||
my $self = shift;
|
||||
my ($filename) = @_;
|
||||
my $result = rename($self->{tempfilename},$filename);
|
||||
#_chownmod($filename,$files_owner,$files_group,oct(666),$files_mask) if $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub _copy {
|
||||
|
||||
my ($source_filename,$target_filename) = @_;
|
||||
File::Copy::cp($source_filename,$target_filename) or die ($!);
|
||||
|
||||
}
|
||||
|
||||
sub _makedir {
|
||||
|
||||
my ($filename) = @_;
|
||||
my ($name,$path,$suffix) = fileparse($filename,$ama_file_extension);
|
||||
makepath($path,\&fileerror,getlogger(__PACKAGE__)) if ($make_dir and length($path) > 0 and not -d $path);
|
||||
return $filename;
|
||||
|
||||
}
|
||||
|
||||
sub _chownmod {
|
||||
my ($file, $user, $group, $defmode, $mask) = @_;
|
||||
|
||||
if ($user || $group) {
|
||||
my @arg = (-1, -1, $file);
|
||||
$user and ($arg[0] = (getpwnam($user) || -1));
|
||||
$group and ($arg[1] = (getgrnam($group) || -1));
|
||||
chown(@arg);
|
||||
}
|
||||
$mask and chmod($defmode & ~oct($mask), $file);
|
||||
}
|
||||
|
||||
sub flush {
|
||||
my $self = shift;
|
||||
my %params = @_;
|
||||
my (
|
||||
$commit_cb,
|
||||
) = @params{qw/
|
||||
commit_cb
|
||||
/};
|
||||
#unlink 'test.ama';
|
||||
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",($use_tempfiles ? $self->{tempfilename} : _makedir($filename)))) {
|
||||
foreach my $block (@{$self->{blocks}}) {
|
||||
print $fh pack('H*',$block->get_hex());
|
||||
}
|
||||
close $fh;
|
||||
if (defined $commit_cb) {
|
||||
if (&$commit_cb(@_)) {
|
||||
if (not $use_tempfiles or $self->_rename(_makedir($filename))) {
|
||||
_chownmod($filename,$files_owner,$files_group,oct(666),$files_mask);
|
||||
eval {
|
||||
_copy($filename,_makedir($self->get_filename(0,$copy_output_path))) if $copy_output_path;
|
||||
};
|
||||
if ($@) {
|
||||
filewarn("failed to create copy of $filename: " . $@,getlogger(__PACKAGE__));
|
||||
}
|
||||
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 $use_tempfiles;
|
||||
unlink $self->{tempfilename} if $use_tempfiles;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
#restdebug($self,"$self->{crt_path} saved",getlogger(__PACKAGE__));
|
||||
} else {
|
||||
fileerror('failed to open ' . ($use_tempfiles ? $self->{tempfilename} : $filename) . ": $!",getlogger(__PACKAGE__));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
sub close {
|
||||
|
||||
my $self = shift;
|
||||
my %params = @_;
|
||||
my (
|
||||
$get_transfer_out,
|
||||
$commit_cb,
|
||||
) = @params{qw/
|
||||
get_transfer_out
|
||||
commit_cb
|
||||
/};
|
||||
my $result = 0;
|
||||
$self->add_record(
|
||||
$self->_save_transfer_out(&$get_transfer_out(
|
||||
#file_sequence_number => 1,
|
||||
|
||||
#=> (scalar @records),
|
||||
@_
|
||||
)),
|
||||
1,
|
||||
);
|
||||
|
||||
# update transfer_in date/time:
|
||||
my $min_start_dt;
|
||||
$min_start_dt = from_epoch($self->{min_start_time}) if defined $self->{min_start_time};
|
||||
$self->{transfer_in}->get_structure()->get_date_field()->_set_params(
|
||||
date => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date::get_ama_date($min_start_dt // $self->{now}),
|
||||
);
|
||||
$self->{transfer_in}->get_structure()->get_connect_time_field()->_set_params(
|
||||
connect_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime::get_connect_time($min_start_dt // $self->{now}),
|
||||
);
|
||||
# update transfer_out date/time:
|
||||
my $max_end_dt;
|
||||
$max_end_dt = from_epoch($self->{max_end_time}) if defined $self->{max_end_time};
|
||||
$self->{transfer_out}->get_structure()->get_date_field()->_set_params(
|
||||
date => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date::get_ama_date($max_end_dt // $self->{now}),
|
||||
);
|
||||
$self->{transfer_out}->get_structure()->get_connect_time_field()->_set_params(
|
||||
connect_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime::get_connect_time($max_end_dt // $self->{now}),
|
||||
);
|
||||
# update transfer_out count fields:
|
||||
$self->{transfer_out}->get_structure()->get_block_count_field()->_set_params(block_count => $self->get_block_count());
|
||||
$self->{transfer_out}->get_structure()->get_record_count_field()->_set_params(record_count => $self->get_record_count());
|
||||
|
||||
$result |= $self->flush(
|
||||
commit_cb => $commit_cb,
|
||||
@_
|
||||
);
|
||||
$self->reset();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub write_record {
|
||||
|
||||
my $self = shift;
|
||||
my %params = @_;
|
||||
my (
|
||||
$get_transfer_in,
|
||||
$get_record,
|
||||
$get_transfer_out,
|
||||
$commit_cb,
|
||||
) = @params{qw/
|
||||
get_transfer_in
|
||||
get_record
|
||||
get_transfer_out
|
||||
commit_cb
|
||||
/};
|
||||
|
||||
$self->add_record(
|
||||
$self->_save_transfer_in(&$get_transfer_in(
|
||||
#file_sequence_number => 1,
|
||||
@_,
|
||||
)),
|
||||
1
|
||||
) unless $self->{record_count} > 0;
|
||||
|
||||
my $result = 0;
|
||||
my $records = &$get_record(@_);
|
||||
$records = [ $records ] unless 'ARRAY' eq ref $records;
|
||||
foreach my $record (@$records) {
|
||||
if (not $self->add_record($record)) {
|
||||
$result |= $self->close(
|
||||
get_transfer_out => $get_transfer_out,
|
||||
commit_cb => $commit_cb,
|
||||
@_
|
||||
);
|
||||
$self->add_record(
|
||||
$self->_save_transfer_in(&$get_transfer_in(
|
||||
|
||||
#file_sequence_number => 1,
|
||||
@_
|
||||
)),
|
||||
1
|
||||
);
|
||||
|
||||
$self->add_record($record);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub _save_transfer_in {
|
||||
my $self = shift;
|
||||
my $record = shift;
|
||||
if (defined $record) {
|
||||
$self->{transfer_in} = $record;
|
||||
} else {
|
||||
undef $self->{transfer_in};
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
sub _save_transfer_out {
|
||||
my $self = shift;
|
||||
my $record = shift;
|
||||
if (defined $record) {
|
||||
$self->{transfer_out} = $record;
|
||||
} else {
|
||||
undef $self->{transfer_out};
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,59 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Module;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::LogError qw(
|
||||
notimplementederror
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet);
|
||||
our @EXPORT_OK = qw(
|
||||
|
||||
);
|
||||
|
||||
sub new {
|
||||
|
||||
my $base_class = shift;
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet->new(
|
||||
$class,
|
||||
@_);
|
||||
my %params = @_;
|
||||
(
|
||||
$self->{enabled},
|
||||
$self->{module_instance},
|
||||
) = @params{qw/
|
||||
enabled
|
||||
module_instance
|
||||
/};
|
||||
$self->{enabled} //= 1;
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_module_code_field {
|
||||
|
||||
my $self = shift;
|
||||
#my (@params) = @_;
|
||||
|
||||
notimplementederror((ref $self) . ': ' . (caller(0))[3] . ' not implemented',getlogger(__PACKAGE__));
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
sub get_name {
|
||||
my $self = shift;
|
||||
return $self->get_module_code_field()->get_module_code();
|
||||
}
|
||||
|
||||
sub get_enabled {
|
||||
my $self = shift;
|
||||
return $self->{enabled};
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,45 +0,0 @@
|
||||
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;
|
||||
@ -1,49 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module104;
|
||||
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_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;
|
||||
@ -1,53 +0,0 @@
|
||||
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;
|
||||
@ -1,55 +0,0 @@
|
||||
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;
|
||||
@ -1,77 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Record;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet qw($line_terminator);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
|
||||
);
|
||||
|
||||
my $record_descriptor_word_length = 8;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = bless {}, $class;
|
||||
$self->{structure} = shift;
|
||||
$self->{modules} = [ @_ ];
|
||||
$self->{structure}->get_structure_code_field()->set_has_modules((scalar @{$self->{modules}}) > 0);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_structure {
|
||||
my $self = shift;
|
||||
return $self->{structure};
|
||||
}
|
||||
|
||||
sub get_hex {
|
||||
|
||||
my $self = shift;
|
||||
my $result = $self->_get_record_descriptor_word(@_);
|
||||
$result .= $self->{structure}->get_hex(@_);
|
||||
foreach my $module (@{$self->{modules}}) {
|
||||
next unless $module->get_enabled(@_);
|
||||
$result .= $module->get_hex(@_);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub to_string {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
my $result = $line_terminator . $line_terminator . "record data:$line_terminator" . $self->{structure}->to_string(@_);
|
||||
foreach my $module (@{$self->{modules}}) {
|
||||
next unless $module->get_enabled(@_);
|
||||
$result .= $line_terminator . $line_terminator . "module data:$line_terminator" . $module->to_string(@_);
|
||||
}
|
||||
$result .= $line_terminator;
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub get_length {
|
||||
my $self = shift;
|
||||
my $length = $record_descriptor_word_length;
|
||||
$length += $self->{structure}->get_length(@_);
|
||||
foreach my $module (@{$self->{modules}}) {
|
||||
next unless $module->get_enabled(@_);
|
||||
$length += $module->get_length(@_);
|
||||
}
|
||||
return $length;
|
||||
}
|
||||
|
||||
|
||||
sub _get_record_descriptor_word {
|
||||
my $self = shift;
|
||||
return sprintf('%04x',$self->get_length(@_) / 2) . '0000';
|
||||
#return total length in bytes (up to 256*256 bytes)
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,151 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Settings;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Globals qw(
|
||||
$working_path
|
||||
$enablemultithreading
|
||||
$cpucount
|
||||
create_path
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Logging qw(
|
||||
getlogger
|
||||
scriptinfo
|
||||
configurationinfo
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::LogError qw(
|
||||
fileerror
|
||||
filewarn
|
||||
configurationwarn
|
||||
configurationerror
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::LoadConfig qw(
|
||||
split_tuple
|
||||
parse_regexp
|
||||
);
|
||||
use NGCP::BulkProcessor::Utils qw(prompt timestampdigits); #stringtobool
|
||||
#format_number check_ipnet
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
update_settings
|
||||
|
||||
$output_path
|
||||
$copy_output_path
|
||||
$tempfile_path
|
||||
|
||||
$domestic_destination_pattern
|
||||
$international_destination_pattern
|
||||
$domestic_destination_not_pattern
|
||||
$international_destination_not_pattern
|
||||
|
||||
$make_dir
|
||||
$ama_filename_format
|
||||
$use_tempfiles
|
||||
|
||||
$ama_max_blocks
|
||||
|
||||
$files_owner
|
||||
$files_group
|
||||
$files_mask
|
||||
);
|
||||
|
||||
our $output_path = $working_path . 'output/';
|
||||
our $copy_output_path = undef;
|
||||
our $tempfile_path = $working_path . 'temp/';
|
||||
|
||||
our $use_tempfiles = 0;
|
||||
|
||||
our $domestic_destination_pattern = undef;
|
||||
our $international_destination_pattern = undef;
|
||||
our $domestic_destination_not_pattern = undef;
|
||||
our $international_destination_not_pattern = undef;
|
||||
|
||||
our $ama_max_blocks = 1000;
|
||||
|
||||
our $make_dir = 0;
|
||||
our $ama_filename_format = '%1$sP%3$02d%4$02d%5$02d%6$02d%7$02d%9$02dAMA%10$s';
|
||||
|
||||
our $files_owner = '';
|
||||
our $files_group = '';
|
||||
our $files_mask = '';
|
||||
|
||||
sub update_settings {
|
||||
|
||||
my ($data,$configfile) = @_;
|
||||
|
||||
if (defined $data) {
|
||||
|
||||
my $result = 1;
|
||||
|
||||
#&$configurationinfocode("testinfomessage",$configlogger);
|
||||
|
||||
$result &= _prepare_working_paths($data,1);
|
||||
|
||||
$use_tempfiles = $data->{use_tempfiles} if exists $data->{use_tempfiles};
|
||||
$make_dir = $data->{make_dir} if exists $data->{make_dir};
|
||||
|
||||
my $regexp_result;
|
||||
$domestic_destination_pattern = $data->{domestic_destination_pattern} if exists $data->{domestic_destination_pattern};
|
||||
($regexp_result,$domestic_destination_pattern) = parse_regexp($domestic_destination_pattern,$configfile);
|
||||
$result &= $regexp_result;
|
||||
$international_destination_pattern = $data->{international_destination_pattern} if exists $data->{international_destination_pattern};
|
||||
($regexp_result,$international_destination_pattern) = parse_regexp($international_destination_pattern,$configfile);
|
||||
$result &= $regexp_result;
|
||||
$domestic_destination_not_pattern = $data->{domestic_destination_not_pattern} if exists $data->{domestic_destination_not_pattern};
|
||||
($regexp_result,$domestic_destination_not_pattern) = parse_regexp($domestic_destination_not_pattern,$configfile);
|
||||
$result &= $regexp_result;
|
||||
$international_destination_not_pattern = $data->{international_destination_not_pattern} if exists $data->{international_destination_not_pattern};
|
||||
($regexp_result,$international_destination_not_pattern) = parse_regexp($international_destination_not_pattern,$configfile);
|
||||
$result &= $regexp_result;
|
||||
|
||||
my $domestic_intl_pattern_count = 0;
|
||||
foreach ($domestic_destination_pattern,$international_destination_pattern,$domestic_destination_not_pattern,$international_destination_not_pattern) {
|
||||
$domestic_intl_pattern_count += 1 if defined $_;
|
||||
}
|
||||
if ($domestic_intl_pattern_count != 1) {
|
||||
configurationerror($configfile,'exactly 1 parameter out of domestic_destination_pattern, international_destination_pattern, domestic_destination_not_pattern, international_destination_not_pattern is required',getlogger(__PACKAGE__));
|
||||
$result = 0;
|
||||
}
|
||||
|
||||
|
||||
$ama_filename_format = $data->{ama_filename_format} if exists $data->{ama_filename_format};
|
||||
|
||||
$ama_max_blocks = $data->{ama_max_blocks} if exists $data->{ama_max_blocks};
|
||||
|
||||
$files_owner = $data->{files_owner} if exists $data->{files_owner};
|
||||
$files_group = $data->{files_group} if exists $data->{files_group};
|
||||
$files_mask = $data->{files_mask} if exists $data->{files_mask};
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
sub _prepare_working_paths {
|
||||
|
||||
my ($data,$create) = @_;
|
||||
my $result = 1;
|
||||
my $path_result;
|
||||
|
||||
($path_result,$output_path) = create_path($working_path . 'output',$output_path,$create,\&fileerror,getlogger(__PACKAGE__));
|
||||
$result &= $path_result;
|
||||
if ($data->{copy_output_path}) {
|
||||
($path_result,$copy_output_path) = create_path($data->{copy_output_path},$copy_output_path,$create,\&fileerror,getlogger(__PACKAGE__));
|
||||
$result &= $path_result;
|
||||
}
|
||||
($path_result,$tempfile_path) = create_path($working_path . 'temp',$output_path,$create,\&fileerror,getlogger(__PACKAGE__));
|
||||
$result &= $path_result;
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,47 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Structure;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::LogError qw(
|
||||
notimplementederror
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet);
|
||||
our @EXPORT_OK = qw(
|
||||
|
||||
);
|
||||
|
||||
sub new {
|
||||
|
||||
my $base_class = shift;
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet->new(
|
||||
$class,
|
||||
@_);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_structure_code_field {
|
||||
|
||||
my $self = shift;
|
||||
#my (@params) = @_;
|
||||
|
||||
notimplementederror((ref $self) . ': ' . (caller(0))[3] . ' not implemented',getlogger(__PACKAGE__));
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
sub get_name {
|
||||
|
||||
my $self = shift;
|
||||
return $self->get_structure_code_field()->get_structure_code();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,142 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure0510;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Structure qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::HexId qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::StructureCode qw($STRUCTURE_CODE_0510);
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorId qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeId qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TimingIndicator qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::StudyIndicator qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CalledPartyOffHook qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ServiceObserved qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OperatorAction qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ServiceFeature qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OriginatingOpenDigits1 qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OriginatingOpenDigits2 qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OriginatingChargeInformation qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::DomesticInternational qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TerminatingOpenDigits1 qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TerminatingOpenDigits2 qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ElapsedTime qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet NGCP::BulkProcessor::Projects::Export::Ama::Format::Structure);
|
||||
our @EXPORT_OK = qw(
|
||||
$length
|
||||
);
|
||||
#get_instance
|
||||
|
||||
#my $structure_name = 'structure ' . $STRUCTURE_CODE_0510;
|
||||
|
||||
#my $INSTANCE = __PACKAGE__->new();
|
||||
|
||||
our $length = 142;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Structure->new(
|
||||
$class,
|
||||
length => $length,
|
||||
#structure_name => $structure_name,
|
||||
@_);
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::HexId->new(
|
||||
@_,
|
||||
));
|
||||
$self->{structure_code} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::StructureCode->new(
|
||||
structure_code => $STRUCTURE_CODE_0510,
|
||||
@_,
|
||||
);
|
||||
$self->_add_field($self->{structure_code});
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorType->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorId->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeType->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeId->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TimingIndicator->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::StudyIndicator->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CalledPartyOffHook->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ServiceObserved->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OperatorAction->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ServiceFeature->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField->new(
|
||||
field_instance => 'originating',
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OriginatingOpenDigits1->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OriginatingOpenDigits2->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::OriginatingChargeInformation->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::DomesticInternational->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField->new(
|
||||
field_instance => 'terminating',
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TerminatingOpenDigits1->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TerminatingOpenDigits2->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ElapsedTime->new(
|
||||
@_,
|
||||
));
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_structure_code_field {
|
||||
my $self = shift;
|
||||
return $self->{structure_code};
|
||||
}
|
||||
|
||||
#sub get_instance {
|
||||
# return
|
||||
#}
|
||||
|
||||
1;
|
||||
@ -1,109 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure9013;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Structure qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::HexId qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::StructureCode qw($STRUCTURE_CODE_9013);
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorId qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeId qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericIssue qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TracerType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet NGCP::BulkProcessor::Projects::Export::Ama::Format::Structure);
|
||||
our @EXPORT_OK = qw(
|
||||
$length
|
||||
);
|
||||
|
||||
our $length = 64;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Structure->new(
|
||||
$class,
|
||||
length => $length,
|
||||
#structure_name => $structure_name,
|
||||
@_);
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::HexId->new(
|
||||
@_,
|
||||
));
|
||||
$self->{structure_code} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::StructureCode->new(
|
||||
structure_code => $STRUCTURE_CODE_9013,
|
||||
@_,
|
||||
);
|
||||
$self->_add_field($self->{structure_code});
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType->new(
|
||||
call_type => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType::TRANSFER,
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorType->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorId->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeType->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeId->new(
|
||||
@_,
|
||||
));
|
||||
$self->{date} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date->new(
|
||||
@_,
|
||||
);
|
||||
$self->_add_field($self->{date});
|
||||
$self->{connect_time} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime->new(
|
||||
@_,
|
||||
);
|
||||
$self->_add_field($self->{connect_time});
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericIssue->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TracerType->new(
|
||||
tracer_type => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TracerType::TRANSFER_IN,
|
||||
@_,
|
||||
));
|
||||
$self->{file_sequence_number} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber->new(
|
||||
@_,
|
||||
);
|
||||
$self->_add_field($self->{file_sequence_number});
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_structure_code_field {
|
||||
my $self = shift;
|
||||
return $self->{structure_code};
|
||||
}
|
||||
|
||||
sub get_file_sequence_number_field {
|
||||
my $self = shift;
|
||||
return $self->{file_sequence_number};
|
||||
}
|
||||
|
||||
sub get_date_field {
|
||||
my $self = shift;
|
||||
return $self->{date};
|
||||
}
|
||||
|
||||
sub get_connect_time_field {
|
||||
my $self = shift;
|
||||
return $self->{connect_time};
|
||||
}
|
||||
|
||||
#sub get_instance {
|
||||
# return
|
||||
#}
|
||||
|
||||
1;
|
||||
@ -1,131 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure9014;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Structure qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::HexId qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::StructureCode qw($STRUCTURE_CODE_9014);
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorId qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeId qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericIssue qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TracerType qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordCount qw();
|
||||
use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::BlockCount qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::Projects::Export::Ama::Format::FieldSet NGCP::BulkProcessor::Projects::Export::Ama::Format::Structure);
|
||||
our @EXPORT_OK = qw(
|
||||
$length
|
||||
);
|
||||
|
||||
our $length = 78;
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::Projects::Export::Ama::Format::Structure->new(
|
||||
$class,
|
||||
length => $length,
|
||||
#structure_name => $structure_name,
|
||||
@_);
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::HexId->new(
|
||||
@_,
|
||||
));
|
||||
$self->{structure_code} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::StructureCode->new(
|
||||
structure_code => $STRUCTURE_CODE_9014,
|
||||
@_,
|
||||
);
|
||||
$self->_add_field($self->{structure_code});
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType->new(
|
||||
call_type => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType::TRANSFER,
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorType->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SensorId->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeType->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordingOfficeId->new(
|
||||
@_,
|
||||
));
|
||||
$self->{date} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date->new(
|
||||
@_,
|
||||
);
|
||||
$self->_add_field($self->{date});
|
||||
$self->{connect_time} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime->new(
|
||||
@_,
|
||||
);
|
||||
$self->_add_field($self->{connect_time});
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericIssue->new(
|
||||
@_,
|
||||
));
|
||||
$self->_add_field(NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TracerType->new(
|
||||
tracer_type => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TracerType::TRANSFER_OUT,
|
||||
@_,
|
||||
));
|
||||
$self->{file_sequence_number} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber->new(
|
||||
@_,
|
||||
);
|
||||
$self->_add_field($self->{file_sequence_number});
|
||||
|
||||
$self->{record_count} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::RecordCount->new(
|
||||
@_,
|
||||
);
|
||||
$self->_add_field($self->{record_count});
|
||||
|
||||
$self->{block_count} = NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::BlockCount->new(
|
||||
@_,
|
||||
);
|
||||
$self->_add_field($self->{block_count});
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_structure_code_field {
|
||||
my $self = shift;
|
||||
return $self->{structure_code};
|
||||
}
|
||||
|
||||
sub get_file_sequence_number_field {
|
||||
my $self = shift;
|
||||
return $self->{file_sequence_number};
|
||||
}
|
||||
|
||||
sub get_record_count_field {
|
||||
my $self = shift;
|
||||
return $self->{record_count};
|
||||
}
|
||||
|
||||
sub get_block_count_field {
|
||||
my $self = shift;
|
||||
return $self->{block_count};
|
||||
}
|
||||
|
||||
sub get_date_field {
|
||||
my $self = shift;
|
||||
return $self->{date};
|
||||
}
|
||||
|
||||
sub get_connect_time_field {
|
||||
my $self = shift;
|
||||
return $self->{connect_time};
|
||||
}
|
||||
|
||||
#sub get_instance {
|
||||
# return
|
||||
#}
|
||||
|
||||
1;
|
||||
@ -1,248 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Migration::UPCAT::Check;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
no strict 'refs';
|
||||
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::billing_profiles qw();
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::billing::billing_mappings qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::contracts_billing_profile_network qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::contracts_billing_profile_network_schedule qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::contracts qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::contract_balances qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::contacts qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::ncos_levels qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::products qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::domains qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::domain_resellers qw();
|
||||
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_domains qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_subscribers qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_usr_preferences qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_aig_sequence qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_allowed_ip_groups qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases qw();
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_mappings qw();
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_destination_sets qw();
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_destinations qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_trusted_sources qw();
|
||||
|
||||
use NGCP::BulkProcessor::Dao::Trunk::kamailio::voicemail_users qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::kamailio::location qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber qw();
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber qw();
|
||||
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::Resellers qw();
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::Domains qw();
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::BillingProfiles qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
check_billing_db_tables
|
||||
check_provisioning_db_tables
|
||||
check_kamailio_db_tables
|
||||
check_import_db_tables
|
||||
check_rest_get_items
|
||||
);
|
||||
|
||||
my $NOK = 'NOK';
|
||||
my $OK = 'ok';
|
||||
|
||||
sub check_billing_db_tables {
|
||||
|
||||
my ($messages) = @_;
|
||||
|
||||
my $result = 1;
|
||||
my $check_result;
|
||||
my $message;
|
||||
|
||||
my $message_prefix = 'NGCP billing db tables - ';
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::billing_profiles');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::products');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::domains');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::domain_resellers');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::contacts');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::contracts');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::contract_balances');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
#($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::billing_mappings');
|
||||
#$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::contracts_billing_profile_network');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::contracts_billing_profile_network_schedule');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::ncos_levels');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub check_import_db_tables {
|
||||
|
||||
my ($messages) = @_;
|
||||
|
||||
my $result = 1;
|
||||
my $check_result;
|
||||
my $message;
|
||||
|
||||
my $message_prefix = 'import db tables - ';
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub check_provisioning_db_tables {
|
||||
|
||||
my ($messages) = @_;
|
||||
|
||||
my $result = 1;
|
||||
my $check_result;
|
||||
my $message;
|
||||
|
||||
my $message_prefix = 'NGCP provisioning db tables - ';
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_domains');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_subscribers');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_usr_preferences');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_aig_sequence');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_allowed_ip_groups');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
#($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_mappings');
|
||||
#$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
#($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_destination_sets');
|
||||
#$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
#($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_destinations');
|
||||
#$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_trusted_sources');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub check_kamailio_db_tables {
|
||||
|
||||
my ($messages) = @_;
|
||||
|
||||
my $result = 1;
|
||||
my $check_result;
|
||||
my $message;
|
||||
|
||||
my $message_prefix = 'NGCP kamailio db tables - ';
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::kamailio::voicemail_users');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
($check_result,$message) = _check_table($message_prefix,'NGCP::BulkProcessor::Dao::Trunk::kamailio::location');
|
||||
$result &= $check_result; push(@$messages,$message);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub _check_table {
|
||||
|
||||
my ($message_prefix,$module) = @_;
|
||||
my $result = 0;
|
||||
my $message = ($message_prefix // '') . &{$module . '::gettablename'}() . ': ';
|
||||
eval {
|
||||
$result = &{$module . '::check_table'}();
|
||||
};
|
||||
if (@$ or not $result) {
|
||||
return (0,$message . $NOK);
|
||||
} else {
|
||||
return (1,$message . $OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub check_rest_get_items {
|
||||
|
||||
my ($messages) = @_;
|
||||
|
||||
my $result = 1;
|
||||
my $check_result;
|
||||
my $message;
|
||||
|
||||
my $message_prefix = 'NGCP id\'s/constants - ';
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
sub _check_rest_get_item {
|
||||
|
||||
my ($message_prefix,$module,$id,$item_name_field,$get_method,$item_path_method) = @_;
|
||||
my $item = undef;
|
||||
$get_method //= 'get_item';
|
||||
$item_path_method //= 'get_item_path';
|
||||
my $message = ($message_prefix // '') . &{$module . '::' . $item_path_method}($id) . ': ';
|
||||
return (0,$message . $NOK,$item) unless $id;
|
||||
eval {
|
||||
$item = &{$module . '::' . $get_method}($id);
|
||||
};
|
||||
|
||||
if (@$ or not defined $item or ('ARRAY' eq ref $item and (scalar @$item) != 1)) {
|
||||
return (0,$message . $NOK,$item);
|
||||
} else {
|
||||
$item = $item->[0] if ('ARRAY' eq ref $item and (scalar @$item) == 1);
|
||||
return (1,$message . "'" . $item->{$item_name_field} . "' " . $OK,$item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,359 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::ProjectConnectorPool qw(
|
||||
get_import_db
|
||||
destroy_all_dbs
|
||||
);
|
||||
#import_db_tableidentifier
|
||||
|
||||
use NGCP::BulkProcessor::SqlProcessor qw(
|
||||
registertableinfo
|
||||
create_targettable
|
||||
checktableinfo
|
||||
copy_row
|
||||
|
||||
insert_stmt
|
||||
|
||||
process_table
|
||||
);
|
||||
use NGCP::BulkProcessor::SqlRecord qw();
|
||||
|
||||
#use NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::Subscriber qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::SqlRecord);
|
||||
our @EXPORT_OK = qw(
|
||||
create_table
|
||||
gettablename
|
||||
check_table
|
||||
getinsertstatement
|
||||
getupsertstatement
|
||||
|
||||
findby_service_number
|
||||
countby_service_number
|
||||
|
||||
findby_switch_number
|
||||
|
||||
update_delta
|
||||
findby_delta
|
||||
countby_delta
|
||||
|
||||
$deleted_delta
|
||||
$updated_delta
|
||||
$added_delta
|
||||
|
||||
process_records
|
||||
|
||||
@fieldnames
|
||||
);
|
||||
|
||||
#findby_ccacsn
|
||||
#countby_ccacsn
|
||||
|
||||
#findby_domain_sipusername
|
||||
#findby_domain_webusername
|
||||
#list_domain_billingprofilename_resellernames
|
||||
#findby_sipusername
|
||||
#list_barring_resellernames
|
||||
|
||||
my $tablename = 'ccs_subscriber';
|
||||
my $get_db = \&get_import_db;
|
||||
|
||||
our @fieldnames = (
|
||||
"service_number",
|
||||
"switch_number",
|
||||
#"icm",
|
||||
#"routing_type",
|
||||
"customer",
|
||||
#"target_number",
|
||||
#"comment",
|
||||
|
||||
'rownum',
|
||||
);
|
||||
my $expected_fieldnames = [
|
||||
@fieldnames,
|
||||
'delta',
|
||||
];
|
||||
|
||||
# table creation:
|
||||
my $primarykey_fieldnames = [ 'service_number' ];
|
||||
my $indexes = {
|
||||
|
||||
$tablename . '_switch_number' => [ 'switch_number(12)' ],
|
||||
|
||||
$tablename . '_rownum' => [ 'rownum(11)' ],
|
||||
$tablename . '_delta' => [ 'delta(7)' ],};
|
||||
#my $fixtable_statements = [];
|
||||
|
||||
our $deleted_delta = 'DELETED';
|
||||
our $updated_delta = 'UPDATED';
|
||||
our $added_delta = 'ADDED';
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::SqlRecord->new($class,$get_db,
|
||||
$tablename,$expected_fieldnames,$indexes);
|
||||
|
||||
copy_row($self,shift,$expected_fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub create_table {
|
||||
|
||||
my ($truncate) = @_;
|
||||
|
||||
my $db = &$get_db();
|
||||
|
||||
registertableinfo($db,__PACKAGE__,$tablename,$expected_fieldnames,$indexes,$primarykey_fieldnames);
|
||||
return create_targettable($db,__PACKAGE__,$db,__PACKAGE__,$tablename,$truncate,0,undef);
|
||||
|
||||
}
|
||||
|
||||
sub findby_delta {
|
||||
|
||||
my ($delta,$load_recursive) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
return [] unless defined $delta;
|
||||
|
||||
my $rows = $db->db_get_all_arrayref(
|
||||
'SELECT * FROM ' .
|
||||
$table .
|
||||
' WHERE ' .
|
||||
$db->columnidentifier('delta') . ' = ?'
|
||||
,$delta);
|
||||
|
||||
return buildrecords_fromrows($rows,$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub findby_service_number {
|
||||
|
||||
my ($service_number,$load_recursive) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
return undef unless (defined $service_number);
|
||||
|
||||
my $rows = $db->db_get_all_arrayref(
|
||||
'SELECT * FROM ' .
|
||||
$table .
|
||||
' WHERE ' .
|
||||
$db->columnidentifier('service_number') . ' = ?'
|
||||
,$service_number);
|
||||
|
||||
return buildrecords_fromrows($rows,$load_recursive)->[0];
|
||||
|
||||
}
|
||||
|
||||
sub findby_switch_number {
|
||||
|
||||
my ($switch_number,$load_recursive) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
return [] unless (defined $switch_number);
|
||||
|
||||
my $rows = $db->db_get_all_arrayref(
|
||||
'SELECT * FROM ' .
|
||||
$table .
|
||||
' WHERE ' .
|
||||
$db->columnidentifier('switch_number') . ' = ?'
|
||||
,$switch_number);
|
||||
|
||||
return buildrecords_fromrows($rows,$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub update_delta {
|
||||
|
||||
my ($service_number,$delta) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
my $stmt = 'UPDATE ' . $table . ' SET delta = ?';
|
||||
my @params = ();
|
||||
push(@params,$delta);
|
||||
if (defined $service_number) {
|
||||
$stmt .= ' WHERE ' .
|
||||
$db->columnidentifier('service_number') . ' = ?';
|
||||
push(@params,$service_number);
|
||||
}
|
||||
|
||||
return $db->db_do($stmt,@params);
|
||||
|
||||
}
|
||||
|
||||
sub countby_service_number {
|
||||
|
||||
my ($service_number) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
my $stmt = 'SELECT COUNT(*) FROM ' . $table;
|
||||
my @params = ();
|
||||
if (defined $service_number) {
|
||||
$stmt .= ' WHERE ' .
|
||||
$db->columnidentifier('service_number') . ' = ?';
|
||||
push(@params,$service_number);
|
||||
}
|
||||
|
||||
return $db->db_get_value($stmt,@params);
|
||||
|
||||
}
|
||||
|
||||
sub countby_delta {
|
||||
|
||||
my ($deltas) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
my $stmt = 'SELECT COUNT(*) FROM ' . $table . ' WHERE 1=1';
|
||||
my @params = ();
|
||||
if (defined $deltas and 'HASH' eq ref $deltas) {
|
||||
foreach my $in (keys %$deltas) {
|
||||
my @values = (defined $deltas->{$in} and 'ARRAY' eq ref $deltas->{$in} ? @{$deltas->{$in}} : ($deltas->{$in}));
|
||||
$stmt .= ' AND ' . $db->columnidentifier('delta') . ' ' . $in . ' (' . substr(',?' x scalar @values,1) . ')';
|
||||
push(@params,@values);
|
||||
}
|
||||
} elsif (defined $deltas and length($deltas) > 0) {
|
||||
$stmt .= ' AND ' . $db->columnidentifier('delta') . ' = ?';
|
||||
push(@params,$deltas);
|
||||
}
|
||||
|
||||
return $db->db_get_value($stmt,@params);
|
||||
|
||||
}
|
||||
|
||||
sub buildrecords_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my @records = ();
|
||||
my $record;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
foreach my $row (@$rows) {
|
||||
$record = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @records,$record;
|
||||
}
|
||||
}
|
||||
|
||||
return \@records;
|
||||
|
||||
}
|
||||
|
||||
sub process_records {
|
||||
|
||||
my %params = @_;
|
||||
my ($process_code,
|
||||
$static_context,
|
||||
$init_process_context_code,
|
||||
$uninit_process_context_code,
|
||||
$multithreading,
|
||||
$numofthreads) = @params{qw/
|
||||
process_code
|
||||
static_context
|
||||
init_process_context_code
|
||||
uninit_process_context_code
|
||||
multithreading
|
||||
numofthreads
|
||||
/};
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
my @cols = map { $db->columnidentifier($_); } qw/switch_number/;
|
||||
|
||||
return process_table(
|
||||
get_db => $get_db,
|
||||
class => __PACKAGE__,
|
||||
process_code => sub {
|
||||
my ($context,$rowblock,$row_offset) = @_;
|
||||
return &$process_code($context,$rowblock,$row_offset);
|
||||
},
|
||||
static_context => $static_context,
|
||||
init_process_context_code => $init_process_context_code,
|
||||
uninit_process_context_code => $uninit_process_context_code,
|
||||
destroy_reader_dbs_code => \&destroy_all_dbs,
|
||||
multithreading => $multithreading,
|
||||
tableprocessing_threads => $numofthreads,
|
||||
#'select' => 'SELECT ' . join(',',@cols) . ' FROM ' . $table . ' GROUP BY ' . join(',',@cols),
|
||||
'select' => $db->paginate_sort_query('SELECT ' . join(',',@cols) . ' FROM ' . $table . ' GROUP BY ' . join(',',@cols),undef,undef,[{
|
||||
column => 'rownum',
|
||||
numeric => 1,
|
||||
dir => 1,
|
||||
}]),
|
||||
'selectcount' => 'SELECT COUNT(*) FROM (SELECT ' . join(',',@cols) . ' FROM ' . $table . ' GROUP BY ' . join(',',@cols) . ') AS g',
|
||||
);
|
||||
}
|
||||
|
||||
sub getinsertstatement {
|
||||
|
||||
my ($insert_ignore) = @_;
|
||||
check_table();
|
||||
return insert_stmt($get_db,__PACKAGE__,$insert_ignore);
|
||||
|
||||
}
|
||||
|
||||
sub getupsertstatement {
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
my $upsert_stmt = 'INSERT OR REPLACE INTO ' . $table . ' (' .
|
||||
join(', ',map { local $_ = $_; $_ = $db->columnidentifier($_); $_; } @$expected_fieldnames) . ')';
|
||||
my @values = ();
|
||||
foreach my $fieldname (@$expected_fieldnames) {
|
||||
if ('delta' eq $fieldname) {
|
||||
my $stmt = 'SELECT \'' . $updated_delta . '\' FROM ' . $table . ' WHERE ' .
|
||||
$db->columnidentifier('service_number') . ' = ?';
|
||||
push(@values,'COALESCE((' . $stmt . '), \'' . $added_delta . '\')');
|
||||
} else {
|
||||
push(@values,'?');
|
||||
}
|
||||
}
|
||||
$upsert_stmt .= ' VALUES (' . join(',',@values) . ')';
|
||||
return $upsert_stmt;
|
||||
|
||||
}
|
||||
|
||||
sub gettablename {
|
||||
|
||||
return $tablename;
|
||||
|
||||
}
|
||||
|
||||
sub check_table {
|
||||
|
||||
return checktableinfo($get_db,
|
||||
__PACKAGE__,$tablename,
|
||||
$expected_fieldnames,
|
||||
$indexes);
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,470 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::ProjectConnectorPool qw(
|
||||
get_import_db
|
||||
destroy_all_dbs
|
||||
);
|
||||
#import_db_tableidentifier
|
||||
|
||||
use NGCP::BulkProcessor::SqlProcessor qw(
|
||||
registertableinfo
|
||||
create_targettable
|
||||
checktableinfo
|
||||
copy_row
|
||||
|
||||
insert_stmt
|
||||
|
||||
process_table
|
||||
);
|
||||
use NGCP::BulkProcessor::SqlRecord qw();
|
||||
|
||||
#use NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::Subscriber qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::SqlRecord);
|
||||
our @EXPORT_OK = qw(
|
||||
create_table
|
||||
gettablename
|
||||
check_table
|
||||
getinsertstatement
|
||||
getupsertstatement
|
||||
|
||||
findby_ccacsn
|
||||
countby_ccacsn
|
||||
|
||||
findby_domain_sipusername
|
||||
findby_domain_webusername
|
||||
list_domain_billingprofilename_resellernames
|
||||
findby_sipusername
|
||||
list_barring_resellernames
|
||||
|
||||
update_delta
|
||||
findby_delta
|
||||
countby_delta
|
||||
|
||||
$deleted_delta
|
||||
$updated_delta
|
||||
$added_delta
|
||||
|
||||
process_records
|
||||
|
||||
@fieldnames
|
||||
);
|
||||
# findby_ccacsn
|
||||
# countby_ccacsn
|
||||
|
||||
# findby_domain_sipusername
|
||||
# findby_domain_webusername
|
||||
# list_domain_billingprofilename_resellernames
|
||||
# findby_sipusername
|
||||
# list_barring_resellernames
|
||||
|
||||
my $tablename = 'mta_subscriber';
|
||||
my $get_db = \&get_import_db;
|
||||
#my $get_tablename = \&import_db_tableidentifier;
|
||||
|
||||
my @csv_cols = (
|
||||
# fields in order of cols from .csv
|
||||
"_rownum",
|
||||
"_dn",
|
||||
"_txt_sw_username",
|
||||
"sip_password", #"Subscriber sip password",
|
||||
"_len",
|
||||
"_cpe_mta_mac_address",
|
||||
"_cpe_model",
|
||||
"_cpe_vendor",
|
||||
"customer_id", #"Customer ID",
|
||||
);
|
||||
|
||||
our @fieldnames = (
|
||||
@csv_cols,
|
||||
"reseller_name", #"Reseller name",
|
||||
"domain", #"Sip domain name",
|
||||
"billing_profile_name", #"Billing profile name",
|
||||
"sip_username", #"Subscriber sip username",
|
||||
"cc", #"Subscriber primary number - country code (cc)",
|
||||
"ac", #"Subscriber primary number - country code (ac)",
|
||||
"sn", #"Subscriber primary number - country code (sn)",
|
||||
"web_username", #"Subscriber web username",
|
||||
"web_password", #"Subscriber web password",
|
||||
"barring",
|
||||
#"allowed_ips",
|
||||
#"channels",
|
||||
#"voicemail",
|
||||
|
||||
#calculated fields at the end!
|
||||
'rownum',
|
||||
#'range',
|
||||
#'contact_hash',
|
||||
'filenum',
|
||||
'filename',
|
||||
);
|
||||
my $expected_fieldnames = [
|
||||
@fieldnames,
|
||||
'delta',
|
||||
];
|
||||
|
||||
# table creation:
|
||||
my $primarykey_fieldnames = [ 'cc','ac','sn' ];
|
||||
my $indexes = {
|
||||
|
||||
$tablename . '_domain_web_username' => [ 'domain(32)','web_username(32)' ],
|
||||
$tablename . '_domain_sip_username' => [ 'domain(32)','sip_username(32)' ],
|
||||
|
||||
$tablename . '_rownum' => [ 'rownum(11)' ],
|
||||
$tablename . '_delta' => [ 'delta(7)' ],};
|
||||
#my $fixtable_statements = [];
|
||||
|
||||
our $deleted_delta = 'DELETED';
|
||||
our $updated_delta = 'UPDATED';
|
||||
our $added_delta = 'ADDED';
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::SqlRecord->new($class,$get_db,
|
||||
$tablename,$expected_fieldnames,$indexes);
|
||||
|
||||
copy_row($self,shift,$expected_fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub create_table {
|
||||
|
||||
my ($truncate) = @_;
|
||||
|
||||
my $db = &$get_db();
|
||||
|
||||
registertableinfo($db,__PACKAGE__,$tablename,$expected_fieldnames,$indexes,$primarykey_fieldnames);
|
||||
return create_targettable($db,__PACKAGE__,$db,__PACKAGE__,$tablename,$truncate,0,undef);
|
||||
|
||||
}
|
||||
|
||||
sub findby_delta {
|
||||
|
||||
my ($delta,$load_recursive) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
return [] unless defined $delta;
|
||||
|
||||
my $rows = $db->db_get_all_arrayref(
|
||||
'SELECT * FROM ' .
|
||||
$table .
|
||||
' WHERE ' .
|
||||
$db->columnidentifier('delta') . ' = ?'
|
||||
,$delta);
|
||||
|
||||
return buildrecords_fromrows($rows,$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub findby_ccacsn {
|
||||
|
||||
my ($cc,$ac,$sn,$load_recursive) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
return undef unless (defined $cc or defined $ac or defined $sn);
|
||||
|
||||
my $rows = $db->db_get_all_arrayref(
|
||||
'SELECT * FROM ' .
|
||||
$table .
|
||||
' WHERE ' .
|
||||
$db->columnidentifier('cc') . ' = ?' .
|
||||
' AND ' . $db->columnidentifier('ac') . ' = ?' .
|
||||
' AND ' . $db->columnidentifier('sn') . ' = ?'
|
||||
,$cc,$ac,$sn);
|
||||
|
||||
return buildrecords_fromrows($rows,$load_recursive)->[0];
|
||||
|
||||
}
|
||||
|
||||
sub findby_domain_sipusername {
|
||||
|
||||
my ($domain,$sip_username,$load_recursive) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
#return [] unless (defined $cc or defined $ac or defined $sn);
|
||||
|
||||
my $rows = $db->db_get_all_arrayref(
|
||||
$db->paginate_sort_query('SELECT * FROM ' .
|
||||
$table .
|
||||
' WHERE ' .
|
||||
$db->columnidentifier('domain') . ' = ?' .
|
||||
' AND ' . $db->columnidentifier('sip_username') . ' = ?',
|
||||
undef,undef,[{
|
||||
column => 'filenum',
|
||||
numeric => 1,
|
||||
dir => 1,
|
||||
},{
|
||||
column => 'rownum',
|
||||
numeric => 1,
|
||||
dir => 1,
|
||||
}])
|
||||
,$domain,$sip_username);
|
||||
|
||||
return buildrecords_fromrows($rows,$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub findby_domain_webusername {
|
||||
|
||||
my ($domain,$web_username,$load_recursive) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
#return [] unless (defined $cc or defined $ac or defined $sn);
|
||||
|
||||
my $rows = $db->db_get_all_arrayref(
|
||||
$db->paginate_sort_query('SELECT * FROM ' .
|
||||
$table .
|
||||
' WHERE ' .
|
||||
$db->columnidentifier('domain') . ' = ?' .
|
||||
' AND ' . $db->columnidentifier('web_username') . ' = ?',
|
||||
undef,undef,[{
|
||||
column => 'filenum',
|
||||
numeric => 1,
|
||||
dir => 1,
|
||||
},{
|
||||
column => 'rownum',
|
||||
numeric => 1,
|
||||
dir => 1,
|
||||
}])
|
||||
,$domain,$web_username);
|
||||
|
||||
return buildrecords_fromrows($rows,$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub update_delta {
|
||||
|
||||
my ($cc,$ac,$sn,$delta) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
my $stmt = 'UPDATE ' . $table . ' SET delta = ?';
|
||||
my @params = ();
|
||||
push(@params,$delta);
|
||||
if (defined $cc or defined $ac or defined $sn) {
|
||||
$stmt .= ' WHERE ' .
|
||||
$db->columnidentifier('cc') . ' = ?' .
|
||||
' AND ' . $db->columnidentifier('ac') . ' = ?' .
|
||||
' AND ' . $db->columnidentifier('sn') . ' = ?';
|
||||
push(@params,$cc,$ac,$sn);
|
||||
}
|
||||
|
||||
return $db->db_do($stmt,@params);
|
||||
|
||||
}
|
||||
|
||||
sub countby_ccacsn {
|
||||
|
||||
my ($cc,$ac,$sn) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
my $stmt = 'SELECT COUNT(*) FROM ' . $table;
|
||||
my @params = ();
|
||||
if (defined $cc or defined $ac or defined $sn) {
|
||||
$stmt .= ' WHERE ' .
|
||||
$db->columnidentifier('cc') . ' = ?' .
|
||||
' AND ' . $db->columnidentifier('ac') . ' = ?' .
|
||||
' AND ' . $db->columnidentifier('sn') . ' = ?';
|
||||
push(@params,$cc,$ac,$sn);
|
||||
}
|
||||
|
||||
return $db->db_get_value($stmt,@params);
|
||||
|
||||
}
|
||||
|
||||
sub countby_delta {
|
||||
|
||||
my ($deltas) = @_;
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
my $stmt = 'SELECT COUNT(*) FROM ' . $table . ' WHERE 1=1';
|
||||
my @params = ();
|
||||
if (defined $deltas and 'HASH' eq ref $deltas) {
|
||||
foreach my $in (keys %$deltas) {
|
||||
my @values = (defined $deltas->{$in} and 'ARRAY' eq ref $deltas->{$in} ? @{$deltas->{$in}} : ($deltas->{$in}));
|
||||
$stmt .= ' AND ' . $db->columnidentifier('delta') . ' ' . $in . ' (' . substr(',?' x scalar @values,1) . ')';
|
||||
push(@params,@values);
|
||||
}
|
||||
} elsif (defined $deltas and length($deltas) > 0) {
|
||||
$stmt .= ' AND ' . $db->columnidentifier('delta') . ' = ?';
|
||||
push(@params,$deltas);
|
||||
}
|
||||
|
||||
return $db->db_get_value($stmt,@params);
|
||||
|
||||
}
|
||||
|
||||
sub list_domain_billingprofilename_resellernames {
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
my @cols = map { $db->columnidentifier($_); } qw/domain billing_profile_name reseller_name/;
|
||||
my $stmt = 'SELECT ' . join(',',@cols) . ' FROM ' . $table . ' GROUP BY ' . join(',',@cols);
|
||||
my @params = ();
|
||||
|
||||
return $db->db_get_all_arrayref($stmt,@params);
|
||||
|
||||
}
|
||||
|
||||
sub list_barring_resellernames {
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
my @cols = map { $db->columnidentifier($_); } qw/barring reseller_name/;
|
||||
my $stmt = 'SELECT ' . join(',',@cols) . ' FROM ' . $table . ' GROUP BY ' . join(',',@cols);
|
||||
my @params = ();
|
||||
|
||||
return $db->db_get_all_arrayref($stmt,@params);
|
||||
|
||||
}
|
||||
|
||||
sub buildrecords_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my @records = ();
|
||||
my $record;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
foreach my $row (@$rows) {
|
||||
$record = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @records,$record;
|
||||
}
|
||||
}
|
||||
|
||||
return \@records;
|
||||
|
||||
}
|
||||
|
||||
sub process_records {
|
||||
|
||||
my %params = @_;
|
||||
my ($process_code,
|
||||
$static_context,
|
||||
$init_process_context_code,
|
||||
$uninit_process_context_code,
|
||||
$multithreading,
|
||||
$numofthreads) = @params{qw/
|
||||
process_code
|
||||
static_context
|
||||
init_process_context_code
|
||||
uninit_process_context_code
|
||||
multithreading
|
||||
numofthreads
|
||||
/};
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
|
||||
my @cols = map { $db->columnidentifier($_); } qw/domain sip_username/;
|
||||
|
||||
return process_table(
|
||||
get_db => $get_db,
|
||||
class => __PACKAGE__,
|
||||
process_code => sub {
|
||||
my ($context,$rowblock,$row_offset) = @_;
|
||||
return &$process_code($context,$rowblock,$row_offset);
|
||||
},
|
||||
static_context => $static_context,
|
||||
init_process_context_code => $init_process_context_code,
|
||||
uninit_process_context_code => $uninit_process_context_code,
|
||||
destroy_reader_dbs_code => \&destroy_all_dbs,
|
||||
multithreading => $multithreading,
|
||||
tableprocessing_threads => $numofthreads,
|
||||
#'select' => 'SELECT ' . join(',',@cols) . ' FROM ' . $table . ' GROUP BY ' . join(',',@cols),
|
||||
'select' => $db->paginate_sort_query('SELECT ' . join(',',@cols) . ' FROM ' . $table . ' GROUP BY ' . join(',',@cols),undef,undef,[{
|
||||
column => 'filenum',
|
||||
numeric => 1,
|
||||
dir => 1,
|
||||
},{
|
||||
column => 'rownum',
|
||||
numeric => 1,
|
||||
dir => 1,
|
||||
}]),
|
||||
'selectcount' => 'SELECT COUNT(*) FROM (SELECT ' . join(',',@cols) . ' FROM ' . $table . ' GROUP BY ' . join(',',@cols) . ') AS g',
|
||||
);
|
||||
}
|
||||
|
||||
sub getinsertstatement {
|
||||
|
||||
my ($insert_ignore) = @_;
|
||||
check_table();
|
||||
return insert_stmt($get_db,__PACKAGE__,$insert_ignore);
|
||||
|
||||
}
|
||||
|
||||
sub getupsertstatement {
|
||||
|
||||
check_table();
|
||||
my $db = &$get_db();
|
||||
my $table = $db->tableidentifier($tablename);
|
||||
my $upsert_stmt = 'INSERT OR REPLACE INTO ' . $table . ' (' .
|
||||
join(', ',map { local $_ = $_; $_ = $db->columnidentifier($_); $_; } @$expected_fieldnames) . ')';
|
||||
my @values = ();
|
||||
foreach my $fieldname (@$expected_fieldnames) {
|
||||
if ('delta' eq $fieldname) {
|
||||
my $stmt = 'SELECT \'' . $updated_delta . '\' FROM ' . $table . ' WHERE ' .
|
||||
$db->columnidentifier('cc') . ' = ?' .
|
||||
' AND ' . $db->columnidentifier('ac') . ' = ?' .
|
||||
' AND ' . $db->columnidentifier('sn') . ' = ?';
|
||||
push(@values,'COALESCE((' . $stmt . '), \'' . $added_delta . '\')');
|
||||
} else {
|
||||
push(@values,'?');
|
||||
}
|
||||
}
|
||||
$upsert_stmt .= ' VALUES (' . join(',',@values) . ')';
|
||||
return $upsert_stmt;
|
||||
|
||||
}
|
||||
|
||||
sub gettablename {
|
||||
|
||||
return $tablename;
|
||||
|
||||
}
|
||||
|
||||
sub check_table {
|
||||
|
||||
return checktableinfo($get_db,
|
||||
__PACKAGE__,$tablename,
|
||||
$expected_fieldnames,
|
||||
$indexes);
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,392 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Migration::UPCAT::Import;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use threads::shared qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Settings qw(
|
||||
$provision_mta_subscriber_rownum_start
|
||||
$import_multithreading
|
||||
$mta_subscriber_import_numofthreads
|
||||
$ignore_mta_subscriber_unique
|
||||
$mta_subscriber_import_single_row_txn
|
||||
|
||||
$skip_errors
|
||||
|
||||
$mta_default_domain
|
||||
$mta_default_reseller_name
|
||||
$mta_default_billing_profile_name
|
||||
$mta_default_barring
|
||||
$cc_ac_map
|
||||
$default_cc
|
||||
$cc_len_min
|
||||
$cc_len_max
|
||||
$ac_len
|
||||
|
||||
$ignore_ccs_subscriber_unique
|
||||
$provision_ccs_subscriber_rownum_start
|
||||
$ccs_subscriber_import_single_row_txn
|
||||
|
||||
split_number
|
||||
);
|
||||
use NGCP::BulkProcessor::Logging qw (
|
||||
getlogger
|
||||
processing_info
|
||||
processing_debug
|
||||
);
|
||||
use NGCP::BulkProcessor::LogError qw(
|
||||
fileprocessingwarn
|
||||
fileprocessingerror
|
||||
);
|
||||
|
||||
#use NGCP::BulkProcessor::Projects::Migration::UPCAT::FileProcessors::CSVFile qw();
|
||||
use NGCP::BulkProcessor::FileProcessors::CSVFileSimple qw();
|
||||
use NGCP::BulkProcessor::FileProcessors::XslxFileSimple qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber qw();
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::ProjectConnectorPool qw(
|
||||
get_import_db
|
||||
destroy_all_dbs
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber qw();
|
||||
|
||||
use NGCP::BulkProcessor::Array qw(removeduplicates);
|
||||
use NGCP::BulkProcessor::Utils qw(threadid zerofill trim);
|
||||
use NGCP::BulkProcessor::Table qw(get_rowhash);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
import_mta_subscriber
|
||||
import_ccs_subscriber
|
||||
);
|
||||
|
||||
sub import_mta_subscriber {
|
||||
|
||||
my (@files) = @_;
|
||||
|
||||
my $result = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::create_table(0);
|
||||
|
||||
foreach my $file (@files) {
|
||||
$result &= _import_mta_subscriber_checks($file);
|
||||
}
|
||||
|
||||
#my $importer = NGCP::BulkProcessor::Projects::Migration::UPCAT::FileProcessors::CSVFile->new($subscriber_import_numofthreads);
|
||||
my $importer = NGCP::BulkProcessor::FileProcessors::CSVFileSimple->new($mta_subscriber_import_numofthreads);
|
||||
|
||||
my $upsert = _import_mta_subscriber_reset_delta();
|
||||
|
||||
destroy_all_dbs(); #close all db connections before forking..
|
||||
my $warning_count :shared = 0;
|
||||
my $filenum = 0;
|
||||
foreach my $file (@files) {
|
||||
$filenum++;
|
||||
$result &= $importer->process(
|
||||
file => $file,
|
||||
process_code => sub {
|
||||
my ($context,$rows,$row_offset) = @_;
|
||||
my $rownum = $row_offset;
|
||||
my @subscriber_rows = ();
|
||||
foreach my $row (@$rows) {
|
||||
$rownum++;
|
||||
next if (defined $provision_mta_subscriber_rownum_start and $rownum < $provision_mta_subscriber_rownum_start);
|
||||
next if (scalar @$row) == 0;
|
||||
$row = [ map { local $_ = $_; trim($_); $_ =~ s/^"//; $_ =~ s/"$//r; } @$row ];
|
||||
my $record = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber->new($row);
|
||||
$record->{reseller_name} = $mta_default_reseller_name;
|
||||
($record->{sip_username},$record->{domain}) = split('@',$record->{_txt_sw_username},2);
|
||||
$record->{domain} //= $mta_default_domain;
|
||||
$record->{billing_profile_name} = $mta_default_billing_profile_name;
|
||||
($record->{cc},$record->{ac},$record->{sn}) = split_number($record->{_dn});
|
||||
$record->{web_username} = undef;
|
||||
$record->{web_password} = undef;
|
||||
$record->{barring} = $mta_default_barring;
|
||||
#$record->{allowed_ips}
|
||||
#"channels",
|
||||
#"voicemail",
|
||||
|
||||
$record->{rownum} = $rownum;
|
||||
$record->{filenum} = $filenum;
|
||||
$record->{filename} = $file;
|
||||
|
||||
my %r = %$record; my @row_ext = @r{@NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::fieldnames};
|
||||
if ($context->{upsert}) {
|
||||
push(@row_ext,$record->{cc},$record->{ac},$record->{sn});
|
||||
} else {
|
||||
push(@row_ext,$NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::added_delta);
|
||||
}
|
||||
push(@subscriber_rows,\@row_ext); # if &{$context->{check_number_code}}($context,$record);
|
||||
|
||||
#my %r = %$record;
|
||||
#$record->{contact_hash} = get_rowhash([@r{@NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::Subscriber::contact_fieldnames}]);
|
||||
#next unless _unfold_number_ranges($context,$record,\@subscriber_rows);
|
||||
if ($mta_subscriber_import_single_row_txn and (scalar @subscriber_rows) > 0) {
|
||||
while (defined (my $subscriber_row = shift @subscriber_rows)) {
|
||||
if ($skip_errors) {
|
||||
eval { _insert_mta_subscriber_rows($context,[$subscriber_row]); };
|
||||
_warn($context,$@) if $@;
|
||||
} else {
|
||||
_insert_mta_subscriber_rows($context,[$subscriber_row]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (not $mta_subscriber_import_single_row_txn and (scalar @subscriber_rows) > 0) {
|
||||
if ($skip_errors) {
|
||||
eval { _insert_mta_subscriber_rows($context,\@subscriber_rows); };
|
||||
_warn($context,$@) if $@;
|
||||
} else {
|
||||
_insert_mta_subscriber_rows($context,\@subscriber_rows);
|
||||
}
|
||||
}
|
||||
#use Data::Dumper;
|
||||
#print Dumper(\@subscriber_rows);
|
||||
return 1;
|
||||
},
|
||||
init_process_context_code => sub {
|
||||
my ($context)= @_;
|
||||
$context->{db} = &get_import_db(); # keep ref count low..
|
||||
$context->{upsert} = $upsert;
|
||||
#$context->{unfold_ranges} = $subscriber_import_unfold_ranges;
|
||||
#$context->{fieldnames} = \@NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::Subscriber::fieldnames;
|
||||
#$context->{added_delta} = $NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::Subscriber::added_delta;
|
||||
#$context->{create_new_record_code} = sub {
|
||||
# return NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::Subscriber->new(shift);
|
||||
#};
|
||||
|
||||
#$context->{check_number_code} = sub {
|
||||
# my ($context,$record) = @_;
|
||||
# my $result = 1;
|
||||
# my $number = $record->{dn};
|
||||
# my $number = $record->{cc} . $record->{ac} . $record->{sn};
|
||||
# if (NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::Subscriber::findby_ccacsn($record->{cc},$record->{ac},$record->{sn})) {
|
||||
# if ($skip_errors) {
|
||||
# _warn($context,"$record->{sip_username}: duplicate number $number");
|
||||
# } else {
|
||||
# _error($context,"$record->{sip_username}: duplicate number $number");
|
||||
# }
|
||||
# $result = 0;
|
||||
# }
|
||||
# return $result;
|
||||
#};
|
||||
$context->{error_count} = 0;
|
||||
$context->{warning_count} = 0;
|
||||
},
|
||||
uninit_process_context_code => sub {
|
||||
my ($context)= @_;
|
||||
undef $context->{db};
|
||||
destroy_all_dbs();
|
||||
{
|
||||
lock $warning_count;
|
||||
$warning_count += $context->{warning_count};
|
||||
}
|
||||
},
|
||||
multithreading => $import_multithreading
|
||||
);
|
||||
}
|
||||
|
||||
return ($result,$warning_count);
|
||||
|
||||
}
|
||||
|
||||
sub _import_mta_subscriber_checks {
|
||||
my ($file) = @_;
|
||||
my $result = 1;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub _import_mta_subscriber_reset_delta {
|
||||
my $upsert = 0;
|
||||
if (NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::countby_ccacsn() > 0) {
|
||||
processing_info(threadid(),'resetting delta of ' .
|
||||
NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::update_delta(undef,undef,undef,
|
||||
$NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::deleted_delta) .
|
||||
' mta subscriber records',getlogger(__PACKAGE__));
|
||||
$upsert |= 1;
|
||||
}
|
||||
return $upsert;
|
||||
}
|
||||
|
||||
sub _insert_mta_subscriber_rows {
|
||||
my ($context,$subscriber_rows) = @_;
|
||||
$context->{db}->db_do_begin(
|
||||
($context->{upsert} ?
|
||||
NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::getupsertstatement()
|
||||
: NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::getinsertstatement($ignore_mta_subscriber_unique)),
|
||||
#NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::Subscriber::gettablename(),
|
||||
#lock
|
||||
);
|
||||
eval {
|
||||
$context->{db}->db_do_rowblock($subscriber_rows);
|
||||
$context->{db}->db_finish();
|
||||
};
|
||||
my $err = $@;
|
||||
if ($err) {
|
||||
eval {
|
||||
$context->{db}->db_finish(1);
|
||||
};
|
||||
die($err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub import_ccs_subscriber {
|
||||
|
||||
my ($file) = @_;
|
||||
# create tables:
|
||||
my $result = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::create_table(0);
|
||||
|
||||
# checks, e.g. other table must be present:
|
||||
# ..none..
|
||||
|
||||
# prepare parse:
|
||||
my $importer = NGCP::BulkProcessor::FileProcessors::CSVFileSimple->new(); #$user_password_import_numofthreads);
|
||||
|
||||
my $upsert = _import_ccs_subscriber_reset_delta();
|
||||
|
||||
# launch:
|
||||
destroy_all_dbs(); #close all db connections before forking..
|
||||
my $warning_count :shared = 0;
|
||||
return ($result && $importer->process(
|
||||
file => $file,
|
||||
process_code => sub {
|
||||
my ($context,$rows,$row_offset) = @_;
|
||||
my $rownum = $row_offset;
|
||||
my @subscriber_rows = ();
|
||||
foreach my $row (@$rows) {
|
||||
$rownum++;
|
||||
next if (defined $provision_ccs_subscriber_rownum_start and $rownum < $provision_ccs_subscriber_rownum_start);
|
||||
next if (scalar @$row) == 0 or (scalar @$row) == 1;
|
||||
$row = [ map { local $_ = $_; trim($_); $_; } @$row ]; #Encode::encode('utf8',Encode::decode('cp1252',$_));
|
||||
my $record = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber->new($row);
|
||||
$record->{rownum} = $rownum;
|
||||
my %r = %$record; my @row_ext = @r{@NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::fieldnames};
|
||||
if ($context->{upsert}) {
|
||||
push(@row_ext,$record->{service_number});
|
||||
} else {
|
||||
push(@row_ext,$NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::added_delta);
|
||||
}
|
||||
push(@subscriber_rows,\@row_ext); # if &{$context->{check_number_code}}($context,$record);
|
||||
|
||||
#my %r = %$record;
|
||||
#$record->{contact_hash} = get_rowhash([@r{@NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::Subscriber::contact_fieldnames}]);
|
||||
#next unless _unfold_number_ranges($context,$record,\@subscriber_rows);
|
||||
if ($ccs_subscriber_import_single_row_txn and (scalar @subscriber_rows) > 0) {
|
||||
while (defined (my $subscriber_row = shift @subscriber_rows)) {
|
||||
if ($skip_errors) {
|
||||
eval { _insert_ccs_subscriber_rows($context,[$subscriber_row]); };
|
||||
_warn($context,$@) if $@;
|
||||
} else {
|
||||
_insert_ccs_subscriber_rows($context,[$subscriber_row]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (not $ccs_subscriber_import_single_row_txn and (scalar @subscriber_rows) > 0) {
|
||||
if ($skip_errors) {
|
||||
eval { _insert_ccs_subscriber_rows($context,\@subscriber_rows); };
|
||||
_warn($context,$@) if $@;
|
||||
} else {
|
||||
_insert_ccs_subscriber_rows($context,\@subscriber_rows);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
},
|
||||
init_process_context_code => sub {
|
||||
my ($context)= @_;
|
||||
$context->{db} = &get_import_db(); # keep ref count low..
|
||||
$context->{upsert} = $upsert;
|
||||
$context->{error_count} = 0;
|
||||
$context->{warning_count} = 0;
|
||||
},
|
||||
uninit_process_context_code => sub {
|
||||
my ($context)= @_;
|
||||
undef $context->{db};
|
||||
destroy_all_dbs();
|
||||
{
|
||||
lock $warning_count;
|
||||
$warning_count += $context->{warning_count};
|
||||
}
|
||||
},
|
||||
multithreading => $import_multithreading
|
||||
),$warning_count);
|
||||
|
||||
}
|
||||
|
||||
sub _import_ccs_subscriber_reset_delta {
|
||||
my $upsert = 0;
|
||||
if (NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::countby_service_number() > 0) {
|
||||
processing_info(threadid(),'resetting delta of ' .
|
||||
NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::update_delta(undef,
|
||||
$NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::deleted_delta) .
|
||||
' ccs subscriber records',getlogger(__PACKAGE__));
|
||||
$upsert |= 1;
|
||||
}
|
||||
return $upsert;
|
||||
}
|
||||
|
||||
sub _insert_ccs_subscriber_rows {
|
||||
my ($context,$subscriber_rows) = @_;
|
||||
$context->{db}->db_do_begin(
|
||||
($context->{upsert} ?
|
||||
NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::getupsertstatement()
|
||||
: NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::getinsertstatement($ignore_ccs_subscriber_unique)),
|
||||
#NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::Subscriber::gettablename(),
|
||||
#lock
|
||||
);
|
||||
eval {
|
||||
$context->{db}->db_do_rowblock($subscriber_rows);
|
||||
$context->{db}->db_finish();
|
||||
};
|
||||
my $err = $@;
|
||||
if ($err) {
|
||||
eval {
|
||||
$context->{db}->db_finish(1);
|
||||
};
|
||||
die($err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
sub _error {
|
||||
|
||||
my ($context,$message) = @_;
|
||||
$context->{error_count} = $context->{error_count} + 1;
|
||||
fileprocessingerror($context->{filename},$message,getlogger(__PACKAGE__));
|
||||
|
||||
}
|
||||
|
||||
sub _warn {
|
||||
|
||||
my ($context,$message) = @_;
|
||||
$context->{warning_count} = $context->{warning_count} + 1;
|
||||
fileprocessingwarn($context->{filename},$message,getlogger(__PACKAGE__));
|
||||
|
||||
}
|
||||
|
||||
sub _info {
|
||||
|
||||
my ($context,$message,$debug) = @_;
|
||||
if ($debug) {
|
||||
processing_debug($context->{tid},$message,getlogger(__PACKAGE__));
|
||||
} else {
|
||||
processing_info($context->{tid},$message,getlogger(__PACKAGE__));
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,207 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Migration::UPCAT::Preferences;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
no strict 'refs';
|
||||
|
||||
use threads::shared qw();
|
||||
#use List::Util qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Settings qw(
|
||||
$dry
|
||||
$skip_errors
|
||||
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Logging qw (
|
||||
getlogger
|
||||
processing_info
|
||||
processing_debug
|
||||
);
|
||||
use NGCP::BulkProcessor::LogError qw(
|
||||
rowprocessingerror
|
||||
rowprocessingwarn
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::ncos_levels qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::domains qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::domain_resellers qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers qw();
|
||||
|
||||
#use NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber qw();
|
||||
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_subscribers qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_usr_preferences qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_contract_preferences qw();
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_xa_db
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::ProjectConnectorPool qw(
|
||||
destroy_all_dbs
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Utils qw(threadid);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
|
||||
clear_subscriber_preferences
|
||||
delete_subscriber_preference
|
||||
set_subscriber_preference
|
||||
get_subscriber_preference
|
||||
|
||||
clear_contract_preferences
|
||||
delete_contract_preference
|
||||
set_contract_preference
|
||||
get_contract_preference
|
||||
|
||||
);
|
||||
|
||||
my %get_preference_sub_names = (
|
||||
voip_usr_preferences => 'findby_subscriberid_attributeid',
|
||||
voip_contract_preferences => 'findby_contractid_attributeid',
|
||||
);
|
||||
my %preference_id_cols = (
|
||||
voip_usr_preferences => 'subscriber_id',
|
||||
voip_contract_preferences => 'contract_id',
|
||||
);
|
||||
|
||||
sub clear_subscriber_preferences {
|
||||
my ($context,$subscriber_id,$attribute,$except_value) = @_;
|
||||
return _clear_preferences($context,'voip_usr_preferences',$subscriber_id,$attribute,$except_value);
|
||||
}
|
||||
sub delete_subscriber_preference {
|
||||
my ($context,$subscriber_id,$attribute,$value) = @_;
|
||||
return _delete_preference($context,'voip_usr_preferences',$subscriber_id,$attribute,$value);
|
||||
}
|
||||
sub set_subscriber_preference {
|
||||
my ($context,$subscriber_id,$attribute,$value) = @_;
|
||||
return _set_preference($context,'voip_usr_preferences',$subscriber_id,$attribute,$value);
|
||||
}
|
||||
sub get_subscriber_preference {
|
||||
my ($context,$subscriber_id,$attribute) = @_;
|
||||
return _get_preference($context,'voip_usr_preferences',$subscriber_id,$attribute);
|
||||
}
|
||||
|
||||
sub clear_contract_preferences {
|
||||
my ($context,$contract_id,$attribute,$except_value) = @_;
|
||||
return _clear_preferences($context,'voip_contract_preferences',$contract_id,$attribute,$except_value);
|
||||
}
|
||||
sub delete_contract_preference {
|
||||
my ($context,$contract_id,$attribute,$value) = @_;
|
||||
return _delete_preference($context,'voip_contract_preferences',$contract_id,$attribute,$value);
|
||||
}
|
||||
sub set_contract_preference {
|
||||
my ($context,$contract_id,$attribute,$value) = @_;
|
||||
return _set_preference($context,'voip_contract_preferences',$contract_id,$attribute,$value);
|
||||
}
|
||||
sub get_contract_preference {
|
||||
my ($context,$contract_id,$attribute) = @_;
|
||||
return _get_preference($context,'voip_contract_preferences',$contract_id,$attribute);
|
||||
}
|
||||
|
||||
sub _clear_preferences {
|
||||
my ($context,$pref_type,$id,$attribute,$except_value) = @_;
|
||||
|
||||
return &{'NGCP::BulkProcessor::Dao::Trunk::provisioning::' . $pref_type . '::delete_preferences'}($context->{db},
|
||||
$id, $attribute->{id}, defined $except_value ? { 'NOT IN' => $except_value } : undef);
|
||||
|
||||
}
|
||||
|
||||
sub _delete_preference {
|
||||
my ($context,$pref_type,$id,$attribute,$value) = @_;
|
||||
|
||||
return &{'NGCP::BulkProcessor::Dao::Trunk::provisioning::' . $pref_type . '::delete_preferences'}($context->{db},
|
||||
$id, $attribute->{id}, { 'IN' => $value } );
|
||||
|
||||
}
|
||||
|
||||
sub _set_preference {
|
||||
my ($context,$pref_type,$id,$attribute,$value) = @_;
|
||||
|
||||
if ($attribute->{max_occur} == 1) {
|
||||
my $old_preferences = &{'NGCP::BulkProcessor::Dao::Trunk::provisioning::' . $pref_type . '::' . $get_preference_sub_names{$pref_type}}($context->{db},
|
||||
$id,$attribute->{id});
|
||||
if (defined $value) {
|
||||
if ((scalar @$old_preferences) == 1) {
|
||||
&{'NGCP::BulkProcessor::Dao::Trunk::provisioning::' . $pref_type . '::update_row'}($context->{db},{
|
||||
id => $old_preferences->[0]->{id},
|
||||
value => $value,
|
||||
});
|
||||
return $old_preferences->[0]->{id};
|
||||
} else {
|
||||
if ((scalar @$old_preferences) > 1) {
|
||||
&{'NGCP::BulkProcessor::Dao::Trunk::provisioning::' . $pref_type . '::delete_preferences'}($context->{db},
|
||||
$id,$attribute->{id});
|
||||
}
|
||||
return &{'NGCP::BulkProcessor::Dao::Trunk::provisioning::' . $pref_type . '::insert_row'}($context->{db},
|
||||
attribute_id => $attribute->{id},
|
||||
$preference_id_cols{$pref_type} => $id,
|
||||
value => $value,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
&{'NGCP::BulkProcessor::Dao::Trunk::provisioning::' . $pref_type . '::delete_preferences'}($context->{db},
|
||||
$id,$attribute->{id});
|
||||
return undef;
|
||||
}
|
||||
} else {
|
||||
if (defined $value) {
|
||||
return &{'NGCP::BulkProcessor::Dao::Trunk::provisioning::' . $pref_type . '::insert_row'}($context->{db},
|
||||
attribute_id => $attribute->{id},
|
||||
$preference_id_cols{$pref_type} => $id,
|
||||
value => $value,
|
||||
);
|
||||
} else {
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub _get_preference {
|
||||
my ($context,$pref_type,$id,$attribute) = @_;
|
||||
|
||||
my $preferences = &{'NGCP::BulkProcessor::Dao::Trunk::provisioning::' . $pref_type . '::' . $get_preference_sub_names{$pref_type}}($context->{db},
|
||||
$id,$attribute->{id});
|
||||
|
||||
if ($attribute->{max_occur} == 1) {
|
||||
return $preferences->[0];
|
||||
} else {
|
||||
return $preferences;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub _error {
|
||||
|
||||
my ($context,$message) = @_;
|
||||
$context->{error_count} = $context->{error_count} + 1;
|
||||
rowprocessingerror($context->{tid},$message,getlogger(__PACKAGE__));
|
||||
|
||||
}
|
||||
|
||||
sub _warn {
|
||||
|
||||
my ($context,$message) = @_;
|
||||
$context->{warning_count} = $context->{warning_count} + 1;
|
||||
rowprocessingwarn($context->{tid},$message,getlogger(__PACKAGE__));
|
||||
|
||||
}
|
||||
|
||||
sub _info {
|
||||
|
||||
my ($context,$message,$debug) = @_;
|
||||
if ($debug) {
|
||||
processing_debug($context->{tid},$message,getlogger(__PACKAGE__));
|
||||
} else {
|
||||
processing_info($context->{tid},$message,getlogger(__PACKAGE__));
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,101 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Migration::UPCAT::ProjectConnectorPool;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use File::Basename;
|
||||
use Cwd;
|
||||
use lib Cwd::abs_path(File::Basename::dirname(__FILE__) . '/../../../');
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Settings qw(
|
||||
$import_db_file
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_connectorinstancename
|
||||
ping
|
||||
);
|
||||
|
||||
#use NGCP::BulkProcessor::SqlConnectors::MySQLDB;
|
||||
#use NGCP::BulkProcessor::SqlConnectors::OracleDB;
|
||||
#use NGCP::BulkProcessor::SqlConnectors::PostgreSQLDB;
|
||||
use NGCP::BulkProcessor::SqlConnectors::SQLiteDB qw(
|
||||
$staticdbfilemode
|
||||
cleanupdbfiles
|
||||
);
|
||||
#use NGCP::BulkProcessor::SqlConnectors::CSVDB;
|
||||
#use NGCP::BulkProcessor::SqlConnectors::SQLServerDB;
|
||||
#use NGCP::BulkProcessor::RestConnectors::NGCPRestApi;
|
||||
|
||||
use NGCP::BulkProcessor::SqlProcessor qw(cleartableinfo);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
get_import_db
|
||||
import_db_tableidentifier
|
||||
|
||||
destroy_dbs
|
||||
destroy_all_dbs
|
||||
|
||||
ping_dbs
|
||||
ping_all_dbs
|
||||
);
|
||||
|
||||
# thread connector pools:
|
||||
my $import_dbs = {};
|
||||
|
||||
|
||||
sub get_import_db {
|
||||
|
||||
my ($instance_name,$reconnect) = @_;
|
||||
my $name = get_connectorinstancename($instance_name); #threadid(); #shift;
|
||||
|
||||
if (not defined $import_dbs->{$name}) {
|
||||
$import_dbs->{$name} = NGCP::BulkProcessor::SqlConnectors::SQLiteDB->new($instance_name); #$name);
|
||||
if (not defined $reconnect) {
|
||||
$reconnect = 1;
|
||||
}
|
||||
}
|
||||
if ($reconnect) {
|
||||
$import_dbs->{$name}->db_connect($staticdbfilemode,$import_db_file);
|
||||
}
|
||||
|
||||
return $import_dbs->{$name};
|
||||
|
||||
}
|
||||
|
||||
sub import_db_tableidentifier {
|
||||
|
||||
my ($get_target_db,$tablename) = @_;
|
||||
my $target_db = (ref $get_target_db eq 'CODE') ? &$get_target_db() : $get_target_db;
|
||||
return $target_db->getsafetablename(NGCP::BulkProcessor::SqlConnectors::SQLiteDB::get_tableidentifier($tablename,$staticdbfilemode,$import_db_file));
|
||||
|
||||
}
|
||||
|
||||
sub ping_dbs {
|
||||
ping($import_dbs);
|
||||
}
|
||||
|
||||
sub ping_all_dbs {
|
||||
ping_dbs();
|
||||
NGCP::BulkProcessor::ConnectorPool::ping_dbs();
|
||||
}
|
||||
|
||||
sub destroy_dbs {
|
||||
|
||||
|
||||
foreach my $name (keys %$import_dbs) {
|
||||
cleartableinfo($import_dbs->{$name});
|
||||
undef $import_dbs->{$name};
|
||||
delete $import_dbs->{$name};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub destroy_all_dbs() {
|
||||
destroy_dbs();
|
||||
NGCP::BulkProcessor::ConnectorPool::destroy_dbs();
|
||||
}
|
||||
|
||||
1;
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,427 +0,0 @@
|
||||
package NGCP::BulkProcessor::Projects::Migration::UPCAT::Settings;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::Globals qw(
|
||||
$working_path
|
||||
$enablemultithreading
|
||||
$cpucount
|
||||
create_path
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Logging qw(
|
||||
getlogger
|
||||
scriptinfo
|
||||
configurationinfo
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::LogError qw(
|
||||
fileerror
|
||||
filewarn
|
||||
configurationwarn
|
||||
configurationerror
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::LoadConfig qw(
|
||||
split_tuple
|
||||
parse_regexp
|
||||
);
|
||||
use NGCP::BulkProcessor::Utils qw(prompt timestampdigits check_ipnet);
|
||||
#format_number check_ipnet
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
update_settings
|
||||
update_cc_ac_map
|
||||
update_barring_profiles
|
||||
split_number
|
||||
check_dry
|
||||
|
||||
$input_path
|
||||
$output_path
|
||||
$report_filename
|
||||
|
||||
$defaultsettings
|
||||
$defaultconfig
|
||||
|
||||
$import_multithreading
|
||||
$run_id
|
||||
$dry
|
||||
$skip_errors
|
||||
$force
|
||||
$import_db_file
|
||||
|
||||
@mta_subscriber_filenames
|
||||
$mta_subscriber_import_numofthreads
|
||||
$ignore_mta_subscriber_unique
|
||||
$mta_subscriber_import_single_row_txn
|
||||
|
||||
$provision_mta_subscriber_rownum_start
|
||||
$provision_mta_subscriber_multithreading
|
||||
$provision_mta_subscriber_numofthreads
|
||||
$mta_webpassword_length
|
||||
$mta_webusername_length
|
||||
$mta_sippassword_length
|
||||
|
||||
$mta_default_domain
|
||||
$mta_default_reseller_name
|
||||
$mta_default_billing_profile_name
|
||||
$mta_default_barring
|
||||
|
||||
$cc_ac_map_yml
|
||||
$cc_ac_map
|
||||
$default_cc
|
||||
$cc_len_min
|
||||
$cc_len_max
|
||||
$ac_len
|
||||
|
||||
$barring_profiles_yml
|
||||
$barring_profiles
|
||||
|
||||
$ccs_subscriber_filename
|
||||
$ignore_ccs_subscriber_unique
|
||||
$provision_ccs_subscriber_rownum_start
|
||||
$ccs_subscriber_import_single_row_txn
|
||||
|
||||
$provision_ccs_subscriber_multithreading
|
||||
$provision_ccs_subscriber_numofthreads
|
||||
$ccs_reseller_name
|
||||
$ccs_billing_profile_name
|
||||
$ccs_domain
|
||||
$ccs_sippassword_length
|
||||
|
||||
@css_trusted_source_ips
|
||||
|
||||
$cf_default_priority
|
||||
$cf_default_timeout
|
||||
$cft_default_ringtimeout
|
||||
);
|
||||
#$default_channels_map
|
||||
|
||||
our $defaultconfig = 'config.cfg';
|
||||
our $defaultsettings = 'settings.cfg';
|
||||
|
||||
our $input_path = $working_path . 'input/';
|
||||
our $output_path = $working_path . 'output/';
|
||||
our $report_filename = undef;
|
||||
|
||||
our $force = 0;
|
||||
our $dry = 0;
|
||||
our $skip_errors = 0;
|
||||
our $run_id = '';
|
||||
our $import_db_file = _get_import_db_file($run_id,'import');
|
||||
our $import_multithreading = 0; #$enablemultithreading;
|
||||
|
||||
our @mta_subscriber_filenames = ();
|
||||
our $mta_subscriber_import_numofthreads = $cpucount;
|
||||
our $ignore_mta_subscriber_unique = 0;
|
||||
our $mta_subscriber_import_single_row_txn = 1;
|
||||
|
||||
our $provision_mta_subscriber_rownum_start = 0; #all lines
|
||||
our $provision_mta_subscriber_multithreading = $enablemultithreading;
|
||||
our $provision_mta_subscriber_numofthreads = $cpucount;
|
||||
our $mta_webpassword_length = 8;
|
||||
our $mta_webusername_length = 8;
|
||||
our $mta_sippassword_length = 16;
|
||||
|
||||
our $mta_default_domain = undef;
|
||||
our $mta_default_reseller_name = 'default';
|
||||
our $mta_default_billing_profile_name = 'Default Billing Profile';
|
||||
our $mta_default_barring = undef;
|
||||
|
||||
our $cc_ac_map_yml = 'cc_ac.yml';
|
||||
our $cc_ac_map = {};
|
||||
our $default_cc = undef;
|
||||
our $cc_len_min = ~0;
|
||||
our $cc_len_max = 0;
|
||||
our $ac_len = {};
|
||||
|
||||
our $barring_profiles_yml = undef;
|
||||
our $barring_profiles = {};
|
||||
|
||||
our $ccs_subscriber_filename = undef;
|
||||
our $ignore_ccs_subscriber_unique = 0;
|
||||
our $provision_ccs_subscriber_rownum_start = 0;
|
||||
our $ccs_subscriber_import_single_row_txn = 1;
|
||||
|
||||
our $provision_ccs_subscriber_multithreading = $enablemultithreading;
|
||||
our $provision_ccs_subscriber_numofthreads = $cpucount;
|
||||
|
||||
our $ccs_reseller_name = 'default';
|
||||
our $ccs_billing_profile_name = 'Default Billing Profile';
|
||||
our $ccs_domain = undef;
|
||||
our $ccs_sippassword_length = 16;
|
||||
|
||||
our @css_trusted_source_ips = ();
|
||||
|
||||
our $cf_default_priority = 1;
|
||||
our $cf_default_timeout = 300;
|
||||
our $cft_default_ringtimeout = 20;
|
||||
|
||||
sub update_settings {
|
||||
|
||||
my ($data,$configfile) = @_;
|
||||
|
||||
if (defined $data) {
|
||||
|
||||
my $result = 1;
|
||||
my $regexp_result;
|
||||
|
||||
#&$configurationinfocode("testinfomessage",$configlogger);
|
||||
|
||||
$result &= _prepare_working_paths(1);
|
||||
if ($data->{report_filename}) {
|
||||
$report_filename = $output_path . sprintf('/' . $data->{report_filename},timestampdigits());
|
||||
if (-e $report_filename and (unlink $report_filename) == 0) {
|
||||
filewarn('cannot remove ' . $report_filename . ': ' . $!,getlogger(__PACKAGE__));
|
||||
$report_filename = undef;
|
||||
}
|
||||
} else {
|
||||
$report_filename = undef;
|
||||
}
|
||||
|
||||
$dry = $data->{dry} if exists $data->{dry};
|
||||
$skip_errors = $data->{skip_errors} if exists $data->{skip_errors};
|
||||
$import_db_file = _get_import_db_file($run_id,'import');
|
||||
$import_multithreading = $data->{import_multithreading} if exists $data->{import_multithreading};
|
||||
#if ($import_multithreading) {
|
||||
# configurationerror($configfile,"import_multithreading must be disabled to preserve record order",getlogger(__PACKAGE__));
|
||||
#}
|
||||
|
||||
@mta_subscriber_filenames = _get_import_filenames(\@mta_subscriber_filenames,$data,'mta_subscriber_filenames');
|
||||
$mta_subscriber_import_numofthreads = _get_numofthreads($cpucount,$data,'mta_subscriber_import_numofthreads');
|
||||
$ignore_mta_subscriber_unique = $data->{ignore_mta_subscriber_unique} if exists $data->{ignore_mta_subscriber_unique};
|
||||
$mta_subscriber_import_single_row_txn = $data->{mta_subscriber_import_single_row_txn} if exists $data->{mta_subscriber_import_single_row_txn};
|
||||
|
||||
$provision_mta_subscriber_rownum_start = $data->{provision_mta_subscriber_rownum_start} if exists $data->{provision_mta_subscriber_rownum_start};
|
||||
$provision_mta_subscriber_multithreading = $data->{provision_mta_subscriber_multithreading} if exists $data->{provision_mta_subscriber_multithreading};
|
||||
$provision_mta_subscriber_numofthreads = _get_numofthreads($cpucount,$data,'provision_mta_subscriber_numofthreads');
|
||||
$mta_webpassword_length = $data->{mta_webpassword_length} if exists $data->{mta_webpassword_length};
|
||||
if (not defined $mta_webpassword_length or $mta_webpassword_length <= 7) {
|
||||
configurationerror($configfile,'mta_webpassword_length greater than 7 required',getlogger(__PACKAGE__));
|
||||
$result = 0;
|
||||
}
|
||||
$mta_webusername_length = $data->{mta_webusername_length} if exists $data->{mta_webusername_length};
|
||||
if (not defined $mta_webusername_length or $mta_webusername_length <= 7) {
|
||||
configurationerror($configfile,'mta_webusername_length greater than 7 required',getlogger(__PACKAGE__));
|
||||
$result = 0;
|
||||
}
|
||||
$mta_sippassword_length = $data->{mta_sippassword_length} if exists $data->{mta_sippassword_length};
|
||||
if (not defined $mta_sippassword_length or $mta_sippassword_length <= 7) {
|
||||
configurationerror($configfile,'mta_sippassword_length greater than 7 required',getlogger(__PACKAGE__));
|
||||
$result = 0;
|
||||
}
|
||||
#$default_channels = $data->{default_channels} if exists $data->{default_channels};
|
||||
|
||||
$mta_default_domain = $data->{mta_default_domain} if exists $data->{mta_default_domain};
|
||||
$mta_default_reseller_name = $data->{mta_default_reseller_name} if exists $data->{mta_default_reseller_name};
|
||||
$mta_default_billing_profile_name = $data->{mta_default_billing_profile_name} if exists $data->{mta_default_billing_profile_name};
|
||||
$mta_default_barring = $data->{mta_default_barring} if exists $data->{mta_default_barring};
|
||||
|
||||
$cc_ac_map_yml = $data->{cc_ac_map_yml} if exists $data->{cc_ac_map_yml};
|
||||
$default_cc = $data->{default_cc} if exists $data->{default_cc};
|
||||
|
||||
$barring_profiles_yml = $data->{barring_profiles_yml} if exists $data->{barring_profiles_yml};
|
||||
|
||||
($ccs_subscriber_filename) = _get_import_filenames([ $ccs_subscriber_filename ],$data,'ccs_subscriber_filename');
|
||||
$ignore_ccs_subscriber_unique = $data->{ignore_ccs_subscriber_unique} if exists $data->{ignore_ccs_subscriber_unique};
|
||||
$provision_ccs_subscriber_rownum_start = $data->{provision_ccs_subscriber_rownum_start} if exists $data->{provision_ccs_subscriber_rownum_start};
|
||||
$ccs_subscriber_import_single_row_txn = $data->{ccs_subscriber_import_single_row_txn} if exists $data->{ccs_subscriber_import_single_row_txn};
|
||||
$provision_ccs_subscriber_multithreading = $data->{provision_ccs_subscriber_multithreading} if exists $data->{provision_ccs_subscriber_multithreading};
|
||||
$provision_ccs_subscriber_numofthreads = _get_numofthreads($cpucount,$data,'provision_ccs_subscriber_numofthreads');
|
||||
$ccs_reseller_name = $data->{ccs_reseller_name} if exists $data->{ccs_reseller_name};
|
||||
$ccs_billing_profile_name = $data->{ccs_billing_profile_name} if exists $data->{ccs_billing_profile_name};
|
||||
$ccs_domain = $data->{ccs_domain} if exists $data->{ccs_domain};
|
||||
$ccs_sippassword_length = $data->{ccs_sippassword_length} if exists $data->{ccs_sippassword_length};
|
||||
if (not defined $ccs_sippassword_length or $ccs_sippassword_length <= 7) {
|
||||
configurationerror($configfile,'ccs_sippassword_length greater than 7 required',getlogger(__PACKAGE__));
|
||||
$result = 0;
|
||||
}
|
||||
|
||||
@css_trusted_source_ips = split_tuple($data->{css_trusted_source_ips}) if exists $data->{css_trusted_source_ips};
|
||||
foreach my $ip (@css_trusted_source_ips) {
|
||||
unless (check_ipnet($ip)) {
|
||||
configurationerror($configfile,"invalid ip address '$ip'",getlogger(__PACKAGE__));
|
||||
$result = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$cf_default_priority = $data->{cf_default_priority} if exists $data->{cf_default_priority};
|
||||
$cf_default_timeout = $data->{cf_default_timeout} if exists $data->{cf_default_timeout};
|
||||
$cft_default_ringtimeout = $data->{cft_default_ringtimeout} if exists $data->{cft_default_ringtimeout};
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
sub update_cc_ac_map {
|
||||
|
||||
my ($data,$configfile) = @_;
|
||||
|
||||
if (defined $data) {
|
||||
|
||||
my $result = 1;
|
||||
|
||||
eval {
|
||||
$cc_ac_map = $data;
|
||||
};
|
||||
if ($@ or 'HASH' ne ref $cc_ac_map) {
|
||||
$cc_ac_map //= {};
|
||||
configurationerror($configfile,'invalid cc ac map',getlogger(__PACKAGE__));
|
||||
$result = 0;
|
||||
} else {
|
||||
foreach my $cc (keys %$cc_ac_map) {
|
||||
my $ac_map = $cc_ac_map->{$cc};
|
||||
$cc_len_min = length($cc) if length($cc) < $cc_len_min;
|
||||
$cc_len_max = length($cc) if length($cc) > $cc_len_max;
|
||||
$ac_len->{$cc} = { min => ~0, max => 0, };
|
||||
if ('HASH' ne ref $ac_map) {
|
||||
configurationerror($configfile,"invalid $cc ac map",getlogger(__PACKAGE__));
|
||||
$result = 0;
|
||||
} else {
|
||||
foreach my $ac (keys %$ac_map) {
|
||||
if ($ac_map->{$ac}) { # ac enabled
|
||||
$ac_len->{$cc}->{min} = length($ac) if length($ac) < $ac_len->{$cc}->{min};
|
||||
$ac_len->{$cc}->{max} = length($ac) if length($ac) > $ac_len->{$cc}->{max};
|
||||
} else {
|
||||
delete $ac_map->{$ac};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
sub split_number {
|
||||
my ($dn) = @_;
|
||||
my ($cc,$ac,$sn) = ('','',$dn);
|
||||
if ($cc_ac_map) {
|
||||
if ($default_cc) {
|
||||
$cc = $default_cc;
|
||||
$dn =~ s/^0//;
|
||||
$sn = $dn;
|
||||
} else {
|
||||
foreach my $cc_length ($cc_len_min .. $cc_len_max) {
|
||||
my ($_cc,$_dn) = (substr($dn,0,$cc_length), substr($dn,$cc_length));
|
||||
if (exists $cc_ac_map->{$_cc}) {
|
||||
$cc = $_cc;
|
||||
$sn = $_dn;
|
||||
$dn = $_dn;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (exists $cc_ac_map->{$cc}) {
|
||||
my $ac_map = $cc_ac_map->{$cc};
|
||||
foreach my $ac_length ($ac_len->{$cc}->{min} .. $ac_len->{$cc}->{max}) {
|
||||
my ($_ac,$_sn) = (substr($dn,0,$ac_length), substr($dn,$ac_length));
|
||||
if (exists $ac_map->{$_ac}) {
|
||||
$ac = $_ac;
|
||||
$sn = $_sn;
|
||||
#$dn = '';
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ($cc,$ac,$sn);
|
||||
|
||||
}
|
||||
|
||||
sub update_barring_profiles {
|
||||
|
||||
my ($data,$configfile) = @_;
|
||||
|
||||
if (defined $data) {
|
||||
|
||||
my $result = 1;
|
||||
|
||||
eval {
|
||||
$barring_profiles = $data; #->{'mapping'};
|
||||
};
|
||||
if ($@ or 'HASH' ne ref $barring_profiles or (scalar keys %$barring_profiles) == 0) {
|
||||
$barring_profiles //= {};
|
||||
configurationerror($configfile,'no barring mappings found',getlogger(__PACKAGE__));
|
||||
$result = 0;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
sub _prepare_working_paths {
|
||||
|
||||
my ($create) = @_;
|
||||
my $result = 1;
|
||||
my $path_result;
|
||||
|
||||
($path_result,$input_path) = create_path($working_path . 'input',$input_path,$create,\&fileerror,getlogger(__PACKAGE__));
|
||||
$result &= $path_result;
|
||||
($path_result,$output_path) = create_path($working_path . 'output',$output_path,$create,\&fileerror,getlogger(__PACKAGE__));
|
||||
$result &= $path_result;
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub _get_numofthreads {
|
||||
my ($default_value,$data,$key) = @_;
|
||||
my $numofthreads = $default_value;
|
||||
$numofthreads = $data->{$key} if exists $data->{$key};
|
||||
$numofthreads = $cpucount if $numofthreads > $cpucount;
|
||||
return $numofthreads;
|
||||
}
|
||||
|
||||
sub _get_import_db_file {
|
||||
my ($run,$name) = @_;
|
||||
return ((defined $run and length($run) > 0) ? $run . '_' : '') . $name;
|
||||
}
|
||||
|
||||
sub _get_import_filenames {
|
||||
my ($old_value,$data,$key) = @_;
|
||||
my @import_filenames = @$old_value;
|
||||
@import_filenames = split_tuple($data->{$key}) if exists $data->{$key};
|
||||
my @result = ();
|
||||
foreach my $import_filename (@import_filenames) {
|
||||
if (defined $import_filename and length($import_filename) > 0) {
|
||||
$import_filename = $input_path . $import_filename unless -e $import_filename;
|
||||
push(@result,$import_filename);
|
||||
}
|
||||
}
|
||||
return @result;
|
||||
}
|
||||
|
||||
sub check_dry {
|
||||
|
||||
if ($dry) {
|
||||
scriptinfo('running in dry mode - NGCP databases will not be modified',getlogger(__PACKAGE__));
|
||||
return 1;
|
||||
} else {
|
||||
scriptinfo('NO DRY MODE - NGCP DATABASES WILL BE MODIFIED!',getlogger(__PACKAGE__));
|
||||
if (!$force) {
|
||||
if ('yes' eq lc(prompt("Type 'yes' to proceed: "))) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
scriptinfo('force option applied',getlogger(__PACKAGE__));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -1,2 +0,0 @@
|
||||
UPC:
|
||||
default: '0'
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,61 +0,0 @@
|
||||
##general settings:
|
||||
working_path = /home/rkrenn/temp/upcat
|
||||
cpucount = 4
|
||||
enablemultithreading = 0
|
||||
|
||||
##gearman/service listener config:
|
||||
jobservers = 127.0.0.1:4730
|
||||
|
||||
##NGCP MySQL connectivity - "accounting" db:
|
||||
accounting_host = 192.168.0.29
|
||||
accounting_port = 3306
|
||||
accounting_databasename = accounting
|
||||
accounting_username = root
|
||||
accounting_password =
|
||||
|
||||
##NGCP MySQL connectivity - "billing" db:
|
||||
billing_host = 192.168.0.29
|
||||
billing_port = 3306
|
||||
billing_databasename = billing
|
||||
billing_username = root
|
||||
billing_password =
|
||||
|
||||
##NGCP MySQL connectivity - "provisioning" db:
|
||||
provisioning_host = 192.168.0.29
|
||||
provisioning_port = 3306
|
||||
provisioning_databasename = provisioning
|
||||
provisioning_username = root
|
||||
provisioning_password =
|
||||
|
||||
##NGCP MySQL connectivity - "kamailio" db:
|
||||
kamailio_host = 192.168.0.29
|
||||
kamailio_port = 3306
|
||||
kamailio_databasename = kamailio
|
||||
kamailio_username = root
|
||||
kamailio_password =
|
||||
|
||||
##NGCP MySQL connectivity - default db for distributed transactions (XA) to connect to:
|
||||
xa_host = 192.168.0.29
|
||||
xa_port = 3306
|
||||
xa_databasename = ngcp
|
||||
xa_username = root
|
||||
xa_password =
|
||||
|
||||
##NGCP REST-API connectivity:
|
||||
ngcprestapi_uri = https://127.0.0.1:1443
|
||||
ngcprestapi_username = administrator
|
||||
ngcprestapi_password = administrator
|
||||
ngcprestapi_realm = api_admin_http
|
||||
|
||||
##sending email:
|
||||
emailenable = 0
|
||||
erroremailrecipient =
|
||||
warnemailrecipient =
|
||||
completionemailrecipient = rkrenn@sipwise.com
|
||||
doneemailrecipient =
|
||||
|
||||
##logging:
|
||||
fileloglevel = DEBUG
|
||||
screenloglevel = INFO
|
||||
#INFO
|
||||
emailloglevel = OFF
|
||||
@ -1,61 +0,0 @@
|
||||
##general settings:
|
||||
working_path = /home/rkrenn/temp/upcat
|
||||
cpucount = 4
|
||||
enablemultithreading = 0
|
||||
|
||||
##gearman/service listener config:
|
||||
jobservers = 127.0.0.1:4730
|
||||
|
||||
##NGCP MySQL connectivity - "accounting" db:
|
||||
accounting_host = 192.168.0.29
|
||||
accounting_port = 3306
|
||||
accounting_databasename = accounting
|
||||
accounting_username = root
|
||||
accounting_password =
|
||||
|
||||
##NGCP MySQL connectivity - "billing" db:
|
||||
billing_host = 192.168.0.29
|
||||
billing_port = 3306
|
||||
billing_databasename = billing
|
||||
billing_username = root
|
||||
billing_password =
|
||||
|
||||
##NGCP MySQL connectivity - "provisioning" db:
|
||||
provisioning_host = 192.168.0.29
|
||||
provisioning_port = 3306
|
||||
provisioning_databasename = provisioning
|
||||
provisioning_username = root
|
||||
provisioning_password =
|
||||
|
||||
##NGCP MySQL connectivity - "kamailio" db:
|
||||
kamailio_host = 192.168.0.29
|
||||
kamailio_port = 3306
|
||||
kamailio_databasename = kamailio
|
||||
kamailio_username = root
|
||||
kamailio_password =
|
||||
|
||||
##NGCP MySQL connectivity - default db for distributed transactions (XA) to connect to:
|
||||
xa_host = 192.168.0.29
|
||||
xa_port = 3306
|
||||
xa_databasename = ngcp
|
||||
xa_username = root
|
||||
xa_password =
|
||||
|
||||
##NGCP REST-API connectivity:
|
||||
ngcprestapi_uri = https://127.0.0.1:1443
|
||||
ngcprestapi_username = administrator
|
||||
ngcprestapi_password = administrator
|
||||
ngcprestapi_realm = api_admin_http
|
||||
|
||||
##sending email:
|
||||
emailenable = 0
|
||||
erroremailrecipient =
|
||||
warnemailrecipient =
|
||||
completionemailrecipient = rkrenn@sipwise.com
|
||||
doneemailrecipient =
|
||||
|
||||
##logging:
|
||||
fileloglevel = DEBUG
|
||||
screenloglevel = INFO
|
||||
#INFO
|
||||
emailloglevel = OFF
|
||||
@ -1,613 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use File::Basename;
|
||||
use Cwd;
|
||||
use lib Cwd::abs_path(File::Basename::dirname(__FILE__) . '/../../../../../');
|
||||
|
||||
use Getopt::Long qw(GetOptions);
|
||||
use Fcntl qw(LOCK_EX LOCK_NB);
|
||||
|
||||
use NGCP::BulkProcessor::Globals qw();
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Settings qw(
|
||||
update_settings
|
||||
update_cc_ac_map
|
||||
update_barring_profiles
|
||||
|
||||
check_dry
|
||||
$output_path
|
||||
$defaultsettings
|
||||
$defaultconfig
|
||||
$dry
|
||||
$skip_errors
|
||||
$force
|
||||
$run_id
|
||||
|
||||
@mta_subscriber_filenames
|
||||
$cc_ac_map_yml
|
||||
|
||||
$barring_profiles_yml
|
||||
|
||||
$ccs_subscriber_filename
|
||||
|
||||
);
|
||||
#$allowed_ips
|
||||
|
||||
use NGCP::BulkProcessor::Logging qw(
|
||||
init_log
|
||||
getlogger
|
||||
$attachmentlogfile
|
||||
scriptinfo
|
||||
cleanuplogfiles
|
||||
$currentlogfile
|
||||
);
|
||||
use NGCP::BulkProcessor::LogError qw (
|
||||
completion
|
||||
done
|
||||
scriptwarn
|
||||
scripterror
|
||||
filewarn
|
||||
fileerror
|
||||
);
|
||||
use NGCP::BulkProcessor::LoadConfig qw(
|
||||
load_config
|
||||
$SIMPLE_CONFIG_TYPE
|
||||
$YAML_CONFIG_TYPE
|
||||
$ANY_CONFIG_TYPE
|
||||
);
|
||||
use NGCP::BulkProcessor::Array qw(removeduplicates);
|
||||
use NGCP::BulkProcessor::Utils qw(getscriptpath prompt cleanupdir);
|
||||
use NGCP::BulkProcessor::Mail qw(
|
||||
cleanupmsgfiles
|
||||
);
|
||||
use NGCP::BulkProcessor::SqlConnectors::CSVDB qw(cleanupcvsdirs);
|
||||
use NGCP::BulkProcessor::SqlConnectors::SQLiteDB qw(cleanupdbfiles);
|
||||
use NGCP::BulkProcessor::RestConnectors::NGCPRestApi qw(cleanupcertfiles);
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::ProjectConnectorPool qw(destroy_all_dbs);
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber qw();
|
||||
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::contracts qw();
|
||||
use NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers qw();
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases qw();
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_mappings qw();
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_trusted_sources qw();
|
||||
|
||||
#use NGCP::BulkProcessor::Dao::Trunk::kamailio::location qw();
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Check qw(
|
||||
check_billing_db_tables
|
||||
check_provisioning_db_tables
|
||||
check_kamailio_db_tables
|
||||
check_import_db_tables
|
||||
check_rest_get_items
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Import qw(
|
||||
import_mta_subscriber
|
||||
import_ccs_subscriber
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::Projects::Migration::UPCAT::Provisioning qw(
|
||||
provision_mta_subscribers
|
||||
provision_ccs_subscribers
|
||||
$UPDATE_CCS_PREFERENCES_MODE
|
||||
$SET_CCS_CF_MODE
|
||||
$CLEAR_CCS_CF_MODE
|
||||
);
|
||||
|
||||
scripterror(getscriptpath() . ' already running',getlogger(getscriptpath())) unless flock DATA, LOCK_EX | LOCK_NB; # not tested on windows yet
|
||||
|
||||
my @TASK_OPTS = ();
|
||||
|
||||
my $tasks = [];
|
||||
my $files = [];
|
||||
|
||||
my $check_task_opt = 'check';
|
||||
push(@TASK_OPTS,$check_task_opt);
|
||||
|
||||
my $cleanup_task_opt = 'cleanup';
|
||||
push(@TASK_OPTS,$cleanup_task_opt);
|
||||
my $cleanup_all_task_opt = 'cleanup_all';
|
||||
push(@TASK_OPTS,$cleanup_all_task_opt);
|
||||
|
||||
my $import_mta_subscriber_task_opt = 'import_mta_subscriber';
|
||||
push(@TASK_OPTS,$import_mta_subscriber_task_opt);
|
||||
my $truncate_mta_subscriber_task_opt = 'truncate_mta_subscriber';
|
||||
push(@TASK_OPTS,$truncate_mta_subscriber_task_opt);
|
||||
|
||||
my $create_mta_subscriber_task_opt = 'create_mta_subscriber';
|
||||
push(@TASK_OPTS,$create_mta_subscriber_task_opt);
|
||||
|
||||
my $import_ccs_subscriber_task_opt = 'import_ccs_subscriber';
|
||||
push(@TASK_OPTS,$import_ccs_subscriber_task_opt);
|
||||
my $truncate_ccs_subscriber_task_opt = 'truncate_ccs_subscriber';
|
||||
push(@TASK_OPTS,$truncate_ccs_subscriber_task_opt);
|
||||
|
||||
my $create_ccs_subscriber_task_opt = 'create_ccs_subscriber';
|
||||
push(@TASK_OPTS,$create_ccs_subscriber_task_opt);
|
||||
|
||||
my $update_ccs_subscriber_preferences_task_opt = 'update_ccs_subscriber_preferences';
|
||||
push(@TASK_OPTS,$update_ccs_subscriber_preferences_task_opt);
|
||||
|
||||
my $set_ccs_subscriber_cf_task_opt = 'set_ccs_subscriber_cf';
|
||||
push(@TASK_OPTS,$set_ccs_subscriber_cf_task_opt);
|
||||
|
||||
my $clear_ccs_subscriber_cf_task_opt = 'clear_ccs_subscriber_cf';
|
||||
push(@TASK_OPTS,$clear_ccs_subscriber_cf_task_opt);
|
||||
|
||||
if (init()) {
|
||||
main();
|
||||
exit(0);
|
||||
} else {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sub init {
|
||||
|
||||
my $configfile = $defaultconfig;
|
||||
my $settingsfile = $defaultsettings;
|
||||
|
||||
return 0 unless GetOptions(
|
||||
"config=s" => \$configfile,
|
||||
"settings=s" => \$settingsfile,
|
||||
"task=s" => $tasks,
|
||||
"run=s" => \$run_id,
|
||||
"dry" => \$dry,
|
||||
"skip-errors" => \$skip_errors,
|
||||
"force" => \$force,
|
||||
"file=s" => $files,
|
||||
); # or scripterror('error in command line arguments',getlogger(getscriptpath()));
|
||||
|
||||
$tasks = removeduplicates($tasks,1);
|
||||
|
||||
my $result = load_config($configfile);
|
||||
init_log();
|
||||
$result &= load_config($settingsfile,\&update_settings,$SIMPLE_CONFIG_TYPE);
|
||||
$result &= load_config($cc_ac_map_yml,\&update_cc_ac_map,$YAML_CONFIG_TYPE);
|
||||
$result &= load_config($barring_profiles_yml,\&update_barring_profiles,$YAML_CONFIG_TYPE);
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub main() {
|
||||
|
||||
my @messages = ();
|
||||
my @attachmentfiles = ();
|
||||
my $result = 1;
|
||||
my $completion = 0;
|
||||
|
||||
if (defined $tasks and 'ARRAY' eq ref $tasks and (scalar @$tasks) > 0) {
|
||||
scriptinfo('skip-errors: processing won\'t stop upon errors',getlogger(__PACKAGE__)) if $skip_errors;
|
||||
foreach my $task (@$tasks) {
|
||||
|
||||
if (lc($check_task_opt) eq lc($task)) {
|
||||
$result &= check_task(\@messages) if taskinfo($check_task_opt,$result);
|
||||
|
||||
} elsif (lc($cleanup_task_opt) eq lc($task)) {
|
||||
$result &= cleanup_task(\@messages,0) if taskinfo($cleanup_task_opt,$result);
|
||||
} elsif (lc($cleanup_all_task_opt) eq lc($task)) {
|
||||
$result &= cleanup_task(\@messages,1) if taskinfo($cleanup_all_task_opt,$result);
|
||||
|
||||
} elsif (lc($import_mta_subscriber_task_opt) eq lc($task)) {
|
||||
$result &= import_mta_subscriber_task(\@messages) if taskinfo($import_mta_subscriber_task_opt,$result);
|
||||
} elsif (lc($truncate_mta_subscriber_task_opt) eq lc($task)) {
|
||||
$result &= truncate_mta_subscriber_task(\@messages) if taskinfo($truncate_mta_subscriber_task_opt,$result);
|
||||
|
||||
} elsif (lc($create_mta_subscriber_task_opt) eq lc($task)) {
|
||||
if (taskinfo($create_mta_subscriber_task_opt,$result,1)) {
|
||||
next unless check_dry();
|
||||
$result &= create_mta_subscriber_task(\@messages);
|
||||
$completion |= 1;
|
||||
}
|
||||
|
||||
} elsif (lc($import_ccs_subscriber_task_opt) eq lc($task)) {
|
||||
$result &= import_ccs_subscriber_task(\@messages) if taskinfo($import_ccs_subscriber_task_opt,$result);
|
||||
} elsif (lc($truncate_ccs_subscriber_task_opt) eq lc($task)) {
|
||||
$result &= truncate_ccs_subscriber_task(\@messages) if taskinfo($truncate_ccs_subscriber_task_opt,$result);
|
||||
|
||||
} elsif (lc($create_ccs_subscriber_task_opt) eq lc($task)) {
|
||||
if (taskinfo($create_ccs_subscriber_task_opt,$result,1)) {
|
||||
next unless check_dry();
|
||||
$result &= create_ccs_subscriber_task(\@messages);
|
||||
$completion |= 1;
|
||||
}
|
||||
|
||||
} elsif (lc($update_ccs_subscriber_preferences_task_opt) eq lc($task)) {
|
||||
if (taskinfo($update_ccs_subscriber_preferences_task_opt,$result,1)) {
|
||||
next unless check_dry();
|
||||
$result &= update_ccs_subscriber_preferences_task(\@messages);
|
||||
$completion |= 1;
|
||||
}
|
||||
|
||||
} elsif (lc($set_ccs_subscriber_cf_task_opt) eq lc($task)) {
|
||||
if (taskinfo($set_ccs_subscriber_cf_task_opt,$result,1)) {
|
||||
next unless check_dry();
|
||||
$result &= set_ccs_subscriber_cf_task(\@messages);
|
||||
$completion |= 1;
|
||||
}
|
||||
|
||||
} elsif (lc($clear_ccs_subscriber_cf_task_opt) eq lc($task)) {
|
||||
if (taskinfo($clear_ccs_subscriber_cf_task_opt,$result,1)) {
|
||||
next unless check_dry();
|
||||
$result &= clear_ccs_subscriber_cf_task(\@messages);
|
||||
$completion |= 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
$result = 0;
|
||||
scripterror("unknow task option '" . $task . "', must be one of " . join(', ',@TASK_OPTS),getlogger(getscriptpath()));
|
||||
last;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result = 0;
|
||||
scripterror('at least one task option is required. supported tasks: ' . join(', ',@TASK_OPTS),getlogger(getscriptpath()));
|
||||
}
|
||||
|
||||
push(@attachmentfiles,$attachmentlogfile);
|
||||
if ($completion) {
|
||||
completion(join("\n\n",@messages),\@attachmentfiles,getlogger(getscriptpath()));
|
||||
} else {
|
||||
done(join("\n\n",@messages),\@attachmentfiles,getlogger(getscriptpath()));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub taskinfo {
|
||||
my ($task,$result) = @_;
|
||||
scriptinfo($result ? "starting task: '$task'" : "skipping task '$task' due to previous problems",getlogger(getscriptpath()));
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub check_task {
|
||||
my ($messages) = @_;
|
||||
my @check_messages = ();
|
||||
my $result = check_billing_db_tables(\@check_messages);
|
||||
#$result &= ..
|
||||
push(@$messages,join("\n",@check_messages));
|
||||
|
||||
@check_messages = ();
|
||||
$result = check_provisioning_db_tables(\@check_messages);
|
||||
#$result &= ..
|
||||
push(@$messages,join("\n",@check_messages));
|
||||
|
||||
@check_messages = ();
|
||||
$result = check_kamailio_db_tables(\@check_messages);
|
||||
#$result &= ..
|
||||
push(@$messages,join("\n",@check_messages));
|
||||
|
||||
@check_messages = ();
|
||||
$result = check_rest_get_items(\@check_messages);
|
||||
#$result &= ..
|
||||
push(@$messages,join("\n",@check_messages));
|
||||
|
||||
@check_messages = ();
|
||||
$result = check_import_db_tables(\@check_messages);
|
||||
#$result &= ..
|
||||
push(@$messages,join("\n",@check_messages));
|
||||
|
||||
|
||||
destroy_all_dbs();
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub cleanup_task {
|
||||
my ($messages,$clean_generated) = @_;
|
||||
my $result = 0;
|
||||
if (!$clean_generated or $force or 'yes' eq lc(prompt("Type 'yes' to proceed: "))) {
|
||||
eval {
|
||||
cleanupcvsdirs() if $clean_generated;
|
||||
cleanupdbfiles() if $clean_generated;
|
||||
cleanuplogfiles(\&fileerror,\&filewarn,($currentlogfile,$attachmentlogfile));
|
||||
cleanupmsgfiles(\&fileerror,\&filewarn);
|
||||
cleanupcertfiles();
|
||||
cleanupdir($output_path,1,\&filewarn,getlogger(getscriptpath())) if $clean_generated;
|
||||
$result = 1;
|
||||
};
|
||||
}
|
||||
if ($@ or !$result) {
|
||||
push(@$messages,'working directory cleanup INCOMPLETE');
|
||||
return 0;
|
||||
} else {
|
||||
push(@$messages,'working directory folders cleaned up');
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub import_mta_subscriber_task {
|
||||
|
||||
my ($messages) = @_;
|
||||
my ($result,$warning_count) = (0,0);
|
||||
eval {
|
||||
if (scalar @$files) {
|
||||
($result,$warning_count) = import_mta_subscriber(@$files);
|
||||
} else {
|
||||
($result,$warning_count) = import_mta_subscriber(@mta_subscriber_filenames);
|
||||
}
|
||||
};
|
||||
my $err = $@;
|
||||
my $stats = ": $warning_count warnings";
|
||||
eval {
|
||||
$stats .= "\n total mta subscriber records: " .
|
||||
NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::countby_ccacsn() . ' rows';
|
||||
my $added_count = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::countby_delta(
|
||||
$NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::added_delta
|
||||
);
|
||||
$stats .= "\n new: $added_count rows";
|
||||
my $existing_count = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::countby_delta(
|
||||
$NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::updated_delta
|
||||
);
|
||||
$stats .= "\n existing: $existing_count rows";
|
||||
my $deleted_count = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::countby_delta(
|
||||
$NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::deleted_delta
|
||||
);
|
||||
$stats .= "\n removed: $deleted_count rows";
|
||||
};
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"importing mta subscribers INCOMPLETE$stats");
|
||||
} else {
|
||||
push(@$messages,"importing mta subscribers completed$stats");
|
||||
}
|
||||
destroy_all_dbs(); #every task should leave with closed connections.
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub truncate_mta_subscriber_task {
|
||||
|
||||
my ($messages) = @_;
|
||||
my $result = 0;
|
||||
eval {
|
||||
$result = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::create_table(1);
|
||||
};
|
||||
my $err = $@;
|
||||
my $stats = '';
|
||||
eval {
|
||||
$stats .= "\n total mta subscriber records: " .
|
||||
NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::countby_ccacsn() . ' rows';
|
||||
};
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"truncating imported mta subscribers INCOMPLETE$stats");
|
||||
} else {
|
||||
push(@$messages,"truncating imported mta subscribers completed$stats");
|
||||
}
|
||||
destroy_all_dbs(); #every task should leave with closed connections.
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub create_mta_subscriber_task {
|
||||
|
||||
my ($messages) = @_;
|
||||
my ($result,$warning_count,$nonunique_contacts) = (0,0,{});
|
||||
eval {
|
||||
($result,$warning_count,$nonunique_contacts) = provision_mta_subscribers();
|
||||
};
|
||||
my $err = $@;
|
||||
my $stats = ": $warning_count warnings";
|
||||
eval {
|
||||
$stats .= "\n total contracts: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::billing::contracts::countby_status_resellerid(undef,undef) . ' rows';
|
||||
$stats .= "\n total subscribers: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers::countby_status_resellerid(undef,undef) . ' rows';
|
||||
|
||||
$stats .= "\n total aliases: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::countby_subscriberidisprimary(undef,undef) . ' rows';
|
||||
$stats .= "\n primary aliases: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::countby_subscriberidisprimary(undef,1) . ' rows';
|
||||
|
||||
#$stats .= "\n call forwards: " .
|
||||
# NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_mappings::countby_subscriberid_type(undef,undef) . ' rows';
|
||||
|
||||
#$stats .= "\n registrations: " .
|
||||
# NGCP::BulkProcessor::Dao::Trunk::kamailio::location::countby_usernamedomain(undef,undef) . ' rows';
|
||||
|
||||
#$stats .= "\n trusted sources: " .
|
||||
# NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_trusted_sources::countby_subscriberid(undef) . ' rows';
|
||||
|
||||
$stats .= "\n non-unique contacts skipped:\n " . join("\n ",keys %$nonunique_contacts)
|
||||
if (scalar keys %$nonunique_contacts) > 0;
|
||||
};
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"create mta subscribers INCOMPLETE$stats");
|
||||
} else {
|
||||
push(@$messages,"create mta subscribers completed$stats");
|
||||
#if (not $dry) {
|
||||
# push(@$messages,"YOU MIGHT WANT TO RESTART KAMAILIO FOR PERMANENT REGISTRATIONS TO COME INTO EFFECT");
|
||||
#}
|
||||
}
|
||||
destroy_all_dbs();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub import_ccs_subscriber_task {
|
||||
|
||||
my ($messages) = @_;
|
||||
my ($result,$warning_count) = (0,0);
|
||||
eval {
|
||||
if (scalar @$files) {
|
||||
($result,$warning_count) = import_ccs_subscriber($files->[0]);
|
||||
} else {
|
||||
($result,$warning_count) = import_ccs_subscriber($ccs_subscriber_filename);
|
||||
}
|
||||
};
|
||||
my $err = $@;
|
||||
my $stats = ": $warning_count warnings";
|
||||
eval {
|
||||
$stats .= "\n total ccs subscriber records: " .
|
||||
NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::countby_service_number() . ' rows';
|
||||
my $added_count = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::countby_delta(
|
||||
$NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::added_delta
|
||||
);
|
||||
$stats .= "\n new: $added_count rows";
|
||||
my $existing_count = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::countby_delta(
|
||||
$NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::updated_delta
|
||||
);
|
||||
$stats .= "\n existing: $existing_count rows";
|
||||
my $deleted_count = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::countby_delta(
|
||||
$NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::deleted_delta
|
||||
);
|
||||
$stats .= "\n removed: $deleted_count rows";
|
||||
};
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"importing ccs subscribers INCOMPLETE$stats");
|
||||
} else {
|
||||
push(@$messages,"importing ccs subscribers completed$stats");
|
||||
}
|
||||
destroy_all_dbs(); #every task should leave with closed connections.
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub truncate_ccs_subscriber_task {
|
||||
|
||||
my ($messages) = @_;
|
||||
my $result = 0;
|
||||
eval {
|
||||
$result = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::create_table(1);
|
||||
};
|
||||
my $err = $@;
|
||||
my $stats = '';
|
||||
eval {
|
||||
$stats .= "\n total ccs subscriber records: " .
|
||||
NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::countby_service_number() . ' rows';
|
||||
};
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"truncating imported ccs subscribers INCOMPLETE$stats");
|
||||
} else {
|
||||
push(@$messages,"truncating imported ccs subscribers completed$stats");
|
||||
}
|
||||
destroy_all_dbs(); #every task should leave with closed connections.
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub create_ccs_subscriber_task {
|
||||
|
||||
my ($messages) = @_;
|
||||
my ($result,$warning_count) = (0,0);
|
||||
eval {
|
||||
($result,$warning_count) = provision_ccs_subscribers();
|
||||
};
|
||||
my $err = $@;
|
||||
my $stats = ": $warning_count warnings";
|
||||
eval {
|
||||
$stats .= "\n total contracts: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::billing::contracts::countby_status_resellerid(undef,undef) . ' rows';
|
||||
$stats .= "\n total subscribers: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers::countby_status_resellerid(undef,undef) . ' rows';
|
||||
|
||||
$stats .= "\n total aliases: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::countby_subscriberidisprimary(undef,undef) . ' rows';
|
||||
$stats .= "\n primary aliases: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::countby_subscriberidisprimary(undef,1) . ' rows';
|
||||
|
||||
#$stats .= "\n call forwards: " .
|
||||
# NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_mappings::countby_subscriberid_type(undef,undef) . ' rows';
|
||||
|
||||
#$stats .= "\n registrations: " .
|
||||
# NGCP::BulkProcessor::Dao::Trunk::kamailio::location::countby_usernamedomain(undef,undef) . ' rows';
|
||||
|
||||
#$stats .= "\n trusted sources: " .
|
||||
# NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_trusted_sources::countby_subscriberid(undef) . ' rows';
|
||||
};
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"create ccs subscribers INCOMPLETE$stats");
|
||||
} else {
|
||||
push(@$messages,"create ccs subscribers completed$stats");
|
||||
if (not $dry) {
|
||||
push(@$messages,"YOU MIGHT WANT TO RESTART KAMAILIO FOR PERMANENT REGISTRATIONS TO COME INTO EFFECT");
|
||||
}
|
||||
}
|
||||
destroy_all_dbs();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
sub update_ccs_subscriber_preferences_task {
|
||||
my ($messages) = @_;
|
||||
my ($result,$warning_count) = (0,0);
|
||||
eval {
|
||||
($result,$warning_count) = provision_ccs_subscribers($UPDATE_CCS_PREFERENCES_MODE);
|
||||
};
|
||||
my $err = $@;
|
||||
my $stats = ": $warning_count warnings";
|
||||
eval {
|
||||
$stats .= "\n total contracts: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::billing::contracts::countby_status_resellerid(undef,undef) . ' rows';
|
||||
$stats .= "\n total subscribers: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers::countby_status_resellerid(undef,undef) . ' rows';
|
||||
};
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"update ccs subscriber preferences INCOMPLETE$stats");
|
||||
} else {
|
||||
push(@$messages,"update ccs subscribers preferences completed$stats");
|
||||
}
|
||||
destroy_all_dbs();
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub set_ccs_subscriber_cf_task {
|
||||
my ($messages) = @_;
|
||||
my ($result,$warning_count) = (0,0);
|
||||
eval {
|
||||
($result,$warning_count) = provision_ccs_subscribers($SET_CCS_CF_MODE);
|
||||
};
|
||||
my $err = $@;
|
||||
my $stats = ": $warning_count warnings";
|
||||
eval {
|
||||
$stats .= "\n total contracts: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::billing::contracts::countby_status_resellerid(undef,undef) . ' rows';
|
||||
$stats .= "\n total subscribers: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers::countby_status_resellerid(undef,undef) . ' rows';
|
||||
};
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"set ccs subscriber callforwards INCOMPLETE$stats");
|
||||
} else {
|
||||
push(@$messages,"set ccs subscribers callforwards completed$stats");
|
||||
}
|
||||
destroy_all_dbs();
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub clear_ccs_subscriber_cf_task {
|
||||
my ($messages) = @_;
|
||||
my ($result,$warning_count) = (0,0);
|
||||
eval {
|
||||
($result,$warning_count) = provision_ccs_subscribers($CLEAR_CCS_CF_MODE);
|
||||
};
|
||||
my $err = $@;
|
||||
my $stats = ": $warning_count warnings";
|
||||
eval {
|
||||
$stats .= "\n total contracts: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::billing::contracts::countby_status_resellerid(undef,undef) . ' rows';
|
||||
$stats .= "\n total subscribers: " .
|
||||
NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers::countby_status_resellerid(undef,undef) . ' rows';
|
||||
};
|
||||
if ($err or !$result) {
|
||||
push(@$messages,"clear ccs subscriber callforwards INCOMPLETE$stats");
|
||||
} else {
|
||||
push(@$messages,"clear ccs subscribers callforwards completed$stats");
|
||||
}
|
||||
destroy_all_dbs();
|
||||
return $result;
|
||||
}
|
||||
|
||||
#END {
|
||||
# # this should not be required explicitly, but prevents Log4Perl's
|
||||
# # "rootlogger not initialized error upon exit..
|
||||
# destroy_all_dbs
|
||||
#}
|
||||
|
||||
__DATA__
|
||||
This exists to allow the locking code at the beginning of the file to work.
|
||||
DO NOT REMOVE THESE LINES!
|
||||
@ -1,47 +0,0 @@
|
||||
|
||||
#dry=0
|
||||
#skip_errors=0
|
||||
import_multithreading = 0
|
||||
|
||||
#subscriber_filenames = /home/rkrenn/temp/upcat/export1.csv,/home/rkrenn/temp/upcat/export2.csv
|
||||
mta_subscriber_filenames = /home/rkrenn/temp/upcat/ExportTestMigration.csv
|
||||
mta_subscriber_import_numofthreads = 2
|
||||
ignore_mta_subscriber_unique = 0
|
||||
mta_subscriber_import_single_row_txn = 1
|
||||
|
||||
provision_mta_subscriber_rownum_start = 2
|
||||
provision_mta_subscriber_multithreading = 1
|
||||
provision_mta_subscriber_numofthreads = 2
|
||||
mta_webpassword_length = 8
|
||||
mta_webusername_length = 8
|
||||
mta_sippassword_length = 16
|
||||
|
||||
mta_default_domain = d20.upc.at
|
||||
mta_default_reseller_name = UPC
|
||||
mta_default_billing_profile_name = Default Billing UPC
|
||||
mta_default_barring =
|
||||
|
||||
cc_ac_map_yml = cc_ac.yml
|
||||
default_cc = 43
|
||||
barring_profiles_yml = barring_profiles.yml
|
||||
|
||||
report_filename = provision.txt
|
||||
#report_filename = provision_%s.json
|
||||
#default_channels = 1
|
||||
|
||||
ccs_subscriber_filename = /home/rkrenn/temp/upcat/CCS_ICM_Nummern_reduced.csv
|
||||
#/home/rkrenn/temp/upcat/CCS_ICM_Nummern.xlsx
|
||||
ignore_ccs_subscriber_unique = 0
|
||||
provision_ccs_subscriber_rownum_start = 2
|
||||
ccs_subscriber_import_single_row_txn = 1
|
||||
provision_ccs_subscriber_multithreading = 1
|
||||
provision_ccs_subscriber_numofthreads = 2
|
||||
ccs_reseller_name = UPC
|
||||
ccs_billing_profile_name = Default Billing UPC
|
||||
ccs_domain = in-ivr.upc.at
|
||||
ccs_sippassword_length = 16
|
||||
css_trusted_source_ips = 80.110.2.228,80.110.2.229
|
||||
|
||||
cf_default_priority: 1
|
||||
cf_default_timeout: 300
|
||||
cft_default_ringtimeout: 20
|
||||
Loading…
Reference in new issue