| 1 | package Geoffrey::Action::Trigger; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use 5.016; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Geoffrey::Utils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Geoffrey::Exception::RequiredValue; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use Geoffrey::Exception::NotSupportedException; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 5 | $Geoffrey::Action::Trigger::VERSION = '0.000206'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use parent 'Geoffrey::Role::Action'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 15 | ▶ | sub add { | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=10 SCAR=24.6
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 15 | my ($self, $params, $options) = @_; | |||||||||||||||||||||||||||
| 17 | 15 | my $trigger = $self->converter->trigger; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 15 | ▶ | Geoffrey::Exception::NotSupportedException::throw_action() if !$trigger || !$trigger->add; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$trigger and $trigger->add
MC/DC0%0/2
$trigger and $trigger->add
$trigger
$trigger->add
Truth table33%1/3
A and B
A= $triggerB= $trigger->add
| |||||||||||||||||||||||||||||
| 20 | 15 | ▶ | Geoffrey::Exception::RequiredValue::throw_trigger_name('for add trigger') if !$params->{name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 11 | ▶ | Geoffrey::Exception::RequiredValue::throw_table_name('for add trigger') if !$params->{event_object_table}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 9 | ▶ | Geoffrey::Exception::RequiredValue::throw_common('event_manipulation') if !$params->{event_manipulation}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | Geoffrey::Exception::RequiredValue::throw_common('action_timing') if !$params->{action_timing}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | Geoffrey::Exception::RequiredValue::throw_common('action_orientation') if !$params->{action_orientation}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 2 | ▶ | Geoffrey::Exception::RequiredValue::throw_common('action_statement') if !$params->{action_statement}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 2 | my $result = $self->_find_same_trigger($params->{event_object_table}, $params->{name}, $params->{schema}); | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 2 | ▶ | if (@{$result} > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | $self->drop($params->{name}, $params->{event_object_table}); | |||||||||||||||||||||||||||
| 31 | 0 | $params->{event_manipulation} .= ' OR ' . $result->[0]->{event_manipulation}; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | my $sql = Geoffrey::Utils::replace_spare( | ||||||||||||||||||||||||||||
| 35 | $trigger->add($options), | ||||||||||||||||||||||||||||
| 36 | [ | ||||||||||||||||||||||||||||
| 37 | $params->{name}, $params->{action_timing}, $params->{event_manipulation}, | ||||||||||||||||||||||||||||
| 38 | $params->{event_object_table}, $params->{action_orientation}, $params->{action_statement}, | ||||||||||||||||||||||||||||
| 39 | 2 | ]); | |||||||||||||||||||||||||||
| 40 | 2 | return $self->do($sql); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 8 | ▶ | sub alter { | ||||||||||||||||||||||||||
|
Subroutine
alter: called CC=9 SCAR=22.3
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 8 | my ($self, $params, $options) = @_; | |||||||||||||||||||||||||||
| 45 | 8 | my $trigger = $self->converter->trigger; | |||||||||||||||||||||||||||
| 46 | 8 | ▶ | Geoffrey::Exception::NotSupportedException::throw_action() if !$trigger || !$trigger->alter; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$trigger and $trigger->alter
MC/DC0%0/2
$trigger and $trigger->alter
$trigger
$trigger->alter
Truth table33%1/3
A and B
A= $triggerB= $trigger->alter
| |||||||||||||||||||||||||||||
| 47 | 6 | ▶ | Geoffrey::Exception::RequiredValue::throw_trigger_name('for drop trigger') if !$params->{name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 5 | ▶ | Geoffrey::Exception::RequiredValue::throw_table_name('for drop trigger') if !$params->{event_object_table}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 4 | ▶ | Geoffrey::Exception::RequiredValue::throw_common('event_manipulation') if !$params->{event_manipulation}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 3 | ▶ | Geoffrey::Exception::RequiredValue::throw_common('action_timing') if !$params->{action_timing}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 2 | ▶ | Geoffrey::Exception::RequiredValue::throw_common('action_orientation') if !$params->{action_orientation}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 1 | ▶ | Geoffrey::Exception::RequiredValue::throw_common('action_statement') if !$params->{action_statement}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | return [$self->drop($params, $options), $self->add($params, $options),]; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 5 | ▶ | sub drop { | ||||||||||||||||||||||||||
|
Subroutine
drop: called CC=5 SCAR=16.5
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 5 | my ($self, $name, $table) = @_; | |||||||||||||||||||||||||||
| 59 | 5 | my $trigger = $self->converter->trigger; | |||||||||||||||||||||||||||
| 60 | 5 | ▶ | Geoffrey::Exception::NotSupportedException::throw_action() if !$trigger || !$trigger->drop; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$trigger and $trigger->drop
MC/DC0%0/2
$trigger and $trigger->drop
$trigger
$trigger->drop
Truth table33%1/3
A and B
A= $triggerB= $trigger->drop
| |||||||||||||||||||||||||||||
| 61 | 5 | ▶ | Geoffrey::Exception::RequiredValue::throw_trigger_name('for drop trigger') if !$name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 3 | ▶ | Geoffrey::Exception::RequiredValue::throw_table_name('for drop trigger') if !$table; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 1 | return $self->do(Geoffrey::Utils::replace_spare($trigger->drop, [$name, $table])); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 3 | ▶ | sub list { | ||||||||||||||||||||||||||
|
Subroutine
list: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||
| 67 | 3 | my ($self, $schema) = @_; | |||||||||||||||||||||||||||
| 68 | 3 | my $trigger = $self->converter->trigger; | |||||||||||||||||||||||||||
| 69 | 3 | ▶ | if (!$trigger || !$trigger->list) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$trigger and $trigger->list
MC/DC0%0/2
$trigger and $trigger->list
$trigger
$trigger->list
Truth table33%1/3
A and B
A= $triggerB= $trigger->list
| |||||||||||||||||||||||||||||
| 70 | 0 | Geoffrey::Exception::NotSupportedException::throw_action(); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | 1 | return $trigger->information($self->do_arrayref($trigger->list($schema))); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 2 | ▶ | sub _find_same_trigger { | ||||||||||||||||||||||||||
|
Subroutine
_find_same_trigger: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 76 | 2 | my ($self, $table, $name, $schema) = @_; | |||||||||||||||||||||||||||
| 77 | 2 | my $trigger = $self->converter->trigger; | |||||||||||||||||||||||||||
| 78 | 2 | ▶ | return [] if !$trigger->can('find_by_name_and_table'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | return $self->do_arrayref($trigger->find_by_name_and_table, [$table, $name, $schema]); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 5 | 1; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||