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",
13 "circ", "acp", "acn", "ccs");
17 // ----------------------------------------------------------------
18 // Autogenerated by fieldmapper.pl
20 // ----------------------------------------------------------------
22 function Fieldmapper() {}
24 Fieldmapper.prototype.clone = function() {
25 var obj = new this.constructor();
27 for( var i in this.array ) {
28 var thing = this.array[i];
29 if(thing == null) continue;
31 if( thing._isfieldmapper ) {
32 obj.array[i] = thing.clone();
35 if(instanceOf(thing, Array)) {
36 obj.array[i] = new Array();
38 for( var j in thing ) {
40 if( thing[j]._isfieldmapper )
41 obj.array[i][j] = thing[j].clone();
43 obj.array[i][j] = thing[j];
55 function FieldmapperException(message) {
56 this.message = message;
59 FieldmapperException.toString = function() {
60 return "FieldmapperException: " + this.message + "\\n";
67 for my $object (keys %$map) {
70 my $hint = $map->{$object}->{hint};
71 next unless (grep { $_ eq $hint } @web_hints );
72 #next unless( $hint eq "mvr" or $hint eq "aou" or $hint eq "aout" );
75 my $short_name = $map->{$object}->{hint};
79 // ----------------------------------------------------------------
81 // ----------------------------------------------------------------
87 $short_name.prototype = new Fieldmapper();
88 $short_name.prototype.constructor = $short_name;
89 $short_name.baseClass = Fieldmapper.constructor;
91 function $short_name(array) {
93 this.classname = "$short_name";
94 this._isfieldmapper = true;
97 if( array.constructor == Array)
101 throw new FieldmapperException(
102 "Attempt to build fieldmapper object with non-array");
104 } else { this.array = []; }
108 $short_name._isfieldmapper = true;
113 for my $field (keys %{$map->{$object}->{fields}}) {
115 my $position = $map->{$object}->{fields}->{$field}->{position};
118 $short_name.prototype.$field = function(new_value) {
119 if(arguments.length == 1) { this.array[$position] = new_value; }
120 return this.array[$position];