From: miker Date: Sun, 25 Jan 2009 16:51:38 +0000 (+0000) Subject: allow different delimiters; typo X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4e9e5b1363a7bc77ced216ef5b70b9f7896446f8;p=Evergreen.git allow different delimiters; typo git-svn-id: svn://svn.open-ils.org/ILS/trunk@11948 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/extras/fast-extract b/Open-ILS/src/extras/fast-extract index a1dc7dbd2f..56c53ba6c6 100755 --- a/Open-ILS/src/extras/fast-extract +++ b/Open-ILS/src/extras/fast-extract @@ -18,11 +18,12 @@ binmode(STDOUT, ':utf8'); $| = 1; -my ($config, $after) = ('SYSCONFDIR/opensrf_core.xml'); +my ($config, $delim, $after) = ('SYSCONFDIR/opensrf_core.xml', ' | '); GetOptions( "after=s" => \$after, "boostrap=s" => \$config, + "delimiter=s" => \$delim, ); OpenSRF::System->bootstrap_client( config_file => $config ); @@ -47,13 +48,13 @@ my $dsn = "dbi:" . $db_driver . ":dbname=" . $db_name .';host=' . $db_host . ';p my $dbh = DBI->connect($dsn,$db_user,$db_pw, {AutoCommit => 1, pg_enable_utf8 => 1, RaiseError => 1}); my $SQL = 'SELECT id FROM biblio.record_entry'; -$sql .= " WHERE edit_date > '$after'" if ($after); +$SQL .= " WHERE edit_date > '$after'" if ($after); warn "Initial selection SQL: $SQL\n"; my $ids = $dbh->selectcol_arrayref($SQL); -my $sql = <<'SQL'; +$SQL = <<'SQL'; SELECT id, tcn_source, tcn_value, @@ -66,6 +67,6 @@ warn "Record retrieval SQL: $SQL\n"; for my $id ( @$ids ) { my $row = $dbh->selectrow_hashref( $SQL, {}, $id ); - print "$$row{id} | $$row{tnc_source} | $$row{tcn_value} | $$row{marc}\n"; + print "$$row{id}$delim$$row{tnc_source}$delim$$row{tcn_value}$delim$$row{marc}\n"; } diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm index 8fd78a5917..b2f47d9d07 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm @@ -10,7 +10,7 @@ use OpenSRF::Utils::Logger qw/:level/; use OpenILS::Utils::Fieldmapper; use OpenILS::Utils::CStoreEditor q/:funcs/; -use OpenILS::Application::Trigger::ModRunner; +use OpenILS::Application::Trigger::Event; my $log = 'OpenSRF::Utils::Logger'; @@ -18,132 +18,4 @@ my $log = 'OpenSRF::Utils::Logger'; sub initialize {} sub child_init {} -sub build_env { - my $event = shift; - my $environment = shift || {}; - my $cstore = new_editor(); - - my $def = $cstore->retrieve_action_trigger_event_definition( $event->event_def ); - my $hook = $cstore->retrieve_action_trigger_hook( $def->hook ); - my $class = _fm_class_by_hint( $hook->core_type ); - - my $meth = "retreive_" . $class; - $meth =~ s/Fieldmapper:://; - $meth =~ s/::/_/; - - my $target = $cstore->$meth( $event->target ); - $$environment{target} = $target; - $$environment{event} = $event->to_bare_hash; - - my @env_list = $cstore->search_action_trigger_environment( { event_def => $event->event_def } ); - my @param_list = $cstore->search_action_trigger_params( { event_def => $event->event_def } ); - - $$environment{params}{ $_->param } = eval $_->value for ( @param_list ); - - for my $e ( @env_list ) { - my (@label, @path); - @path = split('.', $e->path) if ($e->path); - @label = split('.', $e->label) if ($e->label); - - my $collector = $e->collector; - _object_by_path( $cstore, $target, $collector, \@label, $environment, @path ); - } - - return $environment; -} - -sub _fm_class_by_hint { - my $hint = shift; - - my ($class) = grep { - OpenILS::Utils::Fieldmapper->publish_fieldmapper->{$_}->{hint} eq $hint - } keys %{ OpenILS::Utils::Fieldmapper->publish_fieldmapper }; - - return $class; -} - -sub _object_by_path { - my $cstore = shift; - my $context = shift; - my $collector = shift; - my $label = shift; - my $env = shift; - my @path = @_; - - my $step = shift(@path); - - my $fhint = OpenILS::Utils::Fieldmapper->publish_fieldmapper->{$context->class_name}{links}{$step}{class}; - my $fclass = _fm_class_by_hint( $fhint ); - - my $ffield = OpenILS::Utils::Fieldmapper->publish_fieldmapper->{$context->class_name}{links}{$step}{key}; - my $rtype = OpenILS::Utils::Fieldmapper->publish_fieldmapper->{$context->class_name}{links}{$step}{reltype}; - - my $meth = 'retrieve_'; - my $multi = 0; - my $lfield = $step; - if ($rtype eq 'has_many') { - $meth = 'search_'; - $multi = 1; - $lfield = $context->Identity; - } - - $meth .= $fclass; - $meth =~ s/Fieldmapper:://; - $meth =~ s/::/_/; - - my $obj = $cstore->$meth( { $ffield => $context->$lfield() } ); - - if (@path) { - - my $obj_list = []; - if (!$multi) { - $obj_list = [$obj] if ($obj); - } else { - $obj_list = $obj; - } - - _object_by_path( $cstore, $_, $collector, $label, $env, @path ) for (@$obj_list); - - $obj = $$obj_list[0] if (!$multi); - $context->$step( $obj ) if ($obj && !$label); - - } else { - - if ($collector) { - my $obj_list = [$obj] if ($obj && !$multi); - $obj_list = $obj if ($multi); - - my @new_obj_list; - for my $o ( @$obj_list ) { - push @new_obj_list, - OpenILS::Application::Trigger::ModRunner - ->new( $collector, $o ) - ->run - ->final_result; - } - - if (!$multi) { - $obj = $new_obj_list[0]; - } else { - $obj = \@new_obj_list; - } - } - - if ($label) { - my $node = $env; - my $i = 0; my $max = scalar(@$label) - 1; - for (; $i < $max; $i++) { - my $part = $$label[$i]; - $$node{$part} ||= {}; - $node = $$node{$part}; - } - $$node{$$label[-1]} = $obj; - } else { - $context->$step( $obj ) if ($obj); - } - } - - return $obj; -} - 1; diff --git a/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql b/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql index 5c687324e5..dfe3ff0f84 100644 --- a/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql +++ b/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql @@ -89,6 +89,7 @@ CREATE TABLE action_trigger.event_definition ( template TEXT NOT NULL, -- the TT block. will have an 'environment' hash (or array of hashes, grouped events) built up by validator and collector(s), which can be modified. CONSTRAINT ev_def_owner_hook_val_react_clean_delay_once UNIQUE (owner, hook, validator, reactor, delay, delay_field) ); +); CREATE TABLE action_trigger.environment ( id SERIAL PRIMARY KEY,