# $Id$ # $URL$ logger = logging.getLogger('meresco.availability') logger.debug("Starting logger") availabilityConfig = configs['availability'] collectionString = availabilityConfig.get('collectionList', section="collections") if collectionString == None: logger.error("No collections found!") collectionString = "NO,COLLECTIONS,FOUND" collections = collectionString.split("\n") infra.dd('collections', collections) #FIXME: config namespaceMap = { 'mods': 'http://www.loc.gov/mods/v3' } def inDepot(location): global collections if location.split()[0] in collections: return 1 else: return 0 def getLocator(recordId, mods): sid = any.getSid(recordId) locator = any.createOpenURL(mods) # TP: use the following for testing with locator @ bzv.uvt.nl # locator = "/availability/?" + any.createOpenURL(mods).split('?')[1] return locator + '&sid=' + sid def getAvailabilityByOpenurl(recordId, mods, ID): locator = getLocator(recordId, mods) yield """ """ % {'locator' : locator, 'id' : ID } def getAvailabilityByUitleencode(mods, genre, recordId, ID ): # uitleencodes # a = titel in bestelling # c = niet balie, wel IBL # d = wel balie, niet IBL # e = elektronisch beschikbaar # g = geblokkeerd # o = onbekend # s = speciale toestemming # z = boek zoek # f = niet uitleenbaar, wel fotokopie # i = niet uitleenbaar, geen fotokopie, wel inzage # u = normaal uitleenbaar # b = beperkt uitleenbaar depot = availabilityConfig.get('depot', section="storageList",default='IN DEPOT') library = availabilityConfig.get('library', section="storageList",default='IN LIBRARY') journal = availabilityConfig.get('journal', section="storageList",default='JOURNAL') data = {} documentStorageList = ['locator','depot','library','journal'] for storage in documentStorageList: data[storage] = [] for copyInformation in mods.xpath("//mods:location/mods:holdingSimple/mods:copyInformation", namespaceMap): uitleencode = copyInformation.xpath("mods:note[@type='status']/text()", namespaceMap) location = copyInformation.xpath("mods:shelfLocator/text()", namespaceMap)[0] if uitleencode: # niet uitleenbaar if uitleencode[0] == 'i' or uitleencode[0] == 'f': if inDepot(location): # FIXME: config (tucat) data['depot'].append('%(loc)s' %{'loc': location}) # niet in depot: elif genre == 'journal': # FIXME: config (tuts) data['journal'].append('%(loc)s' %{'loc': location}) else: data['library'].append(location) elif uitleencode[0] == 'u' or uitleencode[0] == 'b': data['locator'].append(copyInformation) for storage in documentStorageList: if storage == 'locator' and data[storage]: for copyInformation in data['locator']: EPN = copyInformation.xpath("mods:note[@type='epn']/text()", namespaceMap)[0] if EPN: location = copyInformation.xpath("mods:shelfLocator/text()", namespaceMap) location = location and location[0] or '' if location: depot = inDepot(location) locator = getLocator(recordId, mods) + "&epn=" + EPN yield """ """ %{'id':ID, 'loc': location, 'inDepot': depot, 'genre': genre, 'locator': locator} elif storage == 'depot' and data[storage]: yield '