diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/CDR.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/CDR.pm deleted file mode 100644 index df2f3c9d..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/CDR.pm +++ /dev/null @@ -1,1074 +0,0 @@ -package NGCP::BulkProcessor::Projects::Export::Ama::Ccs::CDR; -use strict; - -## no critic - -use threads::shared qw(); - -use NGCP::BulkProcessor::Projects::Export::Ama::Ccs::Settings qw( - - $skip_errors - - $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 - -use NGCP::BulkProcessor::Logging qw ( - getlogger - processing_info - processing_debug -); -use NGCP::BulkProcessor::LogError qw( - rowprocessingerror - rowprocessingwarn - fileerror -); - -use NGCP::BulkProcessor::Dao::Trunk::accounting::cdr qw(); -use NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_export_status qw(); -use NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_export_status_data qw(); -use NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_group qw(); -use NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_provider qw(); -use NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_direction qw(); -use NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_tag qw(); -use NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_tag_data qw(); -use NGCP::BulkProcessor::Dao::Trunk::accounting::mark qw(); - -use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_subscribers qw(); -use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases qw(); - -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::Modules::Module000 qw(); -use NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module104 qw(); -use NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module199 qw(); -use NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module611 qw(); - -use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::CallType qw(); -use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date qw(); -use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ServiceFeature qw(); -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(); -use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber qw(); -use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericContextIdentifier qw(); -use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::NetworkOperatorData qw(); -use NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TrunkIdentification qw(); - -use NGCP::BulkProcessor::ConnectorPool qw( - get_xa_db - destroy_dbs - ping_dbs -); - -use NGCP::BulkProcessor::Utils qw(threadid kbytes2gigs); # stringtobool check_ipnet trim); - -use NGCP::BulkProcessor::Calendar qw(from_epoch); -use NGCP::BulkProcessor::Array qw(array_to_map contains); - -require Exporter; -our @ISA = qw(Exporter); -our @EXPORT_OK = qw( - export_cdrs - reset_fsn - reset_export_status -); - -my $BLIND_TRANSFER_NO_IVR = 1; -my $BLIND_TRANSFER = 2; -my $NO_TRANSFER_NO_IVR = 3; -my $NO_TRANSFER = 4; -my $ATTN_TRANSFER_NO_IVR = 5; -my $ATTN_TRANSFER = 6; -my $CFU = 7; - -my $file_sequence_number : shared = 0; -my $rowcount : shared = 0; - -sub reset_export_status { - - my ($from,$to,$call_ids) = @_; - - my $result = 1; - my $context = { tid => threadid(), warning_count => 0, error_count => 0, }; - $result &= _check_export_status_stream($context); - my $updated; - eval { - $updated = NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_export_status_data::update_export_status($context->{export_status_id}, - $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_export_status_data::UNEXPORTED,$from,$to,$call_ids); - }; - if ($@) { - if ($skip_errors) { - _warn($context,"problem with export status reset: " . $@); - } else { - _error($context,"problem with export status reset: " . $@); - } - $result = 0; - } else { - _info($context,"$updated export states reset"); - } - - return $result; - -} - -sub reset_fsn { - - my $result = 1; - my $context = { tid => threadid(), warning_count => 0, error_count => 0, }; - $result &= _check_export_status_stream($context); - #my $fsn; - eval { - NGCP::BulkProcessor::Dao::Trunk::accounting::mark::delete_system_marks(undef, - $export_cdr_stream, - ); - #NGCP::BulkProcessor::Dao::Trunk::accounting::mark::cleanup_system_marks(undef, - # $export_cdr_stream, - #); - #NGCP::BulkProcessor::Dao::Trunk::accounting::mark::set_system_mark(undef, - # $export_cdr_stream, - # '0' #$NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::min_fsn - #); - #$fsn = NGCP::BulkProcessor::Dao::Trunk::accounting::mark::get_system_mark(undef, - # $export_cdr_stream - #); #load mark... - }; - if ($@) { - if ($skip_errors) { - _warn($context,"problem with file sequence number reset: " . $@); - } else { - _error($context,"problem with file sequence number reset: " . $@); - } - $result = 0; - } else { - _info($context,"file sequence number deleted"); #reset to $fsn") - } - return $result; - -} - -sub export_cdrs { - - my $static_context = {}; - my $result = _export_cdrs_create_context($static_context); - - destroy_dbs(); - my $warning_count :shared = 0; - my @ama_files : shared = (); - $result &= NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::process_unexported( - static_context => $static_context, - process_code => sub { - my ($context,$records,$row_offset) = @_; - # we only want to export a call scenario of eg. 4 cdrs, if the block (eg. 1000 cdrs) contains all 4. - $context->{block_call_id_map} = {}; - my $cdr_id_map = {}; - foreach my $record (@$records) { - my ($id,$call_id) = @$record; - my $call_id_prefix = NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::get_callidprefix($call_id); - if (exists $context->{block_call_id_map}->{$call_id_prefix}) { - $context->{block_call_id_map}->{$call_id_prefix} += 1; - } else { - $context->{block_call_id_map}->{$call_id_prefix} = 1; - } - $cdr_id_map->{$id} = 1; - } - $context->{correlated_cdrs_map} = {}; - foreach my $record (@$records) { - my ($id,$call_id) = @$record; - $context->{correlated_cdrs_map}->{$id} = _find_child_cdrs($context,$id); - my $call_id_prefix = NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::get_callidprefix($call_id); - map { $context->{block_call_id_map}->{$call_id_prefix} += 1 if exists $cdr_id_map->{$_->{id}}; } @{$context->{correlated_cdrs_map}->{$id}}; - } - foreach my $record (@$records) { - if (defined $export_cdr_limit) { - lock $rowcount; - if ($rowcount >= $export_cdr_limit) { - _info($context,"exceeding export limit $export_cdr_limit"); - return 0; - } - } - if ($context->{file_sequence_number} > $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::max_fsn) { - _info($context,"exceeding file sequence number " . $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::max_fsn); - return 0; - } - my ($id,$call_id) = @$record; - next unless _export_cdrs_init_context($context,$id,$call_id); - eval { - $context->{file}->write_record( - get_transfer_in => \&_get_transfer_in, - get_record => \&_get_record, - get_transfer_out => \&_get_transfer_out, - commit_cb => \&_commit_export_status, - context => $context, - ); - }; - if ($@) { - if ($skip_errors) { - _warn($context,"problem while exporting call id $call_id (cdr id $id): " . $@); - } else { - _error($context,"problem while exporting call id $call_id (cdr id $id): " . $@); - } - } - } - ping_dbs(); - return 1; - }, - init_process_context_code => sub { - my ($context)= @_; - $context->{db} = &get_xa_db(); - $context->{error_count} = 0; - $context->{warning_count} = 0; - - $context->{ama_files} = []; - $context->{has_next} = 1; - #$context->{rownum} = 0; - - _increment_file_sequence_number($context); - }, - uninit_process_context_code => sub { - my ($context)= @_; - $context->{has_next} = 0; #do not reserve another file sequence number - if ($context->{file_sequence_number} <= $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::max_fsn) { - eval { - $context->{file}->close( - get_transfer_out => \&_get_transfer_out, - commit_cb => \&_commit_export_status, - context => $context, - ); - }; - if ($@) { - if ($skip_errors) { - _warn($context,"problem while closing " . $context->{file}->get_filename() . ": " . $@); - } else { - _error($context,"problem while closing " . $context->{file}->get_filename() . ": " . $@); - } - } - } - - undef $context->{db}; - destroy_dbs(); - - { - lock $warning_count; - $warning_count += $context->{warning_count}; - push(@ama_files,@{$context->{ama_files}}); - } - }, - load_recursive => 0, - blocksize => $export_cdr_blocksize, - multithreading => $export_cdr_multithreading, - numofthreads => $export_cdr_numofthreads, - joins => $export_cdr_joins, - conditions => $export_cdr_conditions, - #sort => [{ column => 'id', numeric => 1, dir => 1 }], - #limit => $export_cdr_limit, - ); - - eval { - NGCP::BulkProcessor::Dao::Trunk::accounting::mark::cleanup_system_marks(undef, - $export_cdr_stream); - }; - if ($@) { - if ($skip_errors) { - _warn($static_context,"problem with file sequence number cleanup: " . $@); - } else { - _error($static_context,"problem with file sequence number cleanup: " . $@); - } - $result = 0; - } else { - _info($static_context,"file sequence numbers cleaned up"); - } - - return ($result,$warning_count,\@ama_files); -} - -sub _find_child_cdrs { - my ($context,$id) = @_; - my @correlated_cdrs = (); - foreach my $correlated_group_cdr (@{NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_group::findby_cdrid($context->{db},$id)}) { - next unless $correlated_group_cdr->{call_id}; - foreach my $correlated_cdr (@{NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::findby_callid($context->{db},$correlated_group_cdr->{call_id})}) { - push(@correlated_cdrs,$correlated_cdr); - } - } - return \@correlated_cdrs; -} - -sub _export_cdrs_init_context { - - my ($context,$cdr_id,$call_id) = @_; - - my $result = 0; - my $parent_cdrs; - $context->{call_id} = $call_id; - my $scenario = { code => 0, ama => [], }; - $context->{scenario} = $scenario; - - if (not exists $context->{file_cdr_id_map}->{$cdr_id}) { #skip if processed for a file already - my $call_id_prefix = NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::get_callidprefix($call_id); - if (exists $context->{block_call_id_map}->{$call_id_prefix}) { #skip if this callid form parent calls that have already been processed - if ((scalar @{NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_group::findby_callid($context->{db},$call_id)}) == 0) { #skip if this is a correlated (child) cdr - $parent_cdrs = NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::findby_callidprefix($context->{db}, - $call_id,$export_cdr_joins,$export_cdr_conditions); #already sorted - my @scenario_cdrs = @$parent_cdrs; - foreach my $cdr (@$parent_cdrs) { - my @correlated_cdrs; - if (exists $context->{correlated_cdrs_map}->{$cdr->{id}}) { - @correlated_cdrs = @{$context->{correlated_cdrs_map}->{$cdr->{id}}}; - } else { - @correlated_cdrs = @{_find_child_cdrs($context,$cdr->{id})}; - } - $cdr->{_correlated_cdrs} = \@correlated_cdrs; - push(@scenario_cdrs,@correlated_cdrs); - } - $scenario->{parent_cdrs} = $parent_cdrs; - $scenario->{all_cdrs} = \@scenario_cdrs; - my $cdrs_in_block = delete $context->{block_call_id_map}->{$call_id_prefix}; - if ((scalar @scenario_cdrs) == $cdrs_in_block) { - my $malformed = 0; - - #blind xfer: - if ((scalar @$parent_cdrs) == 2 - and not $parent_cdrs->[0]->is_xfer() - and $parent_cdrs->[1]->is_xfer() - and (scalar @{$parent_cdrs->[0]->{_correlated_cdrs}}) == 0 - and (scalar @{$parent_cdrs->[1]->{_correlated_cdrs}}) == 0 - and ($scenario->{ccs_subscriber} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_subscribers::findby_uuid(undef,$parent_cdrs->[0]->{destination_user_id})) - and ($scenario->{ccs_subscriber}->{primary_alias} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::findby_subscriberidisprimary($scenario->{ccs_subscriber}->{id},1)->[0]) - and (not defined $primary_alias_pattern or $scenario->{ccs_subscriber}->{primary_alias}->{username} =~ $primary_alias_pattern) - ) { - if (contains(get_u2u_header($context,$parent_cdrs->[0]),\@ivr_u2u_headers,1)) { - $scenario->{code} = $BLIND_TRANSFER; - } else { - $scenario->{code} = $BLIND_TRANSFER_NO_IVR; - } - #my $ivr_duration = abs($parent_cdrs->[0]->{start_time} - $parent_cdrs->[1]->{init_time}); - #if ($ivr_duration < $ivr_duration_limit) { - # $scenario->{code} = $BLIND_TRANSFER_NO_IVR; - #} else { - # $scenario->{code} = $BLIND_TRANSFER; - #} - $result = 1; - #no transfer: - } elsif ((scalar @$parent_cdrs) == 1 - and not $parent_cdrs->[0]->is_xfer() - and not $parent_cdrs->[0]->is_pbx() - and (scalar @{$parent_cdrs->[0]->{_correlated_cdrs}}) == 0 - and ($scenario->{ccs_subscriber} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_subscribers::findby_uuid(undef,$parent_cdrs->[0]->{destination_user_id})) - and ($scenario->{ccs_subscriber}->{primary_alias} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::findby_subscriberidisprimary($scenario->{ccs_subscriber}->{id},1)->[0]) - and (not defined $primary_alias_pattern or $scenario->{ccs_subscriber}->{primary_alias}->{username} =~ $primary_alias_pattern) - ) { - if (contains(get_u2u_header($context,$parent_cdrs->[0]),\@ivr_u2u_headers,1)) { - $scenario->{code} = $NO_TRANSFER; - } else { - $scenario->{code} = $NO_TRANSFER_NO_IVR; - } - #my $ivr_duration = $parent_cdrs->[0]->{duration}; - #if ($ivr_duration < $ivr_duration_limit) { - # $scenario->{code} = $NO_TRANSFER_NO_IVR; - #} else { - # $scenario->{code} = $NO_TRANSFER; - #} - $result = 1; - #attn transfer: - } elsif ((scalar @$parent_cdrs) == 2 - and not $parent_cdrs->[0]->is_pbx() - and $parent_cdrs->[1]->is_pbx() - and (scalar @{$parent_cdrs->[0]->{_correlated_cdrs}}) == 0 - and (scalar @{$parent_cdrs->[1]->{_correlated_cdrs}}) == 1 - and ($scenario->{ccs_subscriber} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_subscribers::findby_uuid(undef,$parent_cdrs->[0]->{destination_user_id})) - and ($scenario->{ccs_subscriber}->{primary_alias} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::findby_subscriberidisprimary($scenario->{ccs_subscriber}->{id},1)->[0]) - and (not defined $primary_alias_pattern or $scenario->{ccs_subscriber}->{primary_alias}->{username} =~ $primary_alias_pattern) - ) { - if (contains(get_u2u_header($context,$parent_cdrs->[1]->{_correlated_cdrs}->[0]),\@ivr_u2u_headers,1)) { - $scenario->{code} = $ATTN_TRANSFER; - } else { - $scenario->{code} = $ATTN_TRANSFER_NO_IVR; - } - #my $correlated_cdr = $parent_cdrs->[1]->{_correlated_cdrs}->[0]; - #my $ivr_duration = abs($correlated_cdr->{start_time} - $parent_cdrs->[1]->{init_time}); - #if ($ivr_duration < $ivr_duration_limit) { - # $scenario->{code} = $ATTN_TRANSFER_NO_IVR; - #} else { - # $scenario->{code} = $ATTN_TRANSFER; - #} - $result = 1; - #cfu: - } elsif ((scalar @$parent_cdrs) == 2 - and not $parent_cdrs->[0]->is_pbx() - and $parent_cdrs->[1]->is_pbx() - and ($parent_cdrs->[1]->{call_type} eq $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::CFU_CALL_TYPE - or $parent_cdrs->[1]->{call_type} eq $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::CFB_CALL_TYPE) - and (scalar @{$parent_cdrs->[0]->{_correlated_cdrs}}) == 0 - and (scalar @{$parent_cdrs->[1]->{_correlated_cdrs}}) == 0 - and ($scenario->{ccs_subscriber} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_subscribers::findby_uuid(undef,$parent_cdrs->[1]->{source_user_id})) - and ($scenario->{ccs_subscriber}->{primary_alias} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::findby_subscriberidisprimary($scenario->{ccs_subscriber}->{id},1)->[0]) - and (not defined $primary_alias_pattern or $scenario->{ccs_subscriber}->{primary_alias}->{username} =~ $primary_alias_pattern) - ) { - $scenario->{code} = $CFU; - $result = 1; - } else { - _info($context,"unknown cdr scenario - cdr ids " . join(', ', map { $_->{id}; } @scenario_cdrs),1); - } - - foreach my $cdr (@scenario_cdrs) { - if ($result) { - $cdr->{_extended_export_status} = $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_export_status_data::OK; - } elsif ($malformed) { - $cdr->{_extended_export_status} = $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_export_status_data::FAILED; - } else { - $cdr->{_extended_export_status} = $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_export_status_data::SKIPPED; - } - $context->{file_cdr_id_map}->{$cdr->{id}} = $cdr; #->{start_time}; - lock $rowcount; - $rowcount += 1; - } - } - } - } - } - - if ($scenario->{code} == $BLIND_TRANSFER_NO_IVR) { - my $originating = _get_originating($parent_cdrs->[0]); - my $terminating = _get_terminating($parent_cdrs->[1]); - my $switch_number = _get_terminating($parent_cdrs->[0]); - push(@{$scenario->{ama}},{ - start_time => $parent_cdrs->[1]->{start_time}, #? - duration => $parent_cdrs->[1]->{duration}, - originating => _rewrite_originating($originating), - terminating => _rewrite_terminating($terminating), - terminating_cdr => $terminating, - unanswered => ($parent_cdrs->[1]->{call_status} ne $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::OK_CALL_STATUS ? 1 : 0), - correlation_id => substr($parent_cdrs->[0]->{id},-7), - nod => { - originating_digits => $originating, - switch_number_digits => _rewrite_switch_number($switch_number), #$scenario->{ccs_subscriber}->{primary_alias}->{username}, - mode => '0001', - }, - }); - } elsif ($scenario->{code} == $BLIND_TRANSFER) { - my $originating = _get_originating($parent_cdrs->[0]); - my $terminating = _get_terminating($parent_cdrs->[1]); - my $switch_number = _get_terminating($parent_cdrs->[0]); - push(@{$scenario->{ama}},{ - start_time => $parent_cdrs->[0]->{start_time}, #? - duration => abs($parent_cdrs->[0]->{start_time} - $parent_cdrs->[1]->{init_time}), - originating => _rewrite_originating($originating), - terminating => ($terminating_open_digits_6001 ? _rewrite_terminating($terminating_open_digits_6001) : _rewrite_terminating($terminating)), - terminating_cdr => ($terminating_open_digits_6001 ? $terminating_open_digits_6001 : $terminating), - unanswered => 0, - correlation_id => substr($parent_cdrs->[0]->{id},-7), - nod => { - originating_digits => $originating, - switch_number_digits => _rewrite_switch_number($switch_number), #$scenario->{ccs_subscriber}->{primary_alias}->{username}, - mode => '6001', - }, - },{ - start_time => $parent_cdrs->[1]->{start_time}, - duration => $parent_cdrs->[1]->{duration}, - originating => _rewrite_originating($originating), - terminating => _rewrite_terminating($terminating), - terminating_cdr => $terminating, - unanswered => ($parent_cdrs->[1]->{call_status} ne $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::OK_CALL_STATUS ? 1 : 0), - correlation_id => substr($parent_cdrs->[0]->{id},-7), - nod => { - originating_digits => $originating, - switch_number_digits => _rewrite_switch_number($switch_number), #$scenario->{ccs_subscriber}->{primary_alias}->{username}, - mode => '2002', - }, - }); - } elsif ($scenario->{code} == $NO_TRANSFER_NO_IVR) { - my $originating = _get_originating($parent_cdrs->[0]); - my $terminating = _get_terminating($parent_cdrs->[0]); - my $switch_number = $terminating; - push(@{$scenario->{ama}},{ - start_time => $parent_cdrs->[0]->{start_time}, #? - duration => 0, - originating => _rewrite_originating($originating), - terminating => _rewrite_terminating($terminating), - terminating_cdr => $terminating, - unanswered => 1, - correlation_id => substr($parent_cdrs->[0]->{id},-7), - nod => { - originating_digits => $originating, - switch_number_digits => _rewrite_switch_number($switch_number), #$scenario->{ccs_subscriber}->{primary_alias}->{username}, - mode => '0001', - }, - }); - } elsif ($scenario->{code} == $NO_TRANSFER) { - my $originating = _get_originating($parent_cdrs->[0]); - my $terminating = _get_terminating($parent_cdrs->[0]); - my $switch_number = $terminating; - push(@{$scenario->{ama}},{ - start_time => $parent_cdrs->[0]->{start_time}, #? - duration => $parent_cdrs->[0]->{duration}, - originating => _rewrite_originating($originating), - terminating => ($terminating_open_digits_6001 ? _rewrite_terminating($terminating_open_digits_6001) : _rewrite_terminating($terminating)), - terminating_cdr => ($terminating_open_digits_6001 ? $terminating_open_digits_6001 : $terminating), - unanswered => 0, - correlation_id => substr($parent_cdrs->[0]->{id},-7), - nod => { - originating_digits => $originating, - switch_number_digits => _rewrite_switch_number($switch_number), #$scenario->{ccs_subscriber}->{primary_alias}->{username}, - mode => '6001', - }, - },{ - start_time => $parent_cdrs->[0]->{start_time}, #? - duration => 0, - originating => _rewrite_originating($originating), - terminating => _rewrite_terminating($terminating), - terminating_cdr => $terminating, - unanswered => 1, - correlation_id => substr($parent_cdrs->[0]->{id},-7), - nod => { - originating_digits => $originating, - switch_number_digits => _rewrite_switch_number($switch_number), #$scenario->{ccs_subscriber}->{primary_alias}->{username}, - mode => '2002', - }, - }); - } elsif ($scenario->{code} == $ATTN_TRANSFER_NO_IVR) { - my $correlated_cdr = $parent_cdrs->[1]->{_correlated_cdrs}->[0]; - my $originating = _get_originating($correlated_cdr); - my $terminating = _get_terminating($parent_cdrs->[1]); - my $switch_number = _get_terminating($correlated_cdr); - push(@{$scenario->{ama}},{ - start_time => $parent_cdrs->[1]->{start_time}, #? - duration => $correlated_cdr->{duration} - abs($correlated_cdr->{start_time} - $parent_cdrs->[1]->{start_time}), - originating => _rewrite_originating($originating), - terminating => _rewrite_terminating($terminating), - terminating_cdr => $terminating, - unanswered => ($correlated_cdr->{call_status} ne $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::OK_CALL_STATUS ? 1 : 0), - correlation_id => substr($parent_cdrs->[0]->{id},-7), - nod => { - originating_digits => $originating, - switch_number_digits => _rewrite_switch_number($switch_number), #$scenario->{ccs_subscriber}->{primary_alias}->{username}, - mode => '0001', - }, - }); - } elsif ($scenario->{code} == $ATTN_TRANSFER) { - my $correlated_cdr = $parent_cdrs->[1]->{_correlated_cdrs}->[0]; - my $originating = _get_originating($correlated_cdr); - my $terminating = _get_terminating($parent_cdrs->[1]); - my $switch_number = _get_terminating($correlated_cdr); - push(@{$scenario->{ama}},{ - start_time => $parent_cdrs->[1]->{start_time}, #? - duration => abs($correlated_cdr->{start_time} - $parent_cdrs->[1]->{init_time}), - originating => _rewrite_originating($originating), - terminating => ($terminating_open_digits_6001 ? _rewrite_terminating($terminating_open_digits_6001) : _rewrite_terminating($terminating)), - terminating_cdr => ($terminating_open_digits_6001 ? $terminating_open_digits_6001 : $terminating), - unanswered => 0, - correlation_id => substr($parent_cdrs->[0]->{id},-7), - nod => { - originating_digits => $originating, - switch_number_digits => _rewrite_switch_number($switch_number), #$scenario->{ccs_subscriber}->{primary_alias}->{username}, - mode => '6001', - }, - },{ - start_time => $parent_cdrs->[1]->{start_time}, #? - duration => $correlated_cdr->{duration} - abs($correlated_cdr->{start_time} - $parent_cdrs->[1]->{start_time}), - originating => _rewrite_originating($originating), - terminating => _rewrite_terminating($terminating), - terminating_cdr => $terminating, - unanswered => ($correlated_cdr->{call_status} ne $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::OK_CALL_STATUS ? 1 : 0), - correlation_id => substr($parent_cdrs->[0]->{id},-7), - nod => { - originating_digits => $originating, - switch_number_digits => _rewrite_switch_number($switch_number), #$scenario->{ccs_subscriber}->{primary_alias}->{username}, - mode => '2002', - }, - }); - } elsif ($scenario->{code} == $CFU) { - my $originating = _get_originating($parent_cdrs->[0]); - my $terminating = _get_terminating($parent_cdrs->[1]); - my $switch_number = _get_terminating($parent_cdrs->[0]); - push(@{$scenario->{ama}},{ - start_time => $parent_cdrs->[1]->{start_time}, #? - duration => $parent_cdrs->[1]->{duration}, - originating => _rewrite_originating($originating), - terminating => _rewrite_terminating($terminating), - terminating_cdr => $terminating, - unanswered => ($parent_cdrs->[1]->{call_status} ne $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr::OK_CALL_STATUS ? 1 : 0), - correlation_id => substr($parent_cdrs->[0]->{id},-7), - nod => { - originating_digits => $originating, - switch_number_digits => _rewrite_switch_number($switch_number), #$scenario->{ccs_subscriber}->{primary_alias}->{username}, - mode => '0001', - }, - }); - } - - return $result; - -} - -sub _get_originating { - my $cdr = shift; - my $src_user; - if ($offnet_anonymous_fallback - and $cdr->{source_user_id} eq "0" - and $cdr->{$ama_originating_digits_cdr_field} =~ /anonymous/i - and $cdr->{source_user} =~ /^[+ 0-9]+$/) { - $src_user = $cdr->{source_user}; - } else { - $src_user = $cdr->{$ama_originating_digits_cdr_field}; - } - if ($src_user =~ /anonymous/i) { - $src_user = $anonymous_originating_digits; - } - return $src_user; -} - -sub _get_terminating { - my $cdr = shift; - return $cdr->{$ama_terminating_digits_cdr_field}; -} - -sub _rewrite_switch_number { - - my ($switch_number) = @_; - return _rewrite_number($switch_number,$switch_number_pattern,$switch_number_replacement); - -} - -sub _rewrite_originating { - - my ($originating) = @_; - return _rewrite_number($originating,$originating_pattern,$originating_replacement); - -} - -sub _rewrite_terminating { - - my ($terminating) = @_; - return _rewrite_number($terminating,$terminating_pattern,$terminating_replacement); - -} - -sub _rewrite_number { - - my ($number,$pattern,$replacement) = @_; - if (defined $pattern and defined $replacement) { - $number =~ s/$pattern/$replacement/; - } - return $number; - -} - -sub _commit_export_status { - - my %params = @_; - my ( - $context, - ) = @params{qw/ - context - /}; - my $result = 1; - _info($context,"file " . $context->{file}->get_filename(1) . " (" . kbytes2gigs(int($context->{file}->get_filesize() / 1024)) . ") - " . $context->{file}->get_record_count() . " records in " . $context->{file}->get_block_count() . " blocks"); - eval { - ping_dbs(); - $context->{db}->db_begin(); - foreach my $id (keys %{$context->{file_cdr_id_map}}) { - #mark exported - NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_export_status_data::upsert_row($context->{db}, - cdr_id => $id, - status_id => $context->{export_status_id}, - export_status => $context->{file_cdr_id_map}->{$id}->{_extended_export_status}, - cdr_start_time => $context->{file_cdr_id_map}->{$id}->{start_time}, - ); - _info($context,"export_status '$context->{file_cdr_id_map}->{$id}->{_extended_export_status}' set for cdr id $id",1); - } - NGCP::BulkProcessor::Dao::Trunk::accounting::mark::insert_system_mark($context->{db}, - $export_cdr_stream, - $context->{file_sequence_number}, - ); #set mark... - _info($context,"file sequence number $context->{file_sequence_number} saved"); - $context->{db}->db_commit(); - }; - $context->{file_cdr_id_map} = {}; - my $err = $@; - if ($err) { - eval { - $context->{db}->db_rollback(1); - }; - #eval { - # unlink $context->{file}->get_filename(); - #}; - die($err); - $result = 0; - } else { - push(@{$context->{ama_files}},$context->{file}->get_filename()); - _increment_file_sequence_number($context) if $context->{has_next}; - } - return $result; - -} - -sub _increment_file_sequence_number { - my ($context) = @_; - lock $file_sequence_number; - $file_sequence_number = $file_sequence_number + 1; - _info($context,"file sequence number incremented: $file_sequence_number",1); - $context->{file_sequence_number} = $file_sequence_number; -} - -sub _get_transfer_in { - - my %params = @_; - my ( - $context, - ) = @params{qw/ - context - /}; - - return NGCP::BulkProcessor::Projects::Export::Ama::Format::Record->new( - NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure9013->new( - - rewritten => 0, - sensor_id => $ama_sensor_id, - - padding => 0, - recording_office_id => $ama_recording_office_id, - - #date => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date::get_ama_date($context->{dt_transfer_in}), - #connect_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime::get_connect_time($context->{dt_transfer_in}), # adjacent? - - file_sequence_number => $context->{file_sequence_number}, - ) - ); - -} - -sub _create_ama_record { - my ($context,$ama) = @_; - $context->{file}->update_start_end_time($ama->{start_time},$ama->{start_time} + $ama->{duration}); - 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 => $ama_sensor_id, - - padding => 0, - recording_office_id => $ama_recording_office_id, - - call_type => '970', - #timing ind 000 - #seervice observed 0c - - unanswered => $ama->{unanswered}, #called party off-hook setzen - - date => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date::get_ama_date(from_epoch($ama->{start_time})), - - 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($ama->{originating}), - originating_open_digits_1 => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField::get_number_digits_1($ama->{originating}), - originating_open_digits_2 => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField::get_number_digits_2($ama->{originating}), - - domestic_international => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::DomesticInternational::get_number_domestic_international($ama->{terminating_cdr}), - - terminating_significant_digits => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField::get_number_length($ama->{terminating}), - terminating_open_digits_1 => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField::get_number_digits_1($ama->{terminating}), - terminating_open_digits_2 => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::SignificantDigitsNextField::get_number_digits_2($ama->{terminating}), - - connect_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime::get_connect_time(from_epoch($ama->{start_time})), - elapsed_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ElapsedTime::get_elapsed_time($ama->{duration}), - ), - NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module611->new( - generic_context_identifier => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericContextIdentifier::IN_CORRELATION_ID, - parsing_rules => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::GenericContextIdentifier::IN_CORRELATION_ID_PARSING_RULES, - additional_digits_dialed => $ama->{correlation_id}, - ), - NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module199->new( - network_operator_data => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::NetworkOperatorData::get_network_operator_data( - $ama->{nod}->{originating_digits}, - $ama->{nod}->{switch_number_digits}, - $ama->{nod}->{mode}, - ), - ), - NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module104->new( - direction => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TrunkIdentification::INCOMING, - trunk_group_number => $ama_incoming_trunk_group_number, - trunk_member_number => '0000', - ), - NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module104->new( - direction => $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::TrunkIdentification::OUTGOING, - trunk_group_number => $ama_outgoing_trunk_group_number, - trunk_member_number => '0000', - ), - NGCP::BulkProcessor::Projects::Export::Ama::Format::Modules::Module000->new( - ), - ); -} - -sub _create_ama_records { - my ($context,$scenario_name) = @_; - my $records = [ map { _create_ama_record($context,$_); } @{$context->{scenario}->{ama}} ]; - _info($context,"$scenario_name - cdr ids " . join(', ', map { $_->{id}; } @{$context->{scenario}->{all_cdrs}}) . ':' . join("\n", map { $_->to_string(); } @$records),1); - return $records; -} - -sub _get_record { - - my %params = @_; - my ( - $context, - ) = @params{qw/ - context - /}; - - if ($context->{scenario}->{code} == $BLIND_TRANSFER_NO_IVR) { - return _create_ama_records($context,'BLIND_TRANSFER_NO_IVR'); - } elsif ($context->{scenario}->{code} == $BLIND_TRANSFER) { - return _create_ama_records($context,'BLIND_TRANSFER'); - } elsif ($context->{scenario}->{code} == $NO_TRANSFER_NO_IVR) { - return _create_ama_records($context,'NO_TRANSFER_NO_IVR'); - } elsif ($context->{scenario}->{code} == $NO_TRANSFER) { - return _create_ama_records($context,'NO_TRANSFER'); - } elsif ($context->{scenario}->{code} == $ATTN_TRANSFER_NO_IVR) { - return _create_ama_records($context,'ATTN_TRANSFER_NO_IVR'); - } elsif ($context->{scenario}->{code} == $ATTN_TRANSFER) { - return _create_ama_records($context,'ATTN_TRANSFER'); - } elsif ($context->{scenario}->{code} == $CFU) { - return _create_ama_records($context,'CFU'); - } else { - _error($context,"unknown scenario $context->{scenario}->{code} for cdr ids " . join(', ',map { $_->{id}; } @{$context->{scenario}->{all_cdrs}}) ); - } - -} - -sub _get_transfer_out { - - my %params = @_; - my ( - $context, - ) = @params{qw/ - context - /}; - - return NGCP::BulkProcessor::Projects::Export::Ama::Format::Record->new( - NGCP::BulkProcessor::Projects::Export::Ama::Format::Structures::Structure9014->new( - @_, - rewritten => 0, - sensor_id => $ama_sensor_id, - - padding => 0, - recording_office_id => $ama_recording_office_id, - - #date => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::Date::get_ama_date($context->{dt_transfer_out}), - #connect_time => NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::ConnectTime::get_connect_time($context->{dt_transfer_out}), - - file_sequence_number => $context->{file_sequence_number}, - - ) - ); - -} - -sub _check_export_status_stream { - - my ($context) = @_; - - my $result = 1; - - my $export_status; - eval { - if ($export_cdr_stream) { - $export_status = NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_export_status::findby_type($export_cdr_stream); - } - $context->{export_status_id} = $export_status->{id} if $export_status; - }; - if ($@ or ($export_cdr_stream and not $export_status)) { - _error($context,"cannot find export stream '$export_cdr_stream'"); - $result = 0; - } elsif ($export_status) { - _info($context,"using export stream '$export_cdr_stream'"); - } - - return $result; - -} - -sub _export_cdrs_create_context { - - my ($context) = @_; - - my $result = 1; - - $context->{tid} = threadid(); - - $result &= _check_export_status_stream($context); - - $context->{file} = NGCP::BulkProcessor::Projects::Export::Ama::Format::File->new(); - $context->{file_cdr_id_map} = {}; - $context->{has_next} = 1; - - my $fsn; - eval { - $fsn = NGCP::BulkProcessor::Dao::Trunk::accounting::mark::get_system_mark(undef, - $export_cdr_stream - ); #load mark... - }; - if ($@) { - _error($context,"cannot get last file sequence number"); - $result = 0; - } else { - my $reset = 0; - if (not defined $fsn) { - $fsn = $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::min_fsn - 1; - } elsif ($fsn < 0) { - $reset = 1; - } elsif ($fsn >= $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::max_fsn) { - if ($export_cdr_rollover_fsn) { - $reset = 1; - } else { - _warn($context,"file sequence number $fsn exceeding limit (" . $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::max_fsn . ")"); - $result = 0; - } - } else { - _info($context,"last file sequence number is $fsn"); - } - if ($reset) { - $fsn = $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::min_fsn - 1; - eval { - NGCP::BulkProcessor::Dao::Trunk::accounting::mark::delete_system_marks(undef, - $export_cdr_stream, - ); - }; - if ($@) { - if ($skip_errors) { - _warn($context,"problem with file sequence number reset: " . $@); - } else { - _error($context,"problem with file sequence number reset: " . $@); - } - $result = 0; - } else { - _info($context,"file sequence number deleted"); #reset to $fsn") - } - } - lock $file_sequence_number; - $file_sequence_number = $fsn; - } - - eval { - ($context->{cdr_provider_map}, my $types, my $ids) = array_to_map(NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_provider::findall(), - sub { return shift->{type}; }, sub { return shift->{id}; }, 'last'); - }; - if ($@) { - _error($context,"failed to load cdr_provider enum: " . $@); - $result = 0; - } elsif (not exists $context->{cdr_provider_map}->{$NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_provider::CUSTOMER}) { - _error($context,"cannot find cdr_provider '" . $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_provider::CUSTOMER . "'"); - $result = 0; - } else { - _info($context,"cdr_provider '" . $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_provider::CUSTOMER . "' found"); - } - eval { - ($context->{cdr_direction_map}, my $types, my $ids) = array_to_map(NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_direction::findall(), - sub { return shift->{type}; }, sub { return shift->{id}; }, 'last'); - }; - if ($@) { - _error($context,"failed to load cdr_direction enum: " . $@); - $result = 0; - } elsif (not exists $context->{cdr_direction_map}->{$NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_direction::SOURCE}) { - _error($context,"cannot find cdr_direction '" . $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_direction::SOURCE . "'"); - $result = 0; - } else { - _info($context,"cdr_direction '" . $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_direction::SOURCE . "' found"); - } - eval { - ($context->{cdr_tag_map}, my $types, my $ids) = array_to_map(NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_tag::findall(), - sub { return shift->{type}; }, sub { return shift->{id}; }, 'last'); - }; - if ($@) { - _error($context,"failed to load cdr_tag enum: " . $@); - $result = 0; - } elsif (not exists $context->{cdr_tag_map}->{$NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_tag::HEADER_USER_TO_USER}) { - _error($context,"cannot find cdr_tag '" . $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_tag::HEADER_USER_TO_USER . "'"); - $result = 0; - } else { - _info($context,"cdr_tag '" . $NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_tag::HEADER_USER_TO_USER . "' found"); - } - - return $result; -} - -sub get_u2u_header { - my ($context,$cdr) = @_; - - my $cdr_tag = NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_tag_data::findby_cdrproviderdirectiontag($context->{db},$cdr->{id}, - $context->{cdr_provider_map}->{$NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_provider::CUSTOMER}, - $context->{cdr_direction_map}->{$NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_direction::SOURCE}, - $context->{cdr_tag_map}->{$NGCP::BulkProcessor::Dao::Trunk::accounting::cdr_tag::HEADER_USER_TO_USER})->[0]; - - if ($cdr_tag) { - return $cdr_tag->{val}; - } else { - return undef; - } - -} - -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/Settings.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/Settings.pm deleted file mode 100644 index a594e75b..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/Settings.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/config.cfg b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/config.cfg deleted file mode 100644 index 74e277fe..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/config.cfg +++ /dev/null @@ -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 diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/config.debug.cfg b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/config.debug.cfg deleted file mode 100644 index f4fd7160..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/config.debug.cfg +++ /dev/null @@ -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 diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/process.pl b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/process.pl deleted file mode 100755 index b147c787..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/process.pl +++ /dev/null @@ -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! diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/settings.cfg b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/settings.cfg deleted file mode 100644 index 81305710..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/settings.cfg +++ /dev/null @@ -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 = \ No newline at end of file diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/settings.debug.cfg b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/settings.debug.cfg deleted file mode 100644 index 6cd8d2fe..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/settings.debug.cfg +++ /dev/null @@ -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 = \ No newline at end of file diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/test.ama b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/test.ama deleted file mode 100644 index 74882f7d..00000000 Binary files a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/test.ama and /dev/null differ diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/test.pl b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/test.pl deleted file mode 100755 index 0d05e365..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Ccs/test.pl +++ /dev/null @@ -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(); diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Block.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Block.pm deleted file mode 100644 index 400552b1..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Block.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Field.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Field.pm deleted file mode 100644 index 9d3a1ff9..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Field.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/FieldSet.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/FieldSet.pm deleted file mode 100644 index cee34e36..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/FieldSet.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/AdditionalDigitsDialed.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/AdditionalDigitsDialed.pm deleted file mode 100644 index 7c6e9564..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/AdditionalDigitsDialed.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/BlockCount.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/BlockCount.pm deleted file mode 100644 index 99897baf..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/BlockCount.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/CallType.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/CallType.pm deleted file mode 100644 index e7601dfa..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/CallType.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/CalledPartyOffHook.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/CalledPartyOffHook.pm deleted file mode 100644 index 35946129..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/CalledPartyOffHook.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ConnectTime.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ConnectTime.pm deleted file mode 100644 index 6b1af82c..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ConnectTime.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/DataDescriptor.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/DataDescriptor.pm deleted file mode 100644 index b6b1916e..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/DataDescriptor.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/Date.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/Date.pm deleted file mode 100644 index e2947847..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/Date.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/DomesticInternational.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/DomesticInternational.pm deleted file mode 100644 index e18a6120..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/DomesticInternational.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ElapsedTime.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ElapsedTime.pm deleted file mode 100644 index 9e130f3a..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ElapsedTime.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/FileSequenceNumber.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/FileSequenceNumber.pm deleted file mode 100644 index d55423c7..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/FileSequenceNumber.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericContextIdentifier.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericContextIdentifier.pm deleted file mode 100644 index af46dbce..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericContextIdentifier.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericIssue.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericIssue.pm deleted file mode 100644 index b722a6c5..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/GenericIssue.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/HexId.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/HexId.pm deleted file mode 100644 index bc08c0a9..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/HexId.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ModuleCode.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ModuleCode.pm deleted file mode 100644 index 026b3371..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ModuleCode.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/NetworkOperatorData.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/NetworkOperatorData.pm deleted file mode 100644 index 8a8f9c84..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/NetworkOperatorData.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OperatorAction.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OperatorAction.pm deleted file mode 100644 index e7c1f30d..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OperatorAction.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OriginatingChargeInformation.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OriginatingChargeInformation.pm deleted file mode 100644 index a27e86cb..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OriginatingChargeInformation.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OriginatingOpenDigits1.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OriginatingOpenDigits1.pm deleted file mode 100644 index 8610b8b1..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OriginatingOpenDigits1.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OriginatingOpenDigits2.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OriginatingOpenDigits2.pm deleted file mode 100644 index 5c449f78..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/OriginatingOpenDigits2.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/RecordCount.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/RecordCount.pm deleted file mode 100644 index a68f5df8..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/RecordCount.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/RecordingOfficeId.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/RecordingOfficeId.pm deleted file mode 100644 index 17fc3729..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/RecordingOfficeId.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/RecordingOfficeType.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/RecordingOfficeType.pm deleted file mode 100644 index 2e7b0ca6..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/RecordingOfficeType.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SensorId.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SensorId.pm deleted file mode 100644 index 6aba18e9..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SensorId.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SensorType.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SensorType.pm deleted file mode 100644 index 8e04d4c2..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SensorType.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ServiceFeature.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ServiceFeature.pm deleted file mode 100644 index 9be2ed6d..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ServiceFeature.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ServiceObserved.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ServiceObserved.pm deleted file mode 100644 index 5fe65408..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/ServiceObserved.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SignificantDigitsNextField.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SignificantDigitsNextField.pm deleted file mode 100644 index bd696326..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/SignificantDigitsNextField.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/StructureCode.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/StructureCode.pm deleted file mode 100644 index 3b4f76f2..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/StructureCode.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/StudyIndicator.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/StudyIndicator.pm deleted file mode 100644 index 71c397fb..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/StudyIndicator.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TerminatingOpenDigits1.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TerminatingOpenDigits1.pm deleted file mode 100644 index e32b6c62..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TerminatingOpenDigits1.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TerminatingOpenDigits2.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TerminatingOpenDigits2.pm deleted file mode 100644 index 73bec68f..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TerminatingOpenDigits2.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TimingIndicator.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TimingIndicator.pm deleted file mode 100644 index d8acff11..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TimingIndicator.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TracerType.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TracerType.pm deleted file mode 100644 index e071bdb8..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TracerType.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TrunkIdentification.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TrunkIdentification.pm deleted file mode 100644 index cf46ac37..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Fields/TrunkIdentification.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/File.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/File.pm deleted file mode 100644 index 3b7bc968..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/File.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Module.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Module.pm deleted file mode 100644 index 446d223a..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Module.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module000.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module000.pm deleted file mode 100644 index 7919d93f..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module000.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module104.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module104.pm deleted file mode 100644 index 69f23afc..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module104.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module199.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module199.pm deleted file mode 100644 index 7eded3db..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module199.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module611.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module611.pm deleted file mode 100644 index 550175fd..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Modules/Module611.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Record.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Record.pm deleted file mode 100644 index f62ee3c1..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Record.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Settings.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Settings.pm deleted file mode 100644 index ae2ae063..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Settings.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structure.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structure.pm deleted file mode 100644 index 09baaa5a..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structure.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure0510.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure0510.pm deleted file mode 100644 index b74e5449..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure0510.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure9013.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure9013.pm deleted file mode 100644 index 2c17e402..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure9013.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure9014.pm b/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure9014.pm deleted file mode 100644 index 9907a10e..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Export/Ama/Format/Structures/Structure9014.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Check.pm b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Check.pm deleted file mode 100644 index 35e071b1..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Check.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Dao/import/CcsSubscriber.pm b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Dao/import/CcsSubscriber.pm deleted file mode 100644 index 7f0f8332..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Dao/import/CcsSubscriber.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Dao/import/MtaSubscriber.pm b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Dao/import/MtaSubscriber.pm deleted file mode 100644 index ad03f875..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Dao/import/MtaSubscriber.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Import.pm b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Import.pm deleted file mode 100644 index a76e0d18..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Import.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Preferences.pm b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Preferences.pm deleted file mode 100644 index ca2dc5cb..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Preferences.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/ProjectConnectorPool.pm b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/ProjectConnectorPool.pm deleted file mode 100644 index 0d1be6e1..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/ProjectConnectorPool.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Provisioning.pm b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Provisioning.pm deleted file mode 100644 index 8bf75c9c..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Provisioning.pm +++ /dev/null @@ -1,1883 +0,0 @@ -package NGCP::BulkProcessor::Projects::Migration::UPCAT::Provisioning; -use strict; - -## no critic - -use threads::shared qw(); -use String::MkPasswd qw(); -#use List::Util qw(); - -use JSON -support_by_pp, -no_export; -use Tie::IxHash; - -use Encode qw(); - -use NGCP::BulkProcessor::Projects::Migration::UPCAT::Settings qw( - $dry - $skip_errors - $report_filename - - $provision_mta_subscriber_multithreading - $provision_mta_subscriber_numofthreads - $mta_webpassword_length - $mta_webusername_length - $mta_sippassword_length - - $barring_profiles - - $provision_ccs_subscriber_multithreading - $provision_ccs_subscriber_numofthreads - - split_number - - $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 -); - -use NGCP::BulkProcessor::Logging qw ( - getlogger - processing_info - processing_debug -); -use NGCP::BulkProcessor::LogError qw( - rowprocessingerror - rowprocessingwarn - fileerror -); - -use NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber qw(); -use NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber qw(); - -use NGCP::BulkProcessor::Dao::Trunk::billing::billing_profiles qw(); -use NGCP::BulkProcessor::Dao::Trunk::billing::products qw(); -use NGCP::BulkProcessor::Dao::Trunk::billing::contacts qw(); -use NGCP::BulkProcessor::Dao::Trunk::billing::contracts 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::contract_balances qw(); -use NGCP::BulkProcessor::Dao::Trunk::billing::domains qw(); -use NGCP::BulkProcessor::Dao::Trunk::billing::resellers qw(); -use NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers qw(); -use NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers qw(); -use NGCP::BulkProcessor::Dao::Trunk::billing::domain_resellers qw(); -use NGCP::BulkProcessor::Dao::Trunk::billing::ncos_levels qw(); - -use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_domains qw(); -use NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases 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_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::RestRequests::Trunk::Subscribers qw(); -use NGCP::BulkProcessor::RestRequests::Trunk::Customers qw(); - -use NGCP::BulkProcessor::Projects::Migration::UPCAT::Preferences qw( - set_subscriber_preference - get_subscriber_preference - clear_subscriber_preferences - delete_subscriber_preference - - set_contract_preference - get_contract_preference - clear_contract_preferences - delete_contract_preference -); -#set_allowed_ips_preferences -#cleanup_aig_sequence_ids - -use NGCP::BulkProcessor::ConnectorPool qw( - get_xa_db -); - -use NGCP::BulkProcessor::Projects::Migration::UPCAT::ProjectConnectorPool qw( - destroy_all_dbs - ping_all_dbs -); - -use NGCP::BulkProcessor::Utils qw(create_uuid threadid timestamp stringtobool trim); #check_ipnet -use NGCP::BulkProcessor::DSSorter qw(sort_by_configs); -use NGCP::BulkProcessor::RandomString qw(createtmpstring); - -require Exporter; -our @ISA = qw(Exporter); -our @EXPORT_OK = qw( - provision_mta_subscribers - provision_ccs_subscribers - $UPDATE_CCS_PREFERENCES_MODE - $SET_CCS_CF_MODE - $CLEAR_CCS_CF_MODE -); - -my $split_ipnets_pattern = join('|',( - quotemeta(','), - quotemeta(';'), - #quotemeta('/') -)); - -my $db_lock :shared = undef; -my $file_lock :shared = undef; - -my $default_barring = 'default'; - -my $ccs_contact_identifier_field = 'gpp9'; - -our $UPDATE_CCS_PREFERENCES_MODE = 'update_ccs_preferences'; -our $SET_CCS_CF_MODE = 'set_ccs_cf'; -our $CLEAR_CCS_CF_MODE = 'clear_ccs_cf'; - -my $cf_types_pattern = '^' . $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_mappings::CFB_TYPE . '|' - . $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_mappings::CFT_TYPE . '|' - . $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_mappings::CFU_TYPE . '|' - . $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_mappings::CFNA_TYPE . '$'; - -sub provision_mta_subscribers { - - my $static_context = { now => timestamp(), _rowcount => undef }; - my $result = _provision_mta_subscribers_checks($static_context); - - destroy_all_dbs(); - my $warning_count :shared = 0; - my %nonunique_contacts :shared = (); - return ($result && NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::process_records( - static_context => $static_context, - process_code => sub { - my ($context,$records,$row_offset) = @_; - ping_all_dbs(); - $context->{_rowcount} = $row_offset; - my @report_data = (); - foreach my $domain_sipusername (@$records) { - $context->{_rowcount} += 1; - next unless _provision_mta_susbcriber($context, - NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::findby_domain_sipusername(@$domain_sipusername)); - push(@report_data,_get_report_obj($context)); - } - #cleanup_aig_sequence_ids($context); - if (defined $report_filename) { - lock $file_lock; - open(my $fh, '>>', $report_filename) or fileerror('cannot open file ' . $report_filename . ': ' . $!,getlogger(__PACKAGE__)); - binmode($fh); - print $fh JSON::to_json(\@report_data,{ allow_nonref => 1, allow_blessed => 1, convert_blessed => 1, pretty => 1, }); - close $fh; - } - return 1; - }, - init_process_context_code => sub { - my ($context)= @_; - $context->{db} = &get_xa_db(); - $context->{error_count} = 0; - $context->{warning_count} = 0; - $context->{nonunique_contacts} = {}; - - }, - uninit_process_context_code => sub { - my ($context)= @_; - undef $context->{db}; - destroy_all_dbs(); - { - lock $warning_count; - $warning_count += $context->{warning_count}; - } - { - lock %nonunique_contacts; - foreach my $sip_username (keys %{$context->{nonunique_contacts}}) { - $nonunique_contacts{$sip_username} = $context->{nonunique_contacts}->{$sip_username}; - } - } - }, - load_recursive => 0, - multithreading => $provision_mta_subscriber_multithreading, - numofthreads => $provision_mta_subscriber_numofthreads, - ),$warning_count,\%nonunique_contacts); - -} - -sub _get_report_obj { - my ($context) = @_; - my %dump = (); - tie(%dump, 'Tie::IxHash'); - foreach my $key (sort keys %$context) { - $dump{$key} = $context->{$key} if 'CODE' ne ref $context->{$key}; - } - foreach my $key (qw/ - sip_account_product - reseller - billing_profile - reseller_map - domain_map - domain - now - error_count - warning_count - attributes - ncos_level_map - ncos_level - nonunique_contacts - tid - db - blocksize - errorstates - queue - readertid - /) { - delete $dump{$key}; - } - return \%dump; -} - -sub _provision_mta_susbcriber { - my ($context,$subscriber_group) = @_; - - return 0 unless _provision_mta_susbcriber_init_context($context,$subscriber_group); - - eval { - lock $db_lock; - $context->{db}->db_begin(); - #_warn($context,'AutoCommit is on') if $context->{db}->{drh}->{AutoCommit}; - - my $existing_billing_voip_subscribers = NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers::findby_domainid_username_states( - $context->{db}, - $context->{domain}->{id}, - $context->{prov_subscriber}->{username}, - { 'NOT IN' => $NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers::TERMINATED_STATE} - ); - - if ((scalar @$existing_billing_voip_subscribers) == 0) { - - _update_mta_contact($context); - _update_contract($context); - #{ - # lock $db_lock; #concurrent writes to voip_numbers causes deadlocks - _update_subscriber($context); - _create_aliases($context); - #} - _update_mta_preferences($context); - #_set_registrations($context); - #_set_callforwards($context); - #todo: additional prefs, AllowedIPs, NCOS, Callforwards. still thinking wether to integrate it - #in this main provisioning loop, or align it in separate run-modes, according to the files given. - - } else { - _warn($context,(scalar @$existing_billing_voip_subscribers) . ' existing billing subscribers found, skipping'); - } - - if ($dry) { - $context->{db}->db_rollback(0); - } else { - $context->{db}->db_commit(); - } - - }; - my $err = $@; - if ($err) { - eval { - $context->{db}->db_rollback(1); - }; - if ($skip_errors) { - _warn($context, $err); - } else { - _error($context, $err); - } - } - - return 1; - -} - -sub _provision_mta_subscribers_checks { - my ($context) = @_; - - my $result = 1; - - my $subscribercount = 0; - eval { - $subscribercount = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::countby_ccacsn(); - }; - if ($@ or $subscribercount == 0) { - rowprocessingerror(threadid(),'please import mta subscribers first',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"$subscribercount mta subscriber found",getlogger(__PACKAGE__)); - } - - my $domain_billingprofilename_resellernames = []; - eval { - $domain_billingprofilename_resellernames = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::list_domain_billingprofilename_resellernames(); - }; - if ($@ or (scalar @$domain_billingprofilename_resellernames) == 0) { - rowprocessingerror(threadid(),"no domains/billing profile names/reseller names",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - $context->{domain_map} = {}; - $context->{reseller_map} = {}; - foreach my $domain_billingprofilename_resellername (@$domain_billingprofilename_resellernames) { - my $domain = $domain_billingprofilename_resellername->{domain}; - unless ($domain) { - rowprocessingerror(threadid(),"empty domain detected",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } - my $billingprofilename = $domain_billingprofilename_resellername->{billing_profile_name}; - unless ($billingprofilename) { - rowprocessingerror(threadid(),"empty billing profile name detected",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } - my $resellername = _apply_reseller_mapping($domain_billingprofilename_resellername->{reseller_name}); - unless ($resellername) { - rowprocessingerror(threadid(),"empty reseller name detected",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } - if (not exists $context->{reseller_map}->{$resellername}) { - eval { - $context->{reseller_map}->{$resellername} = NGCP::BulkProcessor::Dao::Trunk::billing::resellers::findby_name($resellername); - }; - if ($@ or not $context->{reseller_map}->{$resellername}) { - rowprocessingerror(threadid(),"cannot find reseller '$resellername'",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - $context->{reseller_map}->{$resellername}->{billingprofile_map} = {}; - processing_info(threadid(),"reseller '$resellername' found",getlogger(__PACKAGE__)); - } - } - if (not exists $context->{domain_map}->{$domain}) { - eval { - $context->{domain_map}->{$domain} = NGCP::BulkProcessor::Dao::Trunk::billing::domains::findby_domain($domain); - }; - if ($@ or not $context->{domain_map}->{$domain}) { - rowprocessingerror(threadid(),"cannot find billing domain '$domain'",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"billing domain '$domain' found",getlogger(__PACKAGE__)); - eval { - $context->{domain_map}->{$domain}->{prov_domain} = - NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_domains::findby_domain($domain); - }; - if ($@ or not $context->{domain_map}->{$domain}->{prov_domain}) { - rowprocessingerror(threadid(),"cannot find provisioning domain '$domain'",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"provisioning domain '$domain' found",getlogger(__PACKAGE__)); - } - } - } - my $domain_reseller; - eval { - $domain_reseller = NGCP::BulkProcessor::Dao::Trunk::billing::domain_resellers::findby_domainid_resellerid( - $context->{domain_map}->{$domain}->{id}, - $context->{reseller_map}->{$resellername}->{id})->[0]; - }; - if ($@ or not $domain_reseller) { - rowprocessingerror(threadid(),"domain $domain does not belong to reseller $resellername",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"domain $domain belongs to reseller $resellername",getlogger(__PACKAGE__)); - } - - if ($context->{reseller_map}->{$resellername}->{billingprofile_map} and - not exists $context->{reseller_map}->{$resellername}->{billingprofile_map}->{$billingprofilename}) { - - eval { - $context->{reseller_map}->{$resellername}->{billingprofile_map}->{$billingprofilename} = - NGCP::BulkProcessor::Dao::Trunk::billing::billing_profiles::findby_resellerid_name_handle( - $context->{reseller_map}->{$resellername}->{id}, - $billingprofilename, - )->[0]; - }; - if ($@ or not $context->{reseller_map}->{$resellername}->{billingprofile_map}->{$billingprofilename}) { - rowprocessingerror(threadid(),"cannot find billing profile '$billingprofilename' of reseller '$resellername'",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"billing profile '$billingprofilename' of reseller '$resellername' found",getlogger(__PACKAGE__)); - } - } - } - } - - eval { - $context->{sip_account_product} = NGCP::BulkProcessor::Dao::Trunk::billing::products::findby_resellerid_handle(undef, - $NGCP::BulkProcessor::Dao::Trunk::billing::products::SIP_ACCOUNT_HANDLE)->[0]; - }; - if ($@ or not defined $context->{sip_account_product}) { - rowprocessingerror(threadid(),"cannot find $NGCP::BulkProcessor::Dao::Trunk::billing::products::SIP_ACCOUNT_HANDLE product",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"$NGCP::BulkProcessor::Dao::Trunk::billing::products::SIP_ACCOUNT_HANDLE product found",getlogger(__PACKAGE__)); - } - - $result = _provision_subscribers_base_prefs_checks($context,$result); - - my $barring_resellernames = []; - eval { - $barring_resellernames = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::MtaSubscriber::list_barring_resellernames(); - }; - if ($@) { - rowprocessingerror(threadid(),'error retrieving barrings',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - $context->{ncos_level_map} = {}; - foreach my $barring_resellername (@$barring_resellernames) { - my $resellername = _apply_reseller_mapping($barring_resellername->{reseller_name}); - #unless ($resellername) { - # rowprocessingerror(threadid(),"empty reseller name detected",getlogger(__PACKAGE__)); - # $result = 0; #even in skip-error mode.. - #} - my $barring = $barring_resellername->{barrings}; - $barring = $default_barring unless ($barring); - $result &= _check_ncos_level($context,$resellername,$barring); - } - } - - eval { - $context->{attributes}->{ncos_id} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::NCOS_ID_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{ncos_id}) { - rowprocessingerror(threadid(),'cannot find ncos_id attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"ncos_id attribute found",getlogger(__PACKAGE__)); - } - - foreach my $gpp_idx (0..9) { - my $gpp_attr = $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::GPPx_ATTRIBUTE . $gpp_idx; - eval { - $context->{attributes}->{$gpp_attr} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute($gpp_attr); - }; - if ($@ or not defined $context->{attributes}->{$gpp_attr}) { - rowprocessingerror(threadid(),"cannot find $gpp_attr attribute",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"$gpp_attr attribute found",getlogger(__PACKAGE__)); - } - } - - return $result; -} - -sub _check_ncos_level { - my ($context,$resellername,$barring) = @_; - my $result = 1; - if ($barring ne $default_barring and not exists $barring_profiles->{$resellername}) { - rowprocessingerror(threadid(),"barring mappings for reseller $resellername missing",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } elsif ($barring ne $default_barring and not exists $barring_profiles->{$resellername}->{$barring}) { - rowprocessingerror(threadid(),"mappings for barring '" . $barring . "' of reseller $resellername missing",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - my $reseller_id = $context->{reseller_map}->{$resellername}->{id}; - $context->{ncos_level_map}->{$reseller_id} = {} unless exists $context->{ncos_level_map}->{$reseller_id}; - my $level = $barring_profiles->{$resellername}->{$barring}; - unless (exists $context->{ncos_level_map}->{$reseller_id}->{$barring}) { - if (not defined $level or length($level) == 0) { - $context->{ncos_level_map}->{$reseller_id}->{$barring} = undef; - } else { - eval { - $context->{ncos_level_map}->{$reseller_id}->{$barring} = NGCP::BulkProcessor::Dao::Trunk::billing::ncos_levels::findby_resellerid_level( - $reseller_id,$level); - }; - if ($@ or not defined $context->{ncos_level_map}->{$reseller_id}->{$barring}) { - my $err = "cannot find ncos level '$level' of reseller $resellername"; - if (not defined $context->{_rowcount}) { - if ($barring ne $default_barring) { - rowprocessingerror(threadid(),$err,getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - rowprocessingwarn(threadid(),$err,getlogger(__PACKAGE__)); - } - } elsif ($skip_errors) { - _warn($context, $err); - } else { - _error($context, $err); - $result = 0; #even in skip-error mode.. - } - } else { - processing_info(threadid(),"ncos level '$level' of reseller $resellername found",getlogger(__PACKAGE__)); - } - } - } - } - return $result; -} - -sub _update_mta_contact { - - my ($context) = @_; - - my $existing_contracts = NGCP::BulkProcessor::Dao::Trunk::billing::contracts::findby_externalid($context->{contract}->{external_id}); - if ((scalar @$existing_contracts) > 0) { - my $existing_contract = $existing_contracts->[0]; - if ((scalar @$existing_contracts) > 1) { - _warn($context,(scalar @$existing_contracts) . " existing contracts found, using first contact id $existing_contract->{id}"); - } else { - _info($context,"existing contract id $existing_contract->{id} found",1); - } - $context->{contract}->{id} = $existing_contract->{id}; - $context->{bill_subscriber}->{contract_id} = $context->{contract}->{id}; - $context->{prov_subscriber}->{account_id} = $context->{contract}->{id}; - } else { - #_warn($context,"no existing contract of contact id $existing_contact->{id} found, will be created"); - - $context->{contract}->{contact}->{id} = NGCP::BulkProcessor::Dao::Trunk::billing::contacts::insert_row($context->{db}, - $context->{contract}->{contact}, - ); - $context->{contract}->{contact_id} = $context->{contract}->{contact}->{id}; - _info($context,"contact id $context->{contract}->{contact}->{id} created",1); - } - - return 1; - -} - -sub _update_contract { - - my ($context) = @_; - - if ($context->{bill_subscriber}->{contract_id}) { - #todo: the update case - } else { - #the insert case - $context->{contract}->{id} = NGCP::BulkProcessor::Dao::Trunk::billing::contracts::insert_row($context->{db}, - $context->{contract} - ); - $context->{bill_subscriber}->{contract_id} = $context->{contract}->{id}; - $context->{prov_subscriber}->{account_id} = $context->{contract}->{id}; - - NGCP::BulkProcessor::Dao::Trunk::billing::contracts_billing_profile_network_schedule::append_billing_mappings($context->{db}, - $context->{contract}->{id}, - [{ billing_profile_id => $context->{billing_profile}->{id}, }], - ); - - $context->{contract}->{contract_balance_id} = NGCP::BulkProcessor::Dao::Trunk::billing::contract_balances::insert_row($context->{db}, - contract_id => $context->{contract}->{id}, - ); - - _info($context,"contract id $context->{contract}->{id} created",1); - } - return 1; - -} - -sub _update_subscriber { - - my ($context) = @_; - - my $result = 1; - - if ($context->{bill_subscriber}->{id}) { - #todo: the update case - } else { - #the insert case - $context->{bill_subscriber}->{id} = NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers::insert_row($context->{db}, - $context->{bill_subscriber}, - ); - - $context->{prov_subscriber}->{id} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_subscribers::insert_row($context->{db}, - $context->{prov_subscriber}, - ); - - my $number = $context->{numbers}->{primary}; - $context->{voip_numbers}->{primary} = NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers::forupdate_cc_ac_sn_subscriberid($context->{db}, - $number->{cc}, - $number->{ac}, - $number->{sn}, - $context->{bill_subscriber}->{id}); - - if (defined $context->{voip_numbers}->{primary}) { - NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers::update_row($context->{db},{ - id => $context->{voip_numbers}->{primary}->{id}, - reseller_id => $context->{reseller}->{id}, - subscriber_id => $context->{bill_subscriber}->{id}, - status => 'active', - }); - } else { - $context->{voip_numbers}->{primary}->{id} = NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers::insert_row($context->{db}, - cc => $number->{cc}, - ac => $number->{ac}, - sn => $number->{sn}, - reseller_id => $context->{reseller}->{id}, - subscriber_id => $context->{bill_subscriber}->{id}, - ); - } - - $context->{usr_preferences}->{cli} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{cli}, - $number->{number}), value => $number->{number} }; - - NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers::update_row($context->{db},{ - id => $context->{bill_subscriber}->{id}, - primary_number_id => $context->{voip_numbers}->{primary}->{id}, - }); - - _info($context,"subscriber uuid $context->{prov_subscriber}->{uuid} created",1); - - #primary alias - $context->{aliases}->{primary}->{id} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::insert_row($context->{db}, - domain_id => $context->{prov_subscriber}->{domain_id}, - subscriber_id => $context->{prov_subscriber}->{id}, - username => $number->{number}, - ); - - my @allowed_clis = (); - push(@allowed_clis,{ id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{allowed_clis}, - $number->{number}), value => $number->{number}}); - $context->{usr_preferences}->{allowed_clis} = \@allowed_clis; - - NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers::release_subscriber_numbers($context->{db}, - $context->{bill_subscriber}->{id},{ 'NOT IN' => $context->{voip_numbers}->{primary}->{id} }); - - NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::delete_dbaliases($context->{db}, - $context->{prov_subscriber}->{id},{ 'NOT IN' => $number->{number} }); - - clear_subscriber_preferences($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{allowed_clis}, - $number->{number}); - - _info($context,"primary alias $number->{number} created",1); - - $context->{voicemail_user}->{id} = NGCP::BulkProcessor::Dao::Trunk::kamailio::voicemail_users::insert_row($context->{db}, - $context->{voicemail_user}, - ); - - $context->{usr_preferences}->{account_id} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{account_id}, - $context->{contract}->{id}), value => $context->{contract}->{id} }; - - if (length($number->{ac}) > 0) { - $context->{usr_preferences}->{ac} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{ac}, - $number->{ac}), value => $number->{ac} }; - } - if (length($number->{cc}) > 0) { - $context->{usr_preferences}->{cc} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{cc}, - $number->{cc}), value => $number->{cc} }; - } - - } - - return $result; - -} - -sub _update_mta_preferences { - - my ($context) = @_; - - my $result = 1; - - if (defined $context->{ncos_level}) { - $context->{usr_preferences}->{ncos_id} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{ncos_id}, - $context->{ncos_level}->{id}), value => $context->{ncos_level}->{id} }; - _info($context,"ncos_id preference set to $context->{ncos_level}->{id} - $context->{ncos_level}->{level}",1); - } - - if (defined $context->{usr_preferences}->{gpp}) { - my $gpp_idx = 0; - foreach my $gpp_val (@{$context->{usr_preferences}->{gpp}}) { - my $gpp_attr = 'gpp' . $gpp_idx; - $context->{usr_preferences}->{$gpp_attr} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{$gpp_attr}, - $gpp_attr), value => $gpp_val }; - _info($context,"$gpp_attr preference set to $gpp_val",1); - $gpp_idx++; - } - } - - return $result; - -} - -sub _create_aliases { - - my ($context) = @_; - my $result = 1; - - if ((scalar @{$context->{numbers}->{other}}) > 0) { - - my @voip_number_ids = (); - my @usernames = (); - - foreach my $number (@{$context->{numbers}->{other}}) { - - my $voip_number = NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers::forupdate_cc_ac_sn_subscriberid($context->{db}, - $number->{cc}, - $number->{ac}, - $number->{sn}, - $context->{bill_subscriber}->{id}); - - if (defined $voip_number) { - NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers::update_row($context->{db},{ - id => $voip_number->{id}, - reseller_id => $context->{reseller}->{id}, - subscriber_id => $context->{bill_subscriber}->{id}, - status => 'active', - }); - } else { - $voip_number->{id} = NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers::insert_row($context->{db}, - cc => $number->{cc}, - ac => $number->{ac}, - sn => $number->{sn}, - reseller_id => $context->{reseller}->{id}, - subscriber_id => $context->{bill_subscriber}->{id}, - ); - } - - push(@{$context->{voip_numbers}->{other}}, $voip_number); - push(@voip_number_ids, $voip_number->{id}); - - my $alias; - if ($alias = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::findby_subscriberid_username($context->{db}, - $context->{prov_subscriber}->{id}, - $number->{number}, - )->[0]) { - NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::update_row($context->{db},{ - id => $alias->{id}, - is_primary => '0', - }); - $alias->{is_primary} = '0'; - } else { - $alias->{id} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::insert_row($context->{db},{ - domain_id => $context->{prov_subscriber}->{domain_id}, - subscriber_id => $context->{prov_subscriber}->{id}, - is_primary => '0', - username => $number->{number}, - }); - } - - push(@{$context->{aliases}->{other}},$alias); - push(@usernames,$number->{number}); - - delete_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{allowed_clis}, - $number->{number}); - push(@{$context->{usr_preferences}->{allowed_clis}},{ id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{allowed_clis}, - $number->{number}), value => $number->{number}}); - - _info($context,"alias $number->{number} created",1); - } - - push(@voip_number_ids,$context->{voip_numbers}->{primary}->{id}); - push(@usernames,$context->{numbers}->{primary}->{number}); - - NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers::release_subscriber_numbers($context->{db}, - $context->{bill_subscriber}->{id},{ 'NOT IN' => \@voip_number_ids }); - - NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::delete_dbaliases($context->{db},$context->{prov_subscriber}->{id}, - { 'NOT IN' => \@usernames }); - - clear_subscriber_preferences($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{allowed_clis}, - \@usernames ); - - #test: - #my $allowed_clis = get_subscriber_preference($context, - # $context->{prov_subscriber}->{id}, - # $context->{attributes}->{allowed_clis}); - - #my $voip_numbers = NGCP::BulkProcessor::Dao::Trunk::billing::voip_numbers::findby_subscriberid($context->{db}, - # $context->{bill_subscriber}->{id}); - - #my $aliases = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_dbaliases::findby_subscriberid_username($context->{db}, - # $context->{prov_subscriber}->{id},undef); - - #_info($context,(scalar @{$context->{numbers}->{other}}) . " aliases created: " . join(',',(map { $_->{number}; } @{$context->{numbers}->{other}}))); - } - return $result; -} - -sub _provision_mta_susbcriber_init_context { - - my ($context,$subscriber_group) = @_; - - my $result = 1; - - $context->{log_info} = []; - $context->{log_warning} = []; - $context->{log_error} = []; - - my $first = $subscriber_group->[0]; - - unless (defined $first->{sip_username} and length($first->{sip_username}) > 0) { - _warn($context,'empty sip_username ignored'); - $result = 0; - } - - $context->{domain} = $context->{domain_map}->{$first->{domain}}; - my $resellername = _apply_reseller_mapping($first->{reseller_name}); - $context->{reseller} = $context->{reseller_map}->{$first->{reseller_name}}; - $context->{billing_profile} = $context->{reseller}->{billingprofile_map}->{$first->{billing_profile_name}}; - - $context->{prov_subscriber} = {}; - $context->{prov_subscriber}->{username} = $first->{sip_username}; - $context->{prov_subscriber}->{password} = $first->{sip_password}; - $context->{prov_subscriber}->{webusername} = $first->{web_username}; - $context->{prov_subscriber}->{webpassword} = $first->{web_password}; - my $webusername = $first->{web_username}; - - $context->{prov_subscriber}->{uuid} = create_uuid(); - $context->{prov_subscriber}->{domain_id} = $context->{domain}->{prov_domain}->{id}; - - $context->{bill_subscriber} = {}; - $context->{bill_subscriber}->{username} = $first->{sip_username}; - $context->{bill_subscriber}->{domain_id} = $context->{domain}->{id}; - $context->{bill_subscriber}->{uuid} = $context->{prov_subscriber}->{uuid}; - - undef $context->{contract}; - #undef $context->{channels}; - - my @numbers = (); - my %number_dupes = (); - my %contract_dupes = (); - my %barrings = (); - #my $voicemail = 0; - foreach my $subscriber (@$subscriber_group) { - my $number = $subscriber->{cc} . $subscriber->{ac} . $subscriber->{sn}; - if (not exists $number_dupes{$number}) { - push(@numbers,{ - cc => $subscriber->{cc}, - ac => $subscriber->{ac}, - sn => $subscriber->{sn}, - number => $number, - #delta => $subscriber->{delta}, - additional => 0, - filename => $subscriber->{filename}, - }); - $number_dupes{$number} = 1; - } else { - _warn($context,"duplicate number $number ($subscriber->{filename}) ignored"); - } - - if (not exists $contract_dupes{$subscriber->{customer_id}}) { - if (not $context->{contract}) { - $context->{contract} = { - external_id => $subscriber->{customer_id}, - create_timestamp => $context->{now}, - product_id => $context->{sip_account_product}->{id}, - contact => { - reseller_id => $context->{reseller}->{id}, - - firstname => $subscriber->{first_name}, - lastname => $subscriber->{last_name}, - compregnum => $subscriber->{company_registration_number}, - company => $subscriber->{company}, - street => $subscriber->{street}, - postcode => $subscriber->{postal_code}, - city => $subscriber->{city_name}, - #country => $context->{contract}->{contact}->{country}, - phonenumber => $subscriber->{phone_number}, - email => $subscriber->{email}, - vatnum => $subscriber->{vat_number}, - #$contact_hash_field => $subscriber->{contact_hash}, - }, - }; - $contract_dupes{$subscriber->{customer_id}} = 1; - } else { - _warn($context,'non-unique contact data, skipped'); - $context->{nonunique_contacts}->{$context->{prov_subscriber}->{username}} += 1; - $result = 0; - } - } - - unless (defined $context->{prov_subscriber}->{password} and length($context->{prov_subscriber}->{password}) > 0) { - $context->{prov_subscriber}->{password} = $subscriber->{sip_password}; - } - - unless (defined $context->{prov_subscriber}->{webusername} and length($context->{prov_subscriber}->{webusername}) > 0 - and defined $context->{prov_subscriber}->{webpassword} and length($context->{prov_subscriber}->{webpassword}) > 0) { - $context->{prov_subscriber}->{webusername} = $subscriber->{web_username}; - $context->{prov_subscriber}->{webpassword} = $subscriber->{web_password}; - } - - unless (defined $webusername and length($webusername) > 0) { - $webusername = $subscriber->{web_username}; - } - - if (defined $subscriber->{barrings} and length($subscriber->{barrings}) > 0) { - $barrings{$subscriber->{barrings}} = 1; - } - - } - - unless (defined $context->{prov_subscriber}->{password} and length($context->{prov_subscriber}->{password}) > 0) { - my $generated = _generate_sippassword($mta_sippassword_length); - $context->{prov_subscriber}->{password} = $generated; - _info($context,"empty sip_password, using generated '$generated'",1); - } - - unless (defined $context->{prov_subscriber}->{webusername} and length($context->{prov_subscriber}->{webusername}) > 0) { - $context->{prov_subscriber}->{webusername} = $webusername; - $context->{prov_subscriber}->{webpassword} = undef; - } - - if (not (defined $context->{prov_subscriber}->{webusername} and length($context->{prov_subscriber}->{webusername}) > 0)) { - $context->{prov_subscriber}->{webusername} = undef; - $context->{prov_subscriber}->{webpassword} = undef; - _info($context,"empty web_username for sip_username '$first->{sip_username}'",1); - } else { - $webusername = $context->{prov_subscriber}->{webusername}; - my %webusername_dupes = map { $_->{sip_username} => 1; } - @{NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::Subscriber::findby_domain_webusername( - $first->{domain},$webusername)}; - if ((scalar keys %webusername_dupes) > 1) { - my $generated = _generate_webusername($mta_webusername_length); #$first->{sip_username}; - _info($context,"duplicate web_username '$webusername', using generated '$generated'",1); - $context->{prov_subscriber}->{webusername} = $generated; - } - - #$context->{prov_subscriber}->{webpassword} = $first->{web_password}; - if (not (defined $context->{prov_subscriber}->{webpassword} and length($context->{prov_subscriber}->{webpassword}) > 0)) { - my $generated = _generate_webpassword($mta_webpassword_length); - _info($context,"empty web_password for web_username '$webusername', using generated '$generated'",1); - $context->{prov_subscriber}->{webpassword} = $generated; - #} elsif (defined $first->{web_password} and length($first->{web_password}) < 8) { - # $context->{prov_subscriber}->{webpassword} = _generate_webpassword(); - # _info($context,"web_password for web_username '$first->{web_username}' is too short, using '$context->{prov_subscriber}->{webpassword}'"); - } - } - - $context->{ncos_level} = undef; - if ((scalar keys %barrings) > 1) { - my $combined_barring = join('_',sort keys %barrings); - #$result &= - _check_ncos_level($context,$resellername,$combined_barring); - _info($context,"barrings combination $combined_barring"); - $context->{ncos_level} = $context->{ncos_level_map}->{$context->{reseller}->{id}}->{$combined_barring}; - } elsif ((scalar keys %barrings) == 1) { - my ($barring) = keys %barrings; - $context->{ncos_level} = $context->{ncos_level_map}->{$context->{reseller}->{id}}->{$barring}; - } else { - if (exists $context->{ncos_level_map}->{$context->{reseller}->{id}}->{$default_barring}) { - $context->{ncos_level} = $context->{ncos_level_map}->{$context->{reseller}->{id}}->{$default_barring}; - _info($context,"no ncos level, using default '$context->{ncos_level}->{level}'",1); - } - } - - $context->{numbers} = {}; - $context->{numbers}->{other} = sort_by_configs(\@numbers,[ - { numeric => 1, - dir => 1, #-1, - memberchain => [ 'additional' ], - }, - { numeric => 0, - dir => 1, #-1, - memberchain => [ 'cc' ], - }, - { numeric => 0, - dir => 1, #-1, - memberchain => [ 'ac' ], - }, - { numeric => 0, - dir => 1, #-1, - memberchain => [ 'sn' ], - }, - ]); - $context->{numbers}->{primary} = shift(@{$context->{numbers}->{other}}); - #return 0 unless scalar @{$context->{numbers}->{other}}; - - $context->{voip_numbers} = {}; - $context->{voip_numbers}->{primary} = undef; - $context->{voip_numbers}->{other} = []; - $context->{aliases} = {}; - $context->{aliases}->{primary} = undef; - $context->{aliases}->{other} = []; - - $context->{voicemail_user} = {}; - $context->{voicemail_user}->{customer_id} = $context->{prov_subscriber}->{uuid}; - $context->{voicemail_user}->{mailbox} = $context->{numbers}->{primary}->{number}; - $context->{voicemail_user}->{password} = sprintf("%04d", int(rand 10000)); - - $context->{usr_preferences} = {}; - - $context->{usr_preferences}->{gpp} = [ - $first->{"_len"}, - $first->{"_cpe_mta_mac_address"}, - $first->{"_cpe_model"}, - $first->{"_cpe_vendor"}, - ]; - - return $result; - -} - - -sub _generate_webpassword { - my $webpassword_length = shift; - return String::MkPasswd::mkpasswd( - -length => $webpassword_length, - -minnum => 1, -minlower => 1, -minupper => 1, -minspecial => 1, - -distribute => 1, -fatal => 1, - ); -} - -sub _generate_sippassword { - my $sippassword_length = shift; - return createtmpstring($sippassword_length); -} - -sub _generate_webusername { - my $webusername_length = shift; - return createtmpstring($webusername_length); -} - -sub _apply_reseller_mapping { - my $reseller_name = shift; - #if (defined $reseller_name and exists $reseller_mapping->{$reseller_name}) { - # return $reseller_mapping->{$reseller_name}; - #} - return $reseller_name; -} - - - - -sub provision_ccs_subscribers { - - my $update_mode = shift; - - my $static_context = { now => timestamp(), _rowcount => undef }; - my $result = _provision_ccs_subscribers_checks($static_context); - - destroy_all_dbs(); - my $warning_count :shared = 0; - return ($result && NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::process_records( - static_context => $static_context, - process_code => sub { - my ($context,$records,$row_offset) = @_; - ping_all_dbs(); - $context->{_rowcount} = $row_offset; - my @report_data = (); - foreach my $switch_number (@$records) { - $context->{_rowcount} += 1; - next unless _provision_ccs_susbcriber($context, - NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::findby_switch_number(@$switch_number), - $update_mode); - push(@report_data,_get_report_obj($context)); - } - #cleanup_aig_sequence_ids($context); - if (defined $report_filename) { - lock $file_lock; - open(my $fh, '>>', $report_filename) or fileerror('cannot open file ' . $report_filename . ': ' . $!,getlogger(__PACKAGE__)); - binmode($fh); - print $fh JSON::to_json(\@report_data,{ allow_nonref => 1, allow_blessed => 1, convert_blessed => 1, pretty => 1, }); - close $fh; - } - return 1; - }, - init_process_context_code => sub { - my ($context)= @_; - $context->{db} = &get_xa_db(); - $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}; - } - }, - load_recursive => 0, - multithreading => $provision_ccs_subscriber_multithreading, - numofthreads => $provision_ccs_subscriber_numofthreads, - ),$warning_count); - -} - -sub _provision_ccs_susbcriber { - - my ($context,$subscriber_group,$update_mode) = @_; - - return 0 unless _provision_ccs_susbcriber_init_context($context,$subscriber_group); - - eval { - lock $db_lock; - $context->{db}->db_begin(); - #_warn($context,'AutoCommit is on') if $context->{db}->{drh}->{AutoCommit}; - - my $existing_billing_voip_subscribers = NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers::findby_domainid_username_states( - $context->{db}, - $context->{domain}->{id}, - $context->{prov_subscriber}->{username}, - { 'NOT IN' => $NGCP::BulkProcessor::Dao::Trunk::billing::voip_subscribers::TERMINATED_STATE} - ); - - if ((scalar @$existing_billing_voip_subscribers) == 0) { - - if (not $update_mode) { - _update_ccs_contact($context); - _update_contract($context); - _update_subscriber($context); - _create_aliases($context); - _update_ccs_preferences($context); - _set_registrations($context); - _set_callforwards($context); - } else { - _warn($context,$context->{prov_subscriber}->{username} . ': no active billing subscribers found for updating, skipping'); - } - - } elsif ((scalar @$existing_billing_voip_subscribers) == 1) { - $context->{bill_subscriber} = $existing_billing_voip_subscribers->[0]; - $context->{prov_subscriber} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_subscribers::findby_uuid( - $context->{db},$context->{bill_subscriber}->{uuid}); - if (defined $context->{prov_subscriber}) { - if ($update_mode eq $UPDATE_CCS_PREFERENCES_MODE) { - _update_ccs_preferences($context); - } elsif ($update_mode eq $SET_CCS_CF_MODE) { - _set_callforwards($context); - } elsif ($update_mode eq $CLEAR_CCS_CF_MODE) { - _set_callforwards($context,1); - } else { - _warn($context,$context->{prov_subscriber}->{username} . ': ' . (scalar @$existing_billing_voip_subscribers) . ' existing billing subscribers found, skipping'); - } - } else { - _warn($context,$context->{prov_subscriber}->{username} . ': no provisioning subscribers found for updating, skipping'); - } - } else { - _warn($context,$context->{prov_subscriber}->{username} . ': ' . (scalar @$existing_billing_voip_subscribers) . ' existing billing subscribers found, skipping'); - } - - if ($dry) { - $context->{db}->db_rollback(0); - } else { - $context->{db}->db_commit(); - } - - }; - my $err = $@; - if ($err) { - eval { - $context->{db}->db_rollback(1); - }; - if ($skip_errors) { - _warn($context, $err); - } else { - _error($context, $err); - } - } - - return 1; - -} - -sub _provision_ccs_subscribers_checks { - my ($context) = @_; - - my $result = 1; - - my $subscribercount = 0; - eval { - $subscribercount = NGCP::BulkProcessor::Projects::Migration::UPCAT::Dao::import::CcsSubscriber::countby_service_number(); - }; - if ($@ or $subscribercount == 0) { - rowprocessingerror(threadid(),'please import ccs subscribers first',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"$subscribercount ccs subscribers found",getlogger(__PACKAGE__)); - } - - eval { - $context->{reseller} = NGCP::BulkProcessor::Dao::Trunk::billing::resellers::findby_name($ccs_reseller_name); - }; - if ($@ or not defined $context->{reseller}) { - rowprocessingerror(threadid(),"cannot find reseller '$ccs_reseller_name'",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"reseller '$ccs_reseller_name' found",getlogger(__PACKAGE__)); - eval { - $context->{domain} = NGCP::BulkProcessor::Dao::Trunk::billing::domains::findby_domain($ccs_domain); - if (defined $context->{domain} - and NGCP::BulkProcessor::Dao::Trunk::billing::domain_resellers::countby_domainid_resellerid($context->{domain}->{id},$context->{reseller}->{id}) == 0) { - undef $context->{domain}; - } - }; - if ($@ or not defined $context->{domain}) { - rowprocessingerror(threadid(),"cannot find billing domain '$ccs_domain' (of reseller '$ccs_reseller_name')",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - - processing_info(threadid(),"billing domain '$ccs_domain' (of reseller '$ccs_reseller_name') found",getlogger(__PACKAGE__)); - eval { - $context->{domain}->{prov_domain} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_domains::findby_domain($ccs_domain); - }; - if ($@ or not defined $context->{domain}->{prov_domain}) { - rowprocessingerror(threadid(),"cannot find provisioning domain '$ccs_domain'",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"provisioning domain '$ccs_domain' found",getlogger(__PACKAGE__)); - } - - } - - eval { - my $billing_profiles = NGCP::BulkProcessor::Dao::Trunk::billing::billing_profiles::findby_resellerid_name_handle($context->{reseller}->{id},$ccs_billing_profile_name); - $context->{billing_profile} = $billing_profiles->[0] if (scalar @$billing_profiles) == 1; - }; - if ($@ or not defined $context->{billing_profile}) { - rowprocessingerror(threadid(),"cannot find billing profile '$ccs_billing_profile_name' (of reseller '$ccs_reseller_name')",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"billing profile '$ccs_billing_profile_name' (of reseller '$ccs_reseller_name') found",getlogger(__PACKAGE__)); - } - - } - - eval { - $context->{pbx_account_product} = NGCP::BulkProcessor::Dao::Trunk::billing::products::findby_resellerid_handle(undef, - $NGCP::BulkProcessor::Dao::Trunk::billing::products::PBX_ACCOUNT_HANDLE)->[0]; - }; - if ($@ or not defined $context->{pbx_account_product}) { - rowprocessingerror(threadid(),"cannot find $NGCP::BulkProcessor::Dao::Trunk::billing::products::PBX_ACCOUNT_HANDLE product",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"$NGCP::BulkProcessor::Dao::Trunk::billing::products::PBX_ACCOUNT_HANDLE product found",getlogger(__PACKAGE__)); - } - - $result = _provision_subscribers_base_prefs_checks($context,$result); - - #extended_dialing_mode, e164_to_ruri and serial_forking_by_q_value - - eval { - $context->{attributes}->{extended_dialing_mode} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::EXTENDED_DIALING_MODE_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{extended_dialing_mode}) { - rowprocessingerror(threadid(),'cannot find extended_dialing_mode attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"extended_dialing_mode attribute found",getlogger(__PACKAGE__)); - } - - eval { - $context->{attributes}->{e164_to_ruri} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::E164_TO_RURI_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{e164_to_ruri}) { - rowprocessingerror(threadid(),'cannot find e164_to_ruri attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"e164_to_ruri attribute found",getlogger(__PACKAGE__)); - } - - eval { - $context->{attributes}->{serial_forking_by_q_value} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::SERIAL_FORKING_BY_Q_VALUE_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{serial_forking_by_q_value}) { - rowprocessingerror(threadid(),'cannot find serial_forking_by_q_value attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"serial_forking_by_q_value attribute found",getlogger(__PACKAGE__)); - } - - eval { - $context->{attributes}->{cloud_pbx} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::CLOUD_PBX_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{cloud_pbx}) { - rowprocessingerror(threadid(),'cannot find cloud_pbx attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"cloud_pbx attribute found",getlogger(__PACKAGE__)); - } - eval { - $context->{attributes}->{cloud_pbx_base_cli} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::CLOUD_PBX_BASE_CLI_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{cloud_pbx_base_cli}) { - rowprocessingerror(threadid(),'cannot find cloud_pbx_base_cli attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"cloud_pbx_base_cli attribute found",getlogger(__PACKAGE__)); - } - eval { - $context->{attributes}->{cloud_pbx_hunt_policy} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::CLOUD_PBX_HUNT_POLICY_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{cloud_pbx_hunt_policy}) { - rowprocessingerror(threadid(),'cannot find cloud_pbx_hunt_policy attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"cloud_pbx_hunt_policy attribute found",getlogger(__PACKAGE__)); - } - eval { - $context->{attributes}->{music_on_hold} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::MUSIC_ON_HOLD_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{music_on_hold}) { - rowprocessingerror(threadid(),'cannot find music_on_hold attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"music_on_hold attribute found",getlogger(__PACKAGE__)); - } - eval { - $context->{attributes}->{shared_buddylist_visibility} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::SHARED_BUDDYLIST_VISIBILITY_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{shared_buddylist_visibility}) { - rowprocessingerror(threadid(),'cannot find shared_buddylist_visibility attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"shared_buddylist_visibility attribute found",getlogger(__PACKAGE__)); - } - - foreach my $cf_attribute (@NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::CF_ATTRIBUTES) { - eval { - $context->{attributes}->{$cf_attribute} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute($cf_attribute); - }; - if ($@ or not defined $context->{attributes}->{$cf_attribute}) { - rowprocessingerror(threadid(),"cannot find $cf_attribute attribute",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"$cf_attribute attribute found",getlogger(__PACKAGE__)); - } - } - - eval { - $context->{attributes}->{ringtimeout} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::RINGTIMEOUT_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{ringtimeout}) { - rowprocessingerror(threadid(),'cannot find ringtimeout attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"ringtimeout attribute found",getlogger(__PACKAGE__)); - } - - foreach my $gpp_idx (0..9) { - my $gpp_attr = $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::GPPx_ATTRIBUTE . $gpp_idx; - eval { - $context->{attributes}->{$gpp_attr} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute($gpp_attr); - }; - if ($@ or not defined $context->{attributes}->{$gpp_attr}) { - rowprocessingerror(threadid(),"cannot find $gpp_attr attribute",getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"$gpp_attr attribute found",getlogger(__PACKAGE__)); - } - } - - return $result; -} - -sub _provision_subscribers_base_prefs_checks { - - my ($context,$result) = @_; - - $context->{attributes} = {}; - - eval { - $context->{attributes}->{allowed_clis} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::ALLOWED_CLIS_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{allowed_clis}) { - rowprocessingerror(threadid(),'cannot find allowed_clis attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"allowed_clis attribute found",getlogger(__PACKAGE__)); - } - - eval { - $context->{attributes}->{cli} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::CLI_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{cli}) { - rowprocessingerror(threadid(),'cannot find cli attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"cli attribute found",getlogger(__PACKAGE__)); - } - - eval { - $context->{attributes}->{ac} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::AC_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{ac}) { - rowprocessingerror(threadid(),'cannot find ac attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"ac attribute found",getlogger(__PACKAGE__)); - } - - eval { - $context->{attributes}->{cc} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::CC_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{cc}) { - rowprocessingerror(threadid(),'cannot find cc attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"cc attribute found",getlogger(__PACKAGE__)); - } - - eval { - $context->{attributes}->{account_id} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::findby_attribute( - $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_preferences::ACCOUNT_ID_ATTRIBUTE); - }; - if ($@ or not defined $context->{attributes}->{account_id}) { - rowprocessingerror(threadid(),'cannot find account_id attribute',getlogger(__PACKAGE__)); - $result = 0; #even in skip-error mode.. - } else { - processing_info(threadid(),"account_id attribute found",getlogger(__PACKAGE__)); - } - - return $result; - -} - -sub _provision_ccs_susbcriber_init_context { - - my ($context,$subscriber_group) = @_; - - my $result = 1; - - $context->{log_info} = []; - $context->{log_warning} = []; - $context->{log_error} = []; - - my $first = $subscriber_group->[0]; - - unless (defined $first->{switch_number} and length($first->{switch_number}) > 0) { - _warn($context,'empty switch_number ignored'); - $result = 0; - } - - $context->{numbers} = {}; - my $primary_number = {}; - ($primary_number->{cc},$primary_number->{ac},$primary_number->{sn}) = split_number($first->{switch_number}); - $primary_number->{number} = $primary_number->{cc} . $primary_number->{ac} . $primary_number->{sn}; - $context->{numbers}->{primary} = $primary_number; - my @service_numbers = (); - foreach my $subscriber (@$subscriber_group) { - $subscriber->{comment} = Encode::decode('utf8',$subscriber->{comment}) if defined $subscriber->{comment}; #mark as utf-8 - my $alias = {}; - ($alias->{cc},$alias->{ac},$alias->{sn}) = split_number($subscriber->{service_number}); - $alias->{number} = $alias->{cc} . $alias->{ac} . $alias->{sn}; - push(@service_numbers,$alias); - } - $context->{numbers}->{other} = \@service_numbers; - #should we skip if there are no service numbers? - if ((scalar @service_numbers) == 0) { - $result = 0; - } - - #$context->{domain} = ; - #$context->{reseller} = ; - #$context->{billing_profile} = ; - - $first->{sip_username} = $primary_number->{number}; - $first->{sip_password} = _generate_sippassword($ccs_sippassword_length); - $first->{web_username} = undef; - $first->{web_password} = undef; - - $context->{prov_subscriber} = {}; - $context->{prov_subscriber}->{username} = $first->{sip_username}; - $context->{prov_subscriber}->{password} = $first->{sip_password}; - $context->{prov_subscriber}->{webusername} = $first->{web_username}; - $context->{prov_subscriber}->{webpassword} = $first->{web_password}; - #my $webusername = $first->{web_username}; - $context->{prov_subscriber}->{is_pbx_pilot} = '1'; - - $context->{prov_subscriber}->{uuid} = create_uuid(); - $context->{prov_subscriber}->{domain_id} = $context->{domain}->{prov_domain}->{id}; - - $context->{bill_subscriber} = {}; - $context->{bill_subscriber}->{username} = $first->{sip_username}; - $context->{bill_subscriber}->{domain_id} = $context->{domain}->{id}; - $context->{bill_subscriber}->{uuid} = $context->{prov_subscriber}->{uuid}; - - $context->{contract} = { - #external_id => $first->{customer}, - create_timestamp => $context->{now}, - product_id => $context->{pbx_account_product}->{id}, - contact => { - reseller_id => $context->{reseller}->{id}, - - #firstname => $subscriber->{first_name}, - #lastname => $subscriber->{last_name}, - #compregnum => $subscriber->{company_registration_number}, - company => $first->{customer}, - #street => $subscriber->{street}, - #postcode => $subscriber->{postal_code}, - #city => $subscriber->{city_name}, - ##country => $context->{contract}->{contact}->{country}, - #phonenumber => $subscriber->{phone_number}, - #email => $subscriber->{email}, - #vatnum => $subscriber->{vat_number}, - ##$contact_hash_field => $subscriber->{contact_hash}, - - gpp0 => $first->{comment}, - - $ccs_contact_identifier_field => ($first->{customer} eq '???' ? $first->{customer} . '_' . $first->{switch_number} : $first->{customer}), - }, - }; - - $context->{voip_numbers} = {}; - $context->{voip_numbers}->{primary} = undef; - $context->{voip_numbers}->{other} = []; - $context->{aliases} = {}; - $context->{aliases}->{primary} = undef; - $context->{aliases}->{other} = []; - - $context->{voicemail_user} = {}; - $context->{voicemail_user}->{customer_id} = $context->{prov_subscriber}->{uuid}; - $context->{voicemail_user}->{mailbox} = $context->{numbers}->{primary}->{number}; - $context->{voicemail_user}->{password} = sprintf("%04d", int(rand 10000)); - - my @registrations = (); - my @trusted_sources = (); - my $q = 1.0; - foreach my $ip (@css_trusted_source_ips) { - push(@registrations,{ - q => $q, - username => $first->{sip_username}, - domain => $context->{domain}->{domain}, - contact => 'sip:' . $first->{sip_username} . '@' . $ip . ':5060', - ruid => NGCP::BulkProcessor::Dao::Trunk::kamailio::location::next_ruid(), - }); - $q = $q / 2.0; - push(@trusted_sources,{ - src_ip => $ip, - protocol => $NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_trusted_sources::PROTOCOL_ANY, - from_pattern => ('sip:' . quotemeta($first->{sip_username}) . '@' . quotemeta($context->{domain}->{domain})), - }); - } - $context->{registrations} = \@registrations; - $context->{trusted_sources} = \@trusted_sources; - - $context->{ringtimeout} = undef; - my %cfsimple = (); - my @callforwards = (); - push(@callforwards,{ - type => 'cfu', - destination => $first->{target_number}, - }) if exists $first->{target_number}; #$first->{routing_type} eq '1:1'; - if ((scalar @callforwards) > 0) { - my %vmcf = (); - my %maxpriority = (); - foreach my $callforward (@callforwards) { - my $type = lc($callforward->{type}); - if ($type =~ /$cf_types_pattern/) { - unless (defined $callforward->{destination} and length($callforward->{destination}) > 0) { - _warn($context,"empty callforward destination, ignoring"); - next; - } - if ($callforward->{destination} =~ /voicemail/i) { - $callforward->{destination} = 'sip:vm' . ('cfb' eq $type ? 'b' : 'u') . $context->{numbers}->{primary}->{number} . '@voicebox.local'; - $vmcf{$type} = 1 unless $vmcf{$type}; - } elsif ($callforward->{destination} !~ /^\d+$/i) { - _warn($context,"invalid callforward destination '$callforward->{destination}', ignoring"); - next; - } else { #todo: allow sip uri destinations - $callforward->{destination} = 'sip:' . $callforward->{destination} .'@' . $context->{domain}->{domain}; - } - $callforward->{priority} //= $cf_default_priority; - $callforward->{timeout} //= $cf_default_timeout; - $callforward->{ringtimeout} //= $cft_default_ringtimeout if 'cft' eq $type; - $context->{ringtimeout} = $callforward->{ringtimeout} if ('cft' eq $type and (not defined $context->{ringtimeout} or $callforward->{ringtimeout} > $context->{ringtimeout})); - - $cfsimple{$type} = [] unless exists $cfsimple{$type}; - push(@{$cfsimple{$type}},{ - destination => $callforward->{destination}, - priority => $callforward->{priority}, - timeout => $callforward->{timeout}, - }); - #$vmcf{$type} = ($callforward->{destination} =~ /voicemail/i) unless $vmcf{$type}; - $maxpriority{$type} = $callforward->{priority} if (not defined $maxpriority{$type} or $callforward->{priority} > $maxpriority{$type}); - } else { - _warn($context,"invalid callforward type '$type', ignoring"); - } - } - } - $context->{callforwards} = \%cfsimple; - - $context->{usr_preferences} = {}; - - $context->{usr_preferences}->{gpp} = [ - undef, - _get_encoded_username($first->{sip_username} . '@' . $context->{domain}->{domain}), - ]; - - $context->{contract_preferences} = {}; - - return $result; - -} - -sub _update_ccs_contact { - - my ($context) = @_; - - my $existing_contacts = NGCP::BulkProcessor::Dao::Trunk::billing::contacts::findby_reselleridfields( - $context->{reseller}->{id}, - { $ccs_contact_identifier_field => $context->{contract}->{contact}->{$ccs_contact_identifier_field} }, - ); - if ((scalar @$existing_contacts) == 0) { - $context->{contract}->{contact}->{id} = NGCP::BulkProcessor::Dao::Trunk::billing::contacts::insert_row($context->{db}, - $context->{contract}->{contact}, - ); - $context->{contract}->{contact_id} = $context->{contract}->{contact}->{id}; - _info($context,"contact id $context->{contract}->{contact}->{id} created",1); - } else { - my $existing_contact = $existing_contacts->[0]; - if ((scalar @$existing_contacts) > 1) { - _warn($context,(scalar @$existing_contacts) . " existing contacts found, using first contact id $existing_contact->{id}"); - } else { - _info($context,"existing contact id $existing_contact->{id} found",1); - } - $context->{contract}->{contact}->{id} = $existing_contact->{id}; - $context->{contract}->{contact_id} = $context->{contract}->{contact}->{id}; - - } - $context->{contract}->{contact_id} = $context->{contract}->{contact}->{id}; - - return 1; - -} - -sub _update_ccs_preferences { - - my ($context) = @_; - - my $result = 1; - - $context->{usr_preferences}->{extended_dialing_mode} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{extended_dialing_mode}, - 'extended_send_dialed'), value => 'extended_send_dialed' }; - - $context->{usr_preferences}->{e164_to_ruri} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{e164_to_ruri}, - '1'), value => '1' }; - - $context->{usr_preferences}->{serial_forking_by_q_value} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{serial_forking_by_q_value}, - '1'), value => '1' }; - - if (defined $context->{usr_preferences}->{gpp}) { - my $gpp_idx = 0; - foreach my $gpp_val (@{$context->{usr_preferences}->{gpp}}) { - my $gpp_attr = 'gpp' . $gpp_idx; - $gpp_idx++; - next unless defined $gpp_val; - $context->{usr_preferences}->{$gpp_attr} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{$gpp_attr}, - $gpp_val), value => $gpp_val }; - _info($context,"$gpp_attr preference set to $gpp_val",1); - } - } - - $context->{usr_preferences}->{cloud_pbx} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{cloud_pbx}, - '1'), value => '1' }; - - $context->{usr_preferences}->{cloud_pbx_base_cli} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{cloud_pbx_base_cli}, - $context->{numbers}->{primary}->{number}), value => $context->{numbers}->{primary}->{number} }; - - $context->{usr_preferences}->{cloud_pbx_hunt_policy} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{cloud_pbx_hunt_policy}, - 'serial'), value => 'serial' }; - - #contract_sound_set = 25 - - $context->{usr_preferences}->{music_on_hold} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{music_on_hold}, - '1'), value => '1' }; - - $context->{usr_preferences}->{shared_buddylist_visibility} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{shared_buddylist_visibility}, - '1'), value => '1' }; - - clear_contract_preferences($context, - $context->{prov_subscriber}->{account_id}, - $context->{attributes}->{allowed_clis}, - undef, - ); - - my @allowed_clis = (); - push(@allowed_clis,{ id => set_contract_preference($context, - $context->{prov_subscriber}->{account_id}, - $context->{attributes}->{allowed_clis}, - "*"), value => "*"}); - $context->{contract_preferences}->{allowed_clis} = \@allowed_clis; - - return $result; - -} - -sub _set_registrations { - - my ($context) = @_; - my $result = 1; - foreach my $registration (@{$context->{registrations}}) { - #print "blah"; - $registration->{id} = NGCP::BulkProcessor::Dao::Trunk::kamailio::location::insert_row($context->{db}, - %$registration); - _info($context,"permanent registration $registration->{contact} added",1); - } - foreach my $trusted_source (@{$context->{trusted_sources}}) { - #print "blah"; - $trusted_source->{id} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_trusted_sources::insert_row($context->{db},{ - %$trusted_source, - subscriber_id => $context->{prov_subscriber}->{id}, - uuid => $context->{prov_subscriber}->{uuid}, - }); - _info($context,"trusted source $trusted_source->{protocol} $trusted_source->{src_ip} from $trusted_source->{from_pattern} added",1); - } - return $result; - -} - -sub _set_callforwards { - - my ($context,$clear) = @_; - my $result = 1; - foreach my $type (keys %{$context->{callforwards}}) { - _info($context,"$type deleted",1) - if NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_mappings::delete_cfmappings($context->{db}, - $context->{prov_subscriber}->{id},{ '=' => $type }); - if ($clear) { - clear_subscriber_preferences($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{$type}, - undef, - ); - } else { - my $destination_set_id = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_destination_sets::insert_row($context->{db},{ - subscriber_id => $context->{prov_subscriber}->{id}, - name => "quickset_$type", - }); - foreach my $callforward (@{$context->{callforwards}->{$type}}) { - $callforward->{id} = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_destinations::insert_row($context->{db},{ - %$callforward, - destination_set_id => $destination_set_id, - }); - } - my $cf_mapping_id = NGCP::BulkProcessor::Dao::Trunk::provisioning::voip_cf_mappings::insert_row($context->{db},{ - subscriber_id => $context->{prov_subscriber}->{id}, - type => $type, - destination_set_id => $destination_set_id, - #time_set_id - }); - - $context->{usr_preferences}->{$type} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{$type}, - $cf_mapping_id), value => $cf_mapping_id }; - - if (defined $context->{ringtimeout}) { - $context->{usr_preferences}->{ringtimeout} = { id => set_subscriber_preference($context, - $context->{prov_subscriber}->{id}, - $context->{attributes}->{ringtimeout}, - $context->{ringtimeout}), value => $context->{ringtimeout} }; - } - _info($context,"$type created (destination(s) " . join(', ',(map { $_->{destination}; } @{$context->{callforwards}->{$type}})) . ")",1); - - $context->{callforwards}->{$type} = { - destination_set => { - destinations => $context->{callforwards}->{$type}, - id => $destination_set_id, - }, - id => $cf_mapping_id, - }; - } - } - return $result; - -} - -sub _get_encoded_username { - - my ($ud) = @_; - - my $packed = pack('CCC C a*', 0, 0x45, 0x80, length($ud), $ud); - - my $checksum = 0; - for my $c (map {ord $_} split(//, $packed)) { - $checksum ^= $c; - } - - $packed .= pack('C', $checksum); - - return uc(unpack('H*', $packed)); - -} - -sub _error { - - my ($context,$message) = @_; - $context->{error_count} = $context->{error_count} + 1; - push(@{$context->{log_error}},$message) if exists $context->{log_error}; - if ($context->{prov_subscriber}) { - $message = ($context->{prov_subscriber}->{username} ? $context->{prov_subscriber}->{username} : '') . ': ' . $message; - } - rowprocessingerror($context->{tid},$message,getlogger(__PACKAGE__)); - -} - -sub _warn { - - my ($context,$message) = @_; - $context->{warning_count} = $context->{warning_count} + 1; - push(@{$context->{log_warning}},$message) if exists $context->{log_warning}; - if ($context->{prov_subscriber}) { - $message = ($context->{prov_subscriber}->{username} ? $context->{prov_subscriber}->{username} : '') . ': ' . $message; - } - rowprocessingwarn($context->{tid},$message,getlogger(__PACKAGE__)); - -} - -sub _info { - - my ($context,$message,$debug) = @_; - push(@{$context->{log_info}},$message) if exists $context->{log_info}; - if ($context->{prov_subscriber}) { - $message = ($context->{prov_subscriber}->{username} ? $context->{prov_subscriber}->{username} : '') . ': ' . $message; - } - if ($debug) { - processing_debug($context->{tid},$message,getlogger(__PACKAGE__)); - } else { - processing_info($context->{tid},$message,getlogger(__PACKAGE__)); - } -} - -1; diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Settings.pm b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Settings.pm deleted file mode 100644 index a24184fa..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/Settings.pm +++ /dev/null @@ -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; diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/barring_profiles.yml b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/barring_profiles.yml deleted file mode 100644 index 8a157ccd..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/barring_profiles.yml +++ /dev/null @@ -1,2 +0,0 @@ -UPC: - default: '0' diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/cc_ac.yml b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/cc_ac.yml deleted file mode 100644 index a3f271b3..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/cc_ac.yml +++ /dev/null @@ -1,1070 +0,0 @@ -43: - 1: 1 - 2142: 1 - 2143: 1 - 2144: 1 - 2145: 1 - 2146: 1 - 2147: 1 - 2160: 1 - 2162: 1 - 2163: 1 - 2164: 1 - 2165: 1 - 2166: 1 - 2167: 1 - 2168: 1 - 2169: 1 - 2172: 1 - 2173: 1 - 2174: 1 - 2175: 1 - 2176: 1 - 2177: 1 - 2212: 1 - 2213: 1 - 2214: 1 - 2215: 1 - 2216: 1 - 2230: 1 - 2231: 1 - 2232: 1 - 2233: 1 - 2234: 1 - 2235: 1 - 2236: 1 - 2237: 1 - 2238: 1 - 2239: 1 - 2242: 1 - 2243: 1 - 2244: 1 - 2245: 1 - 2246: 1 - 2247: 1 - 2248: 1 - 2249: 1 - 2252: 1 - 2253: 1 - 2254: 1 - 2255: 1 - 2256: 1 - 2257: 1 - 2258: 1 - 2259: 1 - 2262: 1 - 2263: 1 - 2264: 1 - 2265: 1 - 2266: 1 - 2267: 1 - 2268: 1 - 2269: 1 - 2271: 1 - 2272: 1 - 2273: 1 - 2274: 1 - 2275: 1 - 2276: 1 - 2277: 1 - 2278: 1 - 2279: 1 - 2282: 1 - 2283: 1 - 2284: 1 - 2285: 1 - 2286: 1 - 2287: 1 - 2288: 1 - 2289: 1 - 2522: 1 - 2523: 1 - 2524: 1 - 2525: 1 - 2526: 1 - 2527: 1 - 2532: 1 - 2533: 1 - 2534: 1 - 2535: 1 - 2536: 1 - 2538: 1 - 2552: 1 - 2554: 1 - 2555: 1 - 2556: 1 - 2557: 1 - 2572: 1 - 2573: 1 - 2574: 1 - 2575: 1 - 2576: 1 - 2577: 1 - 2610: 1 - 2611: 1 - 2612: 1 - 2613: 1 - 2614: 1 - 2615: 1 - 2616: 1 - 2617: 1 - 2618: 1 - 2619: 1 - 2620: 1 - 2621: 1 - 2622: 1 - 2623: 1 - 2624: 1 - 2625: 1 - 2626: 1 - 2627: 1 - 2628: 1 - 2629: 1 - 2630: 1 - 2631: 1 - 2632: 1 - 2633: 1 - 2634: 1 - 2635: 1 - 2636: 1 - 2637: 1 - 2638: 1 - 2639: 1 - 2641: 1 - 2642: 1 - 2643: 1 - 2644: 1 - 2645: 1 - 2646: 1 - 2647: 1 - 2648: 1 - 2649: 1 - 2662: 1 - 2663: 1 - 2664: 1 - 2665: 1 - 2666: 1 - 2667: 1 - 2672: 1 - 2673: 1 - 2674: 1 - 2680: 1 - 2682: 1 - 2683: 1 - 2684: 1 - 2685: 1 - 2686: 1 - 2687: 1 - 2688: 1 - 2689: 1 - 2711: 1 - 2712: 1 - 2713: 1 - 2714: 1 - 2715: 1 - 2716: 1 - 2717: 1 - 2718: 1 - 2719: 1 - 2722: 1 - 2723: 1 - 2724: 1 - 2725: 1 - 2726: 1 - 2728: 1 - 2731: 1 - 2732: 1 - 2733: 1 - 2734: 1 - 2735: 1 - 2736: 1 - 2738: 1 - 2739: 1 - 2741: 1 - 2742: 1 - 2743: 1 - 2744: 1 - 2745: 1 - 2746: 1 - 2747: 1 - 2748: 1 - 2749: 1 - 2752: 1 - 2753: 1 - 2754: 1 - 2755: 1 - 2756: 1 - 2757: 1 - 2758: 1 - 2762: 1 - 2763: 1 - 2764: 1 - 2765: 1 - 2766: 1 - 2767: 1 - 2768: 1 - 2769: 1 - 2772: 1 - 2773: 1 - 2774: 1 - 2782: 1 - 2783: 1 - 2784: 1 - 2786: 1 - 2812: 1 - 2813: 1 - 2814: 1 - 2815: 1 - 2816: 1 - 2822: 1 - 2823: 1 - 2824: 1 - 2825: 1 - 2826: 1 - 2827: 1 - 2828: 1 - 2829: 1 - 2841: 1 - 2842: 1 - 2843: 1 - 2844: 1 - 2845: 1 - 2846: 1 - 2847: 1 - 2848: 1 - 2849: 1 - 2852: 1 - 2853: 1 - 2854: 1 - 2855: 1 - 2856: 1 - 2857: 1 - 2858: 1 - 2859: 1 - 2862: 1 - 2863: 1 - 2864: 1 - 2865: 1 - 2872: 1 - 2873: 1 - 2874: 1 - 2875: 1 - 2876: 1 - 2877: 1 - 2878: 1 - 2912: 1 - 2913: 1 - 2914: 1 - 2915: 1 - 2916: 1 - 2942: 1 - 2943: 1 - 2944: 1 - 2945: 1 - 2946: 1 - 2947: 1 - 2948: 1 - 2949: 1 - 2951: 1 - 2952: 1 - 2953: 1 - 2954: 1 - 2955: 1 - 2956: 1 - 2957: 1 - 2958: 1 - 2959: 1 - 2982: 1 - 2983: 1 - 2984: 1 - 2985: 1 - 2986: 1 - 2987: 1 - 2988: 1 - 2989: 1 - 3112: 1 - 3113: 1 - 3114: 1 - 3115: 1 - 3116: 1 - 3117: 1 - 3118: 1 - 3119: 1 - 3123: 1 - 3124: 1 - 3125: 1 - 3126: 1 - 3127: 1 - 3132: 1 - 3133: 1 - 3134: 1 - 3135: 1 - 3136: 1 - 3137: 1 - 3140: 1 - 3141: 1 - 3142: 1 - 3143: 1 - 3144: 1 - 3145: 1 - 3146: 1 - 3147: 1 - 3148: 1 - 3149: 1 - 3150: 1 - 3151: 1 - 3152: 1 - 3153: 1 - 3155: 1 - 3157: 1 - 3158: 1 - 3159: 1 - 316: 1 - 3170: 1 - 3171: 1 - 3172: 1 - 3173: 1 - 3174: 1 - 3175: 1 - 3176: 1 - 3177: 1 - 3178: 1 - 3179: 1 - 3182: 1 - 3183: 1 - 3184: 1 - 3185: 1 - 3322: 1 - 3323: 1 - 3324: 1 - 3325: 1 - 3326: 1 - 3327: 1 - 3328: 1 - 3329: 1 - 3331: 1 - 3332: 1 - 3333: 1 - 3334: 1 - 3335: 1 - 3336: 1 - 3337: 1 - 3338: 1 - 3339: 1 - 3352: 1 - 3353: 1 - 3354: 1 - 3355: 1 - 3356: 1 - 3357: 1 - 3358: 1 - 3359: 1 - 3362: 1 - 3363: 1 - 3364: 1 - 3365: 1 - 3366: 1 - 3382: 1 - 3383: 1 - 3385: 1 - 3386: 1 - 3387: 1 - 3452: 1 - 3453: 1 - 3454: 1 - 3455: 1 - 3456: 1 - 3457: 1 - 3460: 1 - 3461: 1 - 3462: 1 - 3463: 1 - 3464: 1 - 3465: 1 - 3466: 1 - 3467: 1 - 3468: 1 - 3469: 1 - 3472: 1 - 3473: 1 - 3474: 1 - 3475: 1 - 3476: 1 - 3477: 1 - 3512: 1 - 3513: 1 - 3514: 1 - 3515: 1 - 3516: 1 - 3532: 1 - 3533: 1 - 3534: 1 - 3535: 1 - 3536: 1 - 3537: 1 - 3571: 1 - 3572: 1 - 3573: 1 - 3574: 1 - 3575: 1 - 3576: 1 - 3577: 1 - 3578: 1 - 3579: 1 - 3581: 1 - 3582: 1 - 3583: 1 - 3584: 1 - 3585: 1 - 3586: 1 - 3587: 1 - 3588: 1 - 3611: 1 - 3612: 1 - 3613: 1 - 3614: 1 - 3615: 1 - 3616: 1 - 3617: 1 - 3618: 1 - 3619: 1 - 3622: 1 - 3623: 1 - 3624: 1 - 3631: 1 - 3632: 1 - 3633: 1 - 3634: 1 - 3635: 1 - 3636: 1 - 3637: 1 - 3638: 1 - 3680: 1 - 3682: 1 - 3683: 1 - 3684: 1 - 3685: 1 - 3686: 1 - 3687: 1 - 3688: 1 - 3689: 1 - 3832: 1 - 3833: 1 - 3834: 1 - 3842: 1 - 3843: 1 - 3844: 1 - 3845: 1 - 3846: 1 - 3847: 1 - 3848: 1 - 3849: 1 - 3852: 1 - 3853: 1 - 3854: 1 - 3855: 1 - 3856: 1 - 3857: 1 - 3858: 1 - 3859: 1 - 3861: 1 - 3862: 1 - 3863: 1 - 3864: 1 - 3865: 1 - 3866: 1 - 3867: 1 - 3868: 1 - 3869: 1 - 3882: 1 - 3883: 1 - 3884: 1 - 3885: 1 - 3886: 1 - 4212: 1 - 4213: 1 - 4214: 1 - 4215: 1 - 4220: 1 - 4221: 1 - 4223: 1 - 4224: 1 - 4225: 1 - 4226: 1 - 4227: 1 - 4228: 1 - 4229: 1 - 4230: 1 - 4231: 1 - 4232: 1 - 4233: 1 - 4234: 1 - 4235: 1 - 4236: 1 - 4237: 1 - 4238: 1 - 4239: 1 - 4240: 1 - 4242: 1 - 4243: 1 - 4244: 1 - 4245: 1 - 4246: 1 - 4247: 1 - 4248: 1 - 4252: 1 - 4253: 1 - 4254: 1 - 4255: 1 - 4256: 1 - 4257: 1 - 4258: 1 - 4262: 1 - 4263: 1 - 4264: 1 - 4265: 1 - 4266: 1 - 4267: 1 - 4268: 1 - 4269: 1 - 4271: 1 - 4272: 1 - 4273: 1 - 4274: 1 - 4275: 1 - 4276: 1 - 4277: 1 - 4278: 1 - 4279: 1 - 4282: 1 - 4283: 1 - 4284: 1 - 4285: 1 - 4286: 1 - 4350: 1 - 4352: 1 - 4353: 1 - 4354: 1 - 4355: 1 - 4356: 1 - 4357: 1 - 4358: 1 - 4359: 1 - 463: 1 - 4710: 1 - 4712: 1 - 4713: 1 - 4714: 1 - 4715: 1 - 4716: 1 - 4717: 1 - 4718: 1 - 4732: 1 - 4733: 1 - 4734: 1 - 4735: 1 - 4736: 1 - 4761: 1 - 4762: 1 - 4766: 1 - 4767: 1 - 4768: 1 - 4769: 1 - 4782: 1 - 4783: 1 - 4784: 1 - 4785: 1 - 4822: 1 - 4823: 1 - 4824: 1 - 4825: 1 - 4826: 1 - 4842: 1 - 4843: 1 - 4846: 1 - 4847: 1 - 4848: 1 - 4852: 1 - 4853: 1 - 4855: 1 - 4858: 1 - 4872: 1 - 4873: 1 - 4874: 1 - 4875: 1 - 4876: 1 - 4877: 1 - 4879: 1 - 501: 1 - 502: 1 - 503: 1 - 504: 1 - 505: 1 - 506: 1 - 507: 1 - 508: 1 - 509: 1 - 512: 1 - 517: 1 - 5212: 1 - 5213: 1 - 5214: 1 - 5223: 1 - 5224: 1 - 5225: 1 - 5226: 1 - 5230: 1 - 5232: 1 - 5234: 1 - 5236: 1 - 5238: 1 - 5239: 1 - 5242: 1 - 5243: 1 - 5244: 1 - 5245: 1 - 5246: 1 - 5248: 1 - 5252: 1 - 5253: 1 - 5254: 1 - 5255: 1 - 5256: 1 - 5262: 1 - 5263: 1 - 5264: 1 - 5265: 1 - 5266: 1 - 5272: 1 - 5273: 1 - 5274: 1 - 5275: 1 - 5276: 1 - 5278: 1 - 5279: 1 - 5280: 1 - 5282: 1 - 5283: 1 - 5284: 1 - 5285: 1 - 5286: 1 - 5287: 1 - 5288: 1 - 5289: 1 - 5331: 1 - 5332: 1 - 5333: 1 - 5334: 1 - 5335: 1 - 5336: 1 - 5337: 1 - 5338: 1 - 5339: 1 - 5352: 1 - 5353: 1 - 5354: 1 - 5355: 1 - 5356: 1 - 5357: 1 - 5358: 1 - 5359: 1 - 5372: 1 - 5373: 1 - 5374: 1 - 5375: 1 - 5376: 1 - 5412: 1 - 5413: 1 - 5414: 1 - 5417: 1 - 5418: 1 - 5441: 1 - 5442: 1 - 5443: 1 - 5444: 1 - 5445: 1 - 5446: 1 - 5447: 1 - 5448: 1 - 5449: 1 - 5472: 1 - 5473: 1 - 5474: 1 - 5475: 1 - 5476: 1 - 5477: 1 - 5510: 1 - 5512: 1 - 5513: 1 - 5514: 1 - 5515: 1 - 5516: 1 - 5517: 1 - 5518: 1 - 5519: 1 - 5522: 1 - 5523: 1 - 5524: 1 - 5525: 1 - 5526: 1 - 5550: 1 - 5552: 1 - 5553: 1 - 5554: 1 - 5556: 1 - 5557: 1 - 5558: 1 - 5559: 1 - 5572: 1 - 5573: 1 - 5574: 1 - 5575: 1 - 5576: 1 - 5577: 1 - 5578: 1 - 5579: 1 - 5582: 1 - 5583: 1 - 5585: 1 - 5632: 1 - 5633: 1 - 5634: 1 - 5635: 1 - 5672: 1 - 5673: 1 - 5674: 1 - 5675: 1 - 5676: 1 - 5677: 1 - 5678: 1 - 57: 1 - 59: 1 - 6131: 1 - 6132: 1 - 6133: 1 - 6134: 1 - 6135: 1 - 6136: 1 - 6137: 1 - 6138: 1 - 6212: 1 - 6213: 1 - 6214: 1 - 6215: 1 - 6216: 1 - 6217: 1 - 6219: 1 - 6221: 1 - 6223: 1 - 6224: 1 - 6225: 1 - 6226: 1 - 6227: 1 - 6228: 1 - 6229: 1 - 6232: 1 - 6233: 1 - 6234: 1 - 6235: 1 - 6240: 1 - 6241: 1 - 6242: 1 - 6243: 1 - 6244: 1 - 6245: 1 - 6246: 1 - 6247: 1 - 6272: 1 - 6274: 1 - 6276: 1 - 6277: 1 - 6278: 1 - 6412: 1 - 6413: 1 - 6414: 1 - 6415: 1 - 6416: 1 - 6417: 1 - 6418: 1 - 6432: 1 - 6433: 1 - 6434: 1 - 6452: 1 - 6453: 1 - 6454: 1 - 6455: 1 - 6456: 1 - 6457: 1 - 6458: 1 - 6461: 1 - 6462: 1 - 6463: 1 - 6466: 1 - 6467: 1 - 6468: 1 - 6470: 1 - 6471: 1 - 6472: 1 - 6473: 1 - 6474: 1 - 6475: 1 - 6476: 1 - 6477: 1 - 6478: 1 - 6479: 1 - 6483: 1 - 6484: 1 - 650: 1 - 651: 1 - 652: 1 - 653: 1 - 6541: 1 - 6542: 1 - 6543: 1 - 6544: 1 - 6545: 1 - 6546: 1 - 6547: 1 - 6548: 1 - 6549: 1 - 655: 1 - 6562: 1 - 6563: 1 - 6564: 1 - 6565: 1 - 6566: 1 - 657: 1 - 6582: 1 - 6583: 1 - 6584: 1 - 6588: 1 - 6589: 1 - 659: 1 - 660: 1 - 661: 1 - 662: 1 - 663: 1 - 664: 1 - 665: 1 - 666: 1 - 667: 1 - 668: 1 - 669: 1 - 67: 1 - 68: 1 - 69: 1 - 711: 1 - 718: 1 - 720: 1 - 7211: 1 - 7212: 1 - 7213: 1 - 7214: 1 - 7215: 1 - 7216: 1 - 7217: 1 - 7218: 1 - 7219: 1 - 7221: 1 - 7223: 1 - 7224: 1 - 7225: 1 - 7226: 1 - 7227: 1 - 7228: 1 - 7229: 1 - 7230: 1 - 7231: 1 - 7232: 1 - 7233: 1 - 7234: 1 - 7235: 1 - 7236: 1 - 7237: 1 - 7238: 1 - 7239: 1 - 7240: 1 - 7241: 1 - 7242: 1 - 7243: 1 - 7244: 1 - 7245: 1 - 7246: 1 - 7247: 1 - 7248: 1 - 7249: 1 - 7250: 1 - 7251: 1 - 7252: 1 - 7253: 1 - 7254: 1 - 7255: 1 - 7256: 1 - 7257: 1 - 7258: 1 - 7259: 1 - 7260: 1 - 7261: 1 - 7262: 1 - 7263: 1 - 7264: 1 - 7265: 1 - 7266: 1 - 7267: 1 - 7268: 1 - 7269: 1 - 7272: 1 - 7273: 1 - 7274: 1 - 7276: 1 - 7277: 1 - 7278: 1 - 7279: 1 - 7280: 1 - 7281: 1 - 7282: 1 - 7283: 1 - 7284: 1 - 7285: 1 - 7286: 1 - 7287: 1 - 7288: 1 - 7289: 1 - 732: 1 - 7353: 1 - 7355: 1 - 7357: 1 - 7412: 1 - 7413: 1 - 7414: 1 - 7415: 1 - 7416: 1 - 7432: 1 - 7433: 1 - 7434: 1 - 7435: 1 - 7442: 1 - 7443: 1 - 7444: 1 - 7445: 1 - 7448: 1 - 7471: 1 - 7472: 1 - 7473: 1 - 7474: 1 - 7475: 1 - 7476: 1 - 7477: 1 - 7478: 1 - 7479: 1 - 7480: 1 - 7482: 1 - 7483: 1 - 7484: 1 - 7485: 1 - 7486: 1 - 7487: 1 - 7488: 1 - 7489: 1 - 7562: 1 - 7563: 1 - 7564: 1 - 7565: 1 - 7566: 1 - 7582: 1 - 7583: 1 - 7584: 1 - 7585: 1 - 7586: 1 - 7587: 1 - 7588: 1 - 7612: 1 - 7613: 1 - 7614: 1 - 7615: 1 - 7616: 1 - 7617: 1 - 7618: 1 - 7619: 1 - 7662: 1 - 7663: 1 - 7664: 1 - 7665: 1 - 7666: 1 - 7667: 1 - 7672: 1 - 7673: 1 - 7674: 1 - 7675: 1 - 7676: 1 - 7682: 1 - 7683: 1 - 7684: 1 - 7711: 1 - 7712: 1 - 7713: 1 - 7714: 1 - 7716: 1 - 7717: 1 - 7718: 1 - 7719: 1 - 7722: 1 - 7723: 1 - 7724: 1 - 7727: 1 - 7728: 1 - 7729: 1 - 7732: 1 - 7733: 1 - 7734: 1 - 7735: 1 - 7736: 1 - 7742: 1 - 7743: 1 - 7744: 1 - 7745: 1 - 7746: 1 - 7747: 1 - 7748: 1 - 7750: 1 - 7751: 1 - 7752: 1 - 7753: 1 - 7754: 1 - 7755: 1 - 7757: 1 - 7758: 1 - 7759: 1 - 7762: 1 - 7763: 1 - 7764: 1 - 7765: 1 - 7766: 1 - 7767: 1 - 780: 1 - 7941: 1 - 7942: 1 - 7943: 1 - 7944: 1 - 7945: 1 - 7946: 1 - 7947: 1 - 7948: 1 - 7949: 1 - 7952: 1 - 7953: 1 - 7954: 1 - 7955: 1 - 7956: 1 - 800: 1 - 804: 1 - 810: 1 - 820: 1 - 821: 1 - 828: 1 - 89: 1 - 900: 1 - 901: 1 - 930: 1 - 931: 1 - 939: 1 \ No newline at end of file diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/config.cfg b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/config.cfg deleted file mode 100644 index bd050a02..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/config.cfg +++ /dev/null @@ -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 diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/config.debug.cfg b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/config.debug.cfg deleted file mode 100644 index bd050a02..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/config.debug.cfg +++ /dev/null @@ -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 diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/process.pl b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/process.pl deleted file mode 100755 index c9b4bc8b..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/process.pl +++ /dev/null @@ -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! diff --git a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/settings.cfg b/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/settings.cfg deleted file mode 100644 index 011fc02a..00000000 --- a/lib/NGCP/BulkProcessor/Projects/Migration/UPCAT/settings.cfg +++ /dev/null @@ -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 \ No newline at end of file