2 * ---------------------------------------------------------------------------
3 * Copyright (C) 2011 Equinox Software, Inc.
4 * Mike Rylander <miker@esilibrary.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * ---------------------------------------------------------------------------
18 if(!dojo._hasResource["MARC.AuthorityControlSet"]) {
20 dojo.require('openils.PermaCrud');
21 dojo.require('MARC.FixedFields');
23 dojo._hasResource["MARC.AuthorityControlSet"] = true;
24 dojo.provide("MARC.AuthorityControlSet");
25 dojo.declare('MARC.AuthorityControlSet', null, {
29 constructor : function(kwargs) {
31 if (!MARC.AuthorityControlSet._remote_loaded) {
33 // TODO -- push the raw tree into the oils cache for later reuse
35 var pcrud = new openils.PermaCrud();
36 var acs_list = pcrud.retrieveAll('acs');
39 dojo.forEach( acs_list, function (cs) {
40 MARC.AuthorityControlSet._controlsets[cs.id()] = {
43 description : cs.description(),
44 authority_tag_map : {},
50 // grab the authority fields
51 var acsaf_list = pcrud.search('acsaf', {control_set : cs.id()});
52 MARC.AuthorityControlSet._controlsets[cs.name()].raw.authority_fields( acsaf_list );
55 dojo.forEach( acsaf_list, function (csaf) {
56 // link the main entry if we're subordinate
57 if (csaf.main_entry()) {
59 dojo.filter(acsaf_list, function (x) {
60 return x.id() == csaf.main_entry();
65 // link the sub entries if we're main
67 dojo.filter(acsaf_list, function (x) {
68 return x.main_entry() == csaf.id();
73 var acsbf_list = pcrud.search('acsbf', {authority_field : csaf.id()});
74 csaf.bib_fields( acsbf_list );
76 MARC.AuthorityControlSet._controlsets[cs.name()].bib_fields = [].concat(
77 MARC.AuthorityControlSet._controlsets[cs.name()].bib_fields
81 dojo.forEach( acsbf_list, function (csbf) {
82 // link the main entry if we're subordinate
83 if (csbf.authority_field()) {
85 dojo.filter(acsaf_list, function (x) {
86 return x.a() == csbf.authority_field();
94 // build the authority_tag_map
95 dojo.forEach( MARC.AuthorityControlSet._controlsets[cs.name()].bib_fields, function (bf) {
96 MARC.AuthorityControlSet._controlsets[cs.name()].authority_tag_map[bf.tag()] = [/*XXX*/];
97 MARC.AuthorityControlSet._controlsets[cs.name()].control_map[bf.tag()] = {/*XXX*/};
103 if (kwargs.controlSet) {
104 this._controlset = kwargs.controlSet;
108 controlSetId: function (x) {
109 if (x) this._controlset = x;
110 return this._controlset;
113 controlSet: function (x) {
114 return MARC.AuthorityControlSet._controlsets[this.controlSetId(x)];
117 controlSetList : function () {
119 for (var i in MARC.AuthorityControlSet._controlsets) {
127 MARC.AuthorityControlSet._remote_loaded = false;
129 MARC.AuthorityControlSet._controlsets = {
130 // static sorta-LoC setup ... to be overwritten with server data
133 name : 'Static LoC legacy mapping',
134 description : 'Legacy mapping provided as a default',
135 authority_tag_map : {
136 100 : [[100,500,700],100],
137 700 : [[100,500,700],100],
138 800 : [[100,500,700],100],
139 110 : [[110,510,710],110],
140 610 : [[110,510,710],110],
141 710 : [[110,510,710],110],
142 810 : [[110,510,710],110],
143 111 : [[111,511,711],111],
144 611 : [[111,511,711],111],
145 711 : [[111,511,711],111],
146 811 : [[111,511,711],111],
147 240 : [[130,530,730],130],
148 130 : [[130,530,730],130],
149 730 : [[130,530,730],130],
150 830 : [[130,530,730],130],
151 600 : [[100,500,580,581,582,585,700,780,781,782,785],100],
152 630 : [[130,530,730],130],
153 648 : [[148,548],148],
154 650 : [[150,550,580,581,582,585,750,780,781,782,785],150],
155 651 : [[151,551,580,581,582,585,751,780,781,782,785],151],
156 655 : [[155,555,580,581,582,585,755,780,781,782,785],155]