Revision 319
Added by Aaron Marcuse-Kubitza almost 13 years ago
test/map | ||
---|---|---|
28 | 28 |
) >&2 |
29 | 29 |
} |
30 | 30 |
|
31 |
function fromFile() |
|
32 |
{ |
|
33 |
(_in="$in"; trace) |
|
34 |
("$@" <"$in") || exit # run in a sandbox; abort tester if error |
|
35 |
} |
|
36 |
|
|
31 | 37 |
function map() |
32 | 38 |
{ |
33 | 39 |
test -e "$in" || return 1 |
34 | 40 |
local ext="${in##*.}" # after last "." |
35 |
for map in "../mappings/$src-$out_fmt."$table".csv"; do |
|
41 |
(for map in "../mappings/$src-$out_fmt."$table".csv"; do
|
|
36 | 42 |
table="${map%.*}" # remove extension |
37 | 43 |
table="${table##*.}" # after last "." |
38 | 44 |
{ |
... | ... | |
54 | 60 |
for var in engine host user password database; do |
55 | 61 |
export in_$var="${!var}" |
56 | 62 |
done |
57 |
"$1"
|
|
63 |
"$@"
|
|
58 | 64 |
) |
59 |
else |
|
60 |
(_in="$in"; trace) |
|
61 |
"$1" <"$in" |
|
65 |
else fromFile "$@" |
|
62 | 66 |
fi |
63 |
} || exit # abort tester
|
|
64 |
done |
|
67 |
} || exit |
|
68 |
done) || exit # run in a sandbox; abort tester if error
|
|
65 | 69 |
} |
66 | 70 |
|
67 | 71 |
function toXml() |
... | ... | |
79 | 83 |
function toDb() |
80 | 84 |
{ |
81 | 85 |
trace . "$vegbienDest" |
82 |
(. "$vegbienDest"; set -x; ../map "$map") || exit # abort tester
|
|
86 |
(. "$vegbienDest"; set -x; ../map ${map:+"$map"}) || exit # abort tester
|
|
83 | 87 |
} |
84 | 88 |
|
85 | 89 |
for in in input/*; do |
... | ... | |
91 | 95 |
else table="${stem##*.}" # after last "." |
92 | 96 |
fi |
93 | 97 |
|
94 |
for out_fmt in VegX VegBIEN; do map toXml; done # source to XML |
|
98 |
for out_fmt in VegX VegBIEN; do map toXml; done # source to XMLs |
|
99 |
|
|
95 | 100 |
out_fmt=VegBIEN |
96 |
# VegX to VegBIEN |
|
101 |
# VegX to VegBIEN XML
|
|
97 | 102 |
( |
98 | 103 |
src=VegX method=via_$src |
99 | 104 |
for in in "output/$orig_src."$table".$src.xml"; do |
... | ... | |
101 | 106 |
table="${table%%.*}" # before second "." |
102 | 107 |
map toXml |
103 | 108 |
done |
104 |
) || exit # subshell error also interrupts main shell |
|
109 |
) || exit |
|
110 |
|
|
105 | 111 |
map toDb # source to VegBIEN db |
112 |
# VegBIEN XML to VegBIEN db |
|
113 |
for in in "output/$orig_src."$table".VegBIEN"*".xml"; do fromFile toDb; done |
|
106 | 114 |
done |
Also available in: Unified diff
test/map: Added tests to insert VegBIEN XML into VegBIEN db