| 1 | package Convert::Pheno::Runner; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 136 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 136 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 136 | ▶ | use autodie; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 136 | ▶ | use feature qw(say); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 136 | ▶ | use JSON::XS; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 136 | ▶ | use Convert::Pheno::BFF::DerivedEntities qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | execution_entities | ||||||||||||||||||||||||||||||||||||||||||
| 11 | synthesize_bundle_entities | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 136 | ); | |||||||||||||||||||||||||||||||||||||||||
| 13 | 136 | ▶ | use Convert::Pheno::CBioPortal::ToBFF (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 136 | ▶ | use Convert::Pheno::Context; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 136 | ▶ | use Convert::Pheno::ConversionRequest; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 136 | ▶ | use Convert::Pheno::CDISC::SDTM::ToBFF (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 136 | ▶ | use Convert::Pheno::ClinicalCDM::ToBFF (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 136 | ▶ | use Convert::Pheno::ExecutionContext; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 136 | ▶ | use Convert::Pheno::FHIR::ToBFF (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 136 | ▶ | use Convert::Pheno::Model::Bundle; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 136 | ▶ | use Convert::Pheno::OMOP::ToBFF (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 136 | ▶ | use Convert::Pheno::OpenEHR::ToBFF (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 136 | ▶ | use Convert::Pheno::Operations qw(conversion_spec); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 136 | ▶ | use Convert::Pheno::PXF::ToBFF (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 136 | ▶ | use Convert::Pheno::Tabular::ToBFF (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 136 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 136 | our @EXPORT_OK = qw(resolve_operation run_operation); | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 136 | my %DIRECT_OPERATIONS = ( | |||||||||||||||||||||||||||||||||||||||||
| 31 | bff2pxf => \&Convert::Pheno::do_bff2pxf, | ||||||||||||||||||||||||||||||||||||||||||
| 32 | bff2csv => \&Convert::Pheno::do_bff2csv, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | bff2jsonf => \&Convert::Pheno::do_bff2csv, | ||||||||||||||||||||||||||||||||||||||||||
| 34 | bff2jsonld => \&Convert::Pheno::do_bff2jsonld, | ||||||||||||||||||||||||||||||||||||||||||
| 35 | bff2omop => \&Convert::Pheno::do_bff2omop, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | pxf2csv => \&Convert::Pheno::do_pxf2csv, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | pxf2jsonf => \&Convert::Pheno::do_pxf2csv, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | pxf2jsonld => \&Convert::Pheno::do_pxf2jsonld, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | my %BUNDLE_SOURCE_HANDLERS = ( | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 100 | ▶ | cbioportal => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 100 | return Convert::Pheno::CBioPortal::ToBFF::run_cbioportal_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 44 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 181 | ▶ | 'cdisc-odm' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 181 | return Convert::Pheno::Tabular::ToBFF::run_tabular_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 47 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 242 | ▶ | csv => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 242 | return Convert::Pheno::Tabular::ToBFF::run_tabular_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 50 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 31 | ▶ | 'dataset-json' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 31 | return Convert::Pheno::CDISC::SDTM::ToBFF::run_sdtm_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 53 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 22 | ▶ | 'dataset-xml' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 22 | return Convert::Pheno::CDISC::SDTM::ToBFF::run_sdtm_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 56 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 18 | ▶ | fhir => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 18 | return Convert::Pheno::FHIR::ToBFF::run_fhir_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 59 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 14 | ▶ | i2b2 => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 14 | return Convert::Pheno::ClinicalCDM::ToBFF::run_clinical_cdm_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 62 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 12915 | ▶ | omop => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 12915 | return Convert::Pheno::OMOP::ToBFF::run_omop_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 65 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 20 | ▶ | openehr => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 20 | return Convert::Pheno::OpenEHR::ToBFF::run_openehr_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 68 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 12 | ▶ | pcornet => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 12 | return Convert::Pheno::ClinicalCDM::ToBFF::run_clinical_cdm_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 71 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 341 | ▶ | pxf => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 341 | return Convert::Pheno::PXF::ToBFF::run_pxf_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 180 | ▶ | redcap => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 180 | return Convert::Pheno::Tabular::ToBFF::run_tabular_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 77 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 10 | ▶ | sentinel => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 10 | return Convert::Pheno::ClinicalCDM::ToBFF::run_clinical_cdm_to_bundle(@_); | |||||||||||||||||||||||||||||||||||||||||
| 80 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 136 | ); | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 265 | ▶ | sub resolve_operation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_operation: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 265 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 85 | my $spec = conversion_spec( $self->{method} ) | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 265 | ▶ | or die "Unsupported method <$self->{method}> in runner\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 264 | ▶ | if ( $spec->{operation} eq 'bundle' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | my $handler = $BUNDLE_SOURCE_HANDLERS{ $spec->{source} } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 189 | ▶ | or die "No bundle handler is registered for source <$spec->{source}>\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 189 | return _bundle_operation( spec => $spec, run => $handler ); | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | return _direct_operation( | ||||||||||||||||||||||||||||||||||||||||||
| 95 | spec => $spec, | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 1035 | ▶ | run => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 1035 | my ( $convert, $input ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 1035 | return $DIRECT_OPERATIONS{ $convert->{method} }->( $convert, $input ); | |||||||||||||||||||||||||||||||||||||||||
| 99 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 75 | ▶ | ) if exists $DIRECT_OPERATIONS{ $self->{method} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | die "Unsupported method <$self->{method}> in runner\n"; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 264 | ▶ | sub run_operation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_operation: called CC=25 SCAR=33.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 264 | my ( $self, $input, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 264 | ▶ | my $operation = $arg{operation} || resolve_operation($self); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$arg{'operation'} || resolve_operation($self)
MC/DC0%0/2
$arg{'operation'} || resolve_operation($self)
$arg{'operation'}
resolve_operation($self)
Truth table66%2/3
A || B
A= $arg{'operation'}B= resolve_operation($self)
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 263 | ▶ | my $view = $arg{view} || 'primary'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$arg{'view'} || 'primary'
MC/DC100%1/1
$arg{'view'} || 'primary'
$arg{'view'}
Truth table100%2/2
A
A= $arg{'view'}
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 263 | ▶ | my $operation_name = $operation->{name} || $self->{method}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$operation->{'name'} || $self->{'method'}
MC/DC0%0/2
$operation->{'name'} || $self->{'method'}
$operation->{'name'}
$self->{'method'}
Truth table66%2/3
A || B
A= $operation->{'name'}B= $self->{'method'}
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | my $request = $arg{request} | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 263 | ▶ | || Convert::Pheno::ConversionRequest->from_converter($self); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$arg{'request'} || 'Convert::Pheno::ConversionRequest'->from_converter($self)
MC/DC0%0/2
$arg{'request'} || 'Convert::Pheno::ConversionRequest'->from_converter($self)
$arg{'request'}
'Convert::Pheno::ConversionRequest'->from_converter($self)
Truth table33%1/3
A || B
A= $arg{'request'}B= 'Convert::Pheno::ConversionRequest'->from_converter($self)
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | my $execution = $arg{execution_context} | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 263 | ▶ | || Convert::Pheno::ExecutionContext->new( | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$arg{'execution_context'} || 'Convert::Pheno::ExecutionContext'->new({'request', $request, 'stages', [$operation_name]})
MC/DC0%0/2
$arg{'execution_context'} || 'Convert::Pheno::ExecutionContext'->new({'request', $request, 'stages', [$operation_name]})
$arg{'execution_context'}
'Convert::Pheno::ExecutionContext'->new({'request', $request, 'stages', [$operation_name]})
Truth table33%1/3
A || B
A= $arg{'execution_context'}B= 'Convert::Pheno::ExecutionContext'->new({'request', $request, 'stages', [$operation_name]})
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | request => $request, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | stages => [$operation_name], | ||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 263 | my ($execution_stage) = $execution->begin_next_stage; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 263 | ▶ | die "Execution stage <$execution_stage> does not match operation <$operation_name>\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | unless $execution_stage eq $operation_name; | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 263 | ▶ | die "Unsupported runner view <$view>\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$view eq "primary" or $view eq "bundle"
MC/DC0%0/2
$view eq "primary" or $view eq "bundle"
$view eq "primary"
$view eq "bundle"
Truth table66%2/3
A or B
A= $view eq "primary"B= $view eq "bundle"
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | unless $view eq 'primary' || $view eq 'bundle'; | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 263 | ▶ | if ( $view eq 'bundle' && $operation->{type} ne 'bundle' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$view eq "bundle" and $operation->{"type"} ne "bundle"
MC/DC0%0/2
$view eq "bundle" and $operation->{"type"} ne "bundle"
$view eq "bundle"
$operation->{"type"} ne "bundle"
Truth table66%2/3
A and B
A= $view eq "bundle"B= $operation->{"type"} ne "bundle"
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | die "Method <$self->{method}> does not support bundle dispatch\n"; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 263 | my $context = _resolve_context( $self, $operation ); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 263 | ▶ | my $stream = $view eq 'primary' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | ? Convert::Pheno::_dispatcher_open_stream_out($self) | ||||||||||||||||||||||||||||||||||||||||||
| 134 | : undef; | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 263 | ▶ | my $json = $stream ? JSON::XS->new->canonical->pretty : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 263 | ▶ | my $out_data = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | $view eq 'bundle' | ||||||||||||||||||||||||||||||||||||||||||
| 139 | ? Convert::Pheno::Model::Bundle->new( | ||||||||||||||||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | context => $context, | ||||||||||||||||||||||||||||||||||||||||||
| 142 | entities => $context->entities, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 145 | : undef; | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 263 | my $connections_open = 0; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 263 | my ( $ok, $error ); | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 263 | $ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 151 | 263 | ▶ | if ( $operation->{requires_sqlite} || $self->{terminology_lookup_required} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$operation->{"requires_sqlite"} or $self->{"terminology_lookup_required"}
MC/DC100%2/2
$operation->{"requires_sqlite"} or $self->{"terminology_lookup_required"}
$operation->{"requires_sqlite"}
$self->{"terminology_lookup_required"}
Truth table100%3/3
A or B
A= $operation->{"requires_sqlite"}B= $self->{"terminology_lookup_required"}
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 132 | Convert::Pheno::open_connections_SQLite($self); | |||||||||||||||||||||||||||||||||||||||||
| 153 | 132 | $connections_open = 1; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 132 | $execution->set_resource( sqlite_open => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 263 | $out_data = _process_operation_items( | |||||||||||||||||||||||||||||||||||||||||
| 158 | $self, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | $input, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | $operation, | ||||||||||||||||||||||||||||||||||||||||||
| 161 | $context, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | $view, | ||||||||||||||||||||||||||||||||||||||||||
| 163 | $stream, | ||||||||||||||||||||||||||||||||||||||||||
| 164 | $json, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | $out_data, | ||||||||||||||||||||||||||||||||||||||||||
| 166 | $execution, | ||||||||||||||||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 261 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 169 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 263 | ▶ | $error = $@ unless $ok; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 263 | my @cleanup_errors; | |||||||||||||||||||||||||||||||||||||||||
| 173 | _run_cleanup( | ||||||||||||||||||||||||||||||||||||||||||
| 174 | \@cleanup_errors, | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 'closing SQLite connections', | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 132 | ▶ | sub { Convert::Pheno::close_connections_SQLite($self) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 263 | ▶ | if $connections_open; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 263 | ▶ | $execution->set_resource( sqlite_open => 0 ) if $connections_open; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | _run_cleanup( | ||||||||||||||||||||||||||||||||||||||||||
| 181 | \@cleanup_errors, | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 'closing the terminology audit', | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 263 | ▶ | sub { Convert::Pheno::finalize_term_audit($self) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 263 | ); | |||||||||||||||||||||||||||||||||||||||||
| 185 | 263 | delete $self->{current_row}; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 263 | $execution->clear_current_row; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 263 | ▶ | if ($stream) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 13 | ▶ | if ( $ok && !@cleanup_errors ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ok and not @cleanup_errors
MC/DC50%1/2
$ok and not @cleanup_errors
$ok
not @cleanup_errors
Truth table66%2/3
A and not(B)
A= $okB= not @cleanup_errors
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | _run_cleanup( | ||||||||||||||||||||||||||||||||||||||||||
| 191 | \@cleanup_errors, | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 'finalizing streamed output', | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 12 | ▶ | sub { Convert::Pheno::finalize_stream_out($stream) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 12 | ); | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | _run_cleanup( | ||||||||||||||||||||||||||||||||||||||||||
| 198 | \@cleanup_errors, | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 'closing failed streamed output', | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | close $stream->{fh} | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | if $stream->{fh} && defined fileno( $stream->{fh} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$stream->{"fh"} and defined fileno $stream->{"fh"}
MC/DC0%0/2
$stream->{"fh"} and defined fileno $stream->{"fh"}
$stream->{"fh"}
defined fileno $stream->{"fh"}
Truth table33%1/3
A and B
A= $stream->{"fh"}B= defined fileno $stream->{"fh"}
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 204 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 263 | ▶ | _throw_run_failure( $error, \@cleanup_errors ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $ok or @cleanup_errors
MC/DC50%1/2
not $ok or @cleanup_errors
not $ok
@cleanup_errors
Truth table66%2/3
not(A) or B
A= not $okB= @cleanup_errors
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | if !$ok || @cleanup_errors; | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 261 | ▶ | my $result = $stream ? 1 : $out_data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 261 | $execution->complete_stage($result); | |||||||||||||||||||||||||||||||||||||||||
| 214 | 261 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 263 | ▶ | sub _process_operation_items { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_operation_items: called CC=20 SCAR=30.2
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | my ( | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 263 | $self, $input, $operation, $context, | |||||||||||||||||||||||||||||||||||||||||
| 220 | $view, $stream, $json, $out_data, $execution, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | ) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 263 | my $is_array = ref($input) eq 'ARRAY'; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 263 | ▶ | my $item_count = $is_array ? scalar @{$input} : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 263 | ▶ | if ( $view eq 'primary' && $is_array ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$view eq "primary" and $is_array
MC/DC100%2/2
$view eq "primary" and $is_array
$view eq "primary"
$is_array
Truth table100%3/3
A and B
A= $view eq "primary"B= $is_array
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 175 | $out_data = []; | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 263 | my $total = 0; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 263 | ▶ | for ( my $i = 0; $i < $item_count; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 15122 | my $count = $i + 1; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 15122 | ▶ | my $item = $is_array ? $input->[$i] : $input; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 15122 | $self->{current_row} = $count; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 15122 | $execution->set_current_row($count); | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 15122 | my $raw = _execute_operation_raw( $self, $operation, $item, $context ); | |||||||||||||||||||||||||||||||||||||||||
| 239 | 15120 | ▶ | next unless defined $raw; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 15120 | ▶ | if ( $view eq 'bundle' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 5827 | _merge_bundle( | |||||||||||||||||||||||||||||||||||||||||
| 243 | $out_data, | ||||||||||||||||||||||||||||||||||||||||||
| 244 | $raw, | ||||||||||||||||||||||||||||||||||||||||||
| 245 | $context->entities, | ||||||||||||||||||||||||||||||||||||||||||
| 246 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 5827 | next; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 9293 | my $result = _primary_result( $operation, $raw ); | |||||||||||||||||||||||||||||||||||||||||
| 251 | 9293 | ▶ | next unless defined $result; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 8775 | $total++; | |||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 8775 | ▶ | if ($stream) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 6000 | ▶ | print { $stream->{fh} } ",\n" unless $stream->{first}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | Convert::Pheno::_transform_item( | ||||||||||||||||||||||||||||||||||||||||||
| 258 | $self, | ||||||||||||||||||||||||||||||||||||||||||
| 259 | $result, | ||||||||||||||||||||||||||||||||||||||||||
| 260 | $stream->{fh}, | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 6000 | 1, | |||||||||||||||||||||||||||||||||||||||||
| 262 | $json | ||||||||||||||||||||||||||||||||||||||||||
| 263 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 6000 | $stream->{first} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | elsif ($is_array) { | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 2750 | push @{$out_data}, $result; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 25 | $out_data = $result; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | last if ( $self->{method} eq 'omop2bff' | ||||||||||||||||||||||||||||||||||||||||||
| 274 | && $self->{max_lines_sql} | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 8775 | ▶ | && $total >= $self->{max_lines_sql} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->{"method"} eq "omop2bff" and $self->{"max_lines_sql"} and $total >= $self->{"max_lines_sql"}
$self->{"method"} eq "omop2bff" and $self->{"max_lines_sql"}
MC/DC66%2/3
$self->{"method"} eq "omop2bff" and $self->{"max_lines_sql"} and $total >= $self->{"max_lines_sql"}
$self->{"method"} eq "omop2bff"
$self->{"max_lines_sql"}
$total >= $self->{"max_lines_sql"}
Truth table75%3/4
A and B and C
A= $self->{"method"} eq "omop2bff"B= $self->{"max_lines_sql"}C= $total >= $self->{"max_lines_sql"}
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 261 | ▶ | if ($is_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 235 | ▶ | if ( $self->{verbose} && $self->{method} eq 'omop2bff' && $view eq 'primary' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->{"verbose"} and $self->{"method"} eq "omop2bff" and $view eq "primary"
$self->{"verbose"} and $self->{"method"} eq "omop2bff"
MC/DC0%0/3
$self->{"verbose"} and $self->{"method"} eq "omop2bff" and $view eq "primary"
$self->{"verbose"}
$self->{"method"} eq "omop2bff"
$view eq "primary"
Truth table25%1/4
A and B and C
A= $self->{"verbose"}B= $self->{"method"} eq "omop2bff"C= $view eq "primary"
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | say "==============\nIndividuals total: $total\n"; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 261 | ▶ | synthesize_bundle_entities( $self, $out_data, $context ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | if $view eq 'bundle'; | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 261 | return $out_data; | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 408 | ▶ | sub _run_cleanup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_cleanup: called CC=3 SCAR=15.4
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 408 | my ( $errors, $label, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 408 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 293 | 408 | $code->(); | |||||||||||||||||||||||||||||||||||||||||
| 294 | 408 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 295 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 408 | ▶ | return 1 if $ok; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | my $error = $@ || 'unknown cleanup error'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ || 'unknown cleanup error'
MC/DC0%0/1
$@ || 'unknown cleanup error'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | chomp $error; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | push @{$errors}, "$label: $error"; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | ▶ | sub _throw_run_failure { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_throw_run_failure: called CC=6 SCAR=24.1
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 2 | my ( $error, $cleanup_errors ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | ▶ | my $message = defined $error ? $error : q{}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | ▶ | $message .= "\n" if length($message) && $message !~ /\n\z/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $message and not $message =~ /\n\z/
MC/DC0%0/2
length $message and not $message =~ /\n\z/
length $message
not $message =~ /\n\z/
Truth table33%1/3
A and not(B)
A= length $messageB= not $message =~ /\n\z/
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 2 | ▶ | if ( @{$cleanup_errors} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | $message .= "Conversion cleanup failed:\n" unless length $message; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $message .= join q{}, map { " $_\n" } @{$cleanup_errors}; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 2 | die $message; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 263 | ▶ | sub _resolve_context { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_context: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 263 | my ( $self, $operation ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | return $self->{conversion_context} | ||||||||||||||||||||||||||||||||||||||||||
| 321 | if $operation->{type} eq 'bundle' | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 263 | ▶ | && $self->{conversion_context}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$operation->{"type"} eq "bundle" and $self->{"conversion_context"}
MC/DC100%2/2
$operation->{"type"} eq "bundle" and $self->{"conversion_context"}
$operation->{"type"} eq "bundle"
$self->{"conversion_context"}
Truth table100%3/3
A and B
A= $operation->{"type"} eq "bundle"B= $self->{"conversion_context"}
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | return Convert::Pheno::Context->from_self( | ||||||||||||||||||||||||||||||||||||||||||
| 325 | $self, | ||||||||||||||||||||||||||||||||||||||||||
| 326 | { | ||||||||||||||||||||||||||||||||||||||||||
| 327 | source_format => $operation->{source_format}, | ||||||||||||||||||||||||||||||||||||||||||
| 328 | target_format => $operation->{target_format}, | ||||||||||||||||||||||||||||||||||||||||||
| 329 | entities => execution_entities( | ||||||||||||||||||||||||||||||||||||||||||
| 330 | $self->{entities} || $operation->{default_entities} | ||||||||||||||||||||||||||||||||||||||||||
| 331 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 138 | ▶ | ) if $operation->{type} eq 'bundle'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{'entities'} || $operation->{'default_entities'}
MC/DC0%0/2
$self->{'entities'} || $operation->{'default_entities'}
$self->{'entities'}
$operation->{'default_entities'}
Truth table33%1/3
A || B
A= $self->{'entities'}B= $operation->{'default_entities'}
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 75 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 15122 | ▶ | sub _execute_operation_raw { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_execute_operation_raw: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 15122 | my ( $self, $operation, $input, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 340 | 15122 | return $operation->{run}->( $self, $input, $context ); | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 9293 | ▶ | sub _primary_result { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_primary_result: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 9293 | my ( $operation, $result ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 345 | 9293 | ▶ | return $result unless $operation->{type} eq 'bundle'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 8258 | return $result->primary_entity( $operation->{primary_entity} ); | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 5827 | ▶ | sub _merge_bundle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_merge_bundle: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 5827 | my ( $aggregate, $item_bundle, $entities ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 5827 | for my $entity ( @{$entities} ) { | |||||||||||||||||||||||||||||||||||||||||
| 352 | 8500 | for my $entry ( @{ $item_bundle->entities($entity) } ) { | |||||||||||||||||||||||||||||||||||||||||
| 353 | 4943 | $aggregate->add_entity( $entity => $entry ); | |||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 5827 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 189 | ▶ | sub _bundle_operation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bundle_operation: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 189 | my (%arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 361 | 189 | my $spec = $arg{spec}; | |||||||||||||||||||||||||||||||||||||||||
| 362 | die "Conversion <$spec->{name}> is not a bundle operation\n" | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 189 | ▶ | unless $spec->{operation} eq 'bundle'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 366 | type => 'bundle', | ||||||||||||||||||||||||||||||||||||||||||
| 367 | name => $spec->{name}, | ||||||||||||||||||||||||||||||||||||||||||
| 368 | source_format => $spec->{source}, | ||||||||||||||||||||||||||||||||||||||||||
| 369 | target_format => $spec->{target}, | ||||||||||||||||||||||||||||||||||||||||||
| 370 | requires_sqlite => $spec->{resources}{sqlite} ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 371 | default_entities => $spec->{entities}{default}, | ||||||||||||||||||||||||||||||||||||||||||
| 372 | primary_entity => $spec->{entities}{primary}, | ||||||||||||||||||||||||||||||||||||||||||
| 373 | run => $arg{run}, | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 189 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 75 | ▶ | sub _direct_operation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_direct_operation: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 75 | my (%arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 379 | 75 | my $spec = $arg{spec}; | |||||||||||||||||||||||||||||||||||||||||
| 380 | die "Conversion <$spec->{name}> is not a direct operation\n" | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 75 | ▶ | unless $spec->{operation} eq 'direct'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 384 | type => 'direct', | ||||||||||||||||||||||||||||||||||||||||||
| 385 | name => $spec->{name}, | ||||||||||||||||||||||||||||||||||||||||||
| 386 | requires_sqlite => $spec->{resources}{sqlite} ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 387 | run => $arg{run}, | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 75 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 136 | 1; | |||||||||||||||||||||||||||||||||||||||||