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", "acpl", "acn", "ccs",
14 "perm_ex", "ahn", "aua", "ac", "actscecm");
18 // ----------------------------------------------------------------
19 // Autogenerated by fieldmapper.pl
21 // ----------------------------------------------------------------
23 function Fieldmapper() {}
25 Fieldmapper.prototype.clone = function() {
26 var obj = new this.constructor();
28 for( var i in this.array ) {
29 var thing = this.array[i];
30 if(thing == null) continue;
32 if( thing._isfieldmapper ) {
33 obj.array[i] = thing.clone();
36 if(instanceOf(thing, Array)) {
37 obj.array[i] = new Array();
39 for( var j in thing ) {
41 if( thing[j]._isfieldmapper )
42 obj.array[i][j] = thing[j].clone();
44 obj.array[i][j] = thing[j];
56 function FieldmapperException(message) {
57 this.message = message;
60 FieldmapperException.toString = function() {
61 return "FieldmapperException: " + this.message + "\\n";
68 for my $object (keys %$map) {
71 my $hint = $map->{$object}->{hint};
72 next unless (grep { $_ eq $hint } @web_hints );
73 #next unless( $hint eq "mvr" or $hint eq "aou" or $hint eq "aout" );
76 my $short_name = $map->{$object}->{hint};
80 // ----------------------------------------------------------------
82 // ----------------------------------------------------------------
88 $short_name.prototype = new Fieldmapper();
89 $short_name.prototype.constructor = $short_name;
90 $short_name.baseClass = Fieldmapper.constructor;
92 function $short_name(array) {
94 this.classname = "$short_name";
95 this._isfieldmapper = true;
98 if( array.constructor == Array)
102 throw new FieldmapperException(
103 "Attempt to build fieldmapper object with non-array");
105 } else { this.array = []; }
109 $short_name._isfieldmapper = true;
114 for my $field (keys %{$map->{$object}->{fields}}) {
116 my $position = $map->{$object}->{fields}->{$field}->{position};
119 $short_name.prototype.$field = function(new_value) {
120 if(arguments.length == 1) { this.array[$position] = new_value; }
121 return this.array[$position];