[open-ils-commits] r11948 - in trunk/Open-ILS/src: extras perlmods/OpenILS/Application sql/Pg

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Jan 25 11:51:41 EST 2009


Author: miker
Date: 2009-01-25 11:51:38 -0500 (Sun, 25 Jan 2009)
New Revision: 11948

Modified:
   trunk/Open-ILS/src/extras/fast-extract
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
   trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql
Log:
allow different delimiters; typo

Modified: trunk/Open-ILS/src/extras/fast-extract
===================================================================
--- trunk/Open-ILS/src/extras/fast-extract	2009-01-25 16:49:52 UTC (rev 11947)
+++ trunk/Open-ILS/src/extras/fast-extract	2009-01-25 16:51:38 UTC (rev 11948)
@@ -18,11 +18,12 @@
 
 $| = 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 $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 @@
 
 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";
 }
 

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm	2009-01-25 16:49:52 UTC (rev 11947)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm	2009-01-25 16:51:38 UTC (rev 11948)
@@ -10,7 +10,7 @@
 
 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 @@
 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;

Modified: trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql	2009-01-25 16:49:52 UTC (rev 11947)
+++ trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql	2009-01-25 16:51:38 UTC (rev 11948)
@@ -89,6 +89,7 @@
     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,



More information about the open-ils-commits mailing list