[interchange-cvs] interchange - racke modified lib/Vend/Config.pm
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Thu Sep 26 12:40:01 2002
User: racke
Date: 2002-09-26 16:39:15 GMT
Modified: lib/Vend Config.pm
Log:
allow mapping options like 'fallback'
only shadow a database once
Revision Changes Path
2.72 +37 -12 interchange/lib/Vend/Config.pm
rev 2.72, prev_rev 2.71
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: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.71
retrieving revision 2.72
diff -u -r2.71 -r2.72
--- Config.pm 16 Sep 2002 23:06:31 -0000 2.71
+++ Config.pm 26 Sep 2002 16:39:15 -0000 2.72
@@ -1,6 +1,6 @@
# Vend::Config - Configure Interchange
#
-# $Id: Config.pm,v 2.71 2002/09/16 23:06:31 mheins Exp $
+# $Id: Config.pm,v 2.72 2002/09/26 16:39:15 racke Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -45,7 +45,7 @@
use Vend::Util;
use Vend::Data;
=20
-$VERSION =3D substr(q$Revision: 2.71 $, 10);
+$VERSION =3D substr(q$Revision: 2.72 $, 10);
=20
my %CDname;
=20
@@ -3035,23 +3035,48 @@
elsif ($p eq 'MAP') {
my @f =3D split(/\s+/, $val);
my %parms;
+ my %map_options =3D (fallback =3D> 1);
+ my ($map_table, $map_column);
=20=09=09=09
if (@f < 2) {
config_error("At least two parameters needed for MAP.");
- } elsif (@f > 3) {
- config_error("Too much parameters for MAP.");
} elsif (@f =3D=3D 2) {
@f =3D ($f[0], 'default', $f[1]);
}
- $d->{OrigClass} =3D $d->{Class};
- $d->{Class} =3D 'SHADOW';
- $d->{type} =3D 10;
- if ($f[2] =3D~ /::/) {
- ($parms{table}, $parms{column}) =3D split (/::/, $f[2]);
- } else {
- $parms{column} =3D $f[2];
+
+ my $field =3D shift @f;
+
+ if (@f % 2) {
+ config_error("Incomplete parameter list for MAP.");
+ }
+
+ # now we have a valid configuration and change the database type
+ # if necessary
+
+ unless ($d->{type} eq 10) {
+ $d->{OrigClass} =3D $d->{Class};
+ $d->{Class} =3D 'SHADOW';
+ $d->{type} =3D 10;
+ }
+
+ while (@f) {
+ my $map_key =3D shift @f;
+ my $map_value =3D shift @f;
+
+ if (exists $map_options{$map_key}) {
+ # option like fallback
+ $d->{MAP}->{$field}->{$map_key} =3D $map_value;
+ } else {
+ # mapping direction
+ if ($map_value =3D~ /::/) {
+ ($map_table, $map_value) =3D split (/::/, $map_value);
+ $d->{MAP}->{$field}->{$map_key} =3D {table =3D> $map_table,
+ column =3D> $map_value};
+ } else {
+ $d->{MAP}->{$field}->{$map_key} =3D {column =3D> $map_value};
+ }
+ }
}
- $d->{MAP}->{$f[0]}->{$f[1]} =3D \%parms;
}
=20
else {