def __add_cc_holdings__(self, cc_key='bf:Organization:1'): "Helper function for Colorado College MARC Records" # Assumes hybrid environment if self.redis_datastore.hget('prospector-institution-codes', '9cocp') is not None: cc_key = self.redis_datastore.hget('prospector-institution-codes', '9cocp') holding = Holding(redis_datastore=self.redis_datastore) self.entity_info['ils-bib-number'] = self.record['907']['a'][1:-1] cc_tutt_code = self.record['994']['a'] if tutt_maps.LOCATION_CODE_MAP.has_key(cc_tutt_code): location_key = '{0}:codes:{1}'.format(cc_key, cc_tutt_code) else: location_key = cc_key for key, value in self.entity_info.iteritems(): setattr(holding, key, value) setattr(holding, 'schema:contentLocation', location_key) if self.instance is not None: holding.annotates = self.instance.redis_key self.redis_datastore.sadd("{0}:resourceRole:own".format(cc_key), self.instance.redis_key) holding.save() if location_key != cc_key: # Assumes local location self.redis_datastore.sadd(location_key, holding.redis_key) if hasattr(holding, 'ils-bib-number'): self.redis_datastore.hset('ils-bib-numbers', getattr(holding, 'ils-bib-number'), holding.redis_key) self.holdings.append(holding)
def __create_holding__(self, instance, location_code): """Helper function creates a library holding entity for instance Parameters: instance -- BIBFRAME instance """ new_holding = Holding(redis_datastore=self.redis_datastore, annotates=instance.redis_key) setattr(new_holding, 'schema:contentLocation', location_code) new_holding.save() self.redis_datastore.sadd( '{0}:hasAnnotation'.format(instance.redis_key), new_holding.redis_key)
def __add_consortium_holdings__(self): "Helper function for CARL Alliance MARC records" # quick check if local cc record using 994 field if self.record['994'] is not None: self.__add_cc_holdings__() return all945s = self.record.get_fields('945') for field in all945s: a_subfields = field.get_subfields('a') for subfield in a_subfields: holding = Holding(redis_datastore=self.redis_datastore) data = subfield.split(" ") institution_code = data[0] org_key = self.redis_datastore.hget( 'prospector-institution-codes', institution_code) setattr(holding, 'schema:contentLocation', org_key) setattr(holding, 'ils-bib-number', data[1]) setattr(holding, 'ils-item-number', data[2]) for key,value in self.entity_info.iteritems(): setattr(holding, key, value) if self.instance is not None: holding.annotates = self.instance.redis_key # Use MARC Relator Code for set key self.redis_datastore.sadd( "{0}:resourceRole:own".format(org_key), self.instance.redis_key) holding.save() self.redis_datastore.hset( 'ils-bib-numbers', getattr(holding, 'ils-bib-number'), holding.redis_key) if self.instance is not None: instance_annotation_key = "{0}:hasAnnotation".format( self.instance.redis_key) self.redis_datastore.sadd(instance_annotation_key, holding.redis_key) self.holdings.append(holding)