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 = ("mvr", "au", "aou","aout", "asv", "asva", "asvr", "asvq");
15 // ----------------------------------------------------------------
16 // Autogenerated by fieldmapper.pl
18 // ----------------------------------------------------------------
20 function Fieldmapper() {}
22 Fieldmapper.prototype.clone = function() {
23 var obj = new this.constructor();
25 for( var i in this.array ) {
26 var thing = this.array[i];
27 if(thing == null) continue;
29 if( thing._isfieldmapper ) {
30 obj.array[i] = thing.clone();
33 if(instanceOf(thing, Array)) {
34 obj.array[i] = new Array();
36 for( var j in thing ) {
38 if( thing[j]._isfieldmapper )
39 obj.array[i][j] = thing[j].clone();
41 obj.array[i][j] = thing[j];
53 function FieldmapperException(message) {
54 this.message = message;
57 FieldmapperException.toString = function() {
58 return "FieldmapperException: " + this.message + "\\n";
65 for my $object (keys %$map) {
68 my $hint = $map->{$object}->{hint};
69 next unless (grep { $_ eq $hint } @web_hints );
70 #next unless( $hint eq "mvr" or $hint eq "aou" or $hint eq "aout" );
73 my $short_name = $map->{$object}->{hint};
77 // ----------------------------------------------------------------
79 // ----------------------------------------------------------------
85 $short_name.prototype = new Fieldmapper();
86 $short_name.prototype.constructor = $short_name;
87 $short_name.baseClass = Fieldmapper.constructor;
89 function $short_name(array) {
91 this.classname = "$short_name";
92 this._isfieldmapper = true;
95 if( array.constructor == Array)
99 throw new FieldmapperException(
100 "Attempt to build fieldmapper object with non-array");
102 } else { this.array = []; }
106 $short_name._isfieldmapper = true;
111 for my $field (keys %{$map->{$object}->{fields}}) {
113 my $position = $map->{$object}->{fields}->{$field}->{position};
116 $short_name.prototype.$field = function(new_value) {
117 if(arguments.length == 1) { this.array[$position] = new_value; }
118 return this.array[$position];