return acs_list;
},
+ findControlSetsForAuthorityTag : function (tag) {
+ var me = this;
+ var old_acs = this.controlSetId();
+
+ var acs_list = dojo.filter(
+ me.controlSetList(),
+ function(acs_id) {
+ var a = me.controlSet(acs_id);
+ for (var btag in a.control_map) {
+ for (var sf in a.control_map[btag]) {
+ if (a.control_map[btag][sf][tag]) return true;
+ }
+ }
+ return false;
+ }
+ );
+ this.controlSetId(old_acs);
+ return acs_list;
+ },
+
bibToAuthority : function (field) {
var b_field = this.bibFieldByTag(field.tag);
var table = dojo.create("table", {"className": "authority-record"});
var tbody = dojo.create("tbody", {"id": "authority_" + auth_id}, table);
+
dojo.forEach(
main_entries, function(af) { renderAuthorityMainEntry(m, af, tbody); }
);
function(record) {
var m = new MARC.Record({"xml": record});
- /* is 001 reliable for this? I'm guessing not */
- var auth_id = m.field("001").data;
+ var auth_id = m.subfield("901","c")[1];
auth_ids.push(auth_id);
- var cs = acs_helper.controlSetByThesaurusCode(
- m.extractFixedField("Subj")
- );
+ /* best guess */
+ var t = m.field(/^1/);
+ if (dojo.isArray(t)) t = t[0];
+
+ var cs = acs_helper.findControlSetsForAuthorityTag( t.tag );
+ if (dojo.isArray(cs)) cs = cs[0];
+
+ acs_helper.controlSetId( cs );
dojo.place(
- renderAuthorityRecord(m, cs.raw, auth_id),
+ renderAuthorityRecord(m, acs_helper.controlSet().raw, auth_id),
"authority-record-holder"
);
}
source_f.ind1 = sf.parent().@ind1.toString();
source_f.ind1 = sf.parent().@ind2.toString();
+ var found_acs = [];
+ dojo.forEach( acs.controlSetList(), function (acs_id) {
+ if (acs.controlSet(acs_id).control_map[sf.parent().@tag]) found_acs.push(acs_id);
+ });
+
+ var cmap;
+ if (!found_acs.length) {
+ return false;
+ } else {
+ cmap = acs.controlSet(found_acs[0]).control_map;
+ }
+
for (var i = 0; i < sf.parent().subfield.length(); i++) {
var sf_iter = sf.parent().subfield[i];
/* Filter out subfields that are not controlled for this tag */
- if (!control_map[source_f.tag][sf_iter.@code.toString()]) {
+ if (!cmap[source_f.tag][sf_iter.@code.toString()]) {
continue;
}