[interchange-cvs] interchange - racke modified 2 files
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Fri Aug 2 09:05:01 2002
User: racke
Date: 2002-08-02 13:04:13 GMT
Modified: lib/Vend Config.pm
Modified: lib/Vend/Table Shadow.pm
Log:
started work on mappings to other databases in Vend::Table::Shadow
Revision Changes Path
2.58 +10 -3 interchange/lib/Vend/Config.pm
rev 2.58, prev_rev 2.57
Index: Config.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /anon_cvs/repository/interchange/lib/Vend/Config.pm,v
retrieving revision 2.57
retrieving revision 2.58
diff -u -r2.57 -r2.58
--- Config.pm 22 Jul 2002 16:07:01 -0000 2.57
+++ Config.pm 2 Aug 2002 13:04:09 -0000 2.58
@@ -1,6 +1,6 @@
# Vend::Config - Configure Interchange
#
-# $Id: Config.pm,v 2.57 2002/07/22 16:07:01 mheins Exp $
+# $Id: Config.pm,v 2.58 2002/08/02 13:04:09 racke Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -44,7 +44,7 @@
use Vend::Parse;
use Vend::Util;
=20
-$VERSION =3D substr(q$Revision: 2.57 $, 10);
+$VERSION =3D substr(q$Revision: 2.58 $, 10);
=20
my %CDname;
=20
@@ -2805,6 +2805,8 @@
}
elsif ($p eq 'MAP') {
my @f =3D split(/\s+/, $val);
+ my %parms;
+=09=09=09
if (@f < 2) {
config_error("At least two parameters needed for MAP.");
} elsif (@f > 3) {
@@ -2815,7 +2817,12 @@
$d->{OrigClass} =3D $d->{Class};
$d->{Class} =3D 'SHADOW';
$d->{type} =3D 10;
- $d->{MAP}->{$f[0]}->{$f[1]} =3D $f[2];
+ if ($f[2] =3D~ /::/) {
+ ($parms{table}, $parms{column}) =3D split (/::/, $f[2]);
+ } else {
+ $parms{column} =3D $f[2];
+ }
+ $d->{MAP}->{$f[0]}->{$f[1]} =3D \%parms;
}
=20
else {
1.6 +11 -5 interchange/lib/Vend/Table/Shadow.pm
rev 1.6, prev_rev 1.5
Index: Shadow.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /anon_cvs/repository/interchange/lib/Vend/Table/Shadow.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Shadow.pm 13 Jul 2002 12:44:36 -0000 1.5
+++ Shadow.pm 2 Aug 2002 13:04:12 -0000 1.6
@@ -1,6 +1,6 @@
# Vend::Table::Shadow - Access a virtual "Shadow" table
#
-# $Id: Shadow.pm,v 1.5 2002/07/13 12:44:36 racke Exp $
+# $Id: Shadow.pm,v 1.6 2002/08/02 13:04:12 racke Exp $
#
# Copyright (C) 2002 Stefan Hornburg (Racke) <racke@linuxia.de>
#
@@ -20,7 +20,7 @@
# MA 02111-1307 USA.
=20
package Vend::Table::Shadow;
-$VERSION =3D substr(q$Revision: 1.5 $, 10);
+$VERSION =3D substr(q$Revision: 1.6 $, 10);
=20
# TODO
#
@@ -182,7 +182,6 @@
for (my $i =3D 0; $i < @cols; $i++) {
$column =3D $cols[$i];
if (exists $s->[$CONFIG]->{MAP}->{$column}->{$locale}) {
- $column =3D $s->[$CONFIG]->{MAP}->{$column}->{$locale};
$ref->{$cols[$i]} =3D $s->field($key, $column);
}
}
@@ -192,12 +191,19 @@
=20
sub field {
my ($s, $key, $column) =3D @_;
- my ($map, $locale);
+ my ($map, $locale, $db);
=20=09
$s =3D $s->import_db() unless defined $s->[$OBJ];
$locale =3D $::Scratch->{mv_locale} || 'default';
if (exists $s->[$CONFIG]->{MAP}->{$column}->{$locale}) {
- $column =3D $s->[$CONFIG]->{MAP}->{$column}->{$locale};
+ $map =3D $s->[$CONFIG]->{MAP}->{$column}->{$locale};
+ if (exists $map->{table}) {
+ $db =3D Vend::Data::database_exists_ref($map->{table})
+ or die "unknown table $map->{table} in mapping for column $column of $=
s->[$TABLE] for locale $locale";
+ return $db->field($key, $map->{column});
+ } else {
+ $column =3D $map->{column};
+ }
}
$s->[$OBJ]->field($key, $column);
}