2 use strict; use warnings;
4 use OpenILS::Utils::Fieldmapper;
6 my $map = $Fieldmapper::fieldmap;
8 # if a true value is provided, we generate the web (light) version of the fieldmapper
10 # List of classes needed by the opac
11 my @web_hints = ("ex", "mvr", "au", "aou",
12 "aout", "asv", "asva", "asvr", "asvq", "circ", "acp");
16 // ----------------------------------------------------------------
17 // Autogenerated by fieldmapper.pl
19 // ----------------------------------------------------------------
21 function Fieldmapper() {}
23 Fieldmapper.prototype.clone = function() {
24 var obj = new this.constructor();
26 for( var i in this.array ) {
27 var thing = this.array[i];
28 if(thing == null) continue;
30 if( thing._isfieldmapper ) {
31 obj.array[i] = thing.clone();
34 if(instanceOf(thing, Array)) {
35 obj.array[i] = new Array();
37 for( var j in thing ) {
39 if( thing[j]._isfieldmapper )
40 obj.array[i][j] = thing[j].clone();
42 obj.array[i][j] = thing[j];
54 function FieldmapperException(message) {
55 this.message = message;
58 FieldmapperException.toString = function() {
59 return "FieldmapperException: " + this.message + "\\n";
66 for my $object (keys %$map) {
69 my $hint = $map->{$object}->{hint};
70 next unless (grep { $_ eq $hint } @web_hints );
71 #next unless( $hint eq "mvr" or $hint eq "aou" or $hint eq "aout" );
74 my $short_name = $map->{$object}->{hint};
78 // ----------------------------------------------------------------
80 // ----------------------------------------------------------------
86 $short_name.prototype = new Fieldmapper();
87 $short_name.prototype.constructor = $short_name;
88 $short_name.baseClass = Fieldmapper.constructor;
90 function $short_name(array) {
92 this.classname = "$short_name";
93 this._isfieldmapper = true;
96 if( array.constructor == Array)
100 throw new FieldmapperException(
101 "Attempt to build fieldmapper object with non-array");
103 } else { this.array = []; }
107 $short_name._isfieldmapper = true;
112 for my $field (keys %{$map->{$object}->{fields}}) {
114 my $position = $map->{$object}->{fields}->{$field}->{position};
117 $short_name.prototype.$field = function(new_value) {
118 if(arguments.length == 1) { this.array[$position] = new_value; }
119 return this.array[$position];