+++ /dev/null
-/* vim: et:sw=4:ts=4:
- * ---------------------------------------------------------------------------
- * Copyright (C) 2011 Equinox Software, Inc.
- * Mike Rylander <miker@esilibrary.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * ---------------------------------------------------------------------------
- */
-
-if(!dojo._hasResource["MARC.AuthorityControlSet"]) {
-
- dojo.require('openils.PermaCrud');
- dojo.require('MARC.FixedFields');
-
- dojo._hasResource["MARC.AuthorityControlSet"] = true;
- dojo.provide("MARC.AuthorityControlSet");
- dojo.declare('MARC.AuthorityControlSet', null, {
-
- _controlset : null,
-
- constructor : function(kwargs) {
-
- if (!MARC.AuthorityControlSet._remote_loaded) {
-
- // TODO -- push the raw tree into the oils cache for later reuse
-
- var pcrud = new openils.PermaCrud();
- var acs_list = pcrud.retrieveAll('acs');
-
- // loop over each acs
- dojo.forEach( acs_list, function (cs) {
- MARC.AuthorityControlSet._controlsets[''+cs.id()] = {
- id : cs.id(),
- name : cs.name(),
- description : cs.description(),
- authority_tag_map : {},
- control_map : {},
- bib_fields : [],
- raw : cs
- };
-
- // grab the authority fields
- var acsaf_list = pcrud.search('acsaf', {control_set : cs.id()});
- var at_list = pcrud.search('at', {control_set : cs.id()});
- MARC.AuthorityControlSet._controlsets[''+cs.id()].raw.authority_fields( acsaf_list );
- MARC.AuthorityControlSet._controlsets[''+cs.id()].raw.thesauri( at_list );
-
- // and loop over each
- dojo.forEach( acsaf_list, function (csaf) {
- // link the main entry if we're subordinate
- if (csaf.main_entry()) {
- csaf.main_entry(
- dojo.filter(acsaf_list, function (x) {
- return x.id() == csaf.main_entry();
- })[0]
- );
- }
-
- // link the sub entries if we're main
- csaf.sub_entries(
- dojo.filter(acsaf_list, function (x) {
- return x.main_entry() == csaf.id();
- })[0]
- );
-
- // now, bib fields
- var acsbf_list = pcrud.search('acsbf', {authority_field : csaf.id()});
- csaf.bib_fields( acsbf_list );
-
- MARC.AuthorityControlSet._controlsets[''+cs.id()].bib_fields = [].concat(
- MARC.AuthorityControlSet._controlsets[''+cs.id()].bib_fields
- acsbf_list
- );
-
- dojo.forEach( acsbf_list, function (csbf) {
- // link the main entry if we're subordinate
- if (csbf.authority_field()) {
- csbf.authority_field(
- dojo.filter(acsaf_list, function (x) {
- return x.a() == csbf.authority_field();
- })[0]
- );
- }
-
- });
- });
-
- // build the authority_tag_map
- dojo.forEach( MARC.AuthorityControlSet._controlsets[''+cs.id()].bib_fields, function (bf) {
- MARC.AuthorityControlSet._controlsets[''+cs.id()].control_map[bf.tag()] = {};
- dojo.forEach( bf.authority_field().sf_list().split(''), function (sf_code) {
- MARC.AuthorityControlSet._controlsets[''+cs.id()].control_map[bf.tag()][sf_code] = { bf.authority_field().tag() : sf_code };
- });
- });
- });
-
-
- if (this.controlSetList().length > 0)
- delete MARC.AuthorityControlSet._controlsets['-1'];
-
- MARC.AuthorityControlSet._remote_loaded = true;
- }
-
- if (kwargs.controlSet) {
- this.controlSetId( kwargs.controlSet );
- } else {
- this.controlSetId( this.controlSetList().sort(function(a,b){return (a - b)}) );
- }
- },
-
- controlSetId: function (x) {
- if (x) this._controlset = ''+x;
- return this._controlset;
- },
-
- controlSet: function (x) {
- return MARC.AuthorityControlSet._controlsets[''+this.controlSetId(x)];
- },
-
- authorityFields: function (x) {
- return MARC.AuthorityControlSet._controlsets[''+this.controlSetId(x)].raw.authority_fields();
- },
-
- thesauri: function (x) {
- return MARC.AuthorityControlSet._controlsets[''+this.controlSetId(x)].raw.thesauri();
- },
-
- controlSetList : function () {
- var l = [];
- for (var i in MARC.AuthorityControlSet._controlsets) {
- l.push(i);
- }
- return l;
- },
-
- findControlSetsForTag : function (tag) {
- var old_acs = this.controlSetId();
- var acs_list = dojo.filter(
- this.controlSetList(),
- function(acs_id) { return (this.controlSet(acs_id).control_map[tag]) }
- );
- this.controlSetId(old_acs);
- return acs_list;
- }
-
- });
-
- MARC.AuthorityControlSet._remote_loaded = false;
-
- MARC.AuthorityControlSet._controlsets = {
- // static sorta-LoC setup ... to be overwritten with server data
- -1 : {
- id : -1,
- name : 'Static LoC legacy mapping',
- description : 'Legacy mapping provided as a default',
- contorl_map : {
- 100 : {
- 'a' : { 100 : 'a' },
- 'd' : { 100 : 'd' },
- 'e' : { 100 : 'e' },
- 'q' : { 100 : 'q' }
- },
- 110 : {
- 'a' : { 110 : 'a' },
- 'd' : { 110 : 'd' }
- },
- 111 : {
- 'a' : { 111 : 'a' },
- 'd' : { 111 : 'd' }
- },
- 130 : {
- 'a' : { 130 : 'a' },
- 'd' : { 130 : 'd' }
- },
- 240 : {
- 'a' : { 130 : 'a' },
- 'd' : { 130 : 'd' }
- },
- 400 : {
- 'a' : { 100 : 'a' },
- 'd' : { 100 : 'd' }
- },
- 410 : {
- 'a' : { 110 : 'a' },
- 'd' : { 110 : 'd' }
- },
- 411 : {
- 'a' : { 111 : 'a' },
- 'd' : { 111 : 'd' }
- },
- 440 : {
- 'a' : { 130 : 'a' },
- 'n' : { 130 : 'n' },
- 'p' : { 130 : 'p' }
- },
- 700 : {
- 'a' : { 100 : 'a' },
- 'd' : { 100 : 'd' },
- 'q' : { 100 : 'q' },
- 't' : { 100 : 't' }
- },
- 710 : {
- 'a' : { 110 : 'a' },
- 'd' : { 110 : 'd' }
- },
- 711 : {
- 'a' : { 111 : 'a' },
- 'c' : { 111 : 'c' },
- 'd' : { 111 : 'd' }
- },
- 730 : {
- 'a' : { 130 : 'a' },
- 'd' : { 130 : 'd' }
- },
- 800 : {
- 'a' : { 100 : 'a' },
- 'd' : { 100 : 'd' }
- },
- 810 : {
- 'a' : { 110 : 'a' },
- 'd' : { 110 : 'd' }
- },
- 811 : {
- 'a' : { 111 : 'a' },
- 'd' : { 111 : 'd' }
- },
- 830 : {
- 'a' : { 130 : 'a' },
- 'd' : { 130 : 'd' }
- },
- 600 : {
- 'a' : { 100 : 'a' },
- 'd' : { 100 : 'd' },
- 'q' : { 100 : 'q' },
- 't' : { 100 : 't' },
- 'v' : { 180 : 'v',
- 100 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 100 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 100 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 100 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- },
- 610 : {
- 'a' : { 110 : 'a' },
- 'd' : { 110 : 'd' },
- 't' : { 110 : 't' },
- 'v' : { 180 : 'v',
- 110 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 110 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 110 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 110 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- },
- 611 : {
- 'a' : { 111 : 'a' },
- 'd' : { 111 : 'd' },
- 't' : { 111 : 't' },
- 'v' : { 180 : 'v',
- 111 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 111 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 111 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 111 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- },
- 630 : {
- 'a' : { 130 : 'a' },
- 'd' : { 130 : 'd' }
- },
- 648 : {
- 'a' : { 148 : 'a' },
- 'v' : { 148 : 'v' },
- 'x' : { 148 : 'x' },
- 'y' : { 148 : 'y' },
- 'z' : { 148 : 'z' }
- },
- 650 : {
- 'a' : { 150 : 'a' },
- 'b' : { 150 : 'b' },
- 'v' : { 180 : 'v',
- 150 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 150 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 150 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 150 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- },
- 651 : {
- 'a' : { 151 : 'a' },
- 'v' : { 180 : 'v',
- 151 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 151 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 151 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 151 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- },
- 655 : {
- 'a' : { 155 : 'a' },
- 'v' : { 180 : 'v',
- 155 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 155 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 155 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 155 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- }
- }
- }
- };
-
-}
--- /dev/null
+/* vim: et:sw=4:ts=4:
+ * ---------------------------------------------------------------------------
+ * Copyright (C) 2011 Equinox Software, Inc.
+ * Mike Rylander <miker@esilibrary.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * ---------------------------------------------------------------------------
+ */
+
+if(!dojo._hasResource["openils.AuthorityControlSet"]) {
+
+ dojo.require('openils.PermaCrud');
+ dojo.require('MARC.FixedFields');
+
+ dojo._hasResource["openils.AuthorityControlSet"] = true;
+ dojo.provide("openils.AuthorityControlSet");
+ dojo.declare('openils.AuthorityControlSet', null, {
+
+ _controlset : null,
+
+ constructor : function(kwargs) {
+
+ if (!openils.AuthorityControlSet._remote_loaded) {
+
+ // TODO -- push the raw tree into the oils cache for later reuse
+
+ var pcrud = new openils.PermaCrud();
+ var acs_list = pcrud.retrieveAll('acs');
+
+ // loop over each acs
+ dojo.forEach( acs_list, function (cs) {
+ openils.AuthorityControlSet._controlsets[''+cs.id()] = {
+ id : cs.id(),
+ name : cs.name(),
+ description : cs.description(),
+ authority_tag_map : {},
+ control_map : {},
+ bib_fields : [],
+ raw : cs
+ };
+
+ // grab the authority fields
+ var acsaf_list = pcrud.search('acsaf', {control_set : cs.id()});
+ var at_list = pcrud.search('at', {control_set : cs.id()});
+ openils.AuthorityControlSet._controlsets[''+cs.id()].raw.authority_fields( acsaf_list );
+ openils.AuthorityControlSet._controlsets[''+cs.id()].raw.thesauri( at_list );
+
+ // and loop over each
+ dojo.forEach( acsaf_list, function (csaf) {
+ // link the main entry if we're subordinate
+ if (csaf.main_entry()) {
+ csaf.main_entry(
+ dojo.filter(acsaf_list, function (x) {
+ return x.id() == csaf.main_entry();
+ })[0]
+ );
+ }
+
+ // link the sub entries if we're main
+ csaf.sub_entries(
+ dojo.filter(acsaf_list, function (x) {
+ return x.main_entry() == csaf.id();
+ })[0]
+ );
+
+ // now, bib fields
+ var acsbf_list = pcrud.search('acsbf', {authority_field : csaf.id()});
+ csaf.bib_fields( acsbf_list );
+
+ openils.AuthorityControlSet._controlsets[''+cs.id()].bib_fields = [].concat(
+ openils.AuthorityControlSet._controlsets[''+cs.id()].bib_fields
+ acsbf_list
+ );
+
+ dojo.forEach( acsbf_list, function (csbf) {
+ // link the main entry if we're subordinate
+ if (csbf.authority_field()) {
+ csbf.authority_field(
+ dojo.filter(acsaf_list, function (x) {
+ return x.a() == csbf.authority_field();
+ })[0]
+ );
+ }
+
+ });
+ });
+
+ // build the authority_tag_map
+ dojo.forEach( openils.AuthorityControlSet._controlsets[''+cs.id()].bib_fields, function (bf) {
+ openils.AuthorityControlSet._controlsets[''+cs.id()].control_map[bf.tag()] = {};
+ dojo.forEach( bf.authority_field().sf_list().split(''), function (sf_code) {
+ openils.AuthorityControlSet._controlsets[''+cs.id()].control_map[bf.tag()][sf_code] = { bf.authority_field().tag() : sf_code };
+ });
+ });
+ });
+
+
+ if (this.controlSetList().length > 0)
+ delete openils.AuthorityControlSet._controlsets['-1'];
+
+ openils.AuthorityControlSet._remote_loaded = true;
+ }
+
+ if (kwargs.controlSet) {
+ this.controlSetId( kwargs.controlSet );
+ } else {
+ this.controlSetId( this.controlSetList().sort(function(a,b){return (a - b)}) );
+ }
+ },
+
+ controlSetId: function (x) {
+ if (x) this._controlset = ''+x;
+ return this._controlset;
+ },
+
+ controlSet: function (x) {
+ return openils.AuthorityControlSet._controlsets[''+this.controlSetId(x)];
+ },
+
+ authorityFields: function (x) {
+ return openils.AuthorityControlSet._controlsets[''+this.controlSetId(x)].raw.authority_fields();
+ },
+
+ thesauri: function (x) {
+ return openils.AuthorityControlSet._controlsets[''+this.controlSetId(x)].raw.thesauri();
+ },
+
+ controlSetList : function () {
+ var l = [];
+ for (var i in openils.AuthorityControlSet._controlsets) {
+ l.push(i);
+ }
+ return l;
+ },
+
+ findControlSetsForTag : function (tag) {
+ var old_acs = this.controlSetId();
+ var acs_list = dojo.filter(
+ this.controlSetList(),
+ function(acs_id) { return (this.controlSet(acs_id).control_map[tag]) }
+ );
+ this.controlSetId(old_acs);
+ return acs_list;
+ }
+
+ });
+
+ openils.AuthorityControlSet._remote_loaded = false;
+
+ openils.AuthorityControlSet._controlsets = {
+ // static sorta-LoC setup ... to be overwritten with server data
+ -1 : {
+ id : -1,
+ name : 'Static LoC legacy mapping',
+ description : 'Legacy mapping provided as a default',
+ contorl_map : {
+ 100 : {
+ 'a' : { 100 : 'a' },
+ 'd' : { 100 : 'd' },
+ 'e' : { 100 : 'e' },
+ 'q' : { 100 : 'q' }
+ },
+ 110 : {
+ 'a' : { 110 : 'a' },
+ 'd' : { 110 : 'd' }
+ },
+ 111 : {
+ 'a' : { 111 : 'a' },
+ 'd' : { 111 : 'd' }
+ },
+ 130 : {
+ 'a' : { 130 : 'a' },
+ 'd' : { 130 : 'd' }
+ },
+ 240 : {
+ 'a' : { 130 : 'a' },
+ 'd' : { 130 : 'd' }
+ },
+ 400 : {
+ 'a' : { 100 : 'a' },
+ 'd' : { 100 : 'd' }
+ },
+ 410 : {
+ 'a' : { 110 : 'a' },
+ 'd' : { 110 : 'd' }
+ },
+ 411 : {
+ 'a' : { 111 : 'a' },
+ 'd' : { 111 : 'd' }
+ },
+ 440 : {
+ 'a' : { 130 : 'a' },
+ 'n' : { 130 : 'n' },
+ 'p' : { 130 : 'p' }
+ },
+ 700 : {
+ 'a' : { 100 : 'a' },
+ 'd' : { 100 : 'd' },
+ 'q' : { 100 : 'q' },
+ 't' : { 100 : 't' }
+ },
+ 710 : {
+ 'a' : { 110 : 'a' },
+ 'd' : { 110 : 'd' }
+ },
+ 711 : {
+ 'a' : { 111 : 'a' },
+ 'c' : { 111 : 'c' },
+ 'd' : { 111 : 'd' }
+ },
+ 730 : {
+ 'a' : { 130 : 'a' },
+ 'd' : { 130 : 'd' }
+ },
+ 800 : {
+ 'a' : { 100 : 'a' },
+ 'd' : { 100 : 'd' }
+ },
+ 810 : {
+ 'a' : { 110 : 'a' },
+ 'd' : { 110 : 'd' }
+ },
+ 811 : {
+ 'a' : { 111 : 'a' },
+ 'd' : { 111 : 'd' }
+ },
+ 830 : {
+ 'a' : { 130 : 'a' },
+ 'd' : { 130 : 'd' }
+ },
+ 600 : {
+ 'a' : { 100 : 'a' },
+ 'd' : { 100 : 'd' },
+ 'q' : { 100 : 'q' },
+ 't' : { 100 : 't' },
+ 'v' : { 180 : 'v',
+ 100 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 100 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 100 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 100 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ },
+ 610 : {
+ 'a' : { 110 : 'a' },
+ 'd' : { 110 : 'd' },
+ 't' : { 110 : 't' },
+ 'v' : { 180 : 'v',
+ 110 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 110 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 110 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 110 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ },
+ 611 : {
+ 'a' : { 111 : 'a' },
+ 'd' : { 111 : 'd' },
+ 't' : { 111 : 't' },
+ 'v' : { 180 : 'v',
+ 111 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 111 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 111 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 111 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ },
+ 630 : {
+ 'a' : { 130 : 'a' },
+ 'd' : { 130 : 'd' }
+ },
+ 648 : {
+ 'a' : { 148 : 'a' },
+ 'v' : { 148 : 'v' },
+ 'x' : { 148 : 'x' },
+ 'y' : { 148 : 'y' },
+ 'z' : { 148 : 'z' }
+ },
+ 650 : {
+ 'a' : { 150 : 'a' },
+ 'b' : { 150 : 'b' },
+ 'v' : { 180 : 'v',
+ 150 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 150 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 150 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 150 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ },
+ 651 : {
+ 'a' : { 151 : 'a' },
+ 'v' : { 180 : 'v',
+ 151 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 151 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 151 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 151 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ },
+ 655 : {
+ 'a' : { 155 : 'a' },
+ 'v' : { 180 : 'v',
+ 155 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 155 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 155 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 155 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ }
+ }
+ }
+ };
+
+}
function $(id) { return document.getElementById(id); }
+var acs = new openils.AuthorityControlSet ();
+
function mangle_005() {
var now = new Date();
var y = now.getUTCFullYear();
return true;
}
-var authority_tag_map = {
- 100 : ['[100,500,700]',100],
- 700 : ['[100,500,700]',100],
- 800 : ['[100,500,700]',100],
- 110 : ['[110,510,710]',110],
- 610 : ['[110,510,710]',110],
- 710 : ['[110,510,710]',110],
- 810 : ['[110,510,710]',110],
- 111 : ['[111,511,711]',111],
- 611 : ['[111,511,711]',111],
- 711 : ['[111,511,711]',111],
- 811 : ['[111,511,711]',111],
- 240 : ['[130,530,730]',130],
- 130 : ['[130,530,730]',130],
- 730 : ['[130,530,730]',130],
- 830 : ['[130,530,730]',130],
- 600 : ['[100,500,580,581,582,585,700,780,781,782,785]',100],
- 630 : ['[130,530,730]',130],
- 648 : ['[148,548]',148],
- 650 : ['[150,550,580,581,582,585,750,780,781,782,785]',150],
- 651 : ['[151,551,580,581,582,585,751,780,781,782,785]',151],
- 655 : ['[155,555,580,581,582,585,755,780,781,782,785]',155]
-};
-
-function getAuthorityContextMenu (target, sf) {
- var menu_id = sf.parent().@tag + ':' + sf.@code + '-authority-context-' + sf;
-
- var page = 0;
- var old = dojo.byId( menu_id );
- if (old) {
- page = auth_pages[menu_id];
- old.parentNode.removeChild(old);
- } else {
- auth_pages[menu_id] = 0;
- }
-
- var sf_popup = createPopup({ id : menu_id, flex : 1 });
-
- sf_popup.addEventListener("popuphiding", function(event) {
- if (show_auth_menu) {
- show_auth_menu = false;
- getAuthorityContextMenu(target, sf);
- dojo.byId(menu_id).openPopup();
- }
- }, false);
-
- context_menus.appendChild( sf_popup );
-
- if (!authority_tag_map[sf.parent().@tag]) {
- sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.not_authority_field.label') } ) );
- target.setAttribute('context', 'clipboard');
- return false;
- }
-
- if (sf.toString().replace(/\s*/, '')) {
- browseAuthority(sf_popup, menu_id, target, sf, 20, page);
- }
-
- return true;
-}
-
-/* Apply the complete 1xx */
-function applyFullAuthority ( target, ui_sf, e4x_sf ) {
- var new_vals = dojo.query('*[tag^="1"]', target);
- return applyAuthority( target, ui_sf, e4x_sf, new_vals );
-}
-
-function applySelectedAuthority ( target, ui_sf, e4x_sf ) {
- var new_vals = target.getElementsByAttribute('checked','true');
- return applyAuthority( target, ui_sf, e4x_sf, new_vals );
-}
-
-function applyAuthority ( target, ui_sf, e4x_sf, new_vals ) {
- var field = e4x_sf.parent();
-
- for (var i = 0; i < new_vals.length; i++) {
-
- var sf_list = field.subfield;
- for (var j in sf_list) {
-
- if (sf_list[j].@code == new_vals[i].getAttribute('subfield')) {
- sf_list[j] = new_vals[i].getAttribute('value');
- new_vals[i].setAttribute('subfield','');
- break;
- }
- }
- }
-
- for (var i = 0; i < new_vals.length; i++) {
- if (!new_vals[i].getAttribute('subfield')) continue;
-
- var val = new_vals[i].getAttribute('value');
-
- var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{val}</subfield>;
- sf.@code = new_vals[i].getAttribute('subfield');
-
- field.insertChildAfter(field.subfield[field.subfield.length() - 1], sf);
- }
-
- var row = marcDatafield( field );
-
- var node = ui_sf;
- while (node.nodeName != 'row') {
- node = node.parentNode;
- }
-
- node.parentNode.replaceChild( row, node );
- return true;
-}
-
var control_map = {
100 : {
'a' : { 100 : 'a' },
}
};
+function getAuthorityContextMenu (target, sf) {
+ var menu_id = sf.parent().@tag + ':' + sf.@code + '-authority-context-' + sf;
+
+ var page = 0;
+ var old = dojo.byId( menu_id );
+ if (old) {
+ page = auth_pages[menu_id];
+ old.parentNode.removeChild(old);
+ } else {
+ auth_pages[menu_id] = 0;
+ }
+
+ var sf_popup = createPopup({ id : menu_id, flex : 1 });
+
+ sf_popup.addEventListener("popuphiding", function(event) {
+ if (show_auth_menu) {
+ show_auth_menu = false;
+ getAuthorityContextMenu(target, sf);
+ dojo.byId(menu_id).openPopup();
+ }
+ }, false);
+
+ context_menus.appendChild( sf_popup );
+
+ var found_acs = [];
+ dojo.forEach( acs.controlSetList(), function (acs_id) {
+ if (ac.controlSet(acs_id).control_map[sf.parent().@tag]) found_acs.push(acs_id);
+ });
+
+ if (!found_acs.length) {
+ sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.not_authority_field.label') } ) );
+ target.setAttribute('context', 'clipboard');
+ return false;
+ }
+
+ if (sf.toString().replace(/\s*/, '')) {
+ browseAuthority(sf_popup, menu_id, target, sf, 20, page);
+ }
+
+ return true;
+}
+
+/* Apply the complete 1xx */
+function applyFullAuthority ( target, ui_sf, e4x_sf ) {
+ var new_vals = dojo.query('*[tag^="1"]', target);
+ return applyAuthority( target, ui_sf, e4x_sf, new_vals );
+}
+
+function applySelectedAuthority ( target, ui_sf, e4x_sf ) {
+ var new_vals = target.getElementsByAttribute('checked','true');
+ return applyAuthority( target, ui_sf, e4x_sf, new_vals );
+}
+
+function applyAuthority ( target, ui_sf, e4x_sf, new_vals ) {
+ var field = e4x_sf.parent();
+
+ for (var i = 0; i < new_vals.length; i++) {
+
+ var sf_list = field.subfield;
+ for (var j in sf_list) {
+
+ if (sf_list[j].@code == new_vals[i].getAttribute('subfield')) {
+ sf_list[j] = new_vals[i].getAttribute('value');
+ new_vals[i].setAttribute('subfield','');
+ break;
+ }
+ }
+ }
+
+ for (var i = 0; i < new_vals.length; i++) {
+ if (!new_vals[i].getAttribute('subfield')) continue;
+
+ var val = new_vals[i].getAttribute('value');
+
+ var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{val}</subfield>;
+ sf.@code = new_vals[i].getAttribute('subfield');
+
+ field.insertChildAfter(field.subfield[field.subfield.length() - 1], sf);
+ }
+
+ var row = marcDatafield( field );
+
+ var node = ui_sf;
+ while (node.nodeName != 'row') {
+ node = node.parentNode;
+ }
+
+ node.parentNode.replaceChild( row, node );
+ return true;
+}
+
function validateAuthority (button) {
var grid = document.getElementById('recGrid');
var label = button.getAttribute('label');
var row = rows[i];
var tag = row.firstChild;
- if (!control_map[tag.value]) continue
- button.setAttribute('label', label + ' - ' + tag.value);
-
- var ind1 = tag.nextSibling;
- var ind2 = ind1.nextSibling;
- var subfields = ind2.nextSibling.childNodes;
-
- var tags = {};
-
- for (var j = 0; j < subfields.length; j++) {
- var sf = subfields[j];
- var sf_code = sf.childNodes[1].value;
- var sf_value = sf.childNodes[2].value;
-
- if (!control_map[tag.value][sf_code]) continue;
-
- var found = 0;
- for (var a_tag in control_map[tag.value][sf_code]) {
- if (!tags[a_tag]) tags[a_tag] = [];
- tags[a_tag].push({ term : sf_value, subfield : sf_code });
+ for (var acs_id in acs.controlSetList()) {
+ var control_map = acs.controlSet(acs_id).control_map;
+
+ if (!control_map[tag.value]) continue
+ button.setAttribute('label', label + ' - ' + tag.value);
+
+ var ind1 = tag.nextSibling;
+ var ind2 = ind1.nextSibling;
+ var subfields = ind2.nextSibling.childNodes;
+
+ var tags = {};
+
+ for (var j = 0; j < subfields.length; j++) {
+ var sf = subfields[j];
+ var sf_code = sf.childNodes[1].value;
+ var sf_value = sf.childNodes[2].value;
+
+ if (!control_map[tag.value][sf_code]) continue;
+
+ var found = 0;
+ for (var a_tag in control_map[tag.value][sf_code]) {
+ if (!tags[a_tag]) tags[a_tag] = [];
+ tags[a_tag].push({ term : sf_value, subfield : sf_code });
+ }
+
+ }
+
+ for (var val_tag in tags) {
+ var auth_data = validateBibField( acs_id, [val_tag], tags[val_tag]);
+ var res = new XML( auth_data.responseText );
+ found = parseInt(res.gw::payload.gw::string.toString());
+ if (found) break;
+ }
+
+ // XXX If adt, etc should be validated separately from vxz, etc then move this up into the above for loop
+ for (var j = 0; j < subfields.length; j++) {
+ var sf = subfields[j];
+ if (!found) {
+ dojo.removeClass(sf.childNodes[2], 'marcValidated');
+ dojo.addClass(sf.childNodes[2], 'marcUnvalidated');
+ } else {
+ dojo.removeClass(sf.childNodes[2], 'marcUnvalidated');
+ dojo.addClass(sf.childNodes[2], 'marcValidated');
+ }
}
- }
-
- for (var val_tag in tags) {
- var auth_data = validateBibField( [val_tag], tags[val_tag]);
- var res = new XML( auth_data.responseText );
- found = parseInt(res.gw::payload.gw::string.toString());
if (found) break;
}
-
- // XXX If adt, etc should be validated separately from vxz, etc then move this up into the above for loop
- for (var j = 0; j < subfields.length; j++) {
- var sf = subfields[j];
- if (!found) {
- dojo.removeClass(sf.childNodes[2], 'marcValidated');
- dojo.addClass(sf.childNodes[2], 'marcUnvalidated');
- } else {
- dojo.removeClass(sf.childNodes[2], 'marcUnvalidated');
- dojo.addClass(sf.childNodes[2], 'marcValidated');
- }
- }
}
button.setAttribute('label', label);